程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> MySQL主從復制下改變主服務器IP

MySQL主從復制下改變主服務器IP

編輯:關於MYSQL數據庫

公司所有服務器終於放到同一個機房,開通了內網訪問。這樣,就必須更改某幾台MySQL從服務器的配置,變成內網訪問。

備份

首先是關閉MySQL服務器(slave端)以及備份配置信息

service MySQLd stop

#進入到MySQL目錄
cd /var/lib/MySQL
#備份配置
cp master.info master.info.bak
#查看行數
wc -l < master.info

wc是為了確保修改後master.info的行數保持一樣

修改

之後,修改master.info裡的IP為新的主服務器的IP地址。

然後,不啟動replication的情況下啟動MySQL服務器

service MySQL start --skip-slave-start

驗證

登錄到MySQL並運行SHOW slave status \G

如果看到的IP為新的地址,那麼恭喜,修改成功,接著可以啟動replication了

START SLAVE;
SHOW SLAVE STATUS\G

    *************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: xx.xx.xx.xx
                  Master_User: slave_user
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: master-bin.xxxx
          Read_Master_Log_Pos: xxxxxxxx
               Relay_Log_File: slave-relay-bin.xxxx
                Relay_Log_Pos: xxxxxxxx
        Relay_Master_Log_File: master-bin.xxxx
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB: MySQL,test,information_schema
           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: xxxxxxxxx
              Relay_Log_Space: xxxxxxxxx
              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. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved