Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Fix method that modifies hostname and causes mysql to restart slave

2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Fix method that modifies hostname and causes mysql to restart slave

(this happens only if the information of slave is stored in the file, but this problem will not occur if it exists in the table):

Sometimes after we have changed the hostname a long time ago, after running for several months, suddenly there is something wrong with the system, restart the database, and find that start slave can't get up. Prompt that the file name and displacement of relay-log can not be found.

Solution:

> show slave status\ G write down the file name and binlog pos of the binlog to which the master is currently executed:

* * 1. Row *

Slave_IO_State: Waiting for master to send event

Master_Host: 10.0.21.66

Master_User: rpl

Master_Port: 3306

Master_Log_File: mysql-bin.000308

Exec_Master_Log_Pos: 169761782

Then execute:

> reset slave all

Re-execute the change master:

> CHANGE MASTER TO

MASTER_HOST='10.0.21.66'

MASTER_USER='rpl'

MASTER_PASSWORD='rpl'

MASTER_PORT=3306

MASTER_LOG_FILE='mysql-bin.000308'

MASTER_LOG_POS=169761782

Start slave:

> start slave

> show slave status\ G

# to prevent this from happening, we just need to configure the slave library in my.cnf before configuring it.

Master_info_repository = TABLE

Relay_log_info_repository = TABLE

Relay_log_recovery = 1

Restart the database, and then configure change master.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report