如何搭建和测试MySQL高可用框架Group Replication(组复制)
发表于:2024-11-29 作者:千家信息网编辑
千家信息网最后更新 2024年11月29日,下面讲讲关于如何搭建和测试MySQL高可用框架Group Replication(组复制),文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完如何搭建和测试MySQL高可用框架
千家信息网最后更新 2024年11月29日如何搭建和测试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安全错误
数据库的锁怎样保障安全
四川高配服务器云空间
数据库技术目前发展状况
家庭ftp服务器
软件开发师和结构工程师
服务器root密码失效
上海邀玩网络技术怎么样
元宝山网络安全
有关网络安全防诈骗主题
同步数据服务器不可达
大科技互联网基金
hl编程软件开发者
机关单位网络安全培训课件
关于网络安全的倡议词
www服务器的建立
计算机信息网络安全自学
预防网络安全日记
秦皇岛网络技术哪家强
必虎公共网络安全吗
知识库管理图数据库
福建省服务器是什么意思
数字化改革与网络安全
甘肃高性能服务器直销厂家
阿里云jsp服务器
www服务器的建立
html本地缓存数据库
浦东新区媒体数据库服务商有哪些
机顶盒是不是服务器
软件开发怎么进国家单位
有关于网络安全的句子
电脑下载软件出现服务器断开