MariaDB Docker启动失败

时间:2017-05-11 20:23:19

标签: docker mariadb

我试图用Docker 1.13.1启动MariaDB。

docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=password -p 3306:3306   -p 4567:4567/udp   -p 4567-4568:4567-4568   -p 4444:4444   -v /mnt/data/mysql:/var/lib/mysql mariadb:10.1 chown -R mysql:mysql /var/lib/mysql && mysqld --user=mysql --wsrep-new-cluster

启动后我得到以下输出:

2017-05-11 20:04:55 139780804880320 [Note] mysqld (mysqld 10.1.23-MariaDB-1~jessie) starting as process 6 ...
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: The InnoDB memory heap is disabled
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Using Linux native AIO
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Using SSE crc32 instructions
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Initializing buffer pool, size = 256.0M
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Completed initialization of buffer pool
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2017-05-11 20:04:55 139780804880320 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2017-05-11 20:04:56 139780804880320 [Warning] InnoDB: New log files created, LSN=45883
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Doublewrite buffer not found: creating new
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Doublewrite buffer created
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: 128 rollback segment(s) are active.
2017-05-11 20:04:56 139780804880320 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Foreign key constraint system tables created
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Creating tablespace and datafile system tables.
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Tablespace and datafile system tables created.
2017-05-11 20:04:56 139780804880320 [Note] InnoDB: Waiting for purge to start
2017-05-11 20:04:56 139780804880320 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 0
2017-05-11 20:04:56 139780029413120 [Note] InnoDB: Dumping buffer pool(s) not yet started
2017-05-11 20:04:56 139780804880320 [Note] Plugin 'FEEDBACK' is disabled.
2017-05-11 20:04:56 139780804880320 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded
2017-05-11 20:04:56 139780804880320 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
2017-05-11 20:04:56 139780804880320 [Note] Server socket created on IP: '::'.
2017-05-11 20:04:56 139780804880320 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist

mysql用户拥有该目录,并能够创建ibdata1及相关文件。我无法弄清楚它是否未能创建其他表格和/或它为何无法阅读这些表格?

2 个答案:

答案 0 :(得分:1)

修正:

docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=password -p 3306:3306   -p 4567:4567/udp   -p 4567-4568:4567-4568   -p 4444:4444   -v /mnt/data/mysql:/var/lib/mysql mariadb:10.1 /bin/bash -c 'chown -R mysql:mysql /var/lib/mysql && mysqld --user=mysql --wsrep-new-cluster'

问题是&&之后的所有内容都没有作为命令行插入容器内部,而是插入到主机外壳中,除非作为/ bin / -c选项的参数正确引用bash(/ bin / sh也有效)。

答案 1 :(得分:0)

我在我的启动脚本中解决了这个问题,该脚本是在docker镜像中作为ENTRYPOINT的一部分运行的:

chmod -R ug+rw /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql
service mysql start

这样,我避免了所有的卷安装,只需在普通容器中使用读写层。这是为开源项目构建一个开发人员容器,所以我正在尝试创建一个一体化的容器供我的开发人员使用。可能有一种更清洁的方法可以解决这个问题 - 但这对我有用。