内容纲要
配置 除了server-id不一样外,2实例其他配置均一样
[client]
socket = /tmp/mysql57.sock
[mysqld]
user = mysql
port = 3307
socket = /tmp/mysql57.sock
basedir = /usr/local/mysql
datadir = /data/mysql/data
#open-files-limit = 8192
log-error = /data/mysql/log/mysql_3307_error.log
pid-file = /data/mysql/mysql_3307.pid
######server####################
server-id = 1
##不给从机同步的库(多个写多行)
binlog-ignore-db=mysql
binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=sys
##开启二进制日志
log-bin=/data/mysql/binary/57
log_slave_updates=1
relay-log=relay-log-bin
slave-skip-errors=all
##自动清理 7 天前的log文件,可根据需要修改
expire_logs_days=7
15,16主机均执行命令:
mysql> reset master;
Query OK, 0 rows affected
mysql> show master status;
+-----------+----------+--------------+-------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-----------+----------+--------------+-------------------------------------------------+-------------------+
| 57.000001 | 154 | | mysql,information_schema,performance_schema,sys | |
+-----------+----------+--------------+-------------------------------------------------+-------------------+
1 row in set
15主机执行命令:
mysql> change master to master_host='192.168.10.16', master_port=3307, master_user='root', master_password='xxx', master_log_file='57.000001',master_log_pos=154;
mysql> start slave;
Query OK, 0 rows affected
16主机执行命令:
mysql> change master to master_host='192.168.10.15', master_port=3307, master_user='root', master_password='xxx', master_log_file='57.000001',master_log_pos=154;
mysql> start slave;
Query OK, 0 rows affected