多源主从复制的架构是多主一从,每个主的每个库都由一个单一的从库进行复制,而从库是通过channel来区分每个主库的。多源复制需要每个主的数据库名不能有冲突。通常用于集中管理或者是需要跨实例查询的场景。
模拟场景:
主库A:192.168.100.101
主库B:192.168.100.102
从库C:192.168.100.103
多台主库配置:
server-id = 101 #仅需修改这里 log-bin = mysql-bin gtid-mode = ON enforce-gtid-consistency = ON master_info_repository = TABLE relay_log_info_repository = TABLE grant replication slave client on *.* to 'repl'@'192.168.100.103' identified by '123456';
从库配置:
server-id = 103 #仅需修改这里 gtid-mode = ON enforce-gtid-consistency = ON master_info_repository = TABLE relay_log_info_repository = TABLE change master to master_host='192.168.100.101',master_user='repl',master_password='123456',master_auto_position=1 for channel 'master-101'; #channel的名字可以自定义 change master to master_host='192.168.100.101',master_user='repl',master_password='123456',master_auto_position=1 for channel 'master-102'; #channel的名字可以自定义
发表评论: