How to configure mariadb galera cluster on centos 7?
MariaDB Galera Cluster is a synchronous multi-master cluster for MariaDB. It is a fork of Galera Cluster, the world"s most advanced, free and open source cluster engine. Currently, it only supports InnoDB storage engines.
Bạn đang xem: How to configure mariadb galera cluster on centos 7?
MariaDB Galera Cluster is a true Multi-Master & Active-Active cluster. Due khổng lồ it"s synchronous behaviour, there will be no data lost in case of a node crash because all nodes always hold the same state.
MariaDB Galera Cluster also provides Automatic node provisioning. It means we bởi vì not have to manually backup the database & restore it on new node before adding it khổng lồ Galera cluster. This features gives the additional benefit of Cloud support due khổng lồ simple scale-in và scale-out operations.
In this article, we will create a two-node MariaDB Galera Cluster of MariaDB 10.3 Database on CentOS 7. However, the same steps can be used lớn configure a MariaDB Galera Cluster of larger size.
This article focuses on the installation of MariaDB Galera Cluster on CentOS 7 without diving into theory và definitions pertains to MariaDB. Therefore, it is recommended that you should read Getting Started with MariaDB - Second Edition by Packt Publishing to have basic understanding of MariaDB database.

Table of Contents:
System Specification:
For this article, we are using two CentOS 7 virtual machines as the Galera Cluster nodes.
Hostname: | mariadb-01.example.com | mariadb-02.example.com |
IP Address: | 192.168.116.81 /24 | 192.168.116.82/24 |
CPU: | 2.4 Ghz (2 cores) | 2.4 Ghz (2 cores) |
Memory: | 2 GB | 2 GB |
Operating System: | CentOS 7.6 | CentOS 7.6 |
MariaDB Version: | 10.3.12 | 10.3.12 |
Installing MariaDB 10.3 Database hệ thống on CentOS 7:
Connect to mariadb-01.example.com using ssh as root user.
Install MariaDB and MaxScale yum repositories.
# curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash
# yum makecache fastLoaded plugins: fastestmirrorDetermining fastest mirrors * base: repo.inara.pk * extras: repo.inara.pk * updates: repo.inara.pkbase | 3.6 kB 00:00extras | 3.4 kB 00:00mariadb-main | 2.9 kB 00:00mariadb-maxscale | 2.4 kB 00:00mariadb-tools | 2.9 kB 00:00updates | 3.4 kB 00:00(1/5): mariadb-maxscale/7/x86_64/primary_db | 6.7 kB 00:02(2/5): mariadb-tools/7/x86_64/primary_db | 11 kB 00:02(3/5): mariadb-main/7/x86_64/primary_db | 50 kB 00:03(4/5): extras/7/x86_64/primary_db | 156 kB 00:04(5/5): updates/7/x86_64/primary_db | 1.4 MB 00:09Metadata Cache CreatedInstall MariaDB 10.3 Server and Galera using yum command.
# yum install -y mariadb-server galeraRepeat above steps on all other nodes.
Configuring MariaDB Galera Cluster on CentOS 7:
Allow MariaDB và Galera service ports in Linux firewall.
# firewall-cmd --permanent --add-service=mysqlsuccess# firewall-cmd --permanent --add-port=4567,4568,4444/tcpsuccess# firewall-cmd --reloadsuccessSet SELinux lớn permissive mode for now, and we will enable the enforcing mode later, after creating an SELinux policy for MariaDB Galera cluster.
# setenforce 0Now edit MariaDB configuration file.
Xem thêm: Máy Tính Bảng 10 Inch Trung Quốc, Máy Tính Bảng Tốt Nhất Của Trung Quốc
# vi /etc/my.cnf.d/server.cnfand configure galera section as follows:
Start Galera cluster on mariadb-01.example.com.
# galera_new_clusterStart MariaDB service on all other nodes.
# systemctl start mariadb.serviceIf the service started successfully then, it shows that we have successfully configured our Galera cluster.
Configure MariaDB database instance on each node.
# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB lớn secure it, we"ll need the currentpassword for the root user. If you"ve just installed MariaDB, andyou haven"t set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none):OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MariaDBroot user without the proper authorisation.Set root password?
Create SELinux Policy for MariaDB Galera cluster:
Since, we have configured SELinux in permissive mode. Therefore, all the violations by MariaDB và Galera has been recorded in /var/log/audit/audit.log. We can use it to create a concrete SELinux policy.
Use fgrep & audit2allow commands to extract policy violations log into a text file.
# fgrep "mysqld" /var/log/audit/audit.log | audit2allow -m MySQL_galera -o MySQL_galera.teCompile these logs to lớn a SELinux policy module.
# checkmodule -M -m MySQL_galera.te -o MySQL_galera.modcheckmodule: loading policy configuration from galera.techeckmodule: policy configuration loadedcheckmodule: writing binary representation (version 19) to lớn MySQL_galera.modCreate a package of compiled policy module.
# semodule_package -m MySQL_galera.mod -o MySQL_galera.ppImport this policy into SELinux.
# semodule -i MySQL_galera.ppSet SELinux to lớn run in enforcing mode.
# setenforce 1Test SELinux is working fine by restart MariaDB service on each node.
Finally, enable the MariaDB service on all nodes.
# systemctl enable mariadb.serviceWe have successfully configured a MariaDB Galera Cluster on CentOS 7. Although we have configured a two node cluster, but the same steps are good enough for configuring a MariaDB Galera cluster of larger size.
After configuring a MariaDB Galera Cluster, you should be looking next for a database proxy to lớn perform load balancing and routing for our cluster. Therefore, it is highly recommended that you should read our next post Install MariaDB MaxScale Database Proxy on CentOS 7.
Chuyên mục: Domain Hosting