Mysql

MySQL 集群 - SQL 節點無法連接管理節點

  • March 19, 2019

我正在嘗試部署具有以下架構的 2 台機器 MySQL NDB Cluster:

192.168.1.12 – management node
192.168.1.12 – SQL node
192.168.1.12 – data node
192.168.1.13 – SQL node
192.168.1.13 – data node

基本作業系統為 Ubuntu 14.04,MySQL Cluster 軟體版本為 5.7.25。.

我一直在關注APT儲存庫安裝方法:

$ sudo apt-get install mysql-cluster-community-management-server
$ sudo apt-get install mysql-cluster-community-client
$ sudo apt-get install mysql-cluster-community-data-node
$ sudo apt-get install mysql-cluster-community-server

我只配置了第一台機器 192.168.1.12 管理和第一個數據節點工作正常。

ndb_mgm> show
Connected to Management Server at: 192.168.1.12:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2    @192.168.1.12  (mysql-5.7.25 ndb-7.5.13, starting, Nodegroup: 0)
id=3 (not connected, accepting connect from 192.168.1.13)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @192.168.1.12  (mysql-5.7.25 ndb-7.5.13)

[mysqld(API)]   2 node(s)
id=4 (not connected, accepting connect from 192.168.1.12)
id=5 (not connected, accepting connect from 192.168.1.13)

我的 /var/lib/mysql-cluster/config.ini 文件內容如下:

[ndb_mgmd]
HostName=192.168.1.12
DataDir=/var/lib/mysql-cluster

[ndbd]
HostName=192.168.1.12
NodeId=2
DataDir=/usr/local/mysql/data

[ndbd]
HostName=192.168.1.13
NodeId=3
DataDir=/usr/local/mysql/data

[mysqld]
HostName=192.168.1.12

[mysqld]
HostName=192.168.1.13

在 MySQL 節點上,/etc/mysql/mysql.conf.d/mysqld.cnf 文件讀取為:

[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log
bind-address=192.168.1.12

ndbcluster
ndb-connectstring=192.168.1.12


[mysql_cluster]
ndb-connectstring =192.168.1.12

my.cnf(in 192.168.1.12) 文件內容如下:

[mysql_cluster]
ndb-connectstring =192.168.1.12

這是我的日誌文件/var/log/mysql/error.log:

2019-02-26T21:18:07.772650Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 720710ms. The settings might not be optimal. (flushed=0 and $
2019-02-26T21:18:33.499413Z 0 [Warning] NDB: server id set to zero - changes logged to bin log with server id zero will be logged with another se$
2019-02-26T21:18:33.499926Z 0 [Note] NDB Binlog: Starting...
2019-02-26T21:18:33.500418Z 1 [Note] NDB Binlog: Started
2019-02-26T21:18:33.500438Z 1 [Note] NDB Binlog: Setting up
2019-02-26T21:18:33.500569Z 1 [Note] NDB Binlog: Created schema Ndb object, reference: 0x0, name: 'Ndb Binlog schema change monitoring'
2019-02-26T21:18:33.500684Z 1 [Note] NDB Binlog: Created injector Ndb object, reference: 0x0, name: 'Ndb Binlog data change monitoring'
2019-02-26T21:18:33.500708Z 1 [Note] NDB Binlog: Setup completed
2019-02-26T21:18:33.500720Z 1 [Note] NDB Binlog: Wait for server start completed
2019-02-26T21:18:33.500836Z 0 [Note] NDB Util: Starting...
2019-02-26T21:18:33.500936Z 2 [Note] NDB Util: Wait for server start completed
2019-02-26T21:18:33.501068Z 0 [Note] NDB Index Stat: Starting...
2019-02-26T21:18:33.501097Z 0 [Note] NDB Index Stat: Wait for server start completed
2019-02-26T21:18:33.603096Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data$
2019-02-26T21:18:33.607559Z 0 [Warning] CA certificate ca.pem is self signed.
2019-02-26T21:18:33.609426Z 0 [Note] Server hostname (bind-address): '192.168.1.12'; port: 33$
2019-02-26T21:18:33.609456Z 0 [Note]   - '192.168.1.12' resolves to '192.168.1.12';
2019-02-26T21:18:33.609491Z 0 [Note] Server socket created on IP: '192.168.1.12'.
2019-02-26T21:18:33.702507Z 0 [Note] Event Scheduler: Loaded 0 events
2019-02-26T21:18:33.702850Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.25-ndb-7.5.13'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Cluste$
2019-02-26T21:18:33.702987Z 2 [Note] NDB Util: Wait for cluster to start
2019-02-26T21:18:33.703018Z 0 [Note] NDB Index Stat: Wait for cluster to start
2019-02-26T21:18:33.703086Z 1 [Note] NDB Binlog: Check for incidents
2019-02-26T21:18:33.703101Z 1 [Note] NDB Binlog: Checking for any pending binlog purges
2019-02-26T21:18:33.703132Z 1 [Note] NDB Binlog: Wait for cluster to start
2019-02-26T21:19:03.754192Z 0 [Warning] NDB : Tables not available after 30 seconds.  Conside$

我使用這些命令啟動節點

#Management node
sudo ndb_mgmd -f /var/lib/mysql-cluster/config.ini --bind-address=192.168.1.12

#Data node
sudo ndbd --bind-address=192.168.1.12

#SQL node
sudo service mysql start

**注意:**我只測試了 IP 地址為 192.168.1.12 的機器

您正在嘗試啟動具有 2 個節點的集群,但僅啟動 1 個節點。這是可能的,但在啟動 ndbd/ndbmtd 時需要使用特殊選項,如果我沒記錯的話,這個參數稱為 -no-wait-nodes。在文件中查看更多資訊。所以你在集群之上啟動的方式會無限期地等待另一個節點啟動。

MySQL 伺服器不會啟動,因為集群沒有啟動。

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