(16) MySQL cluster Galera implementation

Source: Internet
Author: User
Tags rsync egrep

(1) Environment introduction

(2) The following configuration three servers are the same
  • Shutting down firewalls and SELinux

    systemctl disable firewalld systemctl stop firewalldsed -ri ‘/SELINUX=/cSELINUX=disabled‘ /etc/selinux/configsetenforce 0
  • Configuring the Yum Source

    cat >>/etc/yum.repos.d/galera.repo<<EOF[galera1]name=galera1baseurl=http://releases.galeracluster.com/mysql-wsrep-5.7/centos/7/x86_64/gpgcheck=0[galera2]name=galera2baseurl=http://releases.galeracluster.com/galera-3/centos/7/x86_64/gpgcheck=0EOF
  • Installing MySQL and Galera plugins

    yum repolistyum list | egrep "wsrep|galera"yum -y install mysql-wsrep-server-5.7.x86_64  rsync galera-3.x86_64 -y
  • Start mysqld

    systemctl start mysqldsystemctl enable mysqldnewpass=$(grep "temporary password" /var/log/mysqld.log | awk ‘{print $NF}‘)mysqladmin -uroot -p"$newpass" password ‘[email protected]‘
  • Create a user for data synchronization

    mysql -uroot [email protected] -e "grant all on *.* to ‘copy‘@‘192.168.1.%‘ identified by ‘[email protected]‘"mysql -uroot [email protected] -e "flush privileges;"
    (3) Modify the configuration file: three different
  • node1:192.168.1.31

      #vi/etc/my.cnfbinlog_format=rowdefault_storage_engine=innodbinnodb_ Autoinc_lock_mode=2bind-address=0.0.0.0wsrep_on=onwsrep_provider=/usr/lib64/galera-3/libgalera_smm.sowsrep_ cluster_address= "gcomm://" wsrep_cluster_name= "test" wsrep_node_address= "192.168.1.31" wsrep_node_name= "Node1" Wsrep_sst_auth=copy:[email protected]wsrep_sst_method=rsync  
      Restart mysqld server: Systemctl Restart Mysqld Verify port status: Ss-anltup | Egrep "3306|4567"  

    Node1 node View status

  • node2:192.168.1.32

      #vi/etc/my.cnfbinlog_format=rowdefault_storage_engine=innodbinnodb_ Autoinc_lock_mode=2bind-address=0.0.0.0wsrep_on=onwsrep_provider=/usr/lib64/galera-3/libgalera_smm.sowsrep_ 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:[email protected]wsrep_sst_method=rsync  
      Restart mysqld server: Systemctl Restart mysqld Verify port status: Ss-anltup | egrep "3306|4567"  
  • node3:192.168.1.33

    #vi /etc/my.cnfbinlog_format=rowdefault_storage_engine=InnoDBinnodb_autoinc_lock_mode=2bind-address=0.0.0.0wsrep_on=ONwsrep_provider=/usr/lib64/galera-3/libgalera_smm.sowsrep_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:[email protected]wsrep_sst_method=rsync
    重启mysqld服务器:systemctl restart mysqld验证端口状态:ss -anltup | egrep "3306|4567"

    Note: The node definition is just beginning to define the cluster is wsrep_cluster_address= "gcomm://" If Node1 restarts the MySQL service,
    This address needs to be modified wsrep_cluster_address= "gcomm://192.168.1.33,192.168.1.32,192.168.1.31"
  • Parameter interpretation
    Wsrep_incoming_addresses: Indicates cluster host IP
    Wsrep_cluster_size: Number of cluster host statistics
    Wsrep_connected: Connection Status

(16) MySQL cluster Galera implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.