Mysql双机热备实现

xiaoxiao2021-02-28  18

部署环境: 操作系统版本:cent-os-7数据库版本:mysql-5.7master1的IP地址:192.168.1.100master2的IP地址:192.168.1.101 1.登录master1和master2分别修改my.cnf: #======master1========# server-id = 1 log-bin=mysql-bin  binlog-do-db = test binlog-ignore-db = mysql log-slave-updates sync_binlog = 1 auto_increment_offset = 1 auto_increment_increment = 2 replicate-do-db = test replicate-ignore-db = mysql,information_schema #======master2========# server-id = 2 log-bin=mysql-bin binlog-do-db = test binlog-ignore-db = mysql log-slave-updates sync_binlog = 1 auto_increment_offset = 2 auto_increment_increment = 2 replicate-do-db = test replicate-ignore-db = mysql,information_schema 修改完后,重启服务。 2.创建同步账户 #======master1========# mysql>grant replication slave on *.* to user@192.168.1.101 identified by "123"; mysql>flush privileges; #======master1========# mysql>grant replication slave on *.* to user@192.168.1.100 identified by "123"; mysql>flush privileges; 3.修改需同步的主数据库 #======master1========# mysql>change master to >master_host='192.168.1.101',master_user='user',master_password='123', >master_log_file='mysql-bin.000001',master_log_pos=154; >start slave; #======master2========# mysql>change master to >master_host='192.168.1.100',master_user='user',master_password='123', >master_log_file=' mysql-bin.00001',master_log_pos=154; >start slave;
转载请注明原文地址: https://www.6miu.com/read-2628282.html

最新回复(0)