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

Example Analysis of mysql Master-Slave configuration in Linux

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you the "sample analysis of mysql master-slave configuration in Linux", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of mysql master-slave configuration in Linux".

Mysql master-slave configuration

1. Prepare

Host: 192.168.244.128

Slave: 192.168.244.130

Configure the host

2. Authorize to the slave server

GRANT REPLICATION SLAVE ON *. * to 'rep1'@'192.168.244.130' identified by' root@bisnow';FLUSH PRIVILEGES

This means that the configuration slave login user name is rep1 and the password is 123, and you must log in from the address 192.168.248.139. After successful login, you can manipulate any table in any library. Among them, if you do not need to restrict the login address, you can change the IP address to one%.

3. Modify the configuration file of the main library

Vi / etc/ my.cnf [mysqld] log-bin=/var/lib/mysql/binlogserver-id=130binlog-do-db = the ID number on the cmdb server-id:master side; log-bin: the log path and file name of synchronization, be sure to note that if mysql has permission to write to this directory (I am lazy here, put it directly under the following datadir); binlog-do-db: the database name to be synchronized

4. Restart the mysql service after configuration

Systemctl restart mysqld.service

5. Check the current binary log name and offset of the master server. The purpose of this operation is to recover the data from this point after starting from the slave database.

Mysql > show master status

Configure Slave

6. Add the following configuration in / etc/my.cnf

Server-id=131

Note: if the slave is copied from the host, the uuid of both mysql is the same and needs to be manually modified in the auto.cnf file in the data directory.

Vi / var/lib/mysql/auto.cnf

7. Use the command to configure the slave:

Change master to master_host='192.168.244.128',master_port=3306,master_user='rep1',master_password='root@bisnow',master_log_file='binlog.000002',master_log_pos=120

8. Start the slave process

9. Check the status of slave. If the following two values are YES, the configuration is correct:

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

At this point, the configuration is complete, the host creates a library, adds data, and automatically synchronizes from the opportunity.

The above is all the contents of the article "sample Analysis of mysql Master-Slave configuration in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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