我正在尝试使用docker compose在本地Windows计算机上运行mariadb:10.2.14
作为galera群集。运行初始boot
节点工作正常,但第二个节点无法加入群集并出现错误:
node_1 | 2018-05-04 3:13:46 140187778701184 [Note] WSREP:view((empty))
node_1 | 2018-05-04 3:13:46 140187778701184 [错误] WSREP:无法打开gcomm后端连接:110:无法访问主视图:110(连接超时)在gcomm / src / pc.cpp:connect(): 158
node_1 | 2018-05-04 3:13:46 140187778701184 [错误] WSREP:gcs / src / gcs_core.cpp:gcs_core_open():208:无法打开后端连接:-110(连接超时)
node_1 | 2018-05-04 3:13:46 140187778701184 [错误] WSREP:gcs / src / gcs.cpp:gcs_open():1458:无法在'gcomm:// boot'打开通道'galera': - 110(连接超时)
node_1 | 2018-05-04 3:13:46 140187778701184 [错误] WSREP:gcs连接失败:连接超时
node_1 | 2018-05-04 3:13:46 140187778701184 [错误] WSREP:wsrep :: connect(gcomm:// boot)失败:7
node_1 | 2018-05-04 3:13:46 140187778701184 [错误]中止
我在容器中运行ping boot
以验证主机名是否已正确解析,但不确定无法连接的原因。我尝试将配置基于我在mariadb:10.1
看到的各种docker文件,例如https://gist.github.com/lucidfrontier45/497341c4b848dfbd6dfb
我的码头撰写文件:
# Docker compose file for running a local MySQL server
version: '2.2'
services:
boot:
image: mariadb:10.2.14
command: mysqld --user=mysql --wsrep_new_cluster
environment:
MYSQL_DATABASE: "db"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# Needed because galera doesn't support MyISAM, which tzinfo uses
MYSQL_INITDB_SKIP_TZINFO: "yes"
ports:
- ${SQL_PORT}:3306
- 4444:4444
- 4567:4567
- 4568:4568
networks:
- sql
volumes:
- ./kubernetes/mariadb.conf.d:/etc/mysql/mariadb.conf.d
- /var/lib/mysql
node:
image: mariadb:10.2.14
command: mysqld --user=mysql --wsrep_cluster_address=gcomm://boot
environment:
MYSQL_DATABASE: "db"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# Needed because galera doesn't support MyISAM, which tzinfo uses
MYSQL_INITDB_SKIP_TZINFO: "yes"
networks:
- sql
volumes:
- ./kubernetes/mariadb.conf.d:/etc/mysql/mariadb.conf.d
- /var/lib/mysql
networks:
sql:
maraidb.conf.d
中的配置文件:
# This will be passed to all mysql clients
[client]
default-character-set=utf8mb4
[mysql]
default-character-set=utf8mb4
# The MySQL server
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
default_storage_engine=innodb
binlog_format=row
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=0
# Allow server to accept connections on all interfaces.
bind-address=0.0.0.0
#
# * Galera-related settings
#
# https://mariadb.com/kb/en/mariadb/galera-cluster-system-variables/
#
[galera]
wsrep_on=ON
wsrep_log_conflicts=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# TODO: is rsync the best option?
wsrep_sst_method=rsync
wsrep_cluster_name=galera
#wsrep_slave_threads=1
答案 0 :(得分:1)
wsrep_cluster_address
参数。
这就是您需要执行以下操作的原因:
1。将wsrep_cluster_address
添加到maraidb.conf.d
中的配置文件中,所有节点都会获得它:
wsrep_cluster_address="gcomm://boot,node"
2。当我们在--wsrep_cluster_address
容器中启动mysqld
时,从mysql
命令中删除node
标记,因为我们已在配置:
version: '2.2'
services:
boot:
image: mariadb:10.2.14
command: mysqld --user=mysql --wsrep_new_cluster
environment:
MYSQL_DATABASE: "db"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# Needed because galera doesn't support MyISAM, which tzinfo uses
MYSQL_INITDB_SKIP_TZINFO: "yes"
ports:
- ${SQL_PORT}:3306
- 4444:4444
- 4567:4567
- 4568:4568
networks:
- sql
volumes:
- ./kubernetes/mariadb.conf.d:/etc/mysql/mariadb.conf.d
- /var/lib/mysql
node:
image: mariadb:10.2.14
command: mysqld --user=mysql
environment:
MYSQL_DATABASE: "db"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# Needed because galera doesn't support MyISAM, which tzinfo uses
MYSQL_INITDB_SKIP_TZINFO: "yes"
networks:
- sql
volumes:
- ./kubernetes/mariadb.conf.d:/etc/mysql/mariadb.conf.d
- /var/lib/mysql
networks:
sql:
答案 1 :(得分:0)
谢谢@Nickolay,你的回答大多有效,但我遇到了另一个问题。它确实让我找到了解决问题的正确方法。
所以似乎主要的问题是--wsrep_new_cluster
本身不足以引导节点,你需要设置wsrep_cluster_address
变量。使用--wsrep_cluster_address=gcomm://
设置它对我来说很有用。
此外,我遇到了似乎存在竞争条件的问题,并且第一个引导节点将无法初始化,并且错误表明它不是最后一个节点。我通过在第二个节点命令中使用短暂睡眠来修复此问题。
我的最终定位器撰写文件:
# Docker compose file for running a local mariadb galera cluster
version: '3.6'
services:
boot:
image: mariadb:10.2.14
command: mysqld --user=mysql --wsrep_cluster_address=gcomm://
environment:
MYSQL_DATABASE: "db"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# Needed because galera doesn't support MyISAM, which tzinfo uses
MYSQL_INITDB_SKIP_TZINFO: "yes"
ports:
- ${SQL_PORT}:3306
- 4444:4444
- 4567:4567
- 4568:4568
volumes:
- ./kubernetes/mariadb.conf.d:/etc/mysql/mariadb.conf.d
- /var/lib/mysql
node:
image: mariadb:10.2.14
command: bash -c "sleep 10; mysqld --user=mysql --wsrep_cluster_address=gcomm://boot"
environment:
MYSQL_DATABASE: "db"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
# Needed because galera doesn't support MyISAM, which tzinfo uses
MYSQL_INITDB_SKIP_TZINFO: "yes"
volumes:
- ./kubernetes/mariadb.conf.d:/etc/mysql/mariadb.conf.d
- /var/lib/mysql