GreatSQL手工部署mgr集群
GreatSQL手工部署mgr集群
接上文:
https://www.cnblogs.com/bjx2020/p/15480485.html
一、mgr特殊配置,如非mgr架构,则可以去掉这部分的配置
# 特殊配置 #mgr loose-plugin_load_add='mysql_clone.so' loose-plugin_load_add='group_replication.so' #所有节点的group_replication_group_name值必须相同 #这是一个标准的UUID格式,可以手动指定,也可以用随机生成的UUID loose-group_replication_group_name="0ad1ab74-e0df-a686-19b0-43389d1c9510" #指定MGR集群各节点的IP+端口,这个端口是专用于MGR的,不是平常所说的mysqld实例端口 #如果是在多节点上部署MGR集群时,要注意这个端口是否会被防火墙拦截 loose-group_replication_local_address ="192.168.29.131:33061" # 这里要换成本地的IP loose-group_replication_group_seeds= "192.168.29.131:33061,192.168.29.132:33061,192.168.29.133:33061" #不建议启动mysqld的同时也启动MGR服务 loose-group_replication_start_on_boot=off #默认不要作为MGR集群引导节点,有需要时再手动执行并立即改回OFF状态 loose-group_replication_bootstrap_group=off #当退出MGR后,把该实例设置为read_only,避免误操作写入数据 loose-group_replication_exit_state_action=READ_ONLY #一般没什么必要开启流控机制 loose-group_replication_flow_control_mode = "DISABLED" #【强烈】建议只用单主模式,如果是实验目的,可以尝试玩玩多主模式 loose-group_replication_single_primary_mode=ON
二、主节点的操作
# 主节点:创建复制用户 SET SQL_LOG_BIN=0; create user 'repl_user'@'192.168.%' IDENTIFIED with mysql_native_password BY 'A3bW^3s#6#yTV132xc6v'; GRANT backup_admin, REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl_user'@'192.168.%'; create user 'repl_user'@'127.0.0.1' IDENTIFIED with mysql_native_password BY 'A3bW^3s#6#yTV132xc6v'; GRANT backup_admin, REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl_user'@'127.0.0.1'; create user 'repl_user'@'localhost' IDENTIFIED with mysql_native_password BY 'A3bW^3s#6#yTV132xc6v'; GRANT backup_admin, REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl_user'@'localhost'; #设置复制通道 CHANGE REPLICATION SOURCE TO SOURCE_USER='repl_user', SOURCE_PASSWORD='A3bW^3s#6#yTV132xc6v' FOR CHANNEL 'group_replication_recovery'; #设置引导节点,启动主节点 SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP = ON; START GROUP_REPLICATION; #启动完毕后,记得关闭引导设置 SET GLOBAL GROUP_REPLICATION_BOOTSTRAP_GROUP = OFF; #确认状态 SELECT * FROM PERFORMANCE_SCHEMA.REPLICATION_GROUP_MEMBERS; SET SQL_LOG_BIN=1;
三、其他节点的操作
# 其他节点 SET SQL_LOG_BIN=0; create user 'repl_user'@'192.168.%' IDENTIFIED with mysql_native_password BY 'A3bW^3s#6#yTV132xc6v'; GRANT backup_admin, REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl_user'@'192.168.%'; create user 'repl_user'@'127.0.0.1' IDENTIFIED with mysql_native_password BY 'A3bW^3s#6#yTV132xc6v'; GRANT backup_admin, REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl_user'@'127.0.0.1'; create user 'repl_user'@'localhost' IDENTIFIED with mysql_native_password BY 'A3bW^3s#6#yTV132xc6v'; GRANT backup_admin, REPLICATION SLAVE,REPLICATION CLIENT ON *.* TO 'repl_user'@'localhost'; #设置复制通道 CHANGE REPLICATION SOURCE TO SOURCE_USER='repl_user', SOURCE_PASSWORD='A3bW^3s#6#yTV132xc6v' FOR CHANNEL 'group_replication_recovery'; # 非主节点直接启动 START GROUP_REPLICATION; #确认状态 SELECT * FROM PERFORMANCE_SCHEMA.REPLICATION_GROUP_MEMBERS; SET SQL_LOG_BIN=1;
单主-多主之间的切换详见另一篇文章:mysql-shell部署MGR