如何在“Ubuntu 服务器上使用MariaDB配置Galera集群”?
一、
安装好三个MariaDB数据库
如何使用“Ubuntu 20.04桌面版,安装MariaDB数据库“?win10系统?-CSDN博客
二、第一个node1,修改
sudo nano /etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1_ip_address,node2_ip_address,node2_ip_address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node1_ip_address"
wsrep_node_name="node1"
按 Ctrl + X
键:保存更改,按 Y
键,然后按回车键。不想要保存更改,按 N
键,然后按回车键
三、第二个node2修改
sudo nano /etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1_ip_address,node2_ip_address,node2_ip_address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node2_ip_address"
wsrep_node_name="node2"
四、第三个node3修改
sudo nano /etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1_ip_address,node2_ip_address,node2_ip_address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node3_ip_address"
wsrep_node_name="node3"
sudo su
systemctl stop mariadb
galera_new_cluster
mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"
systemctl start mariadb
create database db1;
create database db2;
mysql -u root -p
show databases;
原文地址:https://blog.csdn.net/wuwei13798642/article/details/136440156
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!