Database Master-Slave (2)

Source: Internet
Author: User

Main

1.

My.cnf


Server-id = 1

Log-bin=mysql-bin

Read-only=0 #主机, can read and write, 1 only

Binlog-do-db=dbname--The name of the database to synchronize, multiple write multiple lines

Binlog-ignore-db=dbname--Do not synchronize database names, multiple write multiple lines

2.

Restart

Service mysqld Start

3. Create a user

Grant Replication Slave on * * to [e-mail protected] '% ' identified by ' 1234 ';


Flush privileges;


4.

Show master status; Record file:binlog.000016 and position:7333


Cd.



From

1.MY.CNF Server-id = 2

2. See if communication with the main library




Pay: Stop slave;

3.

Change Master to master_host= ' 192.168.1.45 ', master_user= ' repuser ', master_password= ' 1234 ', master_log_file= ' Mysql-bin.000016 ', master_log_pos=9390;


4.

Open start slave;


5. See if the communication

show slave status \g;

As appears

Slave_io_running:yes (Network Normal, if the server is disconnected or no boot);

Slave_sql_running:yes (table structure is normal, if the table structure is not the same, and the data is not the same)

Yes indicates that the synchronization is normal,


Ok


Database Master-Slave (2)

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.