Fedora 32
Sponsored Link

MariaDB : MariaDB Galera Cluster2020/05/15

 
Configure MariaDB Galera Cluster.
All nodes in cluster become Master-Server in this configuration.
[1] Install MariaDB Galera packages on all nodes.
[root@www ~]#
dnf -y install mariadb-server-galera
# if Firewalld is running, allow ports

[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 1st node.
[root@www ~]#
vi /etc/my.cnf.d/galera.cnf
# line 34: change

wsrep_on="
ON
"
# line 43 : specify any cluster name

wsrep_cluster_name="
Galera_Cluster
"
# line 46 : uncomment and change like follows

wsrep_cluster_address="
gcomm://
"
# line 54 : uncomment and change to own IP address

wsrep_node_address="
10.0.0.31
"
# start Galera Cluster

[root@www ~]#
galera_new_cluster

[root@www ~]#
systemctl enable mariadb
[root@www ~]#
vi /etc/my.cnf.d/galera.cnf
# line 46: add all nodes in cluster you plan to add

wsrep_cluster_address="gcomm://
10.0.0.31,10.0.0.51
"
# run basic initial settings

[root@www ~]#
mysql_secure_installation

[3] Configure other nodes except a node of previous section.
[root@node01 ~]#
vi /etc/my.cnf.d/galera.cnf
# line 34: change

wsrep_on="
ON
"
# line 43 : specify cluster name that is the same one with 1st node

wsrep_cluster_name="
Galera_Cluster
"
# line 46 : uncomment and specify all nodes in cluster

wsrep_cluster_address="
gcomm://10.0.0.31,10.0.0.51
"
# line 54 : uncomment and change to own IP address

wsrep_node_address="
10.0.0.51
"
[root@node01 ~]#
systemctl enable --now mariadb

[4] If SELinux is enabled, change policy.
[root@www ~]#
vi my-galera.te
# create new

module my-galera 1.0;

require {
        type firewalld_t;
        type mysqld_t;
        type sysctl_net_t;
        type httpd_config_t;
        type pcscd_t;
        class lnk_file read dir search;
        class capability sys_nice;
}

#============= firewalld_t ==============
allow firewalld_t self:capability sys_nice;

#============= pcscd_t ==============
allow pcscd_t self:capability sys_nice;

#============= mysqld_t ==============
allow mysqld_t sysctl_net_t:dir search;
allow mysqld_t httpd_config_t:lnk_file read;

[root@www ~]#
checkmodule -m -M -o my-galera.mod my-galera.te

[root@www ~]#
semodule_package --outfile my-galera.pp --module my-galera.mod

[root@www ~]#
semodule -i my-galera.pp

[5] That's OK. Make sute the status like follows. It's OK if [wsrep_local_state_comment] is [Synced].
[root@node01 ~]#
mysql

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.12-MariaDB MariaDB Server

Copyright (c) 2000, 2018, 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_local_state_uuid        | f07eae90-9675-11ea-a799-8ab4fe029436                                                                                                           |
| wsrep_protocol_version        | 10                                                                                                                                             |
| wsrep_last_committed          | 2                                                                                                                                              |
| wsrep_replicated              | 0                                                                                                                                              |
| wsrep_replicated_bytes        | 0                                                                                                                                              |
| wsrep_repl_keys               | 0                                                                                                                                              |
| wsrep_repl_keys_bytes         | 0                                                                                                                                              |
| wsrep_repl_data_bytes         | 0                                                                                                                                              |
| wsrep_repl_other_bytes        | 0                                                                                                                                              |
| wsrep_received                | 3                                                                                                                                              |
| wsrep_received_bytes          | 216                                                                                                                                            |
| wsrep_local_commits           | 0                                                                                                                                              |
| wsrep_local_cert_failures     | 0                                                                                                                                              |
| wsrep_local_replays           | 0                                                                                                                                              |
| wsrep_local_send_queue        | 0                                                                                                                                              |
| wsrep_local_send_queue_max    | 1                                                                                                                                              |
| wsrep_local_send_queue_min    | 0                                                                                                                                              |
| wsrep_local_send_queue_avg    | 0                                                                                                                                              |
| wsrep_local_recv_queue        | 0                                                                                                                                              |
| wsrep_local_recv_queue_max    | 1                                                                                                                                              |
| wsrep_local_recv_queue_min    | 0                                                                                                                                              |
| wsrep_local_recv_queue_avg    | 0                                                                                                                                              |
| wsrep_local_cached_downto     | 2                                                                                                                                              |
| wsrep_flow_control_paused_ns  | 0                                                                                                                                              |
| wsrep_flow_control_paused     | 0                                                                                                                                              |
| wsrep_flow_control_sent       | 0                                                                                                                                              |
| wsrep_flow_control_recv       | 0                                                                                                                                              |
| wsrep_cert_deps_distance      | 0                                                                                                                                              |
| wsrep_apply_oooe              | 0                                                                                                                                              |
| wsrep_apply_oool              | 0                                                                                                                                              |
| wsrep_apply_window            | 0                                                                                                                                              |
| wsrep_commit_oooe             | 0                                                                                                                                              |
| wsrep_commit_oool             | 0                                                                                                                                              |
| wsrep_commit_window           | 0                                                                                                                                              |
| wsrep_local_state             | 4                                                                                                                                              |
| wsrep_local_state_comment     | Synced                                                                                                                                         |
| wsrep_cert_index_size         | 0                                                                                                                                              |
| wsrep_causal_reads            | 0                                                                                                                                              |
| wsrep_cert_interval           | 0                                                                                                                                              |
| wsrep_open_transactions       | 0                                                                                                                                              |
| wsrep_open_connections        | 0                                                                                                                                              |
| wsrep_incoming_addresses      | AUTO,AUTO                                                                                                                                      |
| wsrep_cluster_weight          | 2                                                                                                                                              |
| wsrep_desync_count            | 0                                                                                                                                              |
| wsrep_evs_delayed             |                                                                                                                                                |
| wsrep_evs_evict_list          |                                                                                                                                                |
| wsrep_evs_repl_latency        | 0.000244225/0.000466979/0.000826347/0.000174187/7                                                                                              |
| wsrep_evs_state               | OPERATIONAL                                                                                                                                    |
| wsrep_gcomm_uuid              | 0a342110-9676-11ea-a75c-634196d8c6c0                                                                                                           |
| wsrep_applier_thread_count    | 1                                                                                                                                              |
| wsrep_cluster_capabilities    |                                                                                                                                                |
| wsrep_cluster_conf_id         | 18446744073709551615                                                                                                                           |
| wsrep_cluster_size            | 2                                                                                                                                              |
| wsrep_cluster_state_uuid      | f07eae90-9675-11ea-a799-8ab4fe029436                                                                                                           |
| wsrep_cluster_status          | Primary                                                                                                                                        |
| wsrep_connected               | ON                                                                                                                                             |
| wsrep_local_bf_aborts         | 0                                                                                                                                              |
| wsrep_local_index             | 0                                                                                                                                              |
| wsrep_provider_capabilities   | :MULTI_MASTER:CERTIFICATION:PARALLEL_APPLYING:TRX_REPLAY:ISOLATION:PAUSE:CAUSAL_READS:INCREMENTAL_WRITESET:UNORDERED:PREORDERED:STREAMING:NBO: |
| wsrep_provider_name           | Galera                                                                                                                                         |
| wsrep_provider_vendor         | Codership Oy <info@codership.com>                                                                                                              |
| wsrep_provider_version        | 4.3(rXXXX)                                                                                                                                     |
| wsrep_ready                   | ON                                                                                                                                             |
| wsrep_rollbacker_thread_count | 1                                                                                                                                              |
| wsrep_thread_count            | 2                                                                                                                                              |
+-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
65 rows in set (0.002 sec)
Matched Content