mysql slave 轉為 master
1 檢查日誌是否已全部應用:
mysql> show processlist;
+----+-------------+--------------------+------+---------+------+-----------------------------------------------------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+-------------+--------------------+------+---------+------+-----------------------------------------------------------------------+------------------+
| 1 | root | localhost | test | Query | 0 | NULL | show processlist |
| 4 | system user | | NULL | Connect | 345 | Waiting for master to send event | NULL |
| 5 | system user | | NULL | Connect | 295 | Has read all relay log; waiting for the slave I/O thread to update it | NULL |
| 7 | testuser | 192.168.1.100:1506 | NULL | Sleep | 122 | | NULL |
| 8 | testuser | 192.168.1.100:1507 | test | Sleep | 86 | | NULL |
| 9 | testuser | 192.168.1.100:1508 | test | Sleep | 29 | | NULL |
+----+-------------+--------------------+------+---------+------+-----------------------------------------------------------------------+------------------+
6 rows in set (0.00 sec)
2 停止slave,去掉readonly,reset slave:
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
CHANGE master TO master_host='';
mysql> SET global read_only=0;
Query OK, 0 rows affected (0.00 sec)
mysql> reset slave;
Query OK, 0 rows affected (0.04 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 | 869 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
3 修改my.cnf 一些引數(可以考慮重啟一下)
4 關於 reset slave:
RESET SLAVE [ALL]
RESET SLAVE makes the slave forget its replication position in the master's binary log. This statement is meant to be used for a clean start: It deletes the master.info and relay-log.info files, all the relay log files, and starts a new relay log file. To use RESET SLAVE, the slave replication threads must be stopped (use STOP SLAVE if necessary).
All relay log files are deleted, even if they have not been completely executed by the slave SQL thread. (This is a condition likely to exist on a replication slave if you have issued a STOP SLAVE statement or if the slave is highly loaded.)
In MySQL 5.5 (unlike the case in MySQL 5.1 and earlier), RESET SLAVE does not change any replication connection parameters such as master host, master port, master user, or master password, which are retained in memory. This means that START SLAVE can be issued without requiring a CHANGE MASTER TO statement following RESET SLAVE.
In MySQL 5.5.16 and later, you can use RESET SLAVE ALL to reset these connection parameters (Bug #11809016). Connection parameters are also reset if the slave mysqld is shut down.
If the slave SQL thread was in the middle of replicating temporary tables when it was stopped, and RESET SLAVE is issued, these replicated temporary tables are deleted on the slave.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-714346/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL Master/Slave Master/MasterMySqlAST
- MySQL master/slaveMySqlAST
- MySql的Master/SlaveMySqlAST
- mysql master和slave配置MySqlAST
- MySQL 5.5 Master/Slave 配置MySqlAST
- MYSQL的master/slave資料同步配置(轉)MySqlAST
- mysql master slave 主從同步MySqlAST主從同步
- mysql 同步 master-slave薦MySqlAST
- Mysql Slave群切換MasterMySqlAST
- Mysql Slave群切換Master (=)MySqlAST
- MYSQL5的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
- Redis master and slaveRedisAST
- 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
- mysql 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
- 使用etcd選舉sdk實踐master/slave故障轉移AST
- mysql5.6,master/slave架構,master,不寫bingo原因,無法開啟同步複製MySqlAST架構Go
- slave之Seconds_Behind_Master析AST
- 【Mysql】Slave_IO_Running: No---Got fatal error 1236 from masterMySqlGoErrorAST
- 故障案例:主從同步報錯Fatal error: The slave I/O thread stops because master and slave have equal MySQL server主從同步ErrorthreadASTMySqlServer
- Setup MariaDB Master/Slave Replication for Docker MariaDBASTDocker
- MySQL新建SlaveMySql