问题描述
我已经基于 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进程
挂起造成的.上面的配置和 CLI 参数是正确的.在 init 进程启动之前唯一要做的就是在数据目录中创建并清空 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 Cluster 了解使用自定义 MariaDB 映像并且是概念证明的用法用于创建集群.
See sample MariaDB Cluster for usage which uses a custom MariaDB image and is a proof of concept for creating clusters.
这篇关于无法创建 MariaDB Galera 集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!