MySQL Master-slave replication

Source: Internet
Author: User
Tags unique id

I. Conditions of preparation

Two MySQL servers:

MASTERSERVER:REDHAT6.3-64-bit system, ip:192.168.136.11

SLAVESERVER:REDHAT6.3-64-bit system, ip:192.168.136.12


Second, configure the Masterserver server

1, log in to master server, edit the/etc/my.cnf file, add the following content:

Log-bin=mysql-bin//[must] enable binary logging

Server-id=1//[must be] server unique ID, default is 1, usually take IP last paragraph

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/74/wKioL1V9dXGjDaHvAACHS8ad_WA340.jpg "title=" 1.jpg " alt= "Wkiol1v9dxgjdahvaachs8ad_wa340.jpg"/>

2. Add the account number on the master server to access the master server from the slave server and authorize.


Grant Replication Slave on * * to ' zhangsan ' @ '% ' indentified by ' 123456 ';

#授权给张三一个可以同步数据的权限, the user can connect from any IP (you can specify a fixed IP address)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/78/wKiom1V9dG2hDWrsAAB_Gp5oAfM908.jpg "title=" 3.jpg " alt= "Wkiom1v9dg2hdwrsaab_gp5oafm908.jpg"/>

3. View Master Status

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/75/wKioL1V9et7zCVThAACdltNrIbE995.jpg "title=" 4.jpg " alt= "Wkiol1v9et7zcvthaacdltnribe995.jpg"/>


Third, configure the slave server

1, login slave server, edit/etc/my.cnf

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/79/wKiom1V9eYCzBNU5AACIdLaAdEg185.jpg "title=" 5.jpg " alt= "Wkiom1v9eyczbnu5aacidlaadeg185.jpg"/>

2. Edit the Masterinfo file and open the slave service.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/75/wKioL1V9e3LTV1_vAABGIZwEHwk734.jpg "title=" 7.jpg " alt= "Wkiol1v9e3ltv1_vaabgizwehwk734.jpg"/>

3, check the slave status, the following two items are configured successfully:

Slave_io_running:yes

Slave_sql_running:yes

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/75/wKioL1V9fAHyDxjnAADEhd0LoL0545.jpg "title=" 8.jpg " alt= "Wkiol1v9fahydxjnaadehd0lol0545.jpg"/>


Iv. Verification

1. Create a database AA on the master server;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/75/wKioL1V9fE2jfrKbAACAvKpKCpQ889.jpg "title=" 9.jpg " alt= "Wkiol1v9fe2jfrkbaacavkpkcpq889.jpg"/>

2, see on the slave server, whether there is a AA database, if any, the master-slave replication configuration is successful.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/75/wKioL1V9fJOiRK4_AABmaiH0RnQ266.jpg "title=" 10.jpg "alt=" Wkiol1v9fjoirk4_aabmaih0rnq266.jpg "/>




This article is from the Linux OPS blog, so be sure to keep this source http://jinghsy.blog.51cto.com/7648537/1661840

MySQL Master-slave replication

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.