Centos6.5 build MYSQ master-slave complex

Source: Internet
Author: User

Lab Environment: Primary server Address: 192.168.168.93 from server address: 192.168.168.102


First, install MySQL because the centos6.5 system is installed by default MySQL, so need to uninstall out of the MySQL, master, from the server to do the same operation

1. Yum remove MySQL 2, install MySQL service  

Ii. configuring MySQL Master and slave

1. First configure the primary server

1) Service mysqld stop

2) VIM/ETC/MY.CNF # #在 [MySQL] section add the following content

[Mysqld]

Log-bin=mysql-bin

Server-id=1

3) Service mysqld start

4) authorization to the Slave server (grant replication Slave on * * to ' root ' @ ' 192.168.168.102 ' identified by ' Guo ';

5) flush privileges;

6) show Mastar status;650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/6E/54/ Wkiol1v5xrei87hxaac1gaajakq431.jpg "title=" 1.jpg "alt=" Wkiol1v5xrei87hxaac1gaajakq431.jpg "/>

Second, configure the slave server

1) Service mysqld stop

2) VIM/ETC/MY.CNF # #在 [mysqld] section add the following:

[Mysqld]

Log-bin=mysql-bin

server-id=2

3) Service mysqld start

4) Change Master to master_host= ' 192.168.168.93 ', master_user= ' root ', master_password= ' Guo ',

Master_log_file= ' mysql-bin.000004 ', master_log_pos=711;

5) Start slave;

6) show slave status\g;650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/6E/58/ Wkiom1v5x2shnitoaagabp49qk0872.jpg "title=" 2.jpg "alt=" Wkiom1v5x2shnitoaagabp49qk0872.jpg "/>


three, to test whether the master-slave server can synchronize, create a table named OpenFire on the primary server test database to see if the server can synchronize the past.

  master server above: use test; create table OpenFire (name varchar), address varchar (a), phone varchar);  insert into data (Name,address,phone) VALUES (' Jerry ', ' Beijing ', ' 13566666666 '); select * FROM data

Verify from server: Use Test;select * form openfire;650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M02/6E/54/ Wkiol1v5yscrrbozaacpptvtk30119.jpg "title=" 3.jpg "alt=" Wkiol1v5yscrrbozaacpptvtk30119.jpg "/>

Iv. completion of master-slave synchronization

This article is from the "Huahuifangje" blog, make sure to keep this source http://4706547.blog.51cto.com/4696547/1660971

Centos6.5 build MYSQ master-slave complex

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.