[英]Bootstraping Percona Xtradb Cluster in Docker gives the error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
My goal is to get a Percona XtraDB Installation running in a Docker Container. 我的目标是要在Docker容器中运行Percona XtraDB安装。 For this i wrote up the following configuration. 为此,我写下了以下配置。
Dockerfile: Dockerfile:
FROM ubuntu:wily
ENV DEBIAN_FRONTEND noninteractive
#
# ENVIRONMENT INSTALL
#
RUN apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get install -y wget curl netcat python-dev python-setuptools python-software-properties vim
RUN easy_install j2cli
COPY my.cnf.j2 /templates/
COPY docker-entrypoint.sh /
RUN chmod +x docker-entrypoint.sh /
#
# PERCONA XTRADB CLUSTER INSTALL
#
RUN echo "deb http://repo.percona.com/apt wily main" >> /etc/apt/sources.list.d/percona.list
RUN echo "deb-src http://repo.percona.com/apt wily main" >> /etc/apt/sources.list.d/percona.list
RUN apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
RUN apt-get update && apt-get install -y percona-xtradb-cluster-56
ENTRYPOINT ["/docker-entrypoint.sh"]
docker-entrypoint.sh docker-entrypoint.sh
#!/bin/bash -e
j2 /templates/my.cnf.j2 > /etc/mysql/my.cnf
exec bash
my.cnf.j2 my.cnf.j2
[mysqld]
user=mysql
default_storage_engine=InnoDB
basedir=/usr
datadir=/var/lib/mysql
socket=/var/run/mysqld/mysqld.sock
innodb_autoinc_lock_mode=2
log_queries_not_using_indexes=1
max_allowed_packet=128M
binlog_format=ROW
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_node_address={{node_ip}}
wsrep_cluster_name="mycluster"
wsrep_cluster_address=gcomm://
wsrep_node_name={{node_name}}
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth="test:test"
!includedir /etc/mysql/conf.d/
wsrep_cluster_address=gcomm:// normally holds a list of 3 node WAN-IPs, i removed them due to privacy. wsrep_cluster_address = gcomm://通常包含3个节点WAN-IP的列表,出于隐私原因,我将其删除。
Building the image works perfectly fine with: 使用以下方法可以很好地构建图像:
docker build --rm -t test .
Starting works also fine with: 起始作品还可以与:
docker run --name Test1 -e "node_ip=127.0.0.1" -e "node_name=Test1" -p 3306:3306 -p 4567:4567 -p 4444:4444 -p 4568:4568 -i -t test
The variable node_ip points at the WAN-IP of my server, i set it to 127.0.0.1 just for privacy reasons. 变量node_ip指向服务器的WAN-IP,出于隐私原因,我将其设置为127.0.0.1。
But when i try to bootstrap mysql in the container with: 但是当我尝试使用以下命令在容器中引导mysql时:
/etc/init.d/mysql bootstrap-pxc
I get this error: 我收到此错误:
2016-03-28 09:24:09 354 [Note] Server hostname (bind-address): '*'; port: 3306
2016-03-28 09:24:09 354 [Note] IPv6 is available.
2016-03-28 09:24:09 354 [Note] - '::' resolves to '::';
2016-03-28 09:24:09 354 [Note] Server socket created on IP: '::'.
2016-03-28 09:24:09 354 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
160328 09:24:09 mysqld_safe mysqld from pid file /var/lib/mysql/8605688929d8.pid ended
How can i solve this to get the XtraDB running in my Container? 如何解决此问题以使XtraDB在我的容器中运行?
mysql_install_db chown mysql.mysql -R /var/lib/mysql service mysql start
上面的方法似乎没有问题,请对其进行测试。
It could be a permissions problem. 可能是权限问题。 Try adding the following after your FROM
statment: 尝试在FROM
语句之后添加以下内容:
RUN useradd mysql \
&& mkdir /var/lib/mysql \
&& chown -R mysql:mysql /var/lib/mysql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.