我正在尝试使用以下架构部署 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(在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 服务器不会启动,因为集群未启动。