In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Server 192.168.1.1 (master) 192.168.1.2 (slave) synchronizes the server, which is required only if the server is already replicating but is not using gtid. For new servers, proceed to step 5. Set the read_only system variable on each server to ON, making the server read-only by issuing the following commands: mysql > SET @ @ global.read_only = ON;Query OK on master and slave, respectively, and 0 rows affected (0.00 sec) waits for all ongoing transactions to commit or roll back. Then, let slave catch up with master. Before continuing, make sure that slave has processed all updates, which is very important to stop the mysql services on both master and slave [root@iz2ze3bc56k6c4f3rsiahvz] # service mysqld stopRedirecting to / bin/systemctl stop mysqld.service# to see if [root@iz2ze3bc56k6c4f3rsiahvz] # ps-ef | grep mysqlroot 31143 30584 0 23:09 pts/0 00:00:00 grep-color=auto mysql# did stop enabling both servers and opening GTIDs. To enable GTID-based replication, you must start each server with GTID mode enabled by setting the gtid_mode variable to ON and enabling the enforce_gtid_consistency variable to ensure that only statements that are secure for GTID-based replication are logged. In addition, before configuring the slave settings, you should start slaves with the-skip-slave-start option. Why do you need to specify-- skip-slave-start, because if-- skip-slave-start is specified, replication will not start when mysql starts. Because the mysql.gtid_executed table was added in MySQL 5.7.5, it is not necessary to enable binary logging in order to use GTIDs. This means that you can use a slave server that has GTIDs but no binary logging. Masters must always enable binary logging so that it can be copied. Based on the above, we need to make different configurations for master and slave. Next, I will post the configuration diagram for master and slave. Master configuration parameters explain that log-bin means to turn on the binary log server _ id, which is unique, used to distinguish between servers, in the replication topology. Cannot appear the same server_idgtid_mode means to enable GTIDenforce_gtid_consistency to ensure that only the explanation of slave configuration parameters for GTID-based replication security statements is recorded (please refer to the explanation of the same parameters above) if skip-slave-start specifies-- skip-slave-start, then replication will not start when mysql starts and then start the mysql of master and slave At this point, the read-only mode of master can be disabled to configure slave to use GTID-based automatic positioning. Tell slave to use master with GTID-based transactions as the replication data source and to use GTID-based automatic location instead of file-based location. Issue a CHANGE MASTER TO statement on slave, including the MASTER_AUTO_POSITION option in the statement, telling slave that the transaction corresponding to master is recognized by GTID. Neither the MASTER_LOG_FILE option nor the MASTER_LOG_POS option can be used with MASTER_AUTO_POSITION set to 1, and an attempt to do so will cause the CHANGE MASTER TO statement to fail with an error. On master # create a copy account mysql > CREATE USER 'wangwu'@'%' IDENTIFIED BY' Wangwu@123456';Query OK, 0 rows affected (0.00 sec) mysql > GRANT REPLICATION SLAVE ON. TO 'wangwu'@'%';Query OK, 0 rows affected (0.01 sec) # must log in to the account remotely after creation, and verify that you can log in to slave and issue CHANGE MASTER TOmysql > CHANGE MASTER TO MASTER_HOST='192.168.1.1', MASTER_USER =' wangwu',MASTER_PASSWORD = 'Wangwu@123456', MASTER_AUTO_POSITION = 1 The Query OK, 0 rows affected, 2 warnings (0.01 sec) parameters explain the ip address of MASTER_HOST master, the replication username of MASTER_USER master, the password of replication user MASTER_AUTO_POSITION of MASTER_PASSWORD master, when using MASTER_AUTO_POSITION = 1 with CHANGE MASTER TO, slave attempts to connect to master using the gtid-based replication protocol. Make a new backup because you have enabled GTID, existing backups created before GTIDs is enabled are not available on these servers now. Make a new backup at this time so that you don't have a backup available. Start replication mysql > start slave;Query OK on slave, 0 rows affected (0.00 sec) # to see if mastermysql > show slave status\ G sees two YES, that means no problem disabling read-only mode is necessary only if you configured the server to read-only in step 2. To allow the server to start accepting updates again, issue the following statement: mysql > SET @ @ global.read_only = OFF;Query OK, 0 rows affected (0.00 sec) add some data to the master, and then whether you can see it in slave? if you can see it, it's fine. If you can't see it, check the error log of slave in time.
Reference: https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-howto.html
PREV:4:GTID gives a brief introduction to https://blog.51cto.com/itzhoujun/2352688
NEXT: 6: implementation of multi-source replication https://blog.51cto.com/itzhoujun/2353940
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.