MySQL快速搭建主从关系

转至元数据起始

对新实例部署一键快速实现主从关系,根据官方提供的工具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.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值