MySQL Main master Building

Source: Internet
Author: User

1. Modify it on the basis of MySQL master/slave:

#master1上

[Mysqld]

server-id=101

L Og-bin = Mysql-bin

Auto-increment-increment = 2

auto-increment-offset =

#master2上

[Mysqld]

server-id=103

Log-bin = Mysql-bin

Auto-increment-increment = 2

auto-increment-offset = 1001

2, respectively for two master to create a variety of users for each other's use

#master1的机器上mysql> CREATE USER ‘master1‘@‘%‘ IDENTIFIED BY ‘123456‘;#master2的机器上mysql> CREATE USER ‘master2‘@‘%‘ IDENTIFIED BY ‘123456‘; 

3. Grant replication permissions to users individually

 #master1的机器上mysql  > GRANT REPLICATION SLAVE on *.< Span class= "Hljs-subst" >* to  ' Master1 ' @  '% ' identified by  ' 123456 ';  #master2的机器上mysql > GRANT REPLICATION SLAVE on *. * to  ' master2 ' @ '% ' identified by  ' 123456 ';         

4, restart the service separately, through show master status to view the binary file name and POS location, to configure the replication location for slave

5. Switch master Separately, note Master_log_file and Master_log_pos

#master1的机器上

mysql> Change Master to master_host=' 192.168.137.103 ', master_user=' Master2 ', master_password=' 123456 ', master_log_file=' mysql-bin.000003 ', master_log_pos=951;

#master2的机器上

< Span class= "hljs-string" >mysql> change Master to Master_host= ' 192.168.137.101 ', Master_user= ' Master1 ', master _password= ' 123456 ', Master_log_file= ' mysql-bin.000004 ', Master_log_pos=698;

6. Then start the verification:

Start slave

Ok!!!!!!!

MySQL Main master Building

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.