我正在尝试部署具有 2 个管理节点、2 个 SQL 节点和 4 个数据节点的 8 台机器 MySQL NDB 集群。基本操作系统为 Ubuntu 16.04,MySQL Cluster 软件版本为 7.5.4。在专用服务器上运行一切。
我正在使用私有网络,并在 /etc/hosts 中定义了所有主机及其私有 IP
我的 config.ini 文件内容如下:
[ndbd default]
NoOfReplicas=2
DataMemory=16384M
IndexMemory=1024M
LockPagesInMainMemory=1
NoOfFragmentLogFiles=300
MaxNoOfConcurrentOperations=100000
SchedulerSpinTimer=400
SchedulerExecutionTimer=100
RealTimeScheduler=1
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=200
RedoBuffer=32M
MaxNoOfTables=2048
MaxNoOfOrderedIndexes=512
[mysqld default]
[ndb_mgmd default]
[tcp default]
SendBufferMemory=20M
ReceiveBufferMemory=20M
# Cluster Control / Management node
[ndb_mgmd]
NodeId=1
hostname=dbc1.enhancier.net
[ndb_mgmd]
NodeId=2
hostname=dbc2.enhancier.net
# Data Node 1
[ndbd]
NodeId=3
hostname=dbc3.enhancier.net
DataDir= /var/lib/mysql-cluster
# Data Node 2
[ndbd]
NodeId=4
HostName=dbc4.enhancier.net
DataDir= /var/lib/mysql-cluster
# Data Node 3
[ndbd]
NodeId=5
HostName=dbc5.enhancier.net
DataDir= /var/lib/mysql-cluster
# Data Node 4
[ndbd]
NodeId=6
HostName=dbc6.enhancier.net
DataDir= /var/lib/mysql-cluster
# SQL Node
[mysqld]
NodeId=7
hostname=dbc7.enhancier.net
# If you to add new SQL Node
[mysqld]
NodeId=8
hostname=dbc8.enhancier.net
在 MySQL 节点上,my.cnf 文件读取为:
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
user=mysql
ndbcluster
ndb-connectstring=dbc1.enhancier.net,dbc2.enhancier.net
[mysql_cluster]
ndb-connectstring=dbc1.enhancier.net,dbc.enhancier.net
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
在启动管理节点时,两者都可以正常联机,但是当我启动 MySQL 节点时,它看不到管理节点。
The ndb_mgm -e show command output is as follows:
root@dbc1:~# ndb_mgm -e show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 4 node(s)
id=3 (not connected, accepting connect from dbc3.enhancier.net)
id=4 (not connected, accepting connect from dbc4.enhancier.net)
id=5 (not connected, accepting connect from dbc5.enhancier.net)
id=6 (not connected, accepting connect from dbc6.enhancier.net)
[ndb_mgmd(MGM)] 2 node(s)
id=1 @10.80.45.5 (mysql-5.7.16 ndb-7.5.4)
id=2 @10.80.45.7 (mysql-5.7.16 ndb-7.5.4)
[mysqld(API)] 2 node(s)
id=7 (not connected, accepting connect from dbc7.enhancier.net)
id=8 (not connected, accepting connect from dbc8.enhancier.net)
注意:我没有连接数据节点......数据节点连接没有问题。这是第 9 次尝试,因此我确信数据节点连接不会成为问题。从来没有。
日志文件内容如下:
root@dbc7:~# cat /var/log/mysqld.log
2017-03-09T11:09:54.561861Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
2017-03-09T11:09:54.761186Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-03-09T11:09:54.761235Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2017-03-09T11:09:54.761248Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.16-ndb-7.5.4-cluster-gpl) starting as process 2378 ...
2017-03-09T11:09:54.763968Z 0 [Note] InnoDB: PUNCH HOLE support not available
2017-03-09T11:09:54.763977Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-03-09T11:09:54.763980Z 0 [Note] InnoDB: Uses event mutexes
2017-03-09T11:09:54.763982Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
2017-03-09T11:09:54.763984Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-03-09T11:09:54.763986Z 0 [Note] InnoDB: Using Linux native AIO
2017-03-09T11:09:54.764101Z 0 [Note] InnoDB: Number of pools: 1
2017-03-09T11:09:54.764144Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-03-09T11:09:54.764759Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-03-09T11:09:54.768703Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-03-09T11:09:54.769895Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-03-09T11:09:54.781020Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-03-09T11:09:54.786031Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-03-09T11:09:54.786059Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-03-09T11:09:54.815368Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-03-09T11:09:54.817085Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-03-09T11:09:54.817104Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-03-09T11:09:54.818254Z 0 [Note] InnoDB: Waiting for purge to start
2017-03-09T11:09:54.868460Z 0 [Note] InnoDB: 5.7.16 started; log sequence number 2536550
2017-03-09T11:09:54.869200Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool
2017-03-09T11:09:54.869672Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-03-09T11:09:54.871666Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170309 16:39:54
2017-03-09T11:10:30.361480Z 0 [Warning] NDB: server id set to zero - changes logged to bin log with server id zero will be logged with another server id by slave mysqlds
2017-03-09T11:10:30.361716Z 0 [Note] NDB Binlog: Starting...
2017-03-09T11:10:30.361865Z 1 [Note] NDB Binlog: Started
2017-03-09T11:10:30.361878Z 1 [Note] NDB Binlog: Setting up
2017-03-09T11:10:30.362043Z 1 [Note] NDB Binlog: Created schema Ndb object, reference: 0x0, name: 'Ndb Binlog schema change monitoring'
2017-03-09T11:10:30.362107Z 1 [Note] NDB Binlog: Created injector Ndb object, reference: 0x0, name: 'Ndb Binlog data change monitoring'
2017-03-09T11:10:30.362116Z 1 [Note] NDB Binlog: Setup completed
2017-03-09T11:10:30.362124Z 1 [Note] NDB Binlog: Wait for server start completed
2017-03-09T11:10:30.362346Z 0 [Note] NDB Index Stat: Starting...
2017-03-09T11:10:30.362392Z 0 [Note] NDB Index Stat: Wait for server start completed
2017-03-09T11:10:30.362517Z 0 [Note] NDB Util: Starting...
2017-03-09T11:10:30.362699Z 2 [Note] NDB Util: Wait for server start completed
2017-03-09T11:10:30.420524Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2017-03-09T11:10:30.420637Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2017-03-09T11:10:30.420648Z 0 [Note] IPv6 is available.
2017-03-09T11:10:30.420653Z 0 [Note] - '::' resolves to '::';
2017-03-09T11:10:30.420658Z 0 [Note] Server socket created on IP: '::'.
2017-03-09T11:10:30.425248Z 0 [Note] Event Scheduler: Loaded 0 events
2017-03-09T11:10:30.425335Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
Version: '5.7.16-ndb-7.5.4-cluster-gpl' socket: '/tmp/mysql.sock' port: 3306 MySQL Cluster Community Server (GPL)
2017-03-09T11:10:30.425382Z 1 [Note] NDB Binlog: Check for incidents
2017-03-09T11:10:30.425383Z 0 [Note] NDB Index Stat: Wait for cluster to start
2017-03-09T11:10:30.425386Z 2 [Note] NDB Util: Wait for cluster to start
2017-03-09T11:10:30.425390Z 1 [Note] NDB Binlog: Wait for cluster to start
2017-03-09T11:11:00.435836Z 0 [Warning] NDB : Tables not available after 30 seconds. Consider increasing --ndb-wait-setup value
2017-03-09T11:28:35.749942Z 0 [Note] Giving 2 client threads a chance to die gracefully
2017-03-09T11:28:35.749958Z 0 [Note] Shutting down slave threads
2017-03-09T11:28:35.778243Z 0 [Note] NDB Util: Stopped
2017-03-09T11:28:36.289365Z 1 [Note] NDB Binlog: Server shutdown detected while waiting for ndbcluster to start...
2017-03-09T11:28:36.289416Z 1 [Note] NDB Binlog: Shutting down
2017-03-09T11:28:36.289471Z 1 [Note] NDB Binlog: Stopping...
2017-03-09T11:28:36.290311Z 0 [Note] NDB Binlog: Stopped
2017-03-09T11:28:37.750155Z 0 [Note] Forcefully disconnecting 0 remaining clients
2017-03-09T11:28:37.750213Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2017-03-09T11:28:37.750365Z 0 [Note] Binlog end
2017-03-09T11:28:37.750397Z 0 [Note] NDB Binlog: Stop
2017-03-09T11:28:37.750407Z 0 [Note] NDB Binlog: Wakeup
2017-03-09T11:28:37.750414Z 0 [Note] NDB Binlog: Stop completed
2017-03-09T11:28:37.750656Z 0 [Note] Shutting down plugin 'ngram'
2017-03-09T11:28:37.750668Z 0 [Note] Shutting down plugin 'ARCHIVE'
2017-03-09T11:28:37.750676Z 0 [Note] Shutting down plugin 'ndb_transid_mysql_connection_map'
2017-03-09T11:28:37.750683Z 0 [Note] Shutting down plugin 'ndbinfo'
2017-03-09T11:28:37.751545Z 0 [Note] Shutting down plugin 'ndbcluster'
2017-03-09T11:28:37.751563Z 0 [Note] NDB Index Stat: Stop
2017-03-09T11:28:37.751571Z 0 [Note] NDB Index Stat: Wakeup
2017-03-09T11:28:37.778474Z 0 [Note] NDB Index Stat: Stopping...
2017-03-09T11:28:37.778523Z 0 [Note] NDB Index Stat: Stopped
2017-03-09T11:28:37.778591Z 0 [Note] NDB Index Stat: Stop completed
2017-03-09T11:28:37.778626Z 0 [Note] NDB Util: Stop
2017-03-09T11:28:37.778635Z 0 [Note] NDB Util: Wakeup
2017-03-09T11:28:37.778643Z 0 [Note] NDB Util: Stop completed
2017-03-09T11:28:41.668886Z 0 [Note] Shutting down plugin 'partition'
2017-03-09T11:28:41.668933Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2017-03-09T11:28:41.668944Z 0 [Note] Shutting down plugin 'CSV'
2017-03-09T11:28:41.668953Z 0 [Note] Shutting down plugin 'MEMORY'
2017-03-09T11:28:41.668962Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2017-03-09T11:28:41.668972Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2017-03-09T11:28:41.668984Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2017-03-09T11:28:41.668997Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2017-03-09T11:28:41.669008Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2017-03-09T11:28:41.669019Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2017-03-09T11:28:41.669040Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2017-03-09T11:28:41.669047Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2017-03-09T11:28:41.669054Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2017-03-09T11:28:41.669061Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2017-03-09T11:28:41.669068Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2017-03-09T11:28:41.669075Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2017-03-09T11:28:41.669081Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2017-03-09T11:28:41.669088Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2017-03-09T11:28:41.669097Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2017-03-09T11:28:41.669109Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2017-03-09T11:28:41.669116Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2017-03-09T11:28:41.669122Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2017-03-09T11:28:41.669145Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2017-03-09T11:28:41.669152Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2017-03-09T11:28:41.669158Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2017-03-09T11:28:41.669164Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2017-03-09T11:28:41.669171Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2017-03-09T11:28:41.669177Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2017-03-09T11:28:41.669183Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2017-03-09T11:28:41.669189Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2017-03-09T11:28:41.669195Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2017-03-09T11:28:41.669200Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2017-03-09T11:28:41.669207Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2017-03-09T11:28:41.669213Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2017-03-09T11:28:41.669219Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2017-03-09T11:28:41.669225Z 0 [Note] Shutting down plugin 'InnoDB'
2017-03-09T11:28:41.669391Z 0 [Note] InnoDB: FTS optimize thread exiting.
2017-03-09T11:28:41.669566Z 0 [Note] InnoDB: Starting shutdown...
2017-03-09T11:28:41.769816Z 0 [Note] InnoDB: Dumping buffer pool(s) to /usr/local/mysql/data/ib_buffer_pool
2017-03-09T11:28:41.770153Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170309 16:58:41
2017-03-09T11:28:43.083813Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2536578
2017-03-09T11:28:43.085266Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2017-03-09T11:28:43.085275Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-03-09T11:28:43.085292Z 0 [Note] Shutting down plugin 'MyISAM'
2017-03-09T11:28:43.085299Z 0 [Note] Shutting down plugin 'sha256_password'
2017-03-09T11:28:43.085301Z 0 [Note] Shutting down plugin 'mysql_native_password'
2017-03-09T11:28:43.085505Z 0 [Note] Shutting down plugin 'binlog'
2017-03-09T11:28:43.085769Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
2017-03-09T11:28:43.124535Z mysqld_safe mysqld from pid file /usr/local/mysql/data/dbc7.enhancier.net.local.lan.pid ended
注意:我已经停止了 MySQL 服务。优雅的关机。
经过数小时的研究和至少 8 次重建集群后,我完全迷失了方向。我尝试了许多在网上找到的故障排除步骤。他们之中有一些是:
确保任何机器上都没有 SELinux - 所有机器都是新的,Ubuntu 无论如何都默认不附带 SELinux
未安装 AppArmor
环回地址未配置为主机名
重新安装操作系统并多次重新启动并尝试不同的配置,如 1 个管理节点 - 1 个 SQL 节点 - 2 个数据节点、1 个管理兼数据记录 - 2 个数据节点等。
尝试了 IP 地址而不是主机名 - 尝试了公共 IP 和私有 IP
确保每台服务器都能够在专用网络上 ping 另一台服务器
没有安装防火墙、IPTables 或 UFW
任何指针将不胜感激。如果我的问题听起来太愚蠢,我很抱歉。我是这方面的菜鸟。
我将完全删除 my.cnf 文件中的 [mysql_cluster] 部分,因为它是多余的并且只会导致混淆(您已经有两个不同的 ndb-connectstring 设置)。所以我会从这个配置块开始:
对此:
这应该通过指定管理服务器列出的相同 IP 地址、明确指定端口并将字符串括在引号中来消除许多潜在原因。
如果事情仍然不起作用,那么至少我们已经消除了一些基本的东西。接下来要仔细检查的是确保 mysqld 进程可以通过网络与数据节点通信,给定指定的 IP 地址和端口组合。
但是现在我再次查看 ndb_mgm SHOW 输出,甚至您自己也注意到了,数据节点没有运行!当 mysqld (SQL API) 节点启动时,它会联系管理服务器 (ndb_mgmd) 以发现数据节点(ndbd/ndbmtd 进程)。然后它尝试联系数据节点以检索数据字典(为表拉入 .frm blob)以及其他对象和集群元数据。这就是 30 秒后超时的原因:
当然,它无法提取表元数据,因为数据节点没有响应,因为它们没有运行。:) 管理节点仅作为此序列中的发现机制,它们不保存任何数据。
FWIW,文档在这个主题上不是很好,所以我不怪你在这里感到困惑。
PS 如果您只是想获得一个正在运行和工作的系统,我还建议您尝试Auto Installer。