MySQL 3-node master-slave synchronous replication scheme

Source: Internet
Author: User
Tags local time openssl iptables mysql login

the previous article, "Why do you have toMySQL master from synchronous replication"we explain.MySQL master-slave synchronization of the role of master-slave synchronization principle and the shortcomings of master-slave synchronization. Below we introduce the following 3 nodes: 2 nodes are mainly from each other, 1 nodes as the first 2 nodes from, for the implementation of MySQL5.6 3 node master-slave synchronous replication scheme.

The main steps are as follows:

1. Configure the options required for Mastera-side synchronous replication

2. Create a replication user on the Mastera Master Library and authorize

3.MasterA Main Library Lock table

4. Record the binlog of the Mastera Main Library and the POS location node

5. Export Mastera Main Library M_s_rep database

6. Configure the options required for Masterb-side synchronous replication

7. Create a database M_s_rep on Masterb and import the primary library backup

8. Create a replication user on Masterb and authorize

9. Record Masterb from the binlog of the library and POS location node

10. Configure Mastera and Masterb to master slave and enable sync from library

11. View Masterb's Relay-log and Master.info

12.MasterA Main Library Unlocked

13. Configure the options required for slave-side synchronous replication

14. Create the database m_s_rep on the slave side and import the primary library backup

15. Configure the salve side for Mastera and Masterb Sync and turn on sync

A. Environment Configuration Instructions1.IP Address Assignment

Hostname IP Address node

MYSQL01 10.62.83.201 Mastera

MYSQL02 10.62.83.202 Masterb

MYSQL03 10.62.83.203 Slave

2. Protocols and Ports

node Service Port

Mastera mysqld 3306

Masterb mysqld 3306

Slave mysqld 3306

 3. Package version

Software Version number

OS centosrelease 6.7 (Final)

MySQL Mysql-5.6.27-1.el6.x86_64.rpm-bundle.tar

JDK java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64

two. Installationpre-MySQL prep

In 3 nodes, install the following MySQL5.6.27 dependency packages, respectively, with the following steps:

  1. Dependent Package Installation

# yum install-y openssl* openssl-devel zlib-devel gcc gcc-c++make autoconf readline-devel curl-devel expat-devel gettext- Devel Ruby

  2. Uninstall OS default low version of OpenJDK

# Rpm-qa | grep JDK

# yum-y Remove java-1.6.0 java-1.7.0

3. Install the Java operating environment openjdk-1.8.0

# yum-y Install java-1.8.0

  4. Configure the JDK environment variable $java_home

# Vim/etc/profile

Exportjava_home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.20-3.b26.el6.x86_64/bin/java#new Add Content

  5. Configure DNS local domain name resolution

# vim/etc/hosts

10.62.83.201 MYSQL01 #new Add content

10.62.83.202 MYSQL02

10.62.83.203 MYSQL03

6. Uninstalling older versions of Mysql-libs in the OS

# CD/&& Rpm-qa |grep mysql*

# yum-y Removemysql-libs-5.1.73-3.el6_5.x86_64

7.Firewall Configuration

You can choose to turn off iptables, or configure iptables rules.

three. InstallationMySQL package

Install MySQL5.6.27 as follows in 3 nodes, and perform the following steps:

  1. Unzip the TAR package

# Cd/usr/local/data

# tar Xfmysql-5.6.27-1.el6.x86_64.rpm-bundle.tar

 2. Install the RPM package

# yum-y installmysql-client-5.6.27-1.el6.x86_64.rpm MYSQL-SERVER-5.6.27-1.EL6.X86_64.RP

Four. Master-Slave Relationship configuration Preparation    

MySQL5.6.27 Initial login password is a string of salt password, in order to facilitate login to MySQL, in 3 nodes to perform the following configuration:

  1. Log in to MySQL configuration

To start the MySQL service:

# service MySQL Start

Starting MySQL. success!

To view the MySQL initial key file for each node:

# Cat/root/.mysql_secret

# The random passwordset for the root user at Thu Nov 511:12:13 (local time): Mzmpq1upj0sgyki4

Log in to MySQL:

# mysql-u Root–p # Copy and paste or enter the key manually

After logging in, set a new password for MySQL login:

MySQL > SET passwordfor ' root ' @ ' localhost ' = PASSWORD (' mysql ');

MySQL > flushprivileges;

MySQL > exit;



This article is from the JESSEN6 blog, so be sure to keep this source http://zkhylt.blog.51cto.com/3638719/1775380

MySQL 3-node master-slave synchronous replication scheme

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.