In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Synchronization is invalid due to machine shutdown in the mysql master cluster. I wrote a shell script to facilitate future maintenance:
The script reads as follows:
#! / bin/bash
# set master node, slave node IP and mysql database administrator username password information to synchronize username password information
_ MASTERHOST=192.168.1.207
_ SLAVEHOST=192.168.1.208
_ USER=root
_ MASTERPASD=root
_ SLAVEPASD=root
_ TBUSER=ab
_ TBPASD=123
# configure synchronization from slave to master
Mysql-h $_ MASTERHOST-uroot-p$_MASTERPASD-e "flush tables with read lock;"
Master_log_file= `mysql-u root-h $_ MASTERHOST-p$_MASTERPASD-e "show master status;" | awk 'NR==2 {print $1}' `
Master_log_position= `mysql-u root-h $_ MASTERHOST-p$_MASTERPASD-e "show master status;" | awk 'NR==2 {print $2}' `
Mysql-h $_ MASTERHOST-uroot-p$_MASTERPASD-e "unlock tables;"
Mysql-h $_ SLAVEHOST-uroot-p$_SLAVEPASD-e "stop slave;"
Mysql-h $_ SLAVEHOST-uroot-p$_SLAVEPASD-e "CHANGE MASTER TO MASTER_HOST='$_MASTERHOST',MASTER_PORT=3306,MASTER_USER='$_TBUSER',MASTER_PASSWORD='$_TBPASD',MASTER_LOG_FILE='$master_log_file',MASTER_LOG_POS=$master_log_position;"
Mysql-h $_ SLAVEHOST-uroot-p$_SLAVEPASD-e "start slave;"
# configure master-to-slave synchronization
Mysql-h $_ SLAVEHOST-uroot-p$_SLAVEPASD-e "flush tables with read lock;"
Slave_log_file= `mysql-u root-h $_ SLAVEHOST-p$_SLAVEPASD-e "show master status;" | awk 'NR==2 {print $1}' `
Slave_log_position= `mysql-u root-h $_ SLAVEHOST-p$_SLAVEPASD-e "show master status;" | awk 'NR==2 {print $2}' `
Mysql-h $_ SLAVEHOST-uroot-p$_SLAVEPASD-e "unlock tables;"
Mysql-h $_ MASTERHOST-uroot-p$_MASTERPASD-e "stop slave;"
Mysql-h $_ MASTERHOST-uroot-p$_MASTERPASD-e "CHANGE MASTER TO MASTER_HOST='$_SLAVEHOST',MASTER_PORT=3306,MASTER_USER='$_TBUSER',MASTER_PASSWORD='$_TBPASD',MASTER_LOG_FILE='$slave_log_file',MASTER_LOG_POS=$slave_log_position;"
Mysql-h $_ MASTERHOST-uroot-p$_MASTERPASD-e "start slave;"
# check
Mysql-h $_ MASTERHOST-uroot-p$_MASTERPASD-e "show slave status\ G;" | awk'$0 ~ / Host/ | | $0 ~ / State/ | | $0 ~ / Running/'
Mysql-h $_ SLAVEHOST-uroot-p$_SLAVEPASD-e "show slave status\ G;" | awk'$0 ~ / Host/ | | $0 ~ / State/ | | $0 ~ / Running/'
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.