[MariaDB - Galera ] Galera 설정하기 ( 환경 : MariaDB 10.3 + CentOS8 )
갈레라 클러스터는 총 4개의 포트를 쓰기 때문에 4가지를 방화벽에서 열어줘야 한다.
4567의 경우 udp까지 열어주면 되겠다.
firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --permanent --add-port=4567/tcp
firewall-cmd --permanent --add-port=4567/udp
firewall-cmd --permanent --add-port=4568/tcp
firewall-cmd --permanent --add-port=4444/tcp
[1] Install MariaDB Galera packages on all nodes.
1
2
3
4
5
6
|
[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.
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@www ~]# vi /etc/my.cnf.d/galera.cnf
# 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
# run basic initial settings
[root@www ~]# mysql_secure_installation
|
[3] Configure other nodes except a node of previous section.
1
2
3
4
5
6
7
8
|
[root@node01 ~]# vi /etc/my.cnf.d/galera.cnf
# 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
|
첨가하여 설명을 한다면 아래의 6가지는 필수 항목이라 할 수 있겠다.
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.2.101, 192.168.2.102
wsrep_cluster_name=cluster_whitekeyboard
wsrep_node_name=whitekeyboard_1
wsrep_node_address=192.168.2.101
추가적으로 로그에 관련된 정보를 넣어 만든 설정은 아래와 같고 다시 쓰기 위해서 기록해두고자 한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.2.101, 192.168.2.102
wsrep_cluster_name=cluster_test
wsrep_node_name=node1
wsrep_node_address=192.168.2.102
#Galera Log
log-error=/var/lib/mysql
general_log = 1
general_log_file=/var/lib/mysql/general.log
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
|
[4] That's OK. Make sute the status like follows. It's OK if [wsrep_local_state_comment] is [Synced].
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
[root@node01 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.3.11-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_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 | 7b640dad-faea-11e9-a8e9-eac28b190651 |
| 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.000238062/0.000353304/0.000585888/0.00012582/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 | 9a3f806b-faeb-11e9-9c42-4f064553ffb9 |
| 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.000000 |
| wsrep_local_send_queue_max | 1 |
| wsrep_local_send_queue_min | 0 |
| wsrep_local_state | 4 |
| wsrep_local_state_comment | Synced |
| wsrep_local_state_uuid | 7b640dad-faea-11e9-a8e9-eac28b190651 |
| wsrep_protocol_version | 8 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy <info@codership.com> |
| wsrep_provider_version | 3.23(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.002 sec)
|