Detailed explanation of galera-cluster deployment in cluster mode of MySQL

Detailed explanation of galera-cluster deployment in cluster mode of MySQL

1: Introduction to galera-cluster

Galera Cluster is a free, open-source, high-availability solution developed by Codership. Its official website is http://galeracluster.com. Galera Cluster is a Mariadb cluster with Galera installed (this article only introduces the Mariadb Garela cluster). It has a multi-master feature and supports multi-point writing. The three (or more) nodes of Galera Cluster are in a peer relationship. Each node supports writing. The consistency and integrity of written data are guaranteed within the cluster. The specific implementation principle will be briefly introduced in this article.

The official features are as follows:

  • True multi-master cluster, Active-Active architecture;
  • Synchronous replication, no replication delay;
  • Multithreaded replication;
  • There is no master-slave switching operation and no need to use virtual IP;
  • Hot backup: a single node failure will not affect database services;
  • Supports automatic node joining, no need to manually copy data;
  • Support InnoDB storage engine;
  • Transparent to applications, native MySQL interface;
  • No need to separate read and write;
  • Easy to deploy and use.

2. How galera-cluster works

The main concern is data consistency. Transactions can be applied to every node or not to all. So, as long as they are configured correctly, the databases stay in sync.
The Galera replication plugin is different from traditional MySQL replication and can solve multiple problems, including multi-master write conflicts, replication lag, and master-slave asynchrony.

3: MariaDB's galera-cluster deployment

3.1: Introduction to system software environment

System: CentOS7.5x64

192.168.20.33 jiankong01.yl.com
192.168.20.34 jiankong02.yl.com
192.168.20.35 jiankong03.yl.com

Software: mariadb-galera-cluster.zip

3.2: Configure the time synchronization server

The flyfish host has been configured with the chronyd time server

The time server is: 192.168.20.3

If you don't know how, you can refer to flyfish's configuration of the time server for installing the big data cluster CDH.

How to install and configure is no longer provided here

3.3 Install mariadb-galear-cluster

All cluster nodes execute:

yum remove -y mariadb-libs 

yum install -y unzip boost-devel lsof perl-DBI perl-Data-Dumper

rpm -ivh rpm -ivh MariaDB-10.0.37-centos73-x86_64-* 

rpm -ivh MariaDB-Galera-10.0.37-centos73-x86_64-*

3.4 Node Configuration File

Node 1: jiankong01.yl.com

cd /etc/my.cnf.d

vim server.conf
----
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_provider= /usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.20.33,192.168.20.34,192.168.20.35"
wsrep_cluster_name = 'mycluster'
wsrep_node_name = 'jiankong01.yl.com'
wsrep_node-address = '192.168.20.33'
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
----
Node 2: jiankong02.yl.com

cd /etc/my.cnf.d/

vim server.conf

----
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_provider= /usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.20.33,192.168.20.34,192.168.20.35"
wsrep_cluster_name = 'mycluster'
wsrep_node_name = 'jiankong02.yl.com'
wsrep_node-address = '192.168.20.34'
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
---
Node 3: jiankong03.yl.com

cd /etc/my.cnf.d/
vim server.conf
----
[mysqld]

#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_provider= /usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.20.33,192.168.20.34,192.168.20.35"
wsrep_cluster_name = 'mycluster'
wsrep_node_name = 'jiankong03.yl.com'
wsrep_node-address = '192.168.20.35'
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
----

3.4 Start the cluster

Execute on any node in the cluster

service mysql start --wsrep-new-cluster

Here we take node 3 as an example:

Node 1 and Node 2 execute:

service mysql start 

3.5: Create a database instance

Node 1:

mysql -uroot -pQingchun123.com

create database nCalInfo

Check on nodes 2 and 3

mysql -uroot -pQingchun123.com

show databases 

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to build a MySQL PXC cluster
  • MySQL high availability cluster deployment and failover implementation
  • MySQL 5.7 cluster configuration steps
  • Implementation of Docker deployment of MySQL cluster
  • Detailed steps for installing MySQL using cluster rpm
  • Detailed explanation of MySQL cluster: one master and multiple slaves architecture implementation
  • How to deploy MySQL 5.7 & 8.0 master-slave cluster using Docker
  • Example of how to build a Mysql cluster with docker
  • MySQL Cluster Basic Deployment Tutorial
  • How to build a MySQL high-availability and high-performance cluster

<<:  A brief analysis of the basic implementation of Vue detection data changes

>>:  VMware virtual machine installation Linux system graphic tutorial

Recommend

How to detect whether a file is damaged using Apache Tika

Apache Tika is a library for file type detection ...

Specific use of Linux man command

01. Command Overview Linux provides a rich help m...

Summary of the differences and usage of plugins and components in Vue

The operating environment of this tutorial: Windo...

Javascript to achieve the effect of closing advertisements

Here is a case study on how to close ads using Ja...

Detailed tutorial on installing ElasticSearch 6.4.1 on CentOS7

1. Download the ElasticSearch 6.4.1 installation ...

Native js to implement a simple calculator

This article example shares the specific code of ...

Let's talk about the storage engine in MySQL

Basics In a relational database, each data table ...

Solution to the same IP after cloning Ubuntu 18 virtual machine

Preface I recently used a virtual machine to inst...

JavaScript article will show you how to play with web forms

1. Introduction Earlier we introduced the rapid d...

Detailed explanation of how to use awk in Linux

Before learning awk, we should have learned sed, ...