System Environment: CentOS 6.5
master1:192.168.100.204
master2:192.168.100.205
MySQL version: mysql-5.6.19
Note: MySQL has a different configuration than the 5.5 and 5.5 versions.
Installation of the following two nodes
1: Firewall opens the appropriate port
#/sbin/iptables-i input-p TCP--dport 3306-j ACCEPT
#/etc/rc.d/init.d/iptables Save
2: Install dependent packages
# yum-y Install gcc gcc-c++ ncurses ncurses-devel OpenSSL openssl-devel cmake perl lsof Bison
3: Delete your own MySQL
# rpm-qa|grep MySQL
# rpm-e--allmatches--nodeps mysql-libs-5.1.71-1.el6.x86_64
4: Create a related directory
# Mkdir/doiido/soft
# mkdir-p/doiido/mysql/data/
5: Create a MySQL user
#/usr/sbin/groupadd MySQL
#/usr/sbin/useradd-s/sbin/nologin-m-G MySQL MySQL
# chown-r mysql:mysql/doiido/mysql/
6: Install MySQL
# Cd/doiido/soft
# TAR-ZXVF Mysql-5.6.19.tar.gz
# CD mysql-5.6.19
# Cmake-dcmake_install_prefix=/doiido/server/mysql-dmysql_datadir=/doiido/mysql/data-dwith_innobase_storage_ engine=1-dwith_memory_storage_engine=1-dwith_myisam_storage_engine=1-dsysconfdir=/etc/-dwith_ssl=yes-ddefault_ Charset=utf8-ddefault_collation=utf8_general_ci-dwith_readline=on
# Make && make install
7: Modify the relevant directory permissions and create a soft connection
# chmod +w/doiido/server/mysql
# Chown-r mysql:mysql/doiido/server/mysql/
# ln-s/doiido/server/mysql/lib/lib*/usr/lib/
# ln-s/doiido/server/mysql/bin/mysql/usr/bin
8: Modify the configuration file
# CP/DOIIDO/SERVER/MYSQL/SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF
# vi/etc/my.cnf
9: Install MySQL Database
#/doiido/server/mysql/scripts/mysql_install_db--basedir=/doiido/server/mysql--datadir=/doiido/mysql/data-- User=mysql
10: Set MySQL boot auto start service
# Cp/doiido/server/mysql/support-files/mysql.server/etc/init.d/mysqld
# chkconfig--add mysqld
# chkconfig--level 345 mysqld on
11: Modify the Mysqld file and start MySQL
# Vi/etc/init.d/mysqld
#修改mysqld文件中的下面两项basedir =/doiido/server/mysqldatadir=/doiido/mysql/data
# service Mysqld Start
12: Create a database that needs to be synchronized
# Mysql-uroot-p
mysql> CREATE DATABASE Doiido;
Mysql> GRANT all privileges in doiido.* to [email protected] "%" identified by ' doiido123 ';
Mysql> Exit
--------------------The following operations on the server master1
Modifying a configuration file
# VI/ETC/MY.CNF
[Mysqld] #默认是1, master and slave cannot be the same server-id=1log-bin=bin.logport=3306binlog-do-db =doiido# the database to replicate REPLICATE-DO-DB = Doiido
Restart MySQL
# service Mysqld Restart
Create an account for synchronization
# Mysql-uroot-p
mysql> grant replication Slave on * * to ' dodo ' @ ' 192.168.100.205 ' identified by ' JJJJJJ ';
View file corresponding values and record them
mysql> Show master status;
+------------------+----------+--------------+------------------+-------------------+| File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_set |+------------------+----------+--------------+------------------+-------------------+| bin.000001 | 120 | Doiido | | | +------------------+----------+--------------+------------------+-------------------+
Mysql> exit
--------------------The following operations on the server master2
2. Modify the configuration file on the slave my.cnf
# VI/ETC/MY.CNF
[Mysqld]server-id=2port=3306log-bin=bin.logbinlog-do-db =doiidoreplicate-do-db =doiido
Restart MySQL
# service Mysqld Restart
To establish the appropriate database from the server
# mysql-uroot-p
Set 192.168.100.204 as your own home server
mysql> Change MASTER to
Master_host= ' 192.168.100.204 ', master_port=3306,
Master_user= ' Dodo ',
Master_password= ' JJJJJJ ',
Master_log_file= ' bin.000001 ',
master_log_pos=120;
To start the Copy from Server feature
mysql> start slave;
mysql> show slave status\g;
................... Slave_IO_Running:YesSlave_SQL_Running:Yes ....... ........
Note:
#Slave_IO_Running: Connect to the main library and read logs from the main library to local, generate local log files
#Slave_SQL_Running: Reads the local log file and executes the SQL command in the log.
Both of the above must be yes, and one of the No is an error
Mysql> exit
At this point, the one-way master configuration is complete, such as the need to master from the following configuration
--------------------the following operations on the server Master2
Create an account for synchronization
# mysql-uroot-p
mysql> grant replication Slave on * * to ' dodo ' @ ' 192.168.100.204 ' identified by ' JJJJJJ ';
View file corresponding values and record them
Mysql> Show master status;
+------------------+----------+--------------+------------------+-------------------+| File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_set |+------------------+----------+--------------+------------------+-------------------+| bin.000001 | 649 | Doiido | | | +------------------+----------+--------------+------------------+-------------------+1 row in Set (0.00 sec)
mysql> Exit
--------------------The following operations on the server Master1
Set 192.168.100.205 as your own home server
Mysql> Change MASTER to
Master_host= ' 192.168.100.205 ',
master_port=3306,
Master_user= ' Dodo ',
Master_password= ' JJJJJJ ',
Master_log_file= ' bin.000001 ',
master_log_pos=649;
To start the Copy from Server feature
mysql> start slave;
mysql> Show slave status\g;
................... Slave_IO_Running:YesSlave_SQL_Running:Yes ....... ........
both of the above must be yes, and one of the No is an error
Mysql> exit
This is the master from the configuration is complete
Mysql under Linux main from