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

How to deploy master-slave synchronization in mysql

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article will explain in detail how to deploy master-slave synchronization in mysql. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

Mysql master-slave synchronous deployment:

Master:192.168.2.67

Slave:192.168.2.211

The synchronization system is not the default library, and other libraries in master have been running for some time.

Master side:

Vim / etc/my.cnf

Server-id = 1 master side ID number

Log-bin=/data/logbin/mysql-bin log path and file name

# binlog-do-db = cacti synchronization cacti. If you turn it off here, all other libraries are synchronized except those that are not allowed.

Binlog-ignore-db = mysql is not synchronized with the mysql library, the following is the same as above

Binlog-ignore-db = test

Binlog-ignore-db = information_schema

/ usr/local/mysql/bin/mysql-uroot-p

Mysql > grant replication slave on *. * to rsync@'192.168.2.211' identified by '123456'

Mysql > flush privileges

Mysql > flush tables with read lock

Mysql > show master status

The values of file and position are mainly recorded here, which are used by the Slave side. As follows

File | Position |

+-

| | mysql-bin.000047 | 391592414 |

The other window runs the following:

Tar-czf / data/mysql/cacti.tgz / data/mysql/cacti

Scp / data/mysql/cacti.tgz root@192.168.2.211/data/mysql/cacti.tgz

When finished, return to the previous window to unlock read-only.

> unlock tables

Slave side:

Vim / etc/my.cnf

Server-id = the ID number of 2 slave, which must be larger than the master side.

Save exit.

/ usr/local/mysql/bin/mysqladmin-uroot-p shutdown

Tar xvzf / data/mysql/cacti.tgz / data/mysql/cacti

Chown-R mysql.mysql / data/mysql/cacti

/ usr/local/mysql/bin/mysql-uroot-p

Mysql > stop slave

Mysql > change master to

> master_host='192.168.2.67'

Accounts and passwords created by master_user='rsync', master for master-slave synchronization

> master_password='123456'

> the port number used by the client port set by the master_port='3306', master port.

> the file value recorded on the master_log_file='mysql-bin.000047', master side

The position value of the master_log_pos=391592414; master record

Mysql > start slave

Mysql > show slave status\ G

* * 1. Row *

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.2.67

Master_User: rsync

Master_Port: 3306

Connect_Retry: 30

Master_Log_File: mysql-bin.000047

Read_Master_Log_Pos: 413641446

Relay_Log_File: backter-relay-bin.000002

Relay_Log_Pos: 13433937

Relay_Master_Log_File: mysql-bin.000047

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 405026116

Relay_Log_Space: 22049267

Until_Condition: None

Until_Log_File:

Until_Log_Pos: 0

Master_SSL_Allowed: No

Master_SSL_CA_File:

Master_SSL_CA_Path:

Master_SSL_Cert:

Master_SSL_Cipher:

Master_SSL_Key:

Seconds_Behind_Master: 148

1 row in set (0.00 sec)

On how to deploy master-slave synchronization in mysql to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.

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