2016-03-28 46 views
0

我的目標是獲得在Docker容器中運行的Percona XtraDB安裝。 爲此,我寫下了以下配置。在Docker中引導Percona Xtradb集羣出現以下錯誤:無法打開並鎖定特權表:表'mysql.user'不存在

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

#!/bin/bash -e 
j2 /templates/my.cnf.j2 > /etc/mysql/my.cnf 
exec bash 

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會議://通常保持3節點的列表廣域網IP,我刪除他們由於隱私。

建設中的形象工程完全罰款:

docker build --rm -t test . 

啓動工作也罰款:

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 

變量node_ip點在我的服務器的廣域網IP,我將其設置爲127.0 .0.1僅出於隱私的原因。

但是當我嘗試引導的MySQL在容器:

/etc/init.d/mysql bootstrap-pxc 

我得到這個錯誤:

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 

我怎樣才能解決這個問題得到XtraDB在我的容器中運行?

+0

afaict你沒有運行mysql_install_db有什麼理由嗎? (這將需要運行,然後chown mysql.mysql -R/var/lib/mysql) – Oneiroi

回答

0

這可能是一個權限問題。試試你的FROM statment後加入以下:

RUN useradd mysql \ 
    && mkdir /var/lib/mysql \ 
    && chown -R mysql:mysql /var/lib/mysql 
+0

它可悲沒有幫助,我仍然有同樣的問題。 –

1

mysql_install_db chown mysql.mysql -R /var/lib/mysql service mysql start

上面似乎沒有問題的工作,請測試它。

相關問題