MySQL集群错误: 1005: Can't create table 'ndb_schema' (errno: 13)

标签 mysql cluster-computing

我的 MySQL 集群测试设置遇到问题:

我有两台运行 Ubuntu 和 Docker 的机器(使用多主机网络)和每个节点(ndb_mgmndbdmysqld)通过 Docker 运行。设置如下:

机器 1:

  • ndb_mgmd
  • ndbd1
  • mysqld1

机器 2:

  • ndbd2
  • mysqld2

当我在一台机器上启动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: Query 'CREATE TABLE ...' failed, error: 1005: Can't create table 'ndb_schema' (errno: 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 通常是某种权限错误,但每个节点都对文件夹具有正确的权限(它们实际上写入了一些文件)。如果您需要详细的文件夹权限列表,请告诉我。

谢谢指教!

最佳答案

目前问题还没有解决,但经过一番研究,问题似乎出在Docker内部的AUFS存储上。 I described here the issue.

我在图像内使用较少的层使其工作。我在一个 RUN 指令中组合了很多命令。

以下是适合我的 Dockerfile:

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

也许这对某人有帮助!

关于MySQL集群错误: 1005: Can't create table 'ndb_schema' (errno: 13),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38717260/

相关文章:

c++ - 编译可在Mac上运行,但不能在群集上运行(Linux)

php - 如何根据编号设置我的行跨度值。查询中的结果并根据其集合 ID 更改值(如果它是组或集合)?

mysql - 根据另一列检索数据库数据

MySQL 帮助,使用 where 子句复制条目

mysql - 集群、分片或简单的分区/复制

node.js 多进程日志记录

javascript - 如何在我的简单 Express 应用中使用 Node.js 集群?

hadoop - 是否有任何工具可以查找hadoop集群通常在一天的什么时间没有负载并每天在该时间提交作业

php - 添加到数据库字段时使用其中之一

javascript - 有没有办法在 : $or clause with sequelize? 中包含数组