一、
安装好三个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 susystemctl stop mariadbgalera_new_clustermysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"systemctl start mariadbcreate database db1;create database db2;mysql -u root -pshow databases;