Galera Cluster for Multi Master:第二个节点无法在 Ubuntu 16.04.4 x64 中启动

Galera Cluster for Multi Master: Second node failed to start in Ubuntu 16.04.4 x64

我正在尝试参考本教程测试两台服务器之间的主-主复制:Configure a galera cluster

first节点在执行galera_new_cluster&getwsrep_cluster_size = 1后正常启动,但是执行systemctl start mysqlfor时第二个 节点,我收到如下所示的错误。

Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.

来自 "systemctl status mariadb.service" 的错误:

 Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():208: Failed to open backend connection: -110 (Connection timed out)
 Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1458: Failed to open channel 'test_cluster' at 'gcomm://206.189.37.50,206.189.39.149': -110 (Connection timed out)
 Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: gcs connect failed: Connection timed out
 Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: wsrep::connect(gcomm://206.189.37.50,206.189.39.149) failed: 7
 Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] Aborting
 Jul 18 08:03:56 mariadb-s2 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
 Jul 18 08:03:56 mariadb-s2 systemd[1]: Failed to start MariaDB 10.1.34 database server.
 Jul 18 08:03:56 mariadb-s2 systemd[1]: mariadb.service: Unit entered failed state.
 Jul 18 08:03:56 mariadb-s2 systemd[1]: mariadb.service: Failed with result 'exit-code'.

来自 "journalctl -xe" 的错误:

Jul 18 08:03:22 mariadb-s2 mysqld[7734]: WSREP: Recovered position 5820583f-8a43-11e8-8c80-9e4cdd04427e:0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] /usr/sbin/mysqld (mysqld 10.1.34-MariaDB-1~xenial) starting as process 7956 ...
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Read nil XID from storage engines, skipping position init
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib/galera/libgalera_smm.so'
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: wsrep_load(): Galera 25.3.23(r3789) by Codership Oy <info@codership.com> loaded successfully.
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: CRC-32C: using hardware acceleration.
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Found saved state: 5820583f-8a43-11e8-8c80-9e4cdd04427e:-1, safe_to_bootstrap: 1 
Jul 18 08:03:22 mariadb-s2 mysqld[7734]: WSREP: Recovered position 5820583f-8a43-11e8-8c80-9e4cdd04427e:0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] /usr/sbin/mysqld (mysqld 10.1.34-MariaDB-1~xenial) starting as process 7956 ...
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Read nil XID from storage engines, skipping position init
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib/galera/libgalera_smm.so'
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: wsrep_load(): Galera 25.3.23(r3789) by Codership Oy <info@codership.com> loaded successfully.
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: CRC-32C: using hardware acceleration.
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Found saved state: 5820583f-8a43-11e8-8c80-9e4cdd04427e:-1, safe_to_bootstrap: 1
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Passing config to GCS: base_dir = /var/lib/mysql/; base_host = 206.189.39.149; base_port = 4567; cert.log_conflicts = no; debug = no; evs.auto_evi
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Assign initial position for certification: 0, protocol version: -1
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: wsrep_sst_grab()
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Start replication
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Setting initial position to 5820583f-8a43-11e8-8c80-9e4cdd04427e:0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: protonet asio version 0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: Using CRC-32C for message checksums.
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: backend: asio
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: gcomm thread scheduling priority set to other:0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Warning] WSREP: access file(/var/lib/mysql//gvwstate.dat) failed(No such file or directory)
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: restore pc from disk failed
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: GMCast version 0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: EVS version 0
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: gcomm: connecting to group 'test_cluster', peer '206.189.37.50:,206.189.39.149:'
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection established to 0a4e92b4 tcp://206.189.39.149:4567
Jul 18 08:03:22 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:22 140559072364800 [Warning] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') address 'tcp://206.189.39.149:4567' points to own listening address, blacklisting
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:25 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:25 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 0a4e92b4 with addr tcp://206.189.39.149:4567 timed out, no messages seen in PT3S
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:25 140559072364800 [Warning] WSREP: no nodes coming from prim view, prim not possible
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:25 140559072364800 [Note] WSREP: view(view_id(NON_PRIM,0a4e92b4,1) memb {
Jul 18 08:03:25 mariadb-s2 mysqld[7956]:         0a4e92b4,0
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: } joined {
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: } left {
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: } partitioned {
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: })
Jul 18 08:03:25 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:25 140559072364800 [Warning] WSREP: last inactive check more than PT1.5S ago (PT3.50398S), skipping check
Jul 18 08:03:29 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:29 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:34 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:34 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:38 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:38 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:43 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:43 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:47 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:47 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:49 mariadb-s2 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=e2:57:b6:36:df:64:ec:38:73:0c:78:30:08:00 SRC=123.249.27.191 DST=206.189.39.149 LEN=40 TOS=0x00 PREC=0x00 TTL=113 ID=256 PROTO=TCP SPT=39069 DPT=8888 WINDOW=16384 RES=0x00 S
Jul 18 08:03:52 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:52 140559072364800 [Note] WSREP: (0a4e92b4, 'tcp://0.0.0.0:4567') connection to peer 00000000 with addr tcp://206.189.37.50:4567 timed out, no messages seen in PT3S
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [Note] WSREP: view((empty))
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: failed to open gcomm backend connection: 110: failed to reach primary view: 110 (Connection timed out)
Jul 18 08:03:55 mariadb-s2 mysqld[7956]:          at gcomm/src/pc.cpp:connect():158
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():208: Failed to open backend connection: -110 (Connection timed out)
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1458: Failed to open channel 'test_cluster' at 'gcomm://206.189.37.50,206.189.39.149': -110 (Connection timed out)
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: gcs connect failed: Connection timed out
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] WSREP: wsrep::connect(gcomm://206.189.37.50,206.189.39.149) failed: 7
Jul 18 08:03:55 mariadb-s2 mysqld[7956]: 2018-07-18  8:03:55 140559072364800 [ERROR] Aborting
Jul 18 08:03:56 mariadb-s2 systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jul 18 08:03:56 mariadb-s2 systemd[1]: Failed to start MariaDB 10.1.34 database server.

节点1的配置:

[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="test_cluster"
wsrep_cluster_address="gcomm://206.189.37.50,206.189.39.149"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="206.189.37.50"
wsrep_node_name="node1"

节点2的配置:

[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="test_cluster"
wsrep_cluster_address="gcomm://206.189.37.50,206.189.39.149"

# Galera Synchronization Configuration
wsrep_sst_method=rsync

# Galera Node Configuration
wsrep_node_address="206.189.39.149"
wsrep_node_name="node2"

我在 Stack Overflow 中提到过许多类似的问题,但 none 的建议有所帮助。我仍然遇到同样的错误。

日志显示 Ubuntu 防火墙 (UFW) 处于活动状态,因此连接很可能被防火墙阻止。

要查看这是否是问题所在,您可以 运行 ufw disable。如果复制在禁用 ufw 的情况下工作,请确保添加规则以允许 从 node1 的 ip 到 node2 上的 tcp 端口 4567 的连接,以及 node2 的 ip 到 node1 上的 tcp 端口 4567 的连接。

添加规则后检查 ufw list 的输出,如果一切正常,运行 ufw enable 重新激活防火墙。

您可以运行 man ufw 了解有关 UFW 配置的更多信息。