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

【从大坑中爬出】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

 

 

Comments (7)

  1. db浆糊

    Reply
    1. 香蕉与打火机 (Post author)

      昨儿把MHA配上了,这两天有时间再试试主主从

      Reply
  2. db浆糊

    好的

    Reply
  3. Pingback: mysql MHA configuration | 香蕉与打火机

  4. 歪妖内涵网

    无意溜达到了这里,留下足迹

    Reply
  5. 最励志官网

    很好的网站,赞一个,加油!

    Reply
  6. 糗事百科

    来瞅瞅啦~

    Reply

Leave a Comment

电子邮件地址不会被公开。 必填项已用*标注