[root@mysql-s ~]# mysql -uroot -p123456 -S /tmp/mysql.sock -e "SHOW SLAVE STATUS FOR CHANNEL 'mysql-m1'\G"|egrep "Slave_IO_Running|Slave_SQL_Running"
mysql: [Warning] Using a password on the command line interface can be insecure.
Slave_IO_Running: Connecting (报错) 此处为yes才是正常的
Slave_SQL_Running: Yes
[root@mysql-s ~]# mysql -urep -p123456 -h192.168.56.21
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.56.21' (113)
[root@mysql-s ~]# mysql -urep -p123456 -h192.168.56.22
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.56.22' (113)
[root@mysql-s ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules:
[root@mysql-m1 tmp]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules:
[root@mysql-m2 tmp]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@mysql-m2 tmp]#
7.3. 修改/ect/my.cnf中server_id 未生效:
[root@mysql-s ~]# mysql -urep -p123456 -h192.168.56.21 成功连接
但是从库连接mysql-m1还是报错:
但是从库连接mysql-m2还是报错:
[root@mysql-s ~]# mysql -uroot -p123456 -S /tmp/mysql.sock -e "SHOW SLAVE STATUS FOR CHANNEL 'mysql-m1'\G"|egrep "Slave_IO_Running|Slave_SQL_Running|Last_IO_Error"
mysql: [Warning] Using a password on the command line interface can be insecure.
Slave_IO_Running: No
Slave_SQL_Running: Yes
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server>
Slave_SQL_Running_State: Slave has read all> Last_IO_Error_Timestamp: 160508 03:03:05
原因是/ect/my.cnf 配置文件中修改server_id时。没有重启服务,所以修改没有生效
[root@mysql-s mysql-5.7.10]# cd /aliyun/server/mysql-5.7.10/
pkill mysqld
[root@mysql-s mysql-5.7.10]# sh start_mysql.sh
三个数据库都同样操作
7.4.但是还是报错:
[root@mysql-s ~]# mysql -uroot -p123456 -S /tmp/mysql.sock -e "SHOW SLAVE STATUS FOR CHANNEL 'mysql-m1'\G"|egrep "Slave_IO_Running|Slave_SQL_Running|Last_IO_Error"
mysql: [Warning] Using a password on the command line interface can be insecure.
Slave_IO_Running: No
Slave_SQL_Running: Yes
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
Slave_SQL_Running_State: Slave has read all> Last_IO_Error_Timestamp: 160508 03:23:36
[root@mysql-s mysql-5.7.10]# mysql -uroot -p123456 -S /tmp/mysql.sock -e "SHOW SLAVE STATUS FOR CHANNEL 'mysql-m1'\G"|egrep "Slave_IO_Running|Slave_SQL_Running|Last_IO_Error"
mysql: [Warning] Using a password on the command line interface can be insecure.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Last_IO_Error:
Slave_SQL_Running_State: Slave has read all> Last_IO_Error_Timestamp:
可以通过查看performance_schema相关的表查看同步状态,执行命令:
mysql> SELECT * FROM performance_schema.replication_connection_status;
监控复制状态