zoukankan      html  css  js  c++  java
  • 【环境部署】centos7安装mysql-5.7.19 group-replication

    --mysql高可用官方文档:
    mysql下载地址:
    https://www.mysql.com/downloads/  :下载这个:MySQL Community Server (GPL) 5.7.19版本
     
    --安装参考链接:
    #mysql 组复制的原理介绍:
    #mysql group-replication安装部署介绍
     
    安装拓扑图:
    172.27.129.2 mysql-ha-s1
    172.27.129.3 mysql-ha-s2
    172.27.129.4 mysql-ha-s3
     
    安装用户:work
    安装位置:/mnt/disk01
     
    #mysql-ha-s1安装
     
    --安装前准备
    #创建work用户
    groupadd work
    useradd -g work work
     
    #设置hostname以及hosts
    hostnamectl set-hostname mysql-ha-s1
     
    #在/etc/hosts里面添加三台机器的host解析
    172.27.129.2 mysql-ha-s1
    172.27.129.3 mysql-ha-s2
    172.27.129.4 mysql-ha-s3
     
    #关闭服务器防火墙与selinux
    #关闭防火墙
    systemctl stop firewalld.service
    systemctl disable firewalld.service
    firewall-cmd --state
     
    #关闭selinux
    /usr/sbin/sestatus -v
    setenforce 0
    sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
     
    #设置/mnt/disk01权限
    chmod 777 /mnt/disk01
     
    #开始安装进程
    #进入work用户
    su - work
    tar -zxvf /home/work/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
    mv /home/work/mysql-5.7.19-linux-glibc2.12-x86_64 /home/work/mysql-5.7.19
     
    #安装数据库-配置文件与数据分开存储
    /home/work/mysql-5.7.19/bin/mysqld --no-defaults --initialize --explicit_defaults_for_timestamp --basedir=/mnt/disk01/mysql/ --datadir=/mnt/disk01/data
     
    注:请记录安装提示中的初始密码,例如:root@localhost: sdk>cO;Rq3B+
     
    #mysql配置文件内容:

    [mysqld]
    # server configuration
    datadir=/mnt/disk01/data
    basedir=/mnt/disk01/mysql
    #set plugin local value
    plugin_dir=/home/work/mysql-5.7.19/lib/plugin
    port=24801
    socket=/tmp/mysql.sock
     
    # base config
    server_id=1
    gtid_mode=ON
    user=mysql
    enforce_gtid_consistency=ON
    master_info_repository=TABLE
    relay_log_info_repository=TABLE
    binlog_checksum=NONE
    log_slave_updates=ON
    log_bin=binlog
    binlog_format=ROW
     
    # group replication
    transaction_write_set_extraction=XXHASH64
    loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
    loose-group_replication_start_on_boot=off
    loose-group_replication_local_address= "172.27.129.2:24901"
    loose-group_replication_group_seeds= "172.27.129.2:24901,172.27.129.3:24901,172.27.129.4:24901"
    loose-group_replication_bootstrap_group= off
     
    # open mutil_mode config
    loose-group_replication_single_primary_mode=FALSE
    loose-group_replication_enforce_update_everywhere_checks= TRUE

    #创建配置文件
    touch /mnt/disk01/mysql/my.cnf
    将以上配置写入配置文件。
     
    #配置mysql环境变量
    vi ~/.bash_profile
    在“export PATH”上一行增加如下内容:
    PATH=$PATH:/home/work/mysql-5.7.19/bin
     
    使配置文件生效:source ~/.bash_profile
     
    #启动mysql数据库
    /home/work/mysql-5.7.19/bin/mysqld --defaults-file=/mnt/disk01/mysql/my.cnf &
     
    #非交互式修改初始密码
    /home/work/mysql-5.7.19/bin/mysqladmin -S /tmp/mysql.sock -u root -p'sdk>cO;Rq3B+' password ‘your passwd’
     
    #登录数据库:
    mysql -uroot -p'your passwd’
     
    #初始化与安装启动group-replication

    SET SQL_LOG_BIN=0;
    CREATE USER rpl_user@'%';
    GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass';
    FLUSH PRIVILEGES;
    SET SQL_LOG_BIN=1;
    CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
    INSTALL PLUGIN group_replication SONAME 'group_replication.so';
    SET GLOBAL group_replication_bootstrap_group=ON;
    START GROUP_REPLICATION;
    SET GLOBAL group_replication_bootstrap_group=OFF;

    #查询启动状态
    SELECT * FROM performance_schema.replication_group_members;
     
    #安装完毕
     
     #mysql-ha-s2和mysql-ha-s3安装
     
    注:全程参照s1安装,有以下几点存在改变。
     
    1、注意my.cnf的server_id 顺延变为2和3
    2、注意my.cnf的loose-group_replication_local_address顺延
    3、mysql初始化与启动脚本按照如下操作:

    SET SQL_LOG_BIN=0;
    CREATE USER rpl_user@'%';
    GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass';
    FLUSH PRIVILEGES;
    SET SQL_LOG_BIN=1;
    CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
    INSTALL PLUGIN group_replication SONAME 'group_replication.so';
    set global group_replication_allow_local_disjoint_gtids_join=ON;
    START GROUP_REPLICATION;

     
    其他没有区别。
    安装完成,进行测试即可。 
  • 相关阅读:
    Java Output流写入包装问题
    SpringBoot项目单元测试不经过过滤器问题
    SpringSecurity集成启动报 In the composition of all global method configuration, no annotation support was actually activated 异常
    JWT jti和kid属性的说明
    Maven 排除依赖
    第五章 基因概念的发现
    第三章 孟德尔遗传的拓展
    第二章 孟德尔遗传
    第一章 引言
    GWAS全基因组关联分析
  • 原文地址:https://www.cnblogs.com/liujian001/p/7687610.html
Copyright © 2011-2022 走看看