码迷,mamicode.com
首页 > 数据库 > 详细

(十六)MySQL集群galera实现

时间:2018-04-28 23:45:39      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:nload   wal   http   创建   启动   x86_64   集群   install   config   

(1)环境介绍

技术分享图片

galera官网:http://galeracluster.com/downloads/
# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

(2)以下配置三台服务器都相同

  • 关闭防火墙和selinux

    systemctl disable firewalld 
    systemctl stop firewalld
    sed -ri ‘/SELINUX=/cSELINUX=disabled‘ /etc/selinux/config
    setenforce 0
  • 配置yum源

    cat >>/etc/yum.repos.d/galera.repo<<EOF
    [galera1]
    name=galera1
    baseurl=http://releases.galeracluster.com/mysql-wsrep-5.7/centos/7/x86_64/
    gpgcheck=0
    [galera2]
    name=galera2
    baseurl=http://releases.galeracluster.com/galera-3/centos/7/x86_64/
    gpgcheck=0
    EOF
  • 安装mysql和galera插件

    yum repolist
    yum list | egrep "wsrep|galera"
    yum -y install mysql-wsrep-server-5.7.x86_64  rsync galera-3.x86_64 -y
  • 启动mysqld

    systemctl start mysqld
    systemctl enable mysqld
    newpass=$(grep "temporary password" /var/log/mysqld.log | awk ‘{print $NF}‘)
    mysqladmin -uroot -p"$newpass" password ‘Redhat@123‘
  • 创建用于数据同步的用户

    mysql -uroot -pRedhat@123 -e "grant all on *.* to ‘copy‘@‘192.168.1.%‘ identified by ‘Copy@123‘"
    mysql -uroot -pRedhat@123 -e "flush privileges;"

    (3)修改配置文件:三台不一样

  • node1:192.168.1.31

    #vi /etc/my.cnf
    binlog_format=row
    default_storage_engine=InnoDB
    innodb_autoinc_lock_mode=2
    bind-address=0.0.0.0
    wsrep_on=ON
    wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so
    wsrep_cluster_address="gcomm://"
    wsrep_cluster_name="test"
    wsrep_node_address="192.168.1.31"
    wsrep_node_name="node1"
    wsrep_sst_auth=copy:Copy@123
    wsrep_sst_method=rsync
    重启mysqld服务器:systemctl restart mysqld
    验证端口状态:ss -anltup | egrep "3306|4567"

    node1节点上查看状态
    技术分享图片

  • node2:192.168.1.32

    #vi /etc/my.cnf
    binlog_format=row
    default_storage_engine=InnoDB
    innodb_autoinc_lock_mode=2
    bind-address=0.0.0.0
    wsrep_on=ON
    wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so
    wsrep_cluster_address="gcomm://192.168.1.31,192.168.1.32,192.168.1.33"
    wsrep_cluster_name="test"
    wsrep_node_address="192.168.1.32"
    wsrep_node_name="node2"
    wsrep_sst_auth=copy:Copy@123
    wsrep_sst_method=rsync
    重启mysqld服务器:systemctl restart mysqld
    验证端口状态:ss -anltup | egrep "3306|4567"
  • node3:192.168.1.33

    #vi /etc/my.cnf
    binlog_format=row
    default_storage_engine=InnoDB
    innodb_autoinc_lock_mode=2
    bind-address=0.0.0.0
    wsrep_on=ON
    wsrep_provider=/usr/lib64/galera-3/libgalera_smm.so
    wsrep_cluster_address="gcomm://192.168.1.31,192.168.1.32,192.168.1.33"
    wsrep_cluster_name="test"
    wsrep_node_address="192.168.1.33"
    wsrep_node_name="node3"
    wsrep_sst_auth=copy:Copy@123
    wsrep_sst_method=rsync
    重启mysqld服务器:systemctl restart mysqld
    验证端口状态:ss -anltup | egrep "3306|4567"
    技术分享图片
    注意:node定义刚开始定义集群是wsrep_cluster_address="gcomm://",如果node1重启Mysql服务,
    这个地址需要修改wsrep_cluster_address="gcomm://192.168.1.33,192.168.1.32,192.168.1.31"
  • 参数解释
    wsrep_incoming_addresses :表示集群主机ip
    wsrep_cluster_size :集群主机统计数量
    wsrep_connected :连接状态

(十六)MySQL集群galera实现

标签:nload   wal   http   创建   启动   x86_64   集群   install   config   

原文地址:https://www.cnblogs.com/lovelinux199075/p/8969814.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!