70
mysql配置主从复制基于GTIDs
source link: http://yongqing.is-programmer.com/posts/213812.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
妙音posted @ 2018年11月25日 13:59 inmysql with tagsmysql 主从 , 11 阅读
用最简单的例子,教你配置基于GTIDs全局事物id的主从配置。mysql从5.7之后,增加了基于全局事务的主从复制,能够省去,log-bin主从复制找坐标的工作。
环境说明
mysql 8.0.12
过程说明
下面是两台新装的mysql启用全局事务id主从复制的过程
1) 启用log-bin,mysql默认是启动的不需要配置
2) master上创建复制用的帐号
3) master/slave启用gtid
4) slave配置master信息
5) slave启动复制
6) 检查配置是否成功
7) 测试效果
master上创建帐号用于复制
create user 'repl'@'%' identified by 'password'; grant replication slave on *.* to 'repl'@'%';
master启用gtid
#/etc/mysql/my.conf server-id=1 gtid_mode=ON enforce-gtid-consistency=true
slave启用gtid
server-id=2 #id不能重复 gtid_mode=ON enforce-gtid-consistency=true
slave配置master信息
change master TO master_host='192.168.50.111', master_port=3307, master_user='repl', master_password='password', master_auto_position=1;
启动slave
start slave
查看slave状态
#Slave_IO_Running/Slave_SQL_Running两个都是yes表示配置成功 show slave status;
测试
在master创建数据库,slave很快同步过来
参考来源
http://www.yongqingking.top/mysql/2018/11/25/gtid-config.html
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK