Master配置
mkdir -pv /data/mysql/data
mkdir -pv /data/mysql/16
复制代码
vi /data/mysql/16/16.cnf
[mysqld]
log-bin=mysql-bin
server-id=16
复制代码
docker create --name MySqlMaster -v /data/mysql/data/mysql16:/var/lib/mysql -v /data/mysql/16:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=WWW.RokyInfo.Com -p 3306:3306 mysql:5.7
docker start MySqlMaster
登录MySql
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
GRANT REPLICATION SLAVE ON *.* to 'backup'@'%' identified by 'RokyInfo.Net';
复制代码
Slave配置
mkdir -pv /data/mysql/data
mkdir -pv /data/mysql/17
复制代码
vi /data/mysql/17/17.cnf
[mysqld]
log-bin=mysql-bin
server-id=17
复制代码
docker create --name MySqlSlave -v /data/mysql/data/mysql17:/var/lib/mysql -v /data/mysql/17:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=WWW.RokyInfo.Com -p 3306:3306 mysql:5.7
docker start MySqlSlave
登录MySql
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
change master to master_host='192.168.102.16',master_user='backup',master_password='RokyInfo.Net',master_log_file='mysql-bin.000003',master_log_pos=40350;
start slave;
show slave status;
复制代码