Mysql versions later than 3.23.15 provide the database replication function. This feature allows you to synchronize two databases, master-slave mode, and mutual backup mode. The settings of the Database Synchronization replication function are reflected in the mysql settings file. Mysql configuration file (usually my. cnf), in the unix environment in etcmysqlmy. cnf or in the mysql user's
Mysql versions later than 3.23.15 provide the database replication function. This feature allows you to synchronize two databases, master-slave mode, and mutual backup mode. The settings of the Database Synchronization replication function are reflected in the mysql settings file. Mysql configuration file (usually my. cnf), in the unix environment in/etc/mysql/my. cnf or in the mysql user's
Mysql versions later than 3.23.15 provide the database replication function. This feature allows you to synchronize two databases, master-slave mode, and mutual backup mode. The settings of the Database Synchronization replication function are reflected in the mysql settings file. Mysql configuration file (usually my. cnf), in the unix environment in/etc/mysql/my. cnf or in the mysql user's home directory my. cnf.
In the Window environment, if the c: root directory contains the my. cnf file, the configuration file is used. When running the winmysqladmin.exe tool of mysql, this tool will name my. cnf in the c: root directory mycnf. bak. Create my. ini in the winnt directory. The configuration file is read when the mysql server is started. Therefore, you can copy the content in my. cnf to the my. ini file and use the my. ini file as the configuration file of the mysql server.
Setting Method
Set the sample environment:
Operating System: window2000 professional
Mysql: 4.0.4-beta-max-nt-log
A ip: 10.10.10.22
B ip: 10.10.10.53
A: Set
1. Add a user account that is most synchronized to the user: grant file on *. * to backup @ ''10. 10.10.53 ''' identified by '123'
2. Add a database as the synchronization database: create database backup
B: Set
1. Add the most synchronous User Account: grant file on *. * to backup @ ''10. 10.10.22 ''identified by '123'
2. Add a database as the synchronization database: create database backup
Master/Slave Mode: a-> B
If a is the master node, modify the my. ini file of mysql. Add the following configuration to the mysqld configuration item: server-id = 1log-bin # You can set log-bin = c: mysqlbakmysqllog to set the directory of the log file, # mysqllog is the name of the log file. mysql creates several log files with Different Extensions named mysqllog. Binlog-do-db = backup # specify the database for logs
Restart Database Service
Use the show master status Command to view the logs.
If B is slave, modify the my. ini file of B mysql. Add the following configuration to the mysqld configuration item: server-id = 2master-host = 10.10.22master-user = backup # synchronize user account master-password = 1234master-port = 3306master-connect-retry = 60 preset Retry Interval 60 seconds replicate-do-db = backup tells slave to only perform backup database updates
Restart Database
Use show slave status to check the synchronization configuration.
Note: Because the slave configuration information is set, mysql generates master.info in the database directory. to modify the slave configuration, delete the file first. Otherwise, the modified configuration does not take effect.
Dual-host mutual standby mode
If you add slave settings to aand master settings to B, you can synchronize data between B and. Add the following settings to the mysqld configuration item in the configuration file of:
Master-host = 10.10.53master-user = backupmaster-password = 1234replicate-do-db = backupmaster-connect-retry = 10
Add the following settings to the mysqld configuration item in the configuration file of B: log-bin = c: mysqllogmysqllogbinlog-do-db = backup
Note: *. err log file is generated when an error occurs. The synchronization thread exits. When an error is corrected, the synchronization mechanism should be executed to run slave start. Restarting the AB machine enables two-way hot standby.
Test: insert aa (1872000) entries of the big data table to B in batches. Database a can update 2500 entries per second. (Responsible editor: Ming)