Database synchronization from the master

Database synchronization from the master

Binary log 1. Open the configuration on the primary master server

1. Because I was so MySQL5.5 in / etc / folder is no my.cnf file rpm installed, only to / usr / share / mysql / folder to copy to file my-medium.cnf / etc / folder and rename it to my.cnf.

2. Edit the file

vim /etc/my.cnf   #编辑文件

#在[mysqld]下面添加
server-id=1
log-bin=master-bin
log-bin-index=master-bin.index

service mysql restart   #然后重启sql服务

3. Detection of the configuration

mysql> SHOW MASTER STATUS;

Here Insert Picture Description

2. In the configuration open Relay log from the server

1. Also edit the file my.cnf

server-id=2
relay-log-index=slave-relay-bin.index
relay-log=slave-relay-bin

service mysql restart   #同样重启

Configuration database associated with two

1. switched to the main proceeds MySQL

mysql> create user repl;   #创建用户

mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'从xxx.xxx.xxx.xx' IDENTIFIED BY 'mysql'; 
#给权限

mysql> flush privileges;
#刷新

2. switched from,

mysql> change master to master_host='主xxx.xxx.xxx.xx',master_port=3306,master_user='repl',master_password='mysql',master_log_file='master-bin.000001',master_log_pos=0;

Corresponding to the main data file and the master user ip address instance

3. Then turn sync

mysql> stop slave;

mysql> show slave status \G; 

Here Insert Picture Description

​ 这里是原本MySQL5.65版本下的同步,后来发现io异常 Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Slave can not handle replication events with the checksum that master is configured to log; the first event ‘master-bin.000001’ at 4, the last event read from ‘/master-bin.000001’ at 120, the last byte read from ‘/master-bin.000001’ at 120.’

It found to be due mysql5.6 master used, binlog_checksum default setting is crc32. If a slave with a 5.5, binglog_checksum To set the master of none.

Later MySQL5.5 directly installed version, directly succeeded. Master-slave database version should be consistent, because this is the first attempt, so many go wrong.

Here Insert Picture Description

4. Conclusion

If the article is wrong also please chiefs pointed out that this article is used to record the learning process, only for reference.
All the above-mentioned server has been shut down himself.

Released three original articles · won praise 0 · Views 587

Guess you like

Origin blog.csdn.net/qq_43203949/article/details/104521256