In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Master-Slave Cascade replication of MySQL replication Technology
Master database: mysqld1 on 192.168.12.181
Relay mysqld1 on slave:192.168.12.182
Mysqld4 on cascaded slave:192.168.12.181
The Master database synchronizes the data to the relay slave, and then the relay slave acts as the master database of the cascaded slave for data replication. Under the configured master-slave structure, the master configuration does not need to be changed, only the relay slave and cascading slave need to be configured. The implementation steps are as follows:
(1) Relay slave configuration
a. Configure my.cnf
# / etc/my.cnf
Log_slave_updates=1
Log_bin=/data/mysql/log/vm2-bin.log # the above two are key parameters that must be configured
Read_only=ON # optional
Once configured, restart mysqld
b. Query master status
On the relay slave, query master status and record file and position as the synchronization starting point for cascading slave
[mysql] > show master status
+-+
| | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | |
+-+
| | vm2-bin.000009 | 450 | |
+-+
1 row in set (0.00 sec)
c. Backup Relay slave
Backup relay slave as a restore data source for cascading slave
[root@vm2] # mysqldump-uroot-p-- all-databases > slave_bak.sql
[root@vm2 ~] # scp slave_bak.sql vm1:/data/ # to cascade slave
(2) prepare to cascade slave
a. Configuration of cascaded slave
# / etc/my.cnf
[mysqld4]
Port=3309
Basedir=/usr
Datadir=/data/mysql/data4
Socket=/var/lib/mysql/mysql4.sock
Pid-file=/var/run/mysqld/mysqld4.pid
Log-error=/data/mysql/log4/mysqld4.log
User=mysql
Relay-log=/data/mysql/log4/vm4-slave-bin.log
Server_id=4
Slave-skip-errors=all
Start mysqld4, and the database will be initialized at startup through the mysqld_multi command
# mysqld_multi start 4
b. Restore the backup of the relay database
[root@vm1 data] # mysql-uroot-p-S / var/lib/mysql/mysql4.sock
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.