Configuring Master-slave replication for MySQL

Source: Internet
Author: User

MySQL Version: 5.6

ip:192.168.134.178 of the primary server

ip:192.168.134.180 from the server

Now the master-slave machine installed MySQL version 5.6, the installation process is omitted;

1 Modify the MySQL configuration file for the master server:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[must] enable binary logging
server-id=222//[must be] server unique ID, default is 1, usually take IP last paragraph

2 modifying from server slave:
#vi/etc/my.cnf
[Mysqld]
Log-bin=mysql-bin//[not required] enable binary logging
server-id=226//[must be] server unique ID, default is 1, usually take IP last paragraph

READ_ONLY = 1//read-only mode

3 User replication user to create MySQL on master

CREATE USER ' copy ' @ ' 192.168.134.180 ' identified by ' password ';

GRANT REPLICATION SLAVE on * * to ' copy ' @ ' 192.168.134.180 ' identified by ' copy ';

To view the primary server status:

SHOW MASTER STATUS;

4 to operate from the server:

Start MySQL:

Service mysqld Start

Execute in MySQL:

Change MASTER to master_host= ' 192.168.134.178 ', master_user= ' copy ', master_password= ' copy ', Master_port=3306,master_ Log_file= ' mysql-bin.000001 ', master_log_pos=506,master_connect_retry=10;

Start the replication process from the server:

Execute in MySQL:

START SLAVE

View from server Status:

Execute in MySQL:

SHOW SLAVE Status\g;

5 Viewing slave Server status

View

Tail-10/usr/local/mysql/data/slave.err

See the following message stating that the replication process started successfully

39076 [Note] Slave I/O thread:connected to master ' [email protected]:3306 ', replication started in log ' mysql-bin.000001 ' At position 506

6 Testing

Create a table in the master Server Test library Test1

CREATE table Test1 (name varchar (10));

INSERT into test1 values (' Qwer ')

Commit

To see if the synchronization was successful on the server

SELECT * from Test.test1;

Configuring Master-slave replication for MySQL

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.