Mysql

我無法向 mariadb 集群 10.1 添加額外的節點

  • January 17, 2018

我正在安裝一個測試 mariadb 集群,但是當我想添加一個額外的節點時遇到了問題。兩個節點都使用 Red Hat Enterprise Linux Server 版本 7.3 (Maipo)

這些是以下步驟:

在第一個節點 192.168.1.10 上。MariaDB-server 10.1.20 已安裝

  1. #vi /etc/my.cnf.d/server.cnf
[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.1.10,192.168.1.20"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
# start added lines
wsrep_node_address='192.168.1.10'
wsrep_node_name='galera-db01'
wsrep_cluster_name='cluster-test'
wsrep_sst_method = rsync
# end added lines
#
# Allow server to accept connections on all interfaces.
#
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=2

2)#galera_new_cluster。沒有錯誤。

  1. #mysql -uroot -e “顯示狀態如’wsrep_cluster%'”
+--------------------------+--------------------------------------+
| Variable_name            | Value                                |
+--------------------------+--------------------------------------+
| wsrep_cluster_conf_id    | 1                                    |
| wsrep_cluster_size       | 1                                    |
| wsrep_cluster_state_uuid | 0f2debe9-fa32-11e7-9d57-5b2cd22cad06 |
| wsrep_cluster_status     | Primary                              |
+--------------------------+--------------------------------------+

4)接下來。我創建了一個數據庫,其中添加了一張表和一條記錄。

#mysql –uroot
MariaDB [(none)]> create database dbexample;
MariaDB [(none)]> use dbemaxple
MariaDB [(none)]> create table tblemp(name varchar(50));
MariaDB [(none)]> insert into tblemp values('John');

看起來它在第一個節點上執行良好。

在第二個節點 (192.168.1.20) 上。MariaDB-server 10.1.20 已安裝。

  1. #vi /etc/my.cnf.d/server.cnf
[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.1.10,192.168.1.20"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
# start added
wsrep_node_address='192.168.1.20'
wsrep_node_name='galera-db02'
wsrep_cluster_name='cluster-test'
wsrep_sst_method = rsync
# end added
#
# Allow server to accept connections on all interfaces.
#
bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
innodb_flush_log_at_trx_commit=2

6)#service mysql啟動

Starting mysql (via systemctl):  Job for mariadb.service failed 
becausethe control process exited with error code. See "systemctl status 
mariadb.service" and "journalctl -xe" for details.
                                                      [FAILED]

7)#systemctl status mariadb.service -l

â mariadb.service - MariaDB database server
  Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; 
vendor preset: disabled)
 Drop-In: /etc/systemd/system/mariadb.service.d
          ââmigrated-from-my.cnf-settings.conf
  Active: failed (Result: exit-code) since lun 2018-01-15 17:37:02 PET;  54s ago
 Process: 18195 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
 Process: 18116 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
 Process: 18114 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 18195 (code=exited, status=1/FAILURE)
  Status: "MariaDB server is down"

ene 15 17:37:01 cluster4.local mysqld[18195]: at gcomm/src/pc.cpp:connect():158
ene 15 17:37:01 cluster4.local mysqld[18195]: 2018-01-15 17:37:01 140448459192576 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():208:  Failed to open backend connection: -110 (Connection timed out)
ene 15 17:37:01 cluster4.local mysqld[18195]: 2018-01-15 17:37:01 140448459192576 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1380: Failed to open channel 'cluster-test' at 'gcomm://192.168.1.10,192.168.1.20': -110 (Connection timed out)
ene 15 17:37:01 cluster4.local mysqld[18195]: 2018-01-15 17:37:01 140448459192576 [ERROR] WSREP: gcs connect failed: Connection timed out
ene 15 17:37:01 cluster4.local mysqld[18195]: 2018-01-15 17:37:01 140448459192576 [ERROR] WSREP: wsrep::connect(gcomm://192.168.1.10,192.168.1.20) failed: 7
ene 15 17:37:01 cluster4.local mysqld[18195]: 2018-01-15 17:37:01 140448459192576 [ERROR] Aborting
ene 15 17:37:02 cluster4.local systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
ene 15 17:37:02 cluster4.local systemd[1]: Failed to start MariaDB database server.
ene 15 17:37:02 cluster4.local systemd[1]: Unit mariadb.service entered failed state.
ene 15 17:37:02 cluster4.local systemd[1]: mariadb.service failed.

所以問題是為了添加第二個節點缺少什麼?

似乎錯誤與連接有關。

首先,在伺服器 2 上,檢查你能 ping(ICMP) 伺服器 1 嗎?

如果您無法檢查您的連接。

但是如果可以的話,它與防火牆限制有關。

在 MariaDB Galera 集群中,這些埠必須在所有伺服器上打開。

22 (ssh) if you want to use rsync
3306 (MySQL)
4444 (Rsync/ SST)
4567 (Galera)
4568 (Galera IST)

引用自:https://dba.stackexchange.com/questions/195510