mysql的主從切換

來源:互聯網
上載者:User

標籤:mysql的主從切換

切換主從:

  1. 從庫都已經執行完了relay log 中的全部更新:

mysql> stop slave io_thread;

Query OK, 0 rows affected (0.06 sec)


mysql> show processlist\G   

*************************** 1. row ***************************

     Id: 6

   User: system user

   Host: 

     db: NULL

Command: Connect

   Time: 2144

  State: Slave has read all relay log; waiting for the slave I/O thread to update it

   Info: NULL


2.停止slave

mysql> stop slave io_thread;

Query OK, 0 rows affected (0.06 sec)


[[email protected] /]# grep log-bin  /data/3307/my.cnf 

log-bin=/data/3307/mysql3307-bin

[[email protected] /]# 


[[email protected] ~]# /usr/bin/mysqladmin -p3307 --socket=/data/3307/mysql.sock shutdown 

[[email protected] ~]# /opt/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf &

[[email protected] ~]# /usr/bin/mysql -p3307 --socket=/data/3307/mysql.sock 



3.reset master

mysql> stop slave ;

Query OK, 0 rows affected (0.13 sec)


mysql> reset master;

Query OK, 0 rows affected (0.41 sec)


mysql> 



4.刪除master.info  relay-log.info


5.從庫要開啟log-bin ,關閉log-slave-updates,關閉read-only。



mysql的主從切換

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.