基本环境
master slave
mysql版本 mysql-5.7.14x86_64 mysql-5.7.14x86_64
ip 192.168.0.100 192.168.0.101
port 3306 3306
搭建注意事项
主库配置
#master
gtid-mode=on
enforce-gtid-consistency=1
binlog_format=row
server-id=3306100
log-bin=/data/mysql/mysql3306/log/mysql-bin
binlog_cache_size=4M
skip_slave_start=1
主库创建复制账号
create user ‘repl‘@‘192.168.0.%‘ identified by ‘repl4slave‘;
grant replication slave on *.* to ‘repl‘@‘192.168.0.%‘;
从库配置
#master
gtid-mode=on
enforce-gtid-consistency=1
binlog_format=row
server-id=3306101
log-bin=/data/mysql/mysql3306/log/mysql-bin
binlog_cache_size=4M
skip_slave_start=1
查看复制:show slave status\G;
开始复制:start slave
停止复制: stop salve
mysql全库备份
mysqldump -uroot -p --single-transaction --master-data=2 -A > liangxiaoming_20161224.sql
参数查看master
show global variables like "%server%"
show global variables like "%gtid%"
show global variables like "%log_bin%"
show master status;
从库恢复数据
mysql -u root -p <liangxiaoming_20161224.sql
如果恢复不了
show global variables like "%gtid%"
reset master ;
show global variables like "%gtid%"
配置从服务器Slave:
mysql>change master to master_host=‘192.168.0.100‘,master_port=3306,master_user=‘repl‘,master_password=‘repl4slave‘,master_auto_position=1;
Mysql>start slave; //启动从服务器复制功能
#############################################################################################################################################################