Mysql primary wing structures from the synchronizing cloud host

    PAAS database is more classic products, we can say the database is the basis for the foundation, suggestions hands-on learning a DB database. Often more confident, and even the implementation of key moments also started moving in to a customer master database from the synchronization say, in the end is how to configure the script, we have to try their own in order to make customer solutions. Today we Mariadb database in two CentOS Tianyi cloud hosts were the main success from the synchronization test, the following detailed description of the configuration.

First, the environment Introduction

1, Master node

OS: CentOS 7.3

DB:  5.5.50-MariaDB

IP: 192.168.189.90

2, Slave nodes

OS: CentOS 7.3

DB:  5.5.50-MariaDB

IP: 192.168.189.73

3, how to install MariaDB

Install MariaDB (Mysql open source version) is very simple, yum install mariadb-server mariadb -y, done directly.

启用MariaDB,systemctl start mariadb

 

Second, be synchronized from the master configuration script

1, first create a database to be synchronized in Master, Slave node manually

a, mysql -u root -p no default password

b, create database repl create the target database

2, the configuration parameters Master nodes to achieve automatic data synchronization

a、vim /etc/my.cnf

b、

Add the following fields in the configuration section [mysqld]

server-id = 1 // server id

log-bin = mysql-bin // binary log file name

log-slave-updates=1

binlog-do-db = repl // need to synchronize the database, if the Bank does not represent synchronize all database

binlog-ignore-db = mysql // data is ignored, no synchronization database

c, increasing the Master to Slave node synchronization account machine Mysql

MariaDB [(none)]> grant replication slave on *.* to 'repl'@'192.168.189.73' identified by '123456';

flush  privileges;

d, restart mysql process

[root@ecs-maxing-0001 ~]# systemctl restart mariadb

e, check whether the configuration

3, the configuration parameters Slave node to synchronize data automatically received

a、vim /etc/my.cnf

b、

Add the following fields in the configuration section [mysqld]

server-id = 2 // server id

log-bin = mysql-bin // server binary log file

relay-log= mysql-relay-bin

read-only = 1 // set common user can only read read

log-slave-updates=1

replicate-do-db = repl # database to be synchronized, do not write the Bank represents synchronize all database

c, mysql restart process

[root@ecs-maxing-0002 ~]# systemctl restart mariadb

d, disposed in the Slave replication account in Mysql

CHANGE MASTER TO

MASTER_HOST='192.168.189.90',

MASTER_USER='repl',

MASTER_PASSWORD='123456',

MASTER_PORT=3306,

MASTER_LOG_FILE='mysql-bin.000002',

MASTER_LOG_POS=675,

MASTER_CONNECT_RETRY=10;

e, enable Slave Slave node function

MariaDB [(none)]> start slave

    -> ;

Query OK, 0 rows affected (0.00 sec)

 

Third, conduct master configuration synchronization script from acceptance test

1, an increase in data repl Master node database

2, if the node checks the received data in the Slave

Normal data is received.

I hope this article can help you.

More real-time updates, visit public number.    

 

Click here to get the highest ¥ 1888 Ali cloud offering universal vouchers

Guess you like

Origin blog.csdn.net/qq_29718979/article/details/90216166