Проблемы создания кластера galera в docker контейнерах - PullRequest
0 голосов
/ 06 мая 2020

Я пытаюсь создать 3 контейнера базы данных mariadb, подключенные к кластеру galera. Но я получаю ошибки при создании контейнеров. Я вольно следую этому руководству, но, учитывая, что все контейнеры находятся на одном хосте, я должен многое изменить. Это мой файл my.cnf

[mysqld]
bind-address = 0.0.0.0
default_storage_engine = innodb
binlog_format = row

wsrep_on = ON
wsrep_provider = /usr/lib/galera/libgalera_smm.so
wsrep_sst_method = rsync

Я использую следующие строки для создания контейнера bootrap

docker run -it \
        --name db0 \
        --hostname db0 \
        --env MYSQL_ROOT_PASSWORD="rootpass" \
        --mount type=bind,source=/home/ubuntu/containers/mariadb1/datadir,target=/var/lib/mysql \
        --mount type=bind,source=/home/ubuntu/containers/mariadb1/conf.d,target=/etc/mysql/mariadb.conf.d \
        mariadb:10.4 \
        --wsrep_cluster_address=gcomm:// \
        --wsrep_sst_auth="root:rootpass" \
        --wsrep_node_address=db0

Это работает, и когда я проверяю размер кластера, он показывает 1, а grastate .dat файл для db0 выглядит так:

# GALERA saved state
version: 2.1
uuid:    cc7b69bf-8f7a-11ea-b2a9-5bd15e8470ee
seqno:   -1
safe_to_bootstrap: 1

Проблемы возникают при попытке создать другие контейнеры, когда я пытаюсь создать db2 со строками

        --name db2 \
        --hostname db2 \
        --add-host db0:172.17.0.6 \
        --env MYSQL_ROOT_PASSWORD="rootpass" \
        --mount type=bind,source=/home/ubuntu/containers/mariadb2/datadir,target=/var/lib/mysql \
        --mount type=bind,source=/home/ubuntu/containers/mariadb2/conf.d,target=/etc/mysql/mariadb.conf.d \
        mariadb:10.4 \
        --wsrep_cluster_address=gcomm://db0,db1,db2,db3 \
        --wsrep_sst_auth="root:rootpass" \
        --wsrep_node_address=db2

Я получаю это message

2020-05-06 13:45:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
2020-05-06 13:45:21+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-05-06 13:45:21+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
2020-05-06 13:45:22 0 [Note] mysqld (mysqld 10.4.12-MariaDB-1:10.4.12+maria~bionic) starting as process 1 ...
2020-05-06 13:45:22 0 [Note] WSREP: Loading provider /usr/lib/galera/libgalera_smm.so initial position: 00000000-0000-0000-0000-000000000000:-1
wsrep loader: [INFO] wsrep_load(): loading provider library '/usr/lib/galera/libgalera_smm.so'
wsrep loader: [INFO] wsrep_load(): Galera 26.4.3(r4535) by Codership Oy <info@codership.com> loaded successfully.
2020-05-06 13:45:22 0 [Note] WSREP: CRC-32C: using hardware acceleration.
2020-05-06 13:45:22 0 [Note] WSREP: Found saved state: 00000000-0000-0000-0000-000000000000:-1, safe_to_bootstrap: 1
2020-05-06 13:45:22 0 [Note] WSREP: GCache DEBUG: opened preamble:
Version: 2
UUID: 00000000-0000-0000-0000-000000000000
Seqno: -1 - -1
Offset: -1
Synced: 1
2020-05-06 13:45:22 0 [Note] WSREP: Skipped GCache ring buffer recovery: could not determine history UUID.
2020-05-06 13:45:22 0 [Note] WSREP: Passing config to GCS: base_dir = /var/lib/mysql/; base_host = db3; base_port = 4567; cert.log_conflicts = no; cert.optimistic_pa = yes; debug = no; evs.auto_evict = 0; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.join_retrans_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.user_send_window = 2; evs.view_forget_timeout = PT24H; gcache.dir = /var/lib/mysql/; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = galera.cache; gcache.page_size = 128M; gcache.recover = yes; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.segment = 0; gmcast.version = 0; pc.announce_timeout = PT3S; pc.checksum = false; pc
2020-05-06 13:45:22 0 [Note] WSREP: Start replication
2020-05-06 13:45:22 0 [Note] WSREP: Connecting with bootstrap option: 0
2020-05-06 13:45:22 0 [Note] WSREP: Setting GCS initial position to 00000000-0000-0000-0000-000000000000:-1
2020-05-06 13:45:22 0 [Note] WSREP: protonet asio version 0
2020-05-06 13:45:22 0 [Note] WSREP: Using CRC-32C for message checksums.
2020-05-06 13:45:22 0 [Note] WSREP: backend: asio
2020-05-06 13:45:22 0 [Note] WSREP: gcomm thread scheduling priority set to other:0 
2020-05-06 13:45:22 0 [Warning] WSREP: access file(/var/lib/mysql//gvwstate.dat) failed(No such file or directory)
2020-05-06 13:45:22 0 [Note] WSREP: restore pc from disk failed
2020-05-06 13:45:22 0 [Note] WSREP: GMCast version 0
2020-05-06 13:45:22 0 [Warning] WSREP: Failed to resolve tcp://db1:4567
2020-05-06 13:45:22 0 [Warning] WSREP: Failed to resolve tcp://db2:4567
2020-05-06 13:45:22 0 [Note] WSREP: (d4eba789, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
2020-05-06 13:45:22 0 [Note] WSREP: (d4eba789, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
2020-05-06 13:45:22 0 [Note] WSREP: EVS version 1
2020-05-06 13:45:22 0 [Note] WSREP: gcomm: connecting to group 'my_wsrep_cluster', peer 'db0:,db1:,db2:,db3:'
2020-05-06 13:45:22 0 [Note] WSREP: (d4eba789, 'tcp://0.0.0.0:4567') Found matching local endpoint for a connection, blacklisting address tcp://172.17.0.8:4567
2020-05-06 13:45:25 0 [Note] WSREP: EVS version upgrade 0 -> 1
2020-05-06 13:45:25 0 [Note] WSREP: PC protocol upgrade 0 -> 1
2020-05-06 13:45:25 0 [Warning] WSREP: no nodes coming from prim view, prim not possible
2020-05-06 13:45:25 0 [Note] WSREP: view(view_id(NON_PRIM,d4eba789,1) memb {
    d4eba789,0
} joined {
} left {
} partitioned {
})
2020-05-06 13:45:25 0 [Warning] WSREP: last inactive check more than PT1.5S ago (PT3.51323S), skipping check
2020-05-06 13:45:55 0 [Note] WSREP: PC protocol downgrade 1 -> 0
2020-05-06 13:45:55 0 [Note] WSREP: view((empty))
2020-05-06 13:45:55 0 [ERROR] WSREP: failed to open gcomm backend connection: 110: failed to reach primary view: 110 (Connection timed out)
     at gcomm/src/pc.cpp:connect():158
2020-05-06 13:45:55 0 [ERROR] WSREP: gcs/src/gcs_core.cpp:gcs_core_open():220: Failed to open backend connection: -110 (Connection timed out)
2020-05-06 13:45:55 0 [ERROR] WSREP: gcs/src/gcs.cpp:gcs_open():1608: Failed to open channel 'my_wsrep_cluster' at 'gcomm://db0,db1,db2,db3': -110 (Connection timed out)
2020-05-06 13:45:55 0 [ERROR] WSREP: gcs connect failed: Connection timed out
2020-05-06 13:45:55 0 [ERROR] WSREP: wsrep::connect(gcomm://db0,db1,db2,db3) failed: 7
2020-05-06 13:45:55 0 [ERROR] Aborting

Поскольку я запускаю все контейнеры в виртуальной машине OpenStack, я открыл порты 3306. 4444, 4567 и 4568 в моей группе безопасности.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...