MySQL 主主配置 步骤

时间:2022-09-14 13:59:00

  给6.30与6.32搭建主主配置的步骤如下:

   IP:10.200.6.30
   IP:10.200.6.32 
 主主配置步骤:
IP:10.200.6.30
[root@localhost ~]# vi /etc/my.cnf
log-bin=mysql-bin
server-id =1
replicate-ignore-db=mysql
replicate-ignore-db=test
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1

IP:10.200.6.32
log-bin=mysql-bin
server-id =2
#binlog-ignore-db=test
replicate-ignore-db=mysql
replicate-ignore-db=test
replicate-ignore-db=information_schema
replicate-ignore-db=performance_schema
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2

然后分别重启两个mysqld的服务。
2. 授权用户
IP:10.200.6.30
mysql> grant replication slave,file on *.* to 'rep'@'10.200.6.32' identified by 'root';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> change master to  master_host='10.200.6.32', master_user='rep',  master_password='root';
Query OK, 0 rows affected (0.01 sec)
IP: 10.200.6.32
mysql> grant replication slave,file on *.* to 'rep'@'10.200.6.30' identified by 'root';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> change master to  master_host='10.200.6.30', master_user='rep',  master_password='root';