Mysql

MySQL 節點未連接到 NDB 集群中的管理節點

  • March 10, 2017

我正在嘗試部署具有 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 次重建集群後,我完全迷失了方向。我嘗試了許多在網上找到的故障排除步驟。他們之中有一些是:

  1. 確保任何機器上都沒有 SELinux - 所有機器都是新的,Ubuntu 無論如何都預設不附帶 SELinux
  2. 未安裝 AppArmor
  3. 環回地址未配置為主機名
  4. 重新安裝作業系統並多次重新啟動並嘗試不同的配置,如 1 個管理節點 - 1 個 SQL 節點 - 2 個數據節點、1 個管理兼數據記錄 - 2 個數據節點等。
  5. 嘗試了 IP 地址而不是主機名 - 嘗試了公共 IP 和私有 IP
  6. 確保每台伺服器都能夠在專用網路上 ping 另一台伺服器
  7. 沒有安裝防火牆、IPTables 或 UFW

任何指針將不勝感激。如果我的問題聽起來太愚蠢,我很抱歉。我是這方面的菜鳥。

我會刪除

$$ mysql_cluster $$my.cnf 文件中的部分,因為它是多餘的並且只會導致混淆(您已經有兩個不同的 ndb-connectstring 設置)。所以我會從這個配置塊開始:

ndb-connectstring=dbc1.enhancier.net,dbc2.enhancier.net

[mysql_cluster]

ndb-connectstring=dbc1.enhancier.net,dbc.enhancier.net

對此:

ndb-connectstring="10.80.45.5:1186,10.80.45.7:1186"

這應該通過指定管理伺服器列出的相同 IP 地址、明確指定埠並將字元串括在引號中來消除許多潛在原因。

如果事情仍然不起作用,那麼至少我們已經消除了一些基本的東西。接下來要仔細檢查的是確保 mysqld 程序可以通過網路與數據節點通信,給定指定的 IP 地址和埠組合。

但是現在我再次查看 ndb_mgm SHOW 輸出,甚至您自己也注意到了,數據節點沒有執行!當 mysqld (SQL API) 節點啟動時,它會聯繫管理伺服器 (ndb_mgmd) 以發現數據節點(ndbd/ndbmtd 程序)。然後它嘗試聯繫數據節點以檢索數據字典(為表拉入 .frm blob)以及其他對象和集群元數據。這就是 30 秒後超時的原因:

[Warning] NDB : Tables not available after 30 seconds.  Consider increasing --ndb-wait-setup value

當然,它無法提取表元數據,因為數據節點沒有響應*,因為它們沒有執行*。:) 管理節點僅作為此序列中的發現機制,它們不保存任何數據。

FWIW,文件在這個主題上不是很好,所以我不怪你在這裡感到困惑。

PS 如果您只是想獲得一個正在執行的系統,我還建議您嘗試Auto Installer

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