In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.