Generally, the server IP address cannot be changed at will. If the mysql Master/Slave fails to be changed, I will introduce the process of changing the IP address of the master server under MySQL Master/Slave replication.
All the servers of the company are finally placed in the same data center and Intranet access is enabled. In this way, you must change the configuration of several MySQL slave servers.
.
Backup
First, disable the MySQL server (slave) and backup configuration information.
The Code is as follows: |
Copy code |
Service mysqld stop |
The Code is as follows: |
Copy code |
# Go To The mysql directory Cd/var/lib/mysql # Backup configuration Cp master.info. bak # Viewing the number of rows Wc-l <master.info
|
Wc is used to ensure that the number of rows in master.info remains the same after modification.
Modify
Then, modify the IP address in master.info to the IP address of the new master server.
Then, start the MySQL server without starting replication.
The Code is as follows: |
Copy code |
Service mysql start -- skip-slave-start
|
Verify
Log on to MySQL and run SHOW slave status G
If the IP address is the new IP address, congratulations. The modification is successful. Then you can start replication.
The Code is as follows: |
Copy code |
Start slave; SHOW SLAVE STATUSG * *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 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: |