首页 > 数据库 >openEuler欧拉配置MySQL8的MGR单主双从.240108

openEuler欧拉配置MySQL8的MGR单主双从.240108

时间:2025-01-06 11:10:51浏览次数:8  
标签:PRD 单主双 group 240108 MySQL8 loose replication user MS

​一、 系统优化(三个节点全部操作)

关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

关闭selinux

echo "SELINUX=disabled" > /etc/selinux/config
echo "SELINUXTYPE=targeted" >> /etc/selinux/config
cat /etc/selinux/config
setenforce 0

设置主机名

hostnamectl set-hostname PRD-MS-Mysql01

更改host

vim /etc/hosts

XXX.XX.XX.105  PRD-MS-Mysql01
XXX.XX.XX.106  PRD-MS-Mysql02
XXX.XX.XX.107  PRD-MS-Mysql03

安装Mysql

dnf install -y mysql-server
systemctl start mysqld && systemctl enable mysqld

二、MySQL配置 主节点 XXX.XX.XX.105

vim /etc/my.cnf

server_id=105
gtid_mode=ON
enforce_gtid_consistency=ON
binlog_checksum=NONE
log_bin=binlog
log_slave_updates=ON
binlog_format=ROW
master_info_repository=TABLE
relay_log_info_repository=TABLE
transaction_write_set_extraction=XXHASH64
plugin_load_add='group_replication.so'
loose-group_replication_group_name = '57b971b0-8383-11ee-b2f2-2a4e7333b5c9'
loose-group_replication_start_on_boot = off
loose-group_replication_local_address = 'PRD-MS-Mysql01:33061'
loose-group_replication_group_seeds = 'PRD-MS-Mysql01:33061,PRD-MS-Mysql02:33062,PRD-MS-Mysql03:33063'
loose-group_replication_bootstrap_group = off
loose-group_replication_recovery_get_public_key= ON
loose-group_replication_single_primary_mode=on
loose-group_replication_enforce_update_everywhere_checks=off
  loose-group_replication_ip_whitelist='XXX.XX.XX.105,XXX.XX.XX.106,XXX.XX.XX.107'

systemctl restart mysqld

直接输入mysql,改root密码 (Mysql8.0.30 默认root密码为空)

ALTER USER 'root'@'localhost' IDENTIFIED BY '********';

创建MGR组

SET SQL_LOG_BIN=0;
CREATE USER rpl_user@'%' IDENTIFIED BY 'Password105';
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%';
GRANT CONNECTION_ADMIN ON *.* TO rpl_user@'%';
GRANT BACKUP_ADMIN ON *.* TO rpl_user@'%';
GRANT GROUP_REPLICATION_STREAM ON *.* TO rpl_user@'%';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;

CHANGE REPLICATION SOURCE TO SOURCE_USER='rpl_user', SOURCE_PASSWORD='Password105' FOR CHANNEL 'group_replication_recovery';

启动集群 主节点

SET GLOBAL group_replication_bootstrap_group=ON;   
START GROUP_REPLICATION USER='rpl_user', PASSWORD='Password105';
SET GLOBAL group_replication_bootstrap_group=OFF;

查看状态

select * from performance_schema.replication_group_members;
select * from performance_schema.replication_connection_status\G;

报错日志查看:
tail -f /var/log/mysql/mysqld.log

三、MySQL配置 从节点 XXX.XX.XX.106、107

my.cnf,其他和主节点一样,这两个地方分别改:

server-id=106

loose-group_replication_local_address = 'PRD-MS-Mysql02:33062'
loose-group_replication_group_seeds = 'PRD-MS-Mysql01:33061,PRD-MS-Mysql02:33062,PRD-MS-Mysql03:33063'

改root密码、创建MGR组、查日志等,和主库一样,区别在于,从节点只要一句就能启动:

启动集群 从节点

START GROUP_REPLICATION USER='rpl_user', PASSWORD='Password105';

全部OK后,主节点看看:


mysql> select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME              | MEMBER_ID                            | MEMBER_HOST    | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 1d16d8fb-8474-11ee-89c4-2ac8e8fb3ed8 | PRD-MS-Mysql03 |        3306 | ONLINE       | SECONDARY   | 8.0.30         | XCom                       |
| group_replication_applier | 480c6ae8-8535-11ee-a8ef-1e0edcf341b3 | PRD-MS-Mysql01 |        3306 | ONLINE       | PRIMARY     | 8.0.30         | XCom                       |
| group_replication_applier | e6848114-84e8-11ee-ad92-463fdcfb1e78 | PRD-MS-Mysql02 |        3306 | ONLINE       | SECONDARY   | 8.0.30         | XCom                       |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.00 sec)

四、后续优化

更新root密码,设置远程访问

select host,user from user;
update user set host='%' where user='root' and host='localhost';
ALTER USER 'root'@'%' IDENTIFIED BY 'c新密码*';
FLUSH PRIVILEGES;

my.cnf ,打开开机自启,主节点:

loose-group_replication_start_on_boot = on
loose-group_replication_bootstrap_group = on

从节点:
loose-group_replication_start_on_boot = on

​That's All.

标签:PRD,单主双,group,240108,MySQL8,loose,replication,user,MS
From: https://www.cnblogs.com/amadeuslee/p/18654870

相关文章

  • cas5开启Restful接口验证.240108
    ​POM文件中加入rest依赖:<!--Restfulsupport--><dependency><groupId>org.apereo.cas</groupId><artifactId>cas-server-support-rest</artifactId><version>${cas.version......
  • cas5配置LDAP的域控验证.240108
    ​pom.xml在这个下面添加LDAP依赖:<!--...Additionaldependenciesmaybeplacedhere...--><dependency><groupId>org.apereo.cas</groupId><artifactId>cas-server-support-ldap</artifactId><vers......
  • SQL Server Profiler的trc文件生成阻止.240108
    很奇葩,sqlserver自动生成trc文件,每分钟一个,重启服务器也没用。解决思路:查询现在正在跑的trace进程select*fromsys.fn_trace_getinfo(0);关闭C2审计功能EXECsp_configure'c2auditmode','0';重启数据库服务再次查看,已经没了。然后删除数据盘所有的trc文件。......
  • cas5配置redis.240108
    ​POM文件加载redis依赖,重新mavencleanpackage<dependency><groupId>org.apereo.cas</groupId><artifactId>cas-server-support-redis-ticket-registry</artifactId>......
  • dockerfile实现tomcat以及java的war包自动部署.240108
    1.下载jdk和tomcatwgethttps://dlcdn.apache.org/tomcat/tomcat-8/v8.5.93/bin/apache-tomcat-8.5.93.tar.gzwgethttps://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz2.vimDockerfileFROMcentos:latestMAINTAINERAmadeus#nowaddj......
  • 欧拉OpenEuler安装MySQL8.241227
    1.安装mysqltar-xvfmysql-8.0.21-linux-glibc2.12-x86_64.tarmvmysql-8.0.21-linux-glibc2.12-x86_64/usr/local/mysql2.配置mysqlvim/etc/my.cnf[client]default-character-set=utf8mb4[mysqld]#nd-address=0.0.0.0port=3306user=mysqlbasedir=/usr/local/m......
  • centos7快速部署MySQL8
    一、yum安装wgethttps://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpmrpm-Uvhmysql80-community-release-el7-3.noarch.rpmyuminstallmysql-community-serversystemctlstartmysqldgrep'temporarypassword'/var/log/mysqld.log2024-1......
  • 欧拉OpenEuler安装MySQL8
    1.安装mysqltar-xvfmysql-8.0.21-linux-glibc2.12-x86_64.tarmvmysql-8.0.21-linux-glibc2.12-x86_64/usr/local/mysql2.配置mysqlvim/etc/my.cnf[client]default-character-set=utf8mb4[mysqld]#nd-address=0.0.0.0port=3306user=mysqlbasedir=/usr/local/m......
  • 部署mysql8版本,使用rpm包
    rpm包下载地址:MySQL::DownloadMySQLCommunityServer(ArchivedVersions)#安装前一定要关闭selinux#临时关闭setenforce0#永久关闭vi/etc/selinux/configSELINUX=enforcing改为SELINUX=disabled#永久关闭需要重启服务器1、解压安装tar-xvfmysql-8.0.34-1.el......
  • MySQL8.0常用命令
    ----------------------------------------------------------------------------------------------------------------------------------------------------- --查询数据库中哪些线程正在执行showprocesslist;#查版本mysql-V或mysql> select version();mysql-h127......