Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mariadb cluster master and slave

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. On the primary node / etc/my.cnf

Service-id=1

Authorize the permissions of backup users in the main library mysql

Grant replication slave on *. * to backup@'%' identified by 'password'

Export the whole database at the terminal to ensure the consistency of the offset of the database-- master-data=2

Mysqldump-u root-- master-data=2-- all-databases > / tmp/backup.sql

Grep-I "change master to" / tmp/backup.sql records the MASTER_LOG_FILE='mysql-bin.000006', MASTER_LOG_POS=59583; of the first line for use on the slave library

Or execute show master status on the main library\ G can also view

Systemctl restart mariadb

2. On the slave node / etc/my.cnf

Service-id=2

Then save the file to execute from the library mysql

CHANGE MASTER TO

MASTER_HOST='192.168.1.2'

MASTER_USER='backup'

MASTER_PASSWORD='password'

MASTER_LOG_FILE='mysql-bin.000006'

MASTER_LOG_POS=59583

Start slave; starts the slave library

Show slave status\ G check status IO and SQL are both yes and ok

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Show variables like 'server_id'

Set global server_id=2

Show global variables like'% max_connect_errors%'

Set global max_connect_errors=4000; defaults to 100

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report