MARIADB Galera Cluster Deployment

Source: Internet
Author: User
Tags documentation rsync

Unlike the standard MySQL server and MySQL cluster, the MYSQL/MARIADB galera cluster has some small differences in boot mode. Galera need to start a node in the cluster as a reference point, the remaining nodes to join the formation of the cluster. This process is called cluster boot. Booting is an initial step that directs the database node as the primary node, and the other nodes synchronize the data as a reference point for the primary node.


Start the cluster

Install MARIADB on three machines and initialize the configuration. Modify the contents of the/ETC/MY.CNF.D/SERVER.CNF on the first node and add the cluster configuration in the [Galera] section:

wsrep_on=onwsrep_provider=/usr/lib64/galera/libgalera_smm.sowsrep_cluster_address= ' gcomm://' #第一个启动节点配置wsrep_ Cluster_name= ' mariadb_cluster ' wsrep_node_address= ' 192.168.0.56 ' #本机IP地址wsrep_node_name = ' mariadb_node1 ' # Cluster node name Wsrep_sst_method=rsync binlog_format=rowdefault_storage_engine=innodbinnodb_autoinc_lock_mode= 2bind-address=0.0.0.0


Configure the [Galera] section of the/etc/my.cnf.d/server.cnf file on the second and third nodes:

Wsrep_on=onwsrep_provider=/usr/lib64/galera/libgalera_smm.sowsrep_cluster_address= ' gcomm:// 192.168.0.56,192.168.0.58 ' wsrep_cluster_name= ' mariadb_cluster ' wsrep_node_address= ' 192.168.0.57 ' wsrep_node_name = ' Mariadb_node2 ' Wsrep_sst_method=rsync binlog_format=rowdefault_storage_engine=innodbinnodb_autoinc_lock_mode= 2bind-address=0.0.0.0


Wsrep_on=onwsrep_provider=/usr/lib64/galera/libgalera_smm.sowsrep_cluster_address= ' gcomm:// 192.168.0.56,192.168.0.57 ' wsrep_cluster_name= ' mariadb_cluster ' wsrep_node_address= ' 192.168.0.58 ' wsrep_node_name = ' Mariadb_node3 ' Wsrep_sst_method=rsync binlog_format=rowdefault_storage_engine=innodbinnodb_autoinc_lock_mode= 2bind-address=0.0.0.0

If you want to start mariadb galera Cluster, first select the Node1 node as the initial node, node1 as the first boot node, and set Gcomm to NULL, otherwise it will fail to start.

wsrep_cluster_address= ' gcomm://'

Nide1 Start command (different versions of different boot modes):

$ service mysql bootstrap # sysvinit $ service mysql start --wsrep-new-cluster # sysvinit $ galera_new_cluster # systemd $ mysqld_safe --wsrep-new-cluster # command line


After the Node1 is started, start Node2 and node3 in turn. After that, modify the Node1 "wsrep_cluster_address" configuration, adding additional cluster node IPs.

$ systemctl Start mariadb

Check that the system port is present and the system listens to the 3306,4567 port by default.

Log in to the database to see if the cluster node joins:

MariaDB [(None)]> SHOW STATUS like "wsrep_cluster_size";
+--------------------+-------+| variable_name | Value |+--------------------+-------+| Wsrep_cluster_size | 3 |+--------------------+-------+

You can view the synchronization status of a node through Wsrep_cluster_status and Wsrep_local_state_comment.

MariaDB [(None)]> show status Like "Wsrep_cluster_status"; +----------------------+---------+| variable_name | Value |+----------------------+---------+| Wsrep_cluster_status | Primary |+----------------------+---------+1 row in Set (0.00 sec)
MariaDB [(None)]> show status Like "Wsrep_local_state_comment"; +---------------------------+--------+| variable_name | Value |+---------------------------+--------+| wsrep_local_state_comment | Synced |+---------------------------+--------+1 row in Set (0.00 sec)


Warning: When adding a new node to an existing cluster, do not use boot mode (bootstrap) to start the node and cannot use two boot nodes in a cluster.


Failure recovery and restart of the cluster


When our MARIADB galera cluster cluster needs to be restarted (unplanned outages), it is important to ensure the integrity of the data in the future, selecting the appropriate master node as the boot node, and if the boot sequence is incorrect, data loss or failure to start can occur.


When Galera is started with a boot command on a node, that particular node will reach the primary state (check the value of Wsrep_cluster_status). The rest of the nodes only need a normal startup command, they will automatically find the existing main components (PCS) in the cluster and join a cluster. Then, data synchronization occurs through an incremental state transfer (IST) or snapshot State transfer (SST) between the accelerator and the donor.


Therefore, basically, if you want to start a new cluster or if no other node in the cluster is in the primary state, you should only boot the cluster. Care should be taken when choosing what action to take, otherwise it may result in splitting the cluster or losing data.


If the primary node in the cluster is working properly, we only need to start the other nodes normally. So the key point is that after the cluster is all down, we have to find the last one to exit the cluster, and the data is the most complete node. By starting this node, synchronizing the data with this node after other nodes are started can guarantee that the data of the DB cluster is not lost.


Reference Documentation:

Https://severalnines.com/blog/how-bootstrap-mysqlmariadb-galera-cluster

Http://galeracluster.com/documentation-webpages/restartingcluster.html


This article is from the "Trying" blog, make sure to keep this source http://tryingstuff.blog.51cto.com/4603492/1922986

MARIADB Galera Cluster Deployment

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.