我的MySQL群集测试设置遇到了麻烦:
我有两台运行Ubuntu和Docker的机器(使用多主机网络),每个节点(ndb_mgm
,ndbd
和mysqld
)都通过Docker运行。设置如下:
计算机1 :
机器2 :
当我在一台机器上启动mysqld
时,它连接到管理器并想要启动集群,但它无法创建表,整个NDB在mysqld
实例上登录后新的开始:
2016-08-02 09:08:57 135 [Note] NDB: Changed global value of binlog_format from STATEMENT to MIXED
2016-08-02 09:08:58 135 [Note] NDB: NodeID is 4, management server 'ndb_mgmd:1186'
2016-08-02 09:08:58 135 [Note] NDB[0]: NodeID: 4, all storage nodes connected
2016-08-02 09:08:58 135 [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
2016-08-02 09:08:58 135 [Note] NDB Binlog: Starting...
2016-08-02 09:08:58 135 [Note] NDB Binlog: Started
2016-08-02 09:08:58 135 [Note] NDB Binlog: Setting up
2016-08-02 09:08:58 135 [Note] NDB Binlog: Created schema Ndb object, reference: 0x80040004, name: 'Ndb Binlog schema change monitoring'
2016-08-02 09:08:58 135 [Note] NDB Binlog: Created injector Ndb object, reference: 0x80050004, name: 'Ndb Binlog data change monitoring'
2016-08-02 09:08:58 135 [Note] NDB Binlog: Setup completed
2016-08-02 09:08:58 135 [Note] NDB Binlog: Wait for server start completed
2016-08-02 09:08:58 135 [Note] NDB Util: Starting...
2016-08-02 09:08:58 135 [Note] NDB Util: Wait for server start completed
2016-08-02 09:08:58 135 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: bf07c00a-5890-11e6-83a3-02420a000a1e.
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Starting...
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Wait for server start completed
2016-08-02 09:08:58 135 [Note] Server hostname (bind-address): '*'; port: 3306
2016-08-02 09:08:58 135 [Note] IPv6 is available.
2016-08-02 09:08:58 135 [Note] - '::' resolves to '::';
2016-08-02 09:08:58 135 [Note] Server socket created on IP: '::'.
2016-08-02 09:08:58 135 [Note] Event Scheduler: Loaded 0 events
2016-08-02 09:08:58 135 [Note] /usr/local/mysql-cluster-gpl-7.4.12-linux-glibc2.5-x86_64/bin/mysqld: ready for connections.
Version: '5.6.31-ndb-7.4.12-cluster-gpl' socket: '/tmp/mysql.sock' port: 3306 MySQL Cluster Community Server (GPL)
2016-08-02 09:08:58 135 [Note] NDB Util: Wait for cluster to start
2016-08-02 09:08:58 135 [Note] NDB Util: Started
2016-08-02 09:08:58 135 [Note] NDB Binlog: Check for incidents
2016-08-02 09:08:58 135 [Note] NDB Binlog: Wait for cluster to start
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Wait for cluster to start
2016-08-02 09:08:58 135 [Note] NDB Index Stat: Started
2016-08-02 09:08:58 135 [Note] created index stats Ndb object: reference 0x80070004, name: 'Ndb Index Statistics monitoring'
2016-08-02 09:08:58 135 [Note] NDB: Creating mysql.ndb_schema
2016-08-02 09:08:58 135 [ERROR] NDB: Query 'CREATE TABLE IF NOT EXISTS mysql.ndb_schema ( db VARBINARY(63) NOT NULL,name VARBINARY(63) NOT NULL,slock BINARY(32) NOT NULL,query BLOB NOT NULL,node_id INT UNSIGNED NOT NULL,epoch BIGINT UNSIGNED NOT NULL,id INT UNSIGNED NOT NULL,version INT UNSIGNED NOT NULL,type INT UNSIGNED NOT NULL,PRIMARY KEY USING HASH (db,name) ) ENGINE=NDB CHARACTER SET latin1' failed, error: 1005: Can't create table 'ndb_schema' (errno: 13)
最后一行显示,它无法创建表格:
NDB:查询'创建表...'失败,错误:1005:无法创建表' ndb_schema' (错误:13)
如果我签出ndb_mgm
配置,则每个节点似乎都正确连接:
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)] 2 node(s)
id=2 @10.0.10.20 (mysql-5.6.31 ndb-7.4.12, Nodegroup: 0, *)
id=3 @10.0.10.21 (mysql-5.6.31 ndb-7.4.12, Nodegroup: 0)
[ndb_mgmd(MGM)] 1 node(s)
id=1 @10.0.10.10 (mysql-5.6.31 ndb-7.4.12)
[mysqld(API)] 2 node(s)
id=4 @10.0.10.30 (mysql-5.6.31 ndb-7.4.12)
id=5 @10.0.10.31 (mysql-5.6.31 ndb-7.4.12)
ndb_mgmd
的配置:
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
hostname=10.0.10.10
datadir=/var/lib/mysql-cluster
[ndbd]
hostname=10.0.10.20
datadir=/usr/local/mysql/data
[ndbd]
hostname=10.0.10.21
datadir=/usr/local/mysql/data
[mysqld]
hostname=10.0.10.30
[mysqld]
hostname=10.0.10.31
每个mysqld
配置如下:
[mysqld]
ndbcluster
log-error=/var/log/mysql/error.log
在mysqld
实例上运行群集状态不会显示错误:
mysql> SHOW ENGINE NDB STATUS
-> ;
+------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| Type | Name | Status |
+------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
| ndbcluster | connection | cluster_node_id=4, connected_host=ndb_mgmd, connected_port=1186, number_of_data_nodes=2, number_of_ready_data_nodes=2, connect_count=0 |
| ndbcluster | NdbTransaction | created=2, free=2, sizeof=368 |
| ndbcluster | NdbOperation | created=4, free=4, sizeof=944 |
| ndbcluster | NdbIndexScanOperation | created=0, free=0, sizeof=1152 |
| ndbcluster | NdbIndexOperation | created=0, free=0, sizeof=952 |
| ndbcluster | NdbRecAttr | created=0, free=0, sizeof=88 |
| ndbcluster | NdbApiSignal | created=16, free=16, sizeof=144 |
| ndbcluster | NdbLabel | created=0, free=0, sizeof=200 |
| ndbcluster | NdbBranch | created=0, free=0, sizeof=32 |
| ndbcluster | NdbSubroutine | created=0, free=0, sizeof=72 |
| ndbcluster | NdbCall | created=0, free=0, sizeof=24 |
| ndbcluster | NdbBlob | created=0, free=0, sizeof=496 |
| ndbcluster | NdbReceiver | created=0, free=0, sizeof=128 |
| ndbcluster | NdbLockHandle | created=0, free=0, sizeof=48 |
| ndbcluster | binlog | latest_epoch=0, latest_trans_epoch=200377404227594, latest_received_binlog_epoch=0, latest_handled_binlog_epoch=0, latest_applied_binlog_epoch=0 |
+------------+-----------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
15 rows in set (0.00 sec)
如果我想在群集上手动创建表,我会收到以下错误:
mysql> CREATE DATABASE cluster;
Query OK, 1 row affected (0.00 sec)
mysql> CREATE TABLE cluster_test (name VARCHAR(20), value VARCHAR(20)) ENGINE=ndbcluster;
ERROR 1296 (HY000): Got error 4009 'Cluster Failure' from NDBCLUSTER
mysql> show warnings;
+-------+------+--------------------------------------------------+
| Level | Code | Message |
+-------+------+--------------------------------------------------+
| Error | 1296 | Got error 4009 'Cluster Failure' from NDBCLUSTER |
+-------+------+--------------------------------------------------+
1 row in set (0.00 sec)
我不知道从哪里获得详细的错误说明。如果我正确的Errno 13通常是某种权限错误,但每个节点都拥有对文件夹的正确权限(他们实际上写了一些文件)。如果您需要详细的文件夹权限列表,请告诉我。
谢谢你的建议!
答案 0 :(得分:0)
目前问题尚未解决,但经过一些研究后,问题似乎是Docker中的AUFS存储。 I described here the issue.
我在图像中使用较少的图层。我在一个RUN指令中组合了很多命令。
以下是适用于我的Dockerfiles:
mysql守护程序:
FROM ubuntu
RUN apt-get update && \
apt-get install -y libcam-pdf-perl build-essential libaio1 libaio-dev && \
cpan File::Copy \
Sys::Hostname \
Data::Dumper
// .. install mysql cluster files to /usr/local/mysql
WORKDIR /usr/local/mysql
RUN groupadd mysql && \
useradd -g mysql -s /bin/false mysql && \
chown -R root . && \
chown -R mysql data && \
chgrp -R mysql . && \
scripts/mysql_install_db --user=mysql
ENV PATH=/usr/local/mysql/bin:$PATH
USER mysql
<强> NDBD 强>:
FROM ubuntu
// .. install mysql cluster files to /usr/local/bin
RUN chmod +x /usr/local/bin/ndb* && \
mkdir -p /usr/local/mysql/data
<强> ndb_mgm 强>:
FROM ubuntu
// .. install mysql cluster files to /usr/local/bin
RUN chmod +x /usr/local/bin/ndb_mgm* && \
mkdir -p /var/lib/mysql-cluster
也许这有助于某人!