(十六)MySQL叢集galera實現

來源:互聯網
上載者:User

標籤: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 firewalldsed -ri ‘/SELINUX=/cSELINUX=disabled‘ /etc/selinux/configsetenforce 0
  • 配置yum源

    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
  • 安裝mysql和galera外掛程式

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

    systemctl start mysqldsystemctl enable mysqldnewpass=$(grep "temporary password" /var/log/mysqld.log | awk ‘{print $NF}‘)mysqladmin -uroot -p"$newpass" password ‘[email protected]‘
  • 建立用於資料同步的使用者

    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)修改設定檔:三台不一樣
  • 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
    重啟mysqld伺服器:systemctl restart mysqld驗證連接埠狀態:ss -anltup | egrep "3306|4567"

    node1節點上查看狀態

  • 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
    重啟mysqld伺服器:systemctl restart mysqld驗證連接埠狀態: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"

    注意: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實現

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.