试验环境:
master:192.168.1.210(CentOS6.5)
slave:192.168.1.211(CentOS6.5)
VIP:192.168.1.208
MySQL主主互备模式配置
step1:Master服务的/etc/my.cnf配置[mysqld]
basedir = /usr/local/mysql
datadir = /var/lib/mysql
port = 3306
socket = /var/lib/mysql/mysql.sock
server_id = 1
log-bin = mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.% #指定不需要复制的库,mysql.%表示mysql库下的所有对象
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
step2:Slave服务的/etc/my.cnf配置[mysqld]
basedir = /usr/local/mysql
datadir = /var/lib/mysql
port = 3306
socket = /var/lib/mysql/mysql.sock
server_id = 2
log-bin = mysql-bin
relay-log = mysql-relay-bin
replicate-wild-ignore-table=mysql.%
replicate-wild-ignore-table=test.%
replicate-wild-ignore-table=information_schema.%
step3:重启两台主从mysql服务[root@master ~]# service mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL. [ OK ]
[root@slave ~]# service mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL. [ OK ]
step4:查看主从的log-bin日志状态
记录File和Position的值[root@master ~]# mysql -uroot -ppasswd -e 'show master status'
Warning: Using a password on the command line interface can be insecure.
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 414 | | | |
+------------------+----------+--------------+------------------+-------------------+[root@slave ~]# mysql -uroot -ppasswd -e 'show master status'
Warning: Using a password on the command line interface can be insecure.
+----