MySQL master-slave replication and primary master replication

Source: Internet
Author: User

MySQL master-slave replication:

Lab Environment:

Linux CentOS7 two: 192.168.230.10 (master)----192.168.230.11 (from) (System installed, switch off the firewall or configure the firewall).

MySQL 5.7 (Download the official Yum source, yum install-y MySQL mysql-server)

To start the configuration:

MySQL configuration files in general Linux are all in/ETC/MY.CNF (the configuration file in Windows is Mysql.ini)

server-ID1  (guaranteed unique in the entire MySQL cluster) log-bin = binlog (binary) log-bin-index = Binlog.index

Note: The binary log must be turned on because the synchronization of the data is essentially the other MySQL database server executes the binary log of this data change again on this computer.

Start building:

The first step:

Create a MySQL user in 192.168.230.10 that can log on in a 192.168.230.11 host

Users: Mysql11

Password: [email protected] (mysql5.7 default password complexity verification, the actual production environment should also be more complex password settings)

Mysql>grant REPLICATION SLAVE on * * to ' mysql11 ' @ '192.168. 230.11' identified by ' [email protected]one by one'; MySQL>flush privileges;

Step Three:

Tell the binary file name and location

Execute in 192.168.230.11:

           mysql> changeMASTER                     to >master_host= '192.168.  230.10',                     >master_user=' mysql11 ',                     >master_password= ' [email protected]11  ',                     >master_log_file= ' Binlog.  000003',                     >master_log_pos=668;
Or

Change MASTER to master_host= ' 192.168.230.10 ', master_user= ' mysql11 ', master_password= ' [email protected] ', Master_log _file= ' binlog.000003 ', master_log_pos=
668;

Complete the master-slave configuration.

To turn on master-slave replication:

In the 192.168.230.11 (slave translated as slaves)

Mysql>start slave;   #开启复制  This stop slave;//is definitely stopping the copy mode
mysql>show slave status\g   #查看主从复制是否配置成功

When you see Slave_io_running:yes and Slave_sql_running:yes, it shows the state is normal.

Here are a few of the exclusion commands:

MySQL master-slave replication and primary master replication

Related Article

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.