Want to play cluster? Read and write separation? You need to know this first!

Source: Internet
Author: User

The answer is: MySQL master-slave synchronization, clustering, read and write separation, will involve data synchronization, so want to play what things, we still want to put this data synchronization of the basic learning after we can play other, today, think of the dream of PHP to everyone brought this small case, pro-test, no problem!

The following case is a test case, of course, your online server is the same! First you want to ensure that the unity of your operating system, the unity of the version of the database you can open the door of data synchronization! Here's the next step!

1: First you need a virtual machine, then configure the two systems above, of course your MySQL version to be consistent

2: You create a MySQL database in your master's MySQL that you want to sync

etc/under the 3:linux directory

There's a my.cnf file.

Configuration of the primary server

4:vi/etc/my.cnf

Log-bin=mysql-bin

Binlog_format=mixed

Server-id = 1

binlog_do_db = Test #指定需要同步的数据库 (actual application is specified according to the actual situation)

binlog_ignore_db = MySQL #无需同步的数据库

binlog_ignore_db = Information_schema #无需同步的数据库

% settings After synchronization note that if you create a database on the primary server, it will be created from the server, and then they will be synchronized, so you will have to create additional databases to be banned from syncing

Inside the red line is the configuration you want to add

5: Log in to MySQL, and then check the status of the master, the value of the file and position in Jixian, which is used later from the service

Configuration from the server:

1: Also find the file of the MY.CNF

Log-bin=mysql-bin

Binlog_format=mixed

Server-id = 2 #这里是2 The primary server is 1, the following database needs to be synchronized what configuration is the same as the master server

binlog_do_db = Test #指定需要同步的数据库 (actual application is specified according to the actual situation)

binlog_ignore_db = MySQL #无需同步的数据库

binlog_ignore_db = Information_schema #无需同步的数据库

2: Go to MySQL, execute slave stop

Want to play cluster? Read and write separation? You need to know this first!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.