1.mysqlrpladmin 检查主从同步情况。
mysqlrpladmin --master=root:root@192.168.1.51:3306 --slaves=root:root@192.168.1.58:3306 --verbose health
[root@mysql1 mysql]# mysqlrpladmin --master=root:rootroot@192.168.1.51:3306 --slaves=root:rootroot@192.168.1.58:3306 --verbose health
WARNING: Using a password on the command line interface can be insecure.
# Checking privileges.
# Attempting to contact 192.168.1.51 ... Success
# Attempting to contact 192.168.1.58 ... Success
2.停止所有从库。
我们这里只有一个从库,用逗号分隔。
[root@mysql1 mysql]# mysqlrpladmin --master=root:rootroot@192.168.1.51:3306 --slaves=root:rootroot@192.168.1.58:3306 --verbose stop
WARNING: Using a password on the command line interface can be insecure.
# Checking privileges.
# Performing STOP on all slaves.
# Executing stop on slave 192.168.1.58:3306 Ok
# ...done.
3.检查从库
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.51
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-binlog.000088
Read_Master_Log_Pos: 803
Relay_Log_File: mysql2-relay-bin.000002
Relay_Log_Pos: 626
Relay_Master_Log_File: mysql-binlog.000088
Slave_IO_Running: No
Slave_SQL_Running: No
发现从库确实已经关闭。
4.启动从库。
[root@mysql1 mysql]# mysqlrpladmin --master=root:rootroot@192.168.1.51:3306 --slaves=root:rootroot@192.168.1.58:3306 --verbose start
WARNING: Using a password on the command line interface can be insecure.
# Checking privileges.
# Performing START on all slaves.
# Executing start on slave 192.168.1.58:3306 Ok
# ...done.
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.51
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-binlog.000088
Read_Master_Log_Pos: 803
Relay_Log_File: mysql2-relay-bin.000003
Relay_Log_Pos: 363
Relay_Master_Log_File: mysql-binlog.000088
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
发现确实启动了,且在同步。
mysqlrpladmin --master=root:rootroot@192.168.1.51:3306 --slaves=root:rootroot@192.168.1.58:3306 --verbose elect
--总是无法执行成功。
--从库报错。
[Note] Aborted connection 48 to db: 'unconnected' user: 'root' host: '192.168.1.51'
(Got an error reading communication packets)
5.总结。
mysqlrpladmin 可以查看:
1.主从状态。
2.IO,SQL线程的状态。
3.从库比主从延迟情况。
4.数据库版本。
5.当前同步的未知。
6.启动从库
7.关闭从库。