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--
Server 192.168.1.2 (master), server 192.168.1.3 (old slave) server 192.168.1.4 (new slave) you can add another slave to the existing replication configuration without stopping master. To do this, you can set up the new slave by copying the existing slave's data directory and providing a different server ID (specified by the user) and server UUID (generated at startup) for the new slave. Stop copying mysql > stop slave on old slave# Query OK 0 rows affected (0.00 sec) # View primary binary log file and relay log file location mysql > show slave status\ G# disable old slave's mysql service [root@iZ2zee8t2icu340bpmaw23Z ~] # service mysqld stopRedirecting to / bin/systemctl stop mysqld.service [root@iZ2zee8t2icu340bpmaw23Z ~] # ps-ef | grep mysqlroot 14618 14474 0 21:33 pts/0 00:00:00 grep-color=auto mysql# packages old slave data directory [root@iZ2zee8t2icu340bpmaw23Z ~] # cat / etc/my.cnf | Grep datadirdatadir=/var/lib/mysql [root@iZ2zee8t2icu340bpmaw23Z ~] # cd / var/lib/mysql [root@iZ2zee8t2icu340bpmaw23Z mysql] # tar-zcvf / tmp/file.tar.gz * # start MySQL [root @ iZ2zee8t2icu340bpmaw23Z mysql] # service mysqld start# to start copying mysql > start slave Query OK, 0 rows affected, 1 warning (0.00 sec) on new slave # close mysql [root@iZ2ze7skefrz53o5o1at5hZ ~] # service mysqld stopRedirecting to / bin/systemctl stop mysqld.service# copy old slave's data directory first Enter the local mysql data directory [root@iZ2ze7skefrz53o5o1at5hZ ~] # cat / etc/my.cnf | grep datadirdatadir=/var/lib/mysql [root@iZ2ze7skefrz53o5o1at5hZ ~] # cd / var/lib/mysql# use scp to get the data to [root@iZ2ze7skefrz53o5o1at5hZ mysql] # scp root@192.168.1.3:/tmp/file.tar.gz / tmp#. At this time, we need to back up the local data [root@iZ2ze7skefrz53o5o1at5hZ mysql] # tar-zcvf / tmp/mysql. _ back.tar.gz * # then compress the old slave data to [root@iZ2ze7skefrz53o5o1at5hZ mysql] # tar-zxvf / tmp/file.tar.gz# to delete the auto.cnf file from the copy of the data directory on the current machine To start the new slave server with a different build server UUID. Server UUID must be unique. [root@iZ2ze7skefrz53o5o1at5hZ mysql] # rm auto.cnfrm: remove regular file 'auto.cnf'? Y# configure server_id and-- skip-slave-start options for the server, and if-- skip-slave-start is specified, replication will not start when mysql starts. # start the mysql server and log in to view the relevant information. (note here that because you copied the old slave data directory directly, enter the user password corresponding to old slave when you log in to mysql. Finally, you need to modify) mysql > show slave status\ G# if it corresponds to step4, then there is no problem, and then start copying mysql > start slave ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository#1872 error at this time, let's check the error log [root@iZ2ze7skefrz53o5o1at5hZ ~] # tail-f / var/log/mysqld.log
It means that the. / iZ2zee8t2icu340bpmaw23Z-relay-bin.000004 relay log file cannot be found from. / iZ2ze7skefrz53o5o1at5hZ-relay-bin.index because I am using an instance of cold backup file recovery, which still retains the previous relay_log information in the slave_relay_log_ information table in the mysql library, which causes the startup slave to report an error. The solutions are as follows: mysql > reset slave;Query OK, 0 rows affected (0.02 sec) mysql > start slave;Query OK, 0 rows affected (0.02 sec) mysql > show slave status\ G
* then it means that you have successfully added the test data to see if the data is synchronized.
Note:
On the new slave, be sure to check the error log and compare the show slave status content of the new slave with the existing slave to see if there is any difference between Master_Log_File and Read_Master_Log_Pos. Because you directly copied the data directory of old slave, when you log in to the mysql of new salve, enter the user password corresponding to old slave, and finally you need to modify it.
Reset slave explanation:
Reference link: https://dev.mysql.com/doc/refman/5.7/en/reset-slave.htmlRESET SLAVE makes the slave forget its replication position in the master's binary log. This statement is meant to be used for a clean start: It clears the master info and relay log info repositories, deletes all the relay log files, and starts a new relay log file. It also resets to 0 the replication delay specified with the MASTER_DELAY option to CHANGE MASTER TO. RESET SLAVE does not change the values of gtid_executed or gtid_purged.RESET SLAVE makes slave forget where master's binaries are copied. It is mainly used to start a replication cleanly, which clears the master information and relay log information base (that is, the mysql.slave_master_info and slave_relay_log_info tables), deletes all relay log files, and starts a new relay log file. Resets the value specified by the MASTER_DELAY option of CHANGE MASTER TO to 0 gtid_executed reset SLAVE does not change the value of gtid_executed or gtid_purged.
Reference link: https://dev.mysql.com/doc/refman/5.7/en/binlog-replication-configuration-overview.html
PREV: 2: replication https://blog.51cto.com/itzhoujun/2351367 based on binary log file location
NEXT: 4:GTID briefly introduces https://blog.51cto.com/itzhoujun/2352688
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.