当前位置:数据库 > MySQL >>

MySQL主从复制下改变主服务器IP配置过程

公司所有服务器终于放到同一个机房,开通了内网访问。这样,就必须更改某几台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 STATUSG

    *************************** 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:

补充:数据库,mysql教程 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,