galera cluster mariadb

2024-07-24

galera为多主节点,并提供同步复制功能,不像master-slave异步有延迟

A MariaDB Galera cluster requires a minimal of 3 nodes.

Galera Cluster是由第三方公司Codership所研发的一套免费开源的集群高可用方案

Galera Cluster for MySQL 8.0文件:

galera-4-26.4.16-1.el8.x86_64.rpm
mysql-wsrep-8.0-8.0.34-26.15.el8.x86_64.rpm
#################

rocky9 galera cluster mariadb
https://mirrors.aliyun.com/mariadb/yum/11.4.2/rocky9-amd64/rpms/
MariaDB-server-11.4.2-1.el9.x86_64.rpm
galera-4-26.4.16-1.el9.x86_64.rpm

 

1、每个节点正常安装mariadb

mysql_secure_installation

新增 sst_user for galera cluster 使用
GRANT USAGE ON *.* to sst_user@’%’ IDENTIFIED BY ‘sstpassword’;
GRANT ALL PRIVILEGES on *.* to sst_user@’%’;
FLUSH PRIVILEGES

2 第一台mariadb的my.cnf 內容如下

[galera]
wsrep_on = ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://192.168.33.10,192.168.33.11"
wsrep_slave_threads=4 # 預設為1, 盡量設定成 CPU 數量的 4 倍
binlog_format=ROW
default_storage_engine=InnoDB
bind-address=0.0.0.0
wsrep_node_name=node1
wsrep_node_address="192.168.33.11"
wsrep_sst_method=rsync
wsrep_sst_auth=sst_user:sst_user
log_error = /var/log/mysql/error.log

3 ###
wsrep_node_address="192.168.33.12"
wsrep_node_name=node2

4 galera_new_cluster

show status like 'wsrep_cluster_size'

5 haproxy load balance 去分流 mysql 流量

6 Kinds
SST Snapshot state transfer
IST Incremental state transfer

分类:数据库 | 标签: |

相关日志

评论被关闭!