加入收藏 | 设为首页 | 会员中心 | 我要投稿 大连站长网 (https://www.0411zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

MySQL MGR单主模式详细构建过程

发布时间:2022-07-05 20:20:16 所属栏目:MySql教程 来源:互联网
导读:环境: 节点1:192.168.157.128 CentOS 7.6 数据库:mysql-5.7.27-linux-glibc2.12-x86_64 节点2:192.168.157.129 CentOS 7.6 数据库:mysql-5.7.27-linux-glibc2.12-x86_64 节点3:192.168.157.130 CentOS 7.6 数据库:mysql-5.7.27-linux-glibc2.12-x86
  环境:
 
  节点1:192.168.157.128   CentOS 7.6
 
  数据库:mysql-5.7.27-linux-glibc2.12-x86_64
 
  节点2:192.168.157.129   CentOS 7.6
 
  数据库:mysql-5.7.27-linux-glibc2.12-x86_64
 
  节点3:192.168.157.130   CentOS 7.6
 
  数据库:mysql-5.7.27-linux-glibc2.12-x86_64
 
  1、安装MySQL
 
  在三台db服务器上面设置/etc/hosts映射,如下:
 
  192.168.157.128  mgr1
 
  192.168.157.129  mgr2
 
  192.168.157.130  mgr3
 
  安装的数据库服务器:
 
  IP地址:                             端口号:数据目录:      Server-id:
 
  192.168.157.128(mgr1) 3306 /opt/mysql/data 20      
 
  192.168.157.129(mgr2) 3306 /opt/mysql/data 21
 
  192.168.157.130(mgr3) 3306 /opt/mysql/data 22
 
  安装过程略。。。。。
 
  配置my.cnf:
 
  注意每个节点的server_id、loose-group_replication_local_address、loose-group_replication_group_seeds都配置成自己的相应的参数
 
  配置my.cnf:
 
  [client]
 
  port = 3306
 
  socket = /opt/mysql/tmp/mysql.sock
 
  [mysqld]
 
  port = 3306
 
  socket = /opt/mysql/tmp/mysql.sock
 
  back_log = 80
 
  basedir = /opt/mysql
 
  tmpdir = /tmp
 
  datadir = /opt/mysql/data

  init_slave = 'set sql_mode=STRICT_ALL_TABLES'
 
  log-slave-updates
 MySQL MGR单主模式详细构建过程
  [myisamchk]
 
  key_buffer = 512M
 
  sort_buffer_size = 512M
 
  read_buffer = 8M
 
  write_buffer = 8M
 
  [mysqlhotcopy]
 
  interactive-timeout
 
  [mysqld_safe]
 
  open-files-limit = 8192
 
  log-error = /opt/mysql/log/mysql.err
 
  2、创建MGR
 
  在mgr1/mgr2/mgr3上建立复制账号:
 
  mysql>
 
  set sql_log_bin=0;
 
  grant replication slave on *.* to 'repl'@'%' identified by '123456';
 
  flush privileges;
 
  set sql_log_bin=1;
 
  安装group replication插件
 
  在mgr1、mgr2、mgr3上依次安装group replication插件
 
  mysql> INSTALL PLUGIN group_replication SONAME 'group_replication.so';  
 
  配置group replication参数
 
  确保binlog_format是row格式。
 
  mysql> show variables like 'binlog_format';                                              
 
  Db3上启动group_replication:
 
  -- Db3命令行上执行:  
 
  mysql> set global group_replication_allow_local_disjoint_gtids_join=ON;  

  mysql> start group_replication;  
 
  -- 再去master库mgr1上,查看group_replication成员,会有mgr3的显示,而且已经是ONLINE了  
 
  mysql> select * from performance_schema.replication_group_members;
 
  最后查看集群状态,都为ONLINE就表示OK:
 
  mysql> select * from performance_schema.replication_group_members。

(编辑:大连站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!