如何搭建和测试MySQL高可用框架Group Replication(组复制)
发表于:2024-11-30 作者:千家信息网编辑
千家信息网最后更新 2024年11月30日,下面讲讲关于如何搭建和测试MySQL高可用框架Group Replication(组复制),文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完如何搭建和测试MySQL高可用框架
千家信息网最后更新 2024年11月30日如何搭建和测试MySQL高可用框架Group Replication(组复制)
下面讲讲关于如何搭建和测试MySQL高可用框架Group Replication(组复制),文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完如何搭建和测试MySQL高可用框架Group Replication(组复制)这篇文章你一定会有所受益。
[root@wallet01 ~]# uuidgen8d1945a5-5c74-4ba0-8240-e9d731110753[root@wallet01 ~]# vi /etc/my.cnf##单主模型参数[mysqld]server-id = 1gtid_mode = onenforce_gtid_consistency = onlog_bin = mysql-binbinlog_format = rowbinlog_checksum = nonebinlog_cache_size = 16Mmax_binlog_cache_size = 4Gmax_binlog_size = 128Mexpire_logs_days = 7relay_log = relay-binmaster_info_repository = tablerelay_log_info_repository = tablelog_slave_updates = onplugin_load_add='group_replication.so'transaction_write_set_extraction = XXHASH64group_replication_group_name = "8d1945a5-5c74-4ba0-8240-e9d731110753"group_replication_start_on_boot = offgroup_replication_member_weight = 40group_replication_local_address = "192.168.40.34:20001"group_replication_group_seeds="192.168.40.34:20001,192.168.40.35:20001,192.168.40.36:20001"[root@wallet01 ~]# vi /etc/my.cnf##多主模型参数[mysqld]group_replication_enforce_update_everywhere_checks = ongroup_replication_single_primary_mode = off[root@wallet01 ~]# mysql -uroot -pabcd@2019mysql> grant replication slave on *.* to 'repl'@'192.168.40.%' identified by 'repl@2019';Query OK, 0 rows affected, 1 warning (0.02 sec)mysql> flush privileges;Query OK, 0 rows affected (0.03 sec)mysql> reset master;Query OK, 0 rows affected (0.10 sec)mysql> change master to master_user='repl',master_password='repl@2019' for channel 'group_replication_recovery';Query OK, 0 rows affected, 2 warnings (0.25 sec)mysql> set @@global.group_replication_bootstrap_group=on;Query OK, 0 rows affected (0.00 sec)mysql> start group_replication;Query OK, 0 rows affected (2.46 sec)mysql> set @@global.group_replication_bootstrap_group=off;Query OK, 0 rows affected (0.00 sec)mysql> select * from performance_schema.replication_group_members;+---------------------------+--------------------------------------+-------------+-------------+--------------+| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |+---------------------------+--------------------------------------+-------------+-------------+--------------+| group_replication_applier | a0fec232-d84a-11e9-a21c-000c2965b1d9 | wallet01 | 3306 | ONLINE |+---------------------------+--------------------------------------+-------------+-------------+--------------+1 row in set (0.00 sec)mysql> create user xtrabackup@'localhost' identified by 'xtrabackup@2019';Query OK, 0 rows affected (0.07 sec)mysql> grant reload,lock tables,replication client,process on *.* to xtrabackup@'localhost';Query OK, 0 rows affected (0.02 sec)mysql> flush privileges;Query OK, 0 rows affected (0.03 sec)[root@wallet01 ~]# su - mysql[mysql@wallet01 ~]$ ssh-keygen[mysql@wallet01 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub mysql@wallet02[mysql@wallet01 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub mysql@wallet03[mysql@wallet01 ~]$ ssh wallet02 dateMon Feb 18 10:41:16 CST 2019[mysql@wallet01 ~]$ ssh wallet03 dateMon Feb 18 10:42:30 CST 2019[mysql@wallet01 ~]$ xtrabackup --backup --user=xtrabackup --password=xtrabackup@2019 --stream=tar | ssh mysql@wallet02 \ "gzip >/home/mysql/backup/`date '+%Y-%m-%d_%H-%M-%S'`.tar.gz"[mysql@wallet01 ~]$ xtrabackup --backup --user=xtrabackup --password=xtrabackup@2019 --stream=tar | ssh mysql@wallet03 \ "gzip >/home/mysql/backup/`date '+%Y-%m-%d_%H-%M-%S'`.tar.gz"[root@wallet02 ~]# vi /etc/my.cnf[mysqld]server-id = 2gtid_mode = onenforce_gtid_consistency = onlog_bin = mysql-binbinlog_format = rowbinlog_checksum = nonebinlog_cache_size = 16Mmax_binlog_cache_size = 4Gmax_binlog_size = 128Mexpire_logs_days = 7relay_log = relay-binmaster_info_repository = tablerelay_log_info_repository = tablelog_slave_updates = onplugin_load_add='group_replication.so'transaction_write_set_extraction = XXHASH64group_replication_group_name = "8d1945a5-5c74-4ba0-8240-e9d731110753"group_replication_start_on_boot = offgroup_replication_member_weight = 30group_replication_local_address = "192.168.40.35:20001"group_replication_group_seeds="192.168.40.34:20001,192.168.40.35:20001,192.168.40.36:20001"[root@wallet02 ~]# su - mysql[mysql@wallet02 ~]$ cd backup[mysql@wallet02 backup]$ tar izxvf 2019-08-22_10-48-40.tar.gz [mysql@wallet02 backup]$ xtrabackup --prepare --target-dir=/home/mysql/backup[mysql@wallet02 backup]$ xtrabackup --copy-back --target-dir=/home/mysql/backup[mysql@wallet02 backup]$ cat xtrabackup_binlog_infomysql-bin.000001 50522845 8d1945a5-5c74-4ba0-8240-e9d731110753:1-10758[root@wallet02 ~]# service mysqld startLogging to '/var/lib/mysql/wallet02.err'.Starting mysqld: [ OK ][root@wallet02 ~]# mysql -uroot -pabcd@2019mysql> set global gtid_purged='8d1945a5-5c74-4ba0-8240-e9d731110753:1-10758';Query OK, 0 rows affected (0.02 sec)mysql> change master to master_user='repl',master_password='repl@2019' for channel 'group_replication_recovery';Query OK, 0 rows affected, 2 warnings (0.11 sec)mysql> start group_replication;Query OK, 0 rows affected (5.91 sec)mysql> select * from performance_schema.replication_group_members;+---------------------------+--------------------------------------+-------------+-------------+--------------+| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |+---------------------------+--------------------------------------+-------------+-------------+--------------+| group_replication_applier | 82a03979-df58-11e9-8a18-000c29b9ba00 | wallet02 | 3306 | ONLINE || group_replication_applier | a0fec232-d84a-11e9-a21c-000c2965b1d9 | wallet01 | 3306 | ONLINE |+---------------------------+--------------------------------------+-------------+-------------+--------------+2 rows in set (0.00 sec)[root@wallet03 ~]# vi /etc/my.cnf[mysqld]server-id = 3gtid_mode = onenforce_gtid_consistency = onlog_bin = mysql-binbinlog_format = rowbinlog_checksum = nonebinlog_cache_size = 16Mmax_binlog_cache_size = 4Gmax_binlog_size = 128Mexpire_logs_days = 7relay_log = relay-binmaster_info_repository = tablerelay_log_info_repository = tablelog_slave_updates = onplugin_load_add='group_replication.so'transaction_write_set_extraction = XXHASH64group_replication_group_name = "8d1945a5-5c74-4ba0-8240-e9d731110753"group_replication_start_on_boot = offgroup_replication_member_weight = 20group_replication_local_address = "192.168.40.36:20001"group_replication_group_seeds="192.168.40.34:20001,192.168.40.35:20001,192.168.40.36:20001"[root@wallet03 ~]# su - mysql[mysql@wallet03 ~]$ cd backup[mysql@wallet03 backup]$ tar izxvf 2019-08-22_11-03-21.tar.gz [mysql@wallet03 backup]$ xtrabackup --prepare --target-dir=/home/mysql/backup[mysql@wallet03 backup]$ xtrabackup --copy-back --target-dir=/home/mysql/backup[mysql@wallet03 backup]$ cat xtrabackup_binlog_infomysql-bin.000001 50523169 8d1945a5-5c74-4ba0-8240-e9d731110753:1-10759[root@wallet03 ~]# service mysqld startLogging to '/var/lib/mysql/wallet03.err'.Starting mysqld: [ OK ][root@wallet03 ~]# mysql -uroot -pabcd@2019mysql> set global gtid_purged='8d1945a5-5c74-4ba0-8240-e9d731110753:1-10759';Query OK, 0 rows affected (0.04 sec)mysql> change master to master_user='repl',master_password='repl@2019' for channel 'group_replication_recovery';Query OK, 0 rows affected, 2 warnings (0.13 sec)mysql> start group_replication;Query OK, 0 rows affected (3.39 sec)mysql> select * from performance_schema.replication_group_members;+---------------------------+--------------------------------------+-------------+-------------+--------------+| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |+---------------------------+--------------------------------------+-------------+-------------+--------------+| group_replication_applier | 0b7b9f83-df62-11e9-b3ab-000c2955056e | wallet03 | 3306 | ONLINE || group_replication_applier | 82a03979-df58-11e9-8a18-000c29b9ba00 | wallet02 | 3306 | ONLINE || group_replication_applier | a0fec232-d84a-11e9-a21c-000c2965b1d9 | wallet01 | 3306 | ONLINE |+---------------------------+--------------------------------------+-------------+-------------+--------------+3 rows in set (0.00 sec)
对于以上如何搭建和测试MySQL高可用框架Group Replication(组复制)相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的行业资讯板块。
框架
测试
参数
模型
下文
主题
内容
地方
奥妙
文字
更多
板块
篇文章
行业
资讯
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
眼快看书软件开发
君子网络技术有限公司
保定检察院网络安全培训班
高校校园网络安全体系研究开题报告
学习软件开发的电脑配置
软件开发服务端做什么的
凯利网络技术服务公司
软件开发者利润
linux 服务器名称
电脑版方舟服务器没有授权
金山区方便软件开发活动方案
新思科技工业网络安全实例
卖服务器的公司有哪些
农银金科软件开发面试
数据库表名可以用拼音吗
安苏 服务器怎么样
数据库it外包 工资
软件开发考职称怎么考
郑州erp软件开发
根据国家网络安全规定
计算器网络技术优势
北京嘉石众恒网络技术有限公司
网络技术员聊天软件
计算软件开发工具
湖州招软件开发项目
黄浦区电商软件开发供应商
网络安全管理职位认识
噪音小的服务器
软件开发简历描述
戴尔的服务器检测