1.先停止複製進程:
dbadmin@(none) 08:05:45>stop slave;
Query OK, 0 rows affected (0.10 sec)
2.查看叢庫的狀態及複製點座標:
dbadmin@(none) 08:05:52>show slave status \G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: Master_Host
Master_User: Master_User
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.004476
Read_Master_Log_Pos: 289617713
Relay_Log_File: mysqld-relay-bin.000067
Relay_Log_Pos: 289617859
Relay_Master_Log_File: mysql-bin.004476
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 289617713
Relay_Log_Space: 289618059
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 612
1 row in set (0.00 sec)
3.查看一下master.info與relay-log.info文件中的信息,此時文件中記錄的信息與show slave status顯示的信息一致。
dbadmin@(none) 08:05:55>system cat /vobiledata/mysqldata/master.info;
18
mysql-bin.004476
289617713
Master_Host
repl
pass
3306
60
0
0
0.000
0
dbadmin@(none) 08:07:52>system cat /vobiledata/mysqldata/relay-log.info;
./mysqld-relay-bin.000067
289617859
mysql-bin.004476
289617713
4.不帶MASTER_LOG_FILE,MASTER_LOG_POS參數,執行change master 語句,按照mysql官方文檔的說法,執行語句後的複製點應該與之前的複製點一致,然而事實並非如此,執行該語句後,複製點被清空,記錄在master.info和relay-log.info文件中的關於複製點的信息也被清空,如下:
dbadmin@(none) 08:08:24>CHANGE MASTER TO MASTER_HOST='Master_Host', MASTER_USER='repl', MASTER_PASSWORD='pass';
Query OK, 0 rows affected (0.11 sec)
dbadmin@(none) 08:08:55>show slave status \G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: Master_Host
Master_User: Master_User
Master_Port: 3306
Connect_Retry: 60
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: mysqld-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 0
Relay_Log_Space: 107
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 612
1 row in set (0.00 sec)
dbadmin@(none) 08:09:01>system cat /vobiledata/mysqldata/master.info;
18
4
Master_Host
repl
pass
3306
60
0
0
1800.000
0
60
0
0
0.000
0
dbadmin@(none) 08:09:17>system cat /vobiledata/mysqldata/relay-log.info;
./mysqld-relay-bin.000001
4
0
7859
mysql-bin.004476
289617713
重啓複製進程,發現複製點被莫名奇妙的變成了另外一個值,這個值既不是執行語句前的複製點,也不是執行語句後的複製點。
dbadmin@(none) 08:09:26>start slave;
Query OK, 0 rows affected (0.00 sec)
dbadmin@(none) 08:09:47>show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: Master_Host
Master_User: Master_User
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.004430
Read_Master_Log_Pos: 9547576
Relay_Log_File: mysqld-relay-bin.000003
Relay_Log_Pos: 360
Relay_Master_Log_File: mysql-bin.004429
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 214
Relay_Log_Space: 53239
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 436462
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 612
1 row in set (0.00 sec)
dbadmin@(none) 08:09:52>show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: Master_Host
Master_User: Master_User
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.004430
Read_Master_Log_Pos: 61188972
Relay_Log_File: mysqld-relay-bin.000003
Relay_Log_Pos: 360
Relay_Master_Log_File: mysql-bin.004429
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 214
Relay_Log_Space: 53239
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 436482
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 612
1 row in set (0.00 sec)
趕緊停止複製,發現命令居然被長時間卡住,嘗試停止mysql服務,超時異常,最後通過kill 系統進程,並重啓mysql服務,重新設爲正確的複製點。
dbadmin@(none) 08:10:12>stop slave;
查看error log,發現有如下日誌:
160510 8:08:55 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='192.168.110.113', master_port='3306', master_log_file='mysql-bin.004476', master_log_pos='289617713'. New state master_host='192.168.110.113', master_port='3306', master_log_file='', master_log_pos='4'.
160510 8:09:47 [Note] Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log './mysqld-relay-bin.000001' position: 4
160510 8:09:47 [Note] Slave I/O thread: connected to master '[email protected]:3306',replication started in log 'FIRST' at position 4