MySQL master and slave replication structure setup

Source: Internet
Author: User

1 Select two servers, respectively, as a master and standby database

2 Login to the server,

Yum install MySQL;

Yum install mysql-server;

3 Starting the server

Service mysqld Start

4 separate root login MySQL to execute the following command, increase the replication user and authorization (master and Standby in the 192.168.119.* network segment, in order to facilitate the primary and standby switch, both sides are established)

GRANT REPLICATION slave,replication CLIENT on * * to [e-mail protected] ' 192.168.119.% ' identified by ' 1234 ';

5 Configuring/ETC/MY.CNF

First server (Master)

Log_bin=mysql_bin
Server_id=1

Second server (standby)

Log_bin=mysql_bin
server_id=2
Read_only=1

6 login Master (root) execution

Show Master Status\g;

Show

file:mysql-bin.000001
position:106


Login standby (Root) execution

Test whether the mysql-urepl-h192.168.119.128-p1234 can connect to the main library, do not need to check the firewall or/etc/my.cnf whether there is access restrictions, modify the configuration

Mysql-uroot Login to local repository execution:

Change MASTER to
Master_host= ' 192.168.119.128 ',
Master_user= ' Repl ',
master_password= ' 1234 ',
Master_log_file= ' mysql-bin.000001 ',
master_log_pos=106;

Start slave;

show slave status\g;

7, create a table on the main library, view on the library, and you can see

REPL CREATE table on standby, show the MySQL server is running with the--read-only option so it cannot execute this statement

Because the standby library is configured as Read_Only









Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

MySQL master and slave replication structure setup

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.