【从大坑中爬出】mysql 将 slave 转为 master

一、查看日志应用状态

mysql> show processlist;
+----+------+---------------+-------+-------------+------+-----------------------------------------------------------------------+------------------+-----------+---------------+
| Id | User | Host          | db    | Command     | Time | State                                                                 | Info             | Rows_sent | Rows_examined |
+----+------+---------------+-------+-------------+------+-----------------------------------------------------------------------+------------------+-----------+---------------+
|  5 | root | localhost     | ifree | Sleep       | 2250 |                                                                       | NULL             |         0 |             0 |
| 17 | rep  | testdb2:41690 | NULL  | Binlog Dump | 2400 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL             |         0 |             0 |
| 19 | root | localhost     | NULL  | Query       |    0 | init                                                                  | show processlist |         0 |             0 |
+----+------+---------------+-------+-------------+------+-----------------------------------------------------------------------+------------------+-----------+---------------+
3 rows in set (0.00 sec)

(其实我也没看懂。。。)

二、修改/etc/my.cnf(参考master配置,此处祭出师父blog,略)

http://debugo.com/mysql-5-6-master-slave/

三、停slave,关掉只读

    1.停slave

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

    2.关只读

mysql> set global read_only=0;
Query OK, 0 rows affected (0.00 sec)

    3.重置slave

mysql> reset slave;
Query OK, 0 rows affected (0.01 sec)

四、如果未生效则重启下mysql进程试试


参考:http://blog.itpub.net/758322/viewspace-714346



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。