主从复制失败,发现Slave_IO_Running这个进程一直是NO
查看错误日志,得到信息是slave用户无法连接到master服务器上
position 98, relay log './mysqld-relay-bin.000001' position: 4
150921 4:11:08 [ERROR] Slave I/O thread: error connecting to master 'repl@192.168.126.132:3306': Error: 'Host '192.168.126.132' is not allowed to connect to this MySQL server' errno: 1130 retry-time: 60 retries: 86400
150921 5:06:57 [Note] Slave I/O thread killed while connecting to master
150921 5:06:57 [Note] Slave I/O thread exiting, read up to log 'binlog_name.000001', position 98
150921 5:06:57 [Note] Error reading relay log event: slave SQL thread was killed
但是我在slave主机,可以直接使用repl用户连接到master服务器上查询相关的表,为什么说我不允许连接这个机器呢?
伊谢尔伦2017-04-17 13:18:19
I solved it later
1. You should use change master to on the slave machine and write the IP address of the master machine, but I wrote the slave’s own IP address
2. After I modified the IP, I found that The slave I/O thread stops because master and slave have equal MySQL server ids (slave and master use a common server-id number)
I checked the my.cnf file and found that the server-id number of the communication has been assigned by default
# Replication Master Server (default)
# binary logging is required for replication
# log-bin=mysql-bin
# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 2
And this default server_id number overwrites my server_id number above, causing the two server_id numbers to be the same
黄舟2017-04-17 13:18:19
It may be on the master'binlog_name.000001', position 98
. If you think the file has been truncated or deleted, you can set the location of the next binlog through master_log_file and master_log_pos in change master to