MySQL Dual master Configuration
Prepare the environment: the server operating system is RHEL6.4 x86_64 To minimize the installation. Both host A and host B shut down the firewall and SELINUX with IP addresses of 192.168.131.129 and 192.168.131.130,MySQL version is 5.6.26, is a generic binary package.
- Install MySQL
1. host A Operation
# Tar XF mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
# MV Mysql-5.6.26-linux-glibc2.5-x86_64/usr/local/mysql
# useradd-m-s/sbin/nologin MySQL
# Chown-r root:root/usr/local/mysql/*
# Chown-r mysql:mysql/usr/local/mysql/data/
# yum-y Install Libaio
# cd/usr/local/mysql/scripts/
#./mysql_install_db--datadir=/usr/local/mysql/data/--user=mysql--basedir=/usr/local/mysql/
# Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
# echo ' Export path= $PATH:/usr/local/mysql/bin ' >>/etc/profile
# Source/etc/profile
# VIM/ETC/MY.CNF
[Mysqld]
Datadir=/usr/local/mysql/data
Socket=/tmp/mysql.sock
User=mysql
Symbolic-links=0
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
# service Mysqld Start
#chkconfig mysqld on
# SS-TUNLP | grep 3306
# mysqladmin-uroot password ' 123456 ' # Set Database Password
2. host B operation (IBID.)
Second, the configuration of dual-master
1 , host A Operation
# VIM/ETC/MY.CNF
Server-id=20
Log-bin=mysql-bin
Log-bin-index=mysql-bin.index
Replicate-ignore-db=test
Binlog-ignore-db=mysql
Binlog-ignore-db=information_schema
auto-increment-increment=2
Auto-increment-offset=1
# Service Mysqld Restart
# mysql-uroot-p123456
Mysql> flush tables with read lock;
Then open a remote terminal window and do the following:
# mysqldump-uroot-p123456-b Test > Test.sql
Return to the previous terminal window and do the following:
mysql> unlock tables;
mysql> grant replication Slave on * * to ' wdd ' @ ' 192.168.131.130 ' identified by ' 123456 ';
mysql> flush Privileges;
# SCP Test.sql 192.168.131.130:/root
2 , host B Operation
# VIM/ETC/MY.CNF
Server-id = 21
Log-bin=mysql-bin
log-bin-index= Mysql-bin.index
Replicate-do-db=test
Binlog-ignore-db=mysql
Binlog-ignore-db=information_schema
auto-increment-increment=2
auto-increment-offset=2
#service mysqld Restart
# mysql-uroot-p123456 < Test.sql
# mysql-uroot-p123456
mysql> grant replication Slave on * * to ' wdd ' @ ' 192.168.131.129 ' identified by ' 123456 ';
mysql> flush Privileges;
3. host A and host B do the following separately
Host A
① # mysql-uroot-p123456
mysql> SHOW MASTER STATUS;
Mysql> Change Master to
Master_host= ' 192.168.131.130 ',
Master_user= ' Wdd ',
Master_password= ' 123456 ',
Master_log_file= ' mysql-bin.000002 ',
master_log_pos=420;
mysql> start slave;
Mysql> show Slave status\g;
② # mysql-uroot-p123456
Mysql> Show master status;
Mysql> Change Master to
Master_host= ' 192.168.131.129 ',
Master_user= ' Wdd ',
Master_password= ' 123456 ',
Master_log_file= ' mysql-bin.000002 ',
master_log_pos=689;
mysql> start slave;
Mysql> show Slave status\g;
Third, testing
1, host A to do a bit of operation
mysql> use test;
Mysql> CREATE TABLE info (
-ID Int (TEN) NOT NULL Auto_increment primary key,
, name Char (20));
Mysql> Show tables;
2, Host B to operate
mysql> use test;
Mysql> Show tables;
mysql> CREATE TABLE person (
-ID int (a) unsigned NOT NULL Auto_increment primary key,
, name Char (20));
Mysql> Show tables;
3. Perform operation inspection on host a
MySQL Dual master configuration