【主:10.142.132.52 mysql配置文件】
[mysqld]
datadir=/app/mysql/data
socket =/app/mysql/data/mysql.sock
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci
server_id =1
wait_timeout=360000
log-bin=binlog
log-bin-index=binlog.index
log_slave_updates=1
sync-binlog = 1
auto_increment_offset = 2
auto_increment_increment = 2
[client]
#default-character-set=utf8
[mysql.server]
user=mysql
basedir=/app/mysql
default-character-set=utf8
[mysqld_safe]
err-log=/app/mysql/errlog/mysqld.log
【从1:10.142.132.51 mysql配置文件】
[mysqld]
datadir=/app/mysql/data
socket =/app/mysql/data/mysql.sock
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci
relay_log_purge=0
server_id =2
wait_timeout=360000
log-bin=binlog
log-bin-index=binlog.index
log_slave_updates=1
sync-binlog = 1
auto_increment_offset = 1
auto_increment_increment = 2
[client]
#default-character-set=utf8
[mysql.server]
user=mysql
basedir=/app/mysql
default-character-set=utf8
[mysqld_safe]
err-log=/app/mysql/errlog/mysqld.log
【从2:10.142.132.48 mysql配置文件】
[mysqld]
datadir=/app/mysql/data
socket =/app/mysql/data/mysql.sock
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci
read_only=1
relay_log_purge=0
server_id = 3
relay_log = /app/mysql/mysql-relay-bin
relay_log_index=/app/mysql/mysql-relay-bin.index
wait_timeout=360000
[client]
#default-character-set=utf8
socket =/app/mysql/data/mysql.sock
[mysql.server]
user=mysql
basedir=/app/mysql
default-character-set=utf8
[mysqld_safe]
err-log=/app/mysql/errlog/mysqld.log
【从3:10.142.132.47 mysql配置文件】
[mysqld]
datadir=/app/mysql/data
socket =/app/mysql/data/mysql.sock
lower_case_table_names=1
character-set-server=utf8
collation-server=utf8_general_ci
read_only=1
relay_log_purge=0
server_id = 4
relay_log = /app/mysql/mysql-relay-bin
relay_log_index=/app/mysql/mysql-relay-bin.index
wait_timeout=360000
[client]
#default-character-set=utf8
[mysql.server]
user=mysql
basedir=/app/mysql
default-character-set=utf8
[mysqld_safe]
err-log=/app/mysql/errlog/mysqld.log
AB复制
【主库】
mysql> GRANT replication slave ON *.* TO ‘lipengfei‘@‘%‘ identified by ‘lipengfei‘;
mysql> show master status\G;
*************************** 1. row ***************************
File: binlog.000001
Position: 120
Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:
1 row in set (0.00 sec)
【所有从库】
mysql> change master to master_host=‘10.142.132.52‘, master_port=3306, master_user=‘lipengfei‘, master_password=‘lipengfei‘, master_log_file=‘binlog.000001‘,master_log_pos=120;
mysql> start slave;