对新实例部署一键快速实现主从关系,根据官方提供的工具mysql-utilities包中mysqlreplicate。
在使用工具需要注意:添加用户时,从库IP地址要明确指定,不要使用带有'%'格式
命令使用格式:mysqlreplicate --master=root@localhost:3306 --slave=root@localhost:3310 --rpl-user=rpl:passwd
–master 指定主库的连接信息
–slave 指定从库的连接信息
–rpl-user 指定用于复制的用户信息,这个用户需要提前在 master 上创建好
mysqlreplicate --master=xx:oo@172.16.0.29:3318 --slave=xx:oo@172.16.0.40:3318 --rpl-user=xx:oo -p
[root@test9 ~]# mysqlreplicate --master=xx:oo@172.16.0.29:3318 --slave=xx:oo@172.16.0.40:3318 --rpl-user=xx:oo -b
WARNING: Using a password on the command line interface can be insecure.
# master on 172.16.0.29: ... connected.
# slave on 172.16.0.40: ... connected.
# Checking for binary logging on master...
# Setting up replication...
# ...done.
MS成功信息输出.....
检擦是否OK
mysqlrplcheck --master=XX:OO@172.16.0.29:3318 --slave=XX:OO@172.16.0.40:3318
WARNING: Using a password on the command line interface can be insecure.
# master on 172.16.0.29: ... connected.
# slave on 172.16.0.40: ... connected.
Test Description Status
---------------------------------------------------------------------------
Checking for binary logging on master [pass]
Are there binlog exceptions? [pass]
Replication user exists? [pass]
Checking server_id values [pass]
Checking server_uuid values [pass]
Is slave connected to master? [pass]
Check master information file [pass]
Checking InnoDB compatibility [pass]
Checking storage engines compatibility [pass]
Checking lower_case_table_names settings [pass]
Checking slave delay (seconds behind master) [pass]
# ...done.