CentOS 7
Sponsored Link

MariaDB 10.2 : MariaDB Galera Cluster2017/10/30

 
Configure MariaDB Galera Cluster.
All nodes in cluster become Master-Server in this configuration.
[1] Install MariaDB Galera packages on all nodes like follows.
# install from SCLo

[root@www ~]#
yum --enablerepo=centos-sclo-rh -y install rh-mariadb102-mariadb-server-galera
# if Firewalld is running, set like follows

[root@www ~]#
firewall-cmd --add-service=mysql --permanent

[root@www ~]#
firewall-cmd --add-port={3306/tcp,4567/tcp,4568/tcp,4444/tcp} --permanent

[root@www ~]#
firewall-cmd --reload

[2] Configure a 1st node like follows.
[root@www ~]#
mv /etc/opt/rh/rh-mariadb102/my.cnf.d/galera.cnf /etc/opt/rh/rh-mariadb102/my.cnf.d/galera.cnf.org

[root@www ~]#
vi /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf
# line 30: uncomment and change like follows

[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=
/opt/rh/rh-mariadb102/root/usr/lib64/galera/libgalera_smm.so

wsrep_cluster_address=
gcomm://

# uncomment like follows

binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"
# own IP address

wsrep_node_address="10.0.0.31"
# replication provider

wsrep_sst_method=rsync
# start Galera Cluster

[root@www ~]#
/opt/rh/rh-mariadb102/root/usr/bin/galera_new_cluster
# run basic initial settings

[root@www ~]#
mysql_secure_installation

[3] Configure other nodes except a node of previous section like follows.
[root@node01 ~]#
mv /etc/opt/rh/rh-mariadb102/my.cnf.d/galera.cnf /etc/opt/rh/rh-mariadb102/my.cnf.d/galera.cnf.org

[root@node01 ~]#
vi /etc/opt/rh/rh-mariadb102/my.cnf.d/mariadb-server.cnf
# line 30: uncomment and change like follows

[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=
/opt/rh/rh-mariadb102/root/usr/lib64/galera/libgalera_smm.so

# specify all nodes in cluster

wsrep_cluster_address=
"gcomm://10.0.0.31,10.0.0.51"

binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# add follows

# cluster name

wsrep_cluster_name="MariaDB_Cluster"
# own IP address

wsrep_node_address="10.0.0.51"
# replication provider

wsrep_sst_method=rsync
[root@node01 ~]#
systemctl start rh-mariadb102-mariadb

[4] The Cluster settings is OK, Make sute the status like follows. It's OK if [wsrep_local_state_comment] is [Synced].
[root@node01 ~]#
mysql -u root -p

Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.2.8-MariaDB-log MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
show status like 'wsrep_%';

+------------------------------+------------------------------------------------+
| Variable_name                | Value                                          |
+------------------------------+------------------------------------------------+
| wsrep_apply_oooe             | 0.000000                                       |
| wsrep_apply_oool             | 0.000000                                       |
| wsrep_apply_window           | 0.000000                                       |
| wsrep_causal_reads           | 0                                              |
| wsrep_cert_deps_distance     | 0.000000                                       |
| wsrep_cert_index_size        | 0                                              |
| wsrep_cert_interval          | 0.000000                                       |
| wsrep_cluster_conf_id        | 2                                              |
| wsrep_cluster_size           | 2                                              |
| wsrep_cluster_state_uuid     | 5f73ca9f-be0e-11e7-b57e-66deb0603196           |
| wsrep_cluster_status         | Primary                                        |
| wsrep_commit_oooe            | 0.000000                                       |
| wsrep_commit_oool            | 0.000000                                       |
| wsrep_commit_window          | 0.000000                                       |
| wsrep_connected              | ON                                             |
| wsrep_desync_count           | 0                                              |
| wsrep_evs_delayed            |                                                |
| wsrep_evs_evict_list         |                                                |
| wsrep_evs_repl_latency       | 0.000607146/0.00150996/0.00418607/0.00134739/5 |
| wsrep_evs_state              | OPERATIONAL                                    |
| wsrep_flow_control_paused    | 0.000000                                       |
| wsrep_flow_control_paused_ns | 0                                              |
| wsrep_flow_control_recv      | 0                                              |
| wsrep_flow_control_sent      | 0                                              |
| wsrep_gcomm_uuid             | e1ceedcc-be0e-11e7-bdc4-6332d9eeeb20           |
| wsrep_incoming_addresses     | 10.0.0.31:3306,10.0.0.51:3306                  |
| wsrep_last_committed         | 3                                              |
| wsrep_local_bf_aborts        | 0                                              |
| wsrep_local_cached_downto    | 18446744073709551615                           |
| wsrep_local_cert_failures    | 0                                              |
| wsrep_local_commits          | 0                                              |
| wsrep_local_index            | 1                                              |
| wsrep_local_recv_queue       | 0                                              |
| wsrep_local_recv_queue_avg   | 0.000000                                       |
| wsrep_local_recv_queue_max   | 1                                              |
| wsrep_local_recv_queue_min   | 0                                              |
| wsrep_local_replays          | 0                                              |
| wsrep_local_send_queue       | 0                                              |
| wsrep_local_send_queue_avg   | 0.333333                                       |
| wsrep_local_send_queue_max   | 2                                              |
| wsrep_local_send_queue_min   | 0                                              |
| wsrep_local_state            | 4                                              |
| wsrep_local_state_comment    | Synced                                         |
| wsrep_local_state_uuid       | 5f73ca9f-be0e-11e7-b57e-66deb0603196           |
| wsrep_protocol_version       | 7                                              |
| wsrep_provider_name          | Galera                                         |
| wsrep_provider_vendor        | Codership Oy <info@codership.com>              |
| wsrep_provider_version       | 3.20(rXXXX)                                    |
| wsrep_ready                  | ON                                             |
| wsrep_received               | 3                                              |
| wsrep_received_bytes         | 231                                            |
| wsrep_repl_data_bytes        | 0                                              |
| wsrep_repl_keys              | 0                                              |
| wsrep_repl_keys_bytes        | 0                                              |
| wsrep_repl_other_bytes       | 0                                              |
| wsrep_replicated             | 0                                              |
| wsrep_replicated_bytes       | 0                                              |
| wsrep_thread_count           | 2                                              |
+------------------------------+------------------------------------------------+
58 rows in set (0.01 sec)
Matched Content