问题描述
我已经建立了一个基于mariadb:10.1
的映像,该映像基本上添加了一个新的cluster.conf
,但是在第一个节点开始成功工作之后,第二个节点遇到了以下错误.有人可以帮我在这里调试吗?
I have built an image based on mariadb:10.1
which basically adds a new cluster.conf
but facing the following error on the second node after the first node started working successfully. Can somebody help me debug here?
2016-09-28 10:12:55 139799503415232 [ERROR] WSREP: failed to open gcomm backend connection: 110: failed to reach primary view: 110 (Connection timed out)
at gcomm/src/pc.cpp:connect():162
2016-09-28 10:12:55 139799503415232 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():208: Failed to open backend connection: -110 (Connection timed out)
2016-09-28 10:12:55 139799503415232 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1380: Failed to open channel 'test_cluster' at 'gcomm://172.17.0.2,172.17.0.3,172.17.0.4': -110 (Connection timed out)
2016-09-28 10:12:55 139799503415232 [ERROR] WSREP: gcs connect failed: Connection timed out
2016-09-28 10:12:55 139799503415232 [ERROR] WSREP: wsrep::connect(gcomm://172.17.0.2,172.17.0.3,172.17.0.4) failed: 7
2016-09-28 10:12:55 139799503415232 [ERROR] Aborting
MySQL init process failed.
已采取的调试步骤
注意:确保容器IP地址与显示的相同.
Debugging steps taken
NOTE: Container IP addresses were ensured to be the same as shown.
- 为确保容器之间的网络正常运行,请尝试创建另一个可以登录到第一个容器的mysql实例的容器.
- 这绝对与
MYSQL_HOST
不相关 - 要查看容器是否耗尽了内存,我使用了
docker stats
,发现发生故障的容器在其整个生命周期中仅使用了142MB的微薄内存,直到出现故障为止,这比允许的总内存少得多(〜4GB). - 我正在使用
Docker for Mac
,但是尝试在CentOS VirtualBox上运行相同的命令并给出相同的结果.看起来Mac上的Docker似乎没有问题.
- To ensure networking between containers is working, tried creating another container which could login to the first container's mysql instance.
- This is definitely not related to
MYSQL_HOST
- To see if the container was running out of memory, I used
docker stats
and saw that the failed container was using only a meagre 142MB all through its lifecycle until it failed, which is way lesser than the total memory it was allowed (~4GB). - I am using
Docker for Mac
, but tried running the same on a CentOS VirtualBox and gives the same results. Doesn't look like Docker on Mac has a problem.
配置
[mysqld]
user=mysql
binlog_format=ROW
bind-address=0.0.0.0
default_storage_engine=innodb
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
innodb_buffer_pool_size=122M
innodb_file_per_table=1
innodb_doublewrite=1
query_cache_size=0
query_cache_type=0
wsrep_on=ON
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_sst_method=rsync
启动容器的步骤
# bootstrap node
docker run --rm -e MYSQL_ROOT_PASSWORD=123 \
activatedgeek/mariadb:devel \
--wsrep-cluster-name=test_cluster \
--wsrep-cluster-address=gcomm://172.17.0.2,172.17.0.3,172.17.0.4 \
--wsrep-new-cluster
# add node into cluster
docker run --rm -e MYSQL_ROOT_PASSWORD=123 \
activatedgeek/mariadb:devel \
--wsrep-cluster-name=test_cluster \
--wsrep-cluster-address=gcomm://172.17.0.2,172.17.0.3,172.17.0.4
# add node into cluster
docker run --rm -e MYSQL_ROOT_PASSWORD=123 \
activatedgeek/mariadb:devel \
--wsrep-cluster-name=test_cluster \
--wsrep-cluster-address=gcomm://172.17.0.2,172.17.0.3,172.17.0.4
推荐答案
此问题是由于init process
挂起引起的.上面的配置和CLI参数正确.初始化过程开始之前,唯一要做的就是在数据目录中创建mysql
目录并将其清空(默认为/var/lib/mysql
).必须仅在引导节点以外的所有节点上创建.
This problem is caused due to the hanging init process
. The configurations and CLI arguments above are correct. The only thing to be done before the init process starts is to create and empty mysql
directory in the data directory (/var/lib/mysql
by default). The must only be created on all nodes except the bootstrap node.
mkdir -p /var/lib/mysql/mysql
请参阅示例 MariaDB群集,该示例使用自定义MariaDB图像并作为概念证明.用于创建集群.
See sample MariaDB Cluster for usage which uses a custom MariaDB image and is a proof of concept for creating clusters.
这篇关于无法创建MariaDB Galera群集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!