1、环境
服务器名称 | IP地址 | 备注 |
db-161-131 | 10.32.161.131 | 主 |
db-161-132 | 10.32.161.132 | 主 |
db-161-133 | 10.32.161.133 | 主 |
2、MariaDB安装
参考:https://www.cnblogs.com/a120608yby/p/17312862.html
3、安装集群程序(如果没有安装MariaDB-Server,这里将关联自动安装)
dnf -y install mariadb-server-galera
4、修改配置
# 节点一增加如下配置 # vim /etc/my.cnf ... innodb_autoinc_lock_mode=2 wsrep_on=1 wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_name="Galera_Cluster" wsrep_cluster_address="gcomm://10.32.161.131,10.32.161.132,10.32.161.133" wsrep_node_name=10.32.161.131 wsrep_node_address=10.32.161.131 # 节点二增加如下配置 # vim /etc/my.cnf ... innodb_autoinc_lock_mode=2 wsrep_on=1 wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_name="Galera_Cluster" wsrep_cluster_address="gcomm://10.32.161.131,10.32.161.132,10.32.161.133" wsrep_node_name=10.32.161.132 wsrep_node_address=10.32.161.132 # 节点三增加如下配置 # vim /etc/my.cnf ... innodb_autoinc_lock_mode=2 wsrep_on=1 wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_name="Galera_Cluster" wsrep_cluster_address="gcomm://10.32.161.131,10.32.161.132,10.32.161.133" wsrep_node_name=10.32.161.133 wsrep_node_address=10.32.161.133
5、启动集群及服务
# 在其中一个节点上启动集群 galera_new_cluster systemctl enable mariadb # 另外两个节点上启动MariaDB服务 systemctl enable --now mariadb
6、查看集群状态
# 查看集群状态,确认wsrep_local_state_comment是否为Synced > show status like 'wsrep_%'; +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ | Variable_name | Value | +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ | wsrep_local_state_uuid | 8b45d28f-d9ca-11ed-b6a2-7ab276a477e2 | | wsrep_protocol_version | 10 | | wsrep_last_committed | 9 | | 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 | 13 | | wsrep_received_bytes | 1470 | | 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 | 3 | | wsrep_flow_control_paused_ns | 0 | | wsrep_flow_control_paused | 0 | | wsrep_flow_control_sent | 0 | | wsrep_flow_control_recv | 0 | | wsrep_flow_control_active | false | | wsrep_flow_control_requested | false | | wsrep_cert_deps_distance | 1 | | wsrep_apply_oooe | 0 | | wsrep_apply_oool | 0 | | wsrep_apply_window | 0 | | wsrep_apply_waits | 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 | 2 | | wsrep_causal_reads | 0 | | wsrep_cert_interval | 3.5 | | wsrep_open_transactions | 0 | | wsrep_open_connections | 0 | | wsrep_incoming_addresses | AUTO,AUTO,AUTO | | wsrep_cluster_weight | 3 | | wsrep_desync_count | 0 | | wsrep_evs_delayed | | | wsrep_evs_evict_list | | | wsrep_evs_repl_latency | 0/0/0/0/0 | | wsrep_evs_state | OPERATIONAL | | wsrep_gcomm_uuid | 791e054d-d9cd-11ed-a551-3ea195a0b678 | | wsrep_gmcast_segment | 0 | | wsrep_applier_thread_count | 1 | | wsrep_cluster_capabilities | | | wsrep_cluster_conf_id | 7 | | wsrep_cluster_size | 3 | | wsrep_cluster_state_uuid | 8b45d28f-d9ca-11ed-b6a2-7ab276a477e2 | | 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 | 26.4.11(rXXXX) | | wsrep_ready | ON | | wsrep_rollbacker_thread_count | 1 | | wsrep_thread_count | 2 | +-------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ 69 rows in set (0.002 sec) 或者 > show status like 'wsrep_local_state_comment'; +---------------------------+--------+ | Variable_name | Value | +---------------------------+--------+ | wsrep_local_state_comment | Synced | +---------------------------+--------+ 1 row in set (0.001 sec)
7、集群所有节点重启后服务无法正常启动问题
# 登录节点一,修改safe_to_bootstrap参数为1 # cat /var/lib/mysql/grastate.dat # GALERA saved state version: 2.1 uuid: 15e45d57-d9d0-11ed-a6b7-93a39cf0c63a seqno: -1 safe_to_bootstrap: 0 # 启动集群 galera_new_cluster # 启动另外两个节点MariaDB服务 systemctl start mariadb
参考:https://mariadb.com/kb/en/galera-cluster/
标签:Galera,10.32,wsrep,cluster,state,多主,MariaDB,local,name From: https://www.cnblogs.com/a120608yby/p/17314995.html