Mysql Slave群切換Master (=)
續上。
Mysql Slave群切換Master 後,master轉為slave:
注意:原來的slave變為master後,日誌已經重置,
MASTER_LOG_FILE='mysql-bin.000019',MASTER_LOG_POS=106不在需要,從頭開始應用:
mysql> RESET slave;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.1.202',
-> MASTER_USER='rep',
-> MASTER_PASSWORD='rep',
-> MASTER_LOG_FILE='mysql-bin.000019',
-> MASTER_LOG_POS=106;
Query OK, 0 rows affected (0.17 sec)
-> MASTER_HOST='192.168.1.202',
-> MASTER_USER='rep',
-> MASTER_PASSWORD='rep',
-> MASTER_LOG_FILE='mysql-bin.000019',
-> MASTER_LOG_POS=106;
Query OK, 0 rows affected (0.17 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.202
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000019
Read_Master_Log_Pos: 106
Relay_Log_File: node1-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000019
Slave_IO_Running: No
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: 106
Relay_Log_Space: 106
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: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.1.202
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000019
Read_Master_Log_Pos: 106
Relay_Log_File: node1-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000019
Slave_IO_Running: No
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: 106
Relay_Log_Space: 106
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: 1236
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.1.202',
-> MASTER_USER='rep',
-> MASTER_PASSWORD='rep';
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
-> MASTER_HOST='192.168.1.202',
-> MASTER_USER='rep',
-> MASTER_PASSWORD='rep';
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.1.202',
-> MASTER_USER='rep',
-> MASTER_PASSWORD='rep';
Query OK, 0 rows affected (0.05 sec)
-> MASTER_HOST='192.168.1.202',
-> MASTER_USER='rep',
-> MASTER_PASSWORD='rep';
Query OK, 0 rows affected (0.05 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.202
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: node2-bin.000001
Read_Master_Log_Pos: 400
Relay_Log_File: node1-relay-bin.000002
Relay_Log_Pos: 545
Relay_Master_Log_File: node2-bin.000001
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: 400
Relay_Log_Space: 700
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.202
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: node2-bin.000001
Read_Master_Log_Pos: 400
Relay_Log_File: node1-relay-bin.000002
Relay_Log_Pos: 545
Relay_Master_Log_File: node2-bin.000001
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: 400
Relay_Log_Space: 700
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aa |
| t3 |
| testrep |
+----------------+
3 rows in set (0.01 sec)
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aa |
| t3 |
| testrep |
+----------------+
3 rows in set (0.01 sec)
mysql> select * from t3;
+------+
| i |
+------+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 2 |
| 3 |
| 333 |
| 333 |
| 666 |
| 666 |
+------+
11 rows in set (0.00 sec)
+------+
| i |
+------+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 2 |
| 3 |
| 333 |
| 333 |
| 666 |
| 666 |
+------+
11 rows in set (0.00 sec)
mysql> select * from testrep;
+------+
| i |
+------+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 2 |
| 3 |
| 333 |
| 333 |
| 666 |
| 666 |
| 888 |
+------+
12 rows in set (0.00 sec)
+------+
| i |
+------+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 2 |
| 3 |
| 333 |
| 333 |
| 666 |
| 666 |
| 888 |
+------+
12 rows in set (0.00 sec)
mysql>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-680473/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Mysql Slave群切換MasterMySqlAST
- Mysql 5.6 Master和Slave 主備切換MySqlAST
- MySQL Master/Slave Master/MasterMySqlAST
- MySQL master/slaveMySqlAST
- MySql的Master/SlaveMySqlAST
- mysql master和slave配置MySqlAST
- mysql slave 轉為 masterMySqlAST
- MySQL 5.5 Master/Slave 配置MySqlAST
- mysql master slave 主從同步MySqlAST主從同步
- mysql 同步 master-slave薦MySqlAST
- MySQL master and slave have equal MySQL server UUIDsMySqlASTServerUI
- MySQL錯誤之mysql.slave_master_infoMySqlAST
- mysql建立master/slave詳細步驟MySqlAST
- 利用mysql slave 修復master MyISAM tableMySqlAST
- GP standby切換成masterAST
- Redis master and slaveRedisAST
- MYSQL的master/slave資料同步配置(轉)MySqlAST
- The slave I/O thread stops because master and slave have equal MySQL server UUIDthreadASTMySqlServerUI
- Mysql Master-slave複製簡單配置記錄MySqlAST
- mysql master-slave複製錯誤[解決事例]MySqlAST
- MYSQL5的master slave資料同步配置(轉)MySqlAST
- mysql slave 跟進 master 的關鍵狀態指標MySqlAST指標
- Mysqldump實現mysql的master-slave主從複製MySqlAST
- master and slave have equal MySQL server UUIDs問題解決ASTMySqlServerUI
- MySQL 5.5.x 配置Master-Slave主從複製MySqlAST
- Mongodb的master-slave模式與master-master模式實驗MongoDBAST模式
- Innobackupex實現mysql線上搭建master-slave主從複製MySqlAST
- MySQL報錯Slave: received end packet from server, apparent master shutdownMySqlServerAPPAST
- Linux環境下MySQL5.6Master-Slave配置實戰LinuxMySqlAST
- Jenkins : 安裝 master 和 slaveJenkinsAST
- 用mysqldump --master-data 建立slaveMySqlAST
- MYSQL5.7 MASTER-SLAVE 線上關閉和啟動GTIDMySqlAST
- MySQL主從切換MySql
- mysql5.6,master/slave架構,master,不寫bingo原因,無法開啟同步複製MySqlAST架構Go
- 【MySQL】【高可用】從masterha_master_switch工具簡單分析MHA的切換邏輯MySqlAST
- slave之Seconds_Behind_Master析AST
- 【Mysql】Slave_IO_Running: No---Got fatal error 1236 from masterMySqlGoErrorAST
- 手工切換MySQL主從MySql