MySQL master-Slave synchronization configuration

Source: Internet
Author: User

I. Overview

Mysql-ha currently has a lot of implementations, today with the MySQL double master+keepalived to achieve mysql-ha.

in the In the Mysql-ha environment,MySQL is the main slave relationship, which guarantees the consistency of the two MySQL data.

then use keepalived to implement virtual IP, through keepalived to realize the MySQL fault automatically switch.

Second, the experimental environment

virtual machine operating system memory/g HDD/g note
1 20
Mysql02 192.168.1.101 Ubuntu14.04 1 1 20

third,mysql-server-5.6 installation

The installation process is omitted

Iv. Configuration Mysql Dual Master Architecture

4.1, Create an account for "Replication" on two servers simultaneously

Mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT on *. * to [e-mail protected] ' 192.168.1.% ' identified by ' 1qaz#edc ';

650) this.width=650; "src=" https://note.youdao.com/yws/res/1198/B696A09769EE457CBD7D92A5F61C1D13 "style=" width : 554px; "alt=" B696a09769ee457cbd7d92a5f61c1d13 "/>

Description: Copy account:copy_user Password:1qaz#edc

Note: You need to create it on two servers, IP Address Please change to the actual IP address

4.2, changing configuration files

4.2.1,mysql01 server Configuration

[Email protected]:~# vim/etc/mysql/my.cnf

What you need to modify is as follows:

bind-address = 0.0.0.0 # is set to 0.0.0.0, allowing any IP connection .

Server-id = 1

Log_bin =/var/log/mysql/mysql-bin.log

Relay_log =/var/log/mysql/mysql-relay-bin

Log_slave_updates = 1

650) this.width=650; "src=" https://note.youdao.com/yws/res/1200/7187AD3EDE134021862B7A11A2E6C918 "style=" width : 477px; "alt=" 7187ad3ede134021862b7a11a2e6c918 "/>

4.2.2,mysql02 server Configuration

[Email protected]:~# vim/etc/mysql/my.cnf

What you need to modify is as follows:

bind-address = 0.0.0.0 # is set to 0.0.0.0, allowing any IP connection .

Server-id = 2

Log_bin =/var/log/mysql/mysql-bin.log

Relay_log =/var/log/mysql/mysql-relay-bin

Log_slave_updates = 1

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1199/08018E78C6CD45E4B1C2231D5E4B6DF3 "style=" width : 504px; "alt=" 08018e78c6cd45e4b1c2231d5e4b6df3 "/>

4.3, two servers to restart MySQL service

/etc/init.d/mysql restart

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1201/240DDDB3D72046FC9343377CDCBB5EFF "style=" width : 554px; "alt=" 240dddb3d72046fc9343377cdcbb5eff "/>

4.4, starting replication on two servers separately

4.4.1,mysql01 configuration

mysql> Change Master to master_host= ' 192.168.1.101 ', master_user= ' copy_user ', master_password= ' 1qaz#edc ';

650) this.width=650; "src=" https://note.youdao.com/yws/res/1195/EA03C23B5E8E4C208339CE017BD75128 "style=" width : 554px; "alt=" ea03c23b5e8e4c208339ce017bd75128 "/>

4.4.2,mysql02 configuration

mysql> Change Master to master_host= ' 192.168.1.100 ', master_user= ' copy_user ', master_password= ' 1qaz#edc ';

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1196/88AEB4C366724A678D6067DD0463F9C9 "style=" width : 554px; "alt=" 88aeb4c366724a678d6067dd0463f9c9 "/>

4.5.1,mysql01 start from replication

mysql> start Slave

4.5.2,mysql02 start from replication

mysql> start Slave

4.6, view status on both servers, yes to indicate configuration success

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1197/E165A5E262DC4C02BB0EC2711D5A3EB7 "style=" width : 554px; "alt=" E165a5e262dc4c02bb0ec2711d5a3eb7 "/>

Now any MySQL data changes, and another database will follow the data update.


This article is from "My Ops and my original" blog, so be sure to keep this source http://trtan.blog.51cto.com/8272891/1863557

MySQL master-Slave synchronization configuration

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.