I was in the virtual machine test, preparing two virtual machines in advance to set the IP to:
master:192.168.90.222
slave:192.168.90.221
Master server Configuration
First modify the master's data configuration file under [mysqld] to add the following code:
Server-id = 222 #配置的是服务器的id, ID can not drink another repetition Log-bin = mysql-bin #开启mysql二进制日志bin-log-do-db = Test #需要备份的数据库, if there are multiple entries in the Write line
Master's database configuration file was modified after adding MySQL user, for slave server link use, SQL is as follows:
Grant Replication on *. * to ' Backup '@'192.168.90.221'by'123456' ;
#backup is the user name, 192.168.90.221 is the IP address of slave; 123456 is the password
Restart MySQL for configuration to take effect!
Slave Server Configuration
Modify the Slave database configuration file to add the following configuration:
Server-id = 221 # from server Idmaster-host = 192.168.90.222 #master database Address Master-port = 3306 #master数据端口号master-user = Backup #mas ter user Name Master-password = 123456 #master Database Password replicate-do-db = Test #需要做复制的数据库replicate-ignore-table = test.t1 #跳过的表, this table is no longer System slave-skip-errors = 1032,1062,125 #自动跳过的错误代码 To prevent replication errors from being interrupted
Execute the following SQL statement, built on the link to master:
to Master_host='192.168.90.222', master_user=' Backup ', Master_password='123456', master_log_file= 'mysql-bin.000003', master_log_pos=106;
The values of Master_log_file and Master_log_pos are performed by performing the show master status \g in the master database command line; To view
Execute start slave in the slave database; Start from link
Then perform the show slave status \g; View the state of slave if found
Slave_io_running:yes
Slave_sql_running:yes
These two bits are yes, which means the configuration is successful!
In addition, the master-slave replication must ensure that two database consistent!!!