Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Establishment of mysql Mirror Database under linux operating system (transfer)

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Set up mysql mirror database under linux operating system (transfer) [@ more@] MySQL version: 4.1

Environment introduction: master library 192.168.0.205 slave library 192.168.0.206

1. Create / etc/my.cnf the main library, and modify the key value in [mysqld] to increase it.

Server-id=1 log-bin=binlog_name

2. Add users to the main library to read the main library log from the library.

Grant replication slave,reload,super on *. * to 'slave'@'192.168.0.206' identified by' 123456'

3. Connect the slave library to the master library for testing.

/ opt/mysql/bin/mysql-u slave-p-h 192.168.0.205

4. Stop the slave library, modify the slave library / etc/my.cnf, and add options:

[mysqld] server-id=2 master-host=192.168.0.205 master-user=slave master-password=123456

5. Start the slave library to synchronize the data of the master and slave libraries.

/ opt/mysql/share/mysql/mysql start / opt/mysql/bin/mysql-u root-p mysql > load data from master

Description: this step can also be poured into the database or directly tested in the directory.

6. Conduct tests:

Create tables in the main library

Mysql > create database sampdb; mysql > create table new (name char (20), phone char (20)); mysql > insert into new ('abc,'0532555555')

Open the slave library and see:

/ opt/mysql/bin/mysql-u root-p mysql > show database; mysql sampdb test mysql > use sampdb; mysql > show tables; new indicates that the master-slave database has been created successfully.

7. Master-slave database related commands:

Slave stop; slave start; starts to stop from the database. Show slave statusG; shows which master database binary log is being read from the slave library

Purge master logs to 'binlog.000004'; this command is very careful to delete the useless binary log files of the primary database. If deleted by mistake, there is no way to update automatically from the library.

Change master; modifies the parameter usage from the server.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 267

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report