MySQL可以将一个 MySQL Server的 Instance 中的数据完整的复制到另一个 MySQL Server 的 Instance 中,虽然复制过程并非实时而是异步进行的,可是延时很是之少mysql
原理方面点击:http://www.noobyard.com/article/p-tlfiguqc-oh.htmlios
mysql > Create user repl identified by ‘repl';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'repl' ;
vim my.cnf
#启用二进制日志文件 log-bin=mysql-bin #服务器惟一ID,建议使用IP最后数字 server-id=130
# 重启mysql服务 systemctl restart mysqld # 查看master状态 mysql > show master status;
vim my.cnf
#服务器惟一ID,建议使用IP最后数字 server-id=132 relay-log=slave-relay-bin relay-log-index=slave-relay-bin.index read_only=1
# 重启mysql服务 systemctl restart mysqld mysql > change master to master_host='192.168.60.131',master_user='repl',master_password='repl',master_log_file='mysql-bin.000001',master_log_pos=154; mysql > start slave; mysql > show slave status\G;
当以下两个线程状态为yes,表示主从复制配置成功web
Slave_IO_Running=Yes
Slave_SQL_Running=Yessql
mysql 关闭slave方式:数据库
skip-slave-start
参考:https://blog.csdn.net/u010969226/article/details/44198371vim
主从同步延迟问题:缓存
解决方案:bash