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

Want to play in a group? Separation of reading and writing? You have to understand this first!

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

Share

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

The answer is: Mysql master-slave synchronization, clustering, read-write separation, will involve data synchronization of data, so what do you want to play, we still have to learn the basis of this data synchronization before we can play other, today it is dream PHP to bring you this small case, pro-test, no problem!

The following examples are test cases, of course, your online server is the same! First of all, you have to ensure the unity of your operating system, the unity of the version of the database before you can open the door to data synchronization! Here are the steps!

1: First you need a virtual machine, then configure two systems on it, and of course your mysql version should be consistent.

2: You create a mysql database in your master's mysql that you want to synchronize

3: etc/in Linux directory

There's a file for my.cnf.

Configuration of the primary server

4:vi /etc/my.cnf

log-bin=mysql-bin

binlog_format=mixed

server-id = 1

binlog_do_db = test #Specify the database to be synchronized (specified according to actual situation in actual application)

binlog_ignore_db = mysql #Database without synchronization

binlog_ignore_db = information_schema #Database without synchronization

% After setting up synchronization, note that if you create a database on the master server, the slave server will also be created, and then they will also synchronize, so you have to create other databases to prevent them from synchronizing.

The red line is the configuration you want to add.

5: Log in to mysql, and then check the status of master, the file and position values of Ji County, which will be used later from service

Configuration from Server:

1: Also find that my.cnf file

log-bin=mysql-bin

binlog_format=mixed

server-id = 2 #here is 2 the master server is 1, the following database needs to be synchronized what configuration is the same as the master server

binlog_do_db = test #Specify the database to be synchronized (specified according to actual situation in practical application)

binlog_ignore_db = mysql #Database without synchronization

binlog_ignore_db = information_schema #Database without synchronization

2: Enter mysql, execute slave stop

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