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 5.6 Master和Slave 主備切換MySqlAST
- The slave I/O thread stops because master and slave have equal MySQL server UUIDthreadASTMySqlServerUI
- Mysql Master-slave複製簡單配置記錄MySqlAST
- Mysqldump實現mysql的master-slave主從複製MySqlAST
- mysql slave 跟進 master 的關鍵狀態指標MySqlAST指標
- MySQL報錯Slave: received end packet from server, apparent master shutdownMySqlServerAPPAST
- Setup MariaDB Master/Slave Replication for Docker MariaDBASTDocker
- Innobackupex實現mysql線上搭建master-slave主從複製MySqlAST
- 故障案例:主從同步報錯Fatal error: The slave I/O thread stops because master and slave have equal MySQL server主從同步ErrorthreadASTMySqlServer
- 手工切換MySQL主從MySql
- 資料庫讀寫分離Master-Slave資料庫AST
- 切換分支時:pathspec master did not match any file(s) known to gitASTGit
- MySQL Orchestrator自動導換+VIP切換MySql
- Django切換MySQL資料庫DjangoMySql資料庫
- CentOS中MySQL5.6 資料庫主從(Master/Slave)同步安裝與配置詳解CentOSMySql資料庫AST
- Git使用gh-pages分支切換到master分支錯誤pathspec master did not match any files known to gitGitAST
- 使用etcd選舉sdk實踐master/slave故障轉移AST
- 分散式資料中的坑(一)Master-Slave架構分散式AST架構
- Mysql MHA部署-06手動切換MySql
- 基於Kubernetes構建企業Jenkins master/slave CI/CD平臺JenkinsAST
- mysql MGR搭建和模擬切換演練MySql
- 14. ORACLE到MYSQL上線切換方式OracleMySql
- MySQL 儲存過程進行切換表MySql儲存過程
- MySQL複製跳過錯誤--slave_skip_errors、sql_slave_skip_counter、slave_exec_modeMySqlError
- 程式切換(上下文切換)
- MySQ 資料庫主從同步安裝與配置詳解(Master/Slave)資料庫主從同步AST
- 實屬無奈!Redis 作者被迫修改 master-slave 架構的描述RedisAST架構
- MySQL 主從切換延時高問題分析MySql
- MySQL故障切換之應用無感知設計MySql
- MySQL高可用之MHA切換測試(switchover & failover)MySqlAI
- 難以置信,MySQL也可以無損自由切換MySql
- MYSQL Slave開機啟動指令碼MySql指令碼
- MySQL5.7 Master-Master主主搭建for Centos7MySqlASTCentOS
- 棧切換
- MySQL雙機互備熱備自動切換KVMySql
- MYSQL5.6主從+keepalive高可用自動切換MySql
- MySQL MHA部署 Part 7 MHA手動切換測試MySql
- mysql主備切換canal出現的問題解析MySql
- mysql 5.7+keepalived主從切換步驟簡述MySql