Eu instalei um MariaDB Galera Cluster no Ubuntu 16.04 em 2 nós.
Aqui a informação do node1:
root@localhost:~# sudo more /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://192.168.143.81,192.168.148.75"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="192.168.143.81"
wsrep_node_name="Node1"
e aqui a informação do node2:
[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://192.168.143.81,192.168.148.75"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="192.168.148.75"
wsrep_node_name="Node2”
Tudo estava funcionando bem, já que reiniciei os dois servidores e tive um problema ao iniciar o serviço:
Aug 02 09:18:03 localhost mysqld[3220]: at gcomm/src/pc.cpp:connect():158
Aug 02 09:18:03 localhost mysqld[3220]: 2018-08-02 9:18:03 0 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():208: Failed to open backend connection: -110 (Connection timed out)
Aug 02 09:18:03 localhost mysqld[3220]: 2018-08-02 9:18:03 0 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1458: Failed to open channel 'galera_cluster' at 'gcomm://192.168.153.81,192.168.158.75': -110 (Conn
Aug 02 09:18:03 localhost mysqld[3220]: 2018-08-02 9:18:03 0 [ERROR] WSREP: gcs connect failed: Connection timed out
Aug 02 09:18:03 localhost mysqld[3220]: 2018-08-02 9:18:03 0 [ERROR] WSREP: wsrep::connect(gcomm://192.168.153.81,192.168.158.75) failed: 7
Aug 02 09:18:03 localhost mysqld[3220]: 2018-08-02 9:18:03 0 [ERROR] Aborting
Aug 02 09:18:04 localhost systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Aug 02 09:18:04 localhost systemd[1]: Failed to start MariaDB 10.3.8 database server.
Aug 02 09:18:04 localhost systemd[1]: mariadb.service: Unit entered failed state.
Aug 02 09:18:04 localhost systemd[1]: mariadb.service: Failed with result 'exit-code'.
O problema só acontece após a configuração do failover de IP com KeepAlived com um novo IP flutuante 192.168.143.33
mas também fiz:
$ sudo ufw allow from 192.168.143.33 to any port 3306,4567,4568,4444 proto tcp
$ sudo ufw allow from 192.168.143.33 to any port 3306,4567,4568,4444 proto udp
fazendo
ip addr show eth0
7: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether f2:3c:91:49:7f:0a brd ff:ff:ff:ff:ff:ff
inet 172.104.129.63/24 brd 172.104.129.255 scope global eth0
valid_lft forever preferred_lft forever
inet 192.168.143.33/17 scope global eth0:1
valid_lft forever preferred_lft forever
inet 192.168.143.81/17 scope global secondary eth0:2
valid_lft forever preferred_lft forever
inet6 2a01:7e01::f03c:91ff:fe49:7f0a/64 scope global mngtmpaddr dynamic
valid_lft 2591984sec preferred_lft 604784sec
inet6 fe80::f03c:91ff:fe49:7f0a/64 scope link
valid_lft forever preferred_lft forever
onde 172.104.129.63 é o IP público e os outros um, os IPs privados