From d6778b751f2cdddf3c69cec98ce4e61e7234b073 Mon Sep 17 00:00:00 2001 From: wenyh <44251917+wenyh1@users.noreply.github.com> Date: Thu, 3 Dec 2020 16:28:59 +0800 Subject: [PATCH] compatible PDF format (#173) --- 0.overview/0.7_dble_mgr_quick_start_docker.md | 242 +++++++++--------- 1 file changed, 123 insertions(+), 119 deletions(-) diff --git a/0.overview/0.7_dble_mgr_quick_start_docker.md b/0.overview/0.7_dble_mgr_quick_start_docker.md index 0af57339d..0ce8d4ed4 100755 --- a/0.overview/0.7_dble_mgr_quick_start_docker.md +++ b/0.overview/0.7_dble_mgr_quick_start_docker.md @@ -8,7 +8,7 @@ + 安装mysql连接工具,用于进行连接测试观察结果 ### 0.7.3 安装过程 -* #### 注意:下载docker-compose-mgr.yml文件后,可以直接跳至第4点(执行docker-compose up命令,启动容器) +#### 注意:下载docker-compose-mgr.yml文件后,可以直接跳至第4点(执行docker-compose up命令,启动容器) 1. 下载dble项目,找到docker-images目录: ``` @@ -29,131 +29,135 @@ ``` 3. 执行Dockerfile-Mgr文件,构建actiontech/dble-mgr:latest镜像 -``` -[root@localhost]docker-images# docker build -f="Dockerfile-Mgr" -t="actiontech/dble-mgr:latest" . -[root@localhost]docker-images# docker images -REPOSITORY TAG IMAGE ID CREATED SIZE -actiontech/dble-mgr latest d773d83fe832 46 hours ago 711MB -``` + ``` + [root@localhost]docker-images# docker build -f="Dockerfile-Mgr" -t="actiontech/dble-mgr:latest" . + [root@localhost]docker-images# docker images + REPOSITORY TAG IMAGE ID CREATED SIZE + actiontech/dble-mgr latest d773d83fe832 46 hours ago 711MB + ``` 4. 执行docker-compose-mgr.yml文件,启动六个mysql(两组mgr)和dble-server容器 -``` -[root@localhost]~# cd docker-images -[root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml up -[root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml ps - Name Command State Ports ---------------------------------------------------------------------------------------- -dble-server /opt/dble/bin/wait-for-it. ... Up 0.0.0.0:8066->8066/tcp,0.0.0.0:9066->9066/tcp -mgr-a-1 docker-entrypoint.sh mysql ... Up 0.0.0.0:3307->3306/tcp,33060/tcp -mgr-a-2 docker-entrypoint.sh mysql ... Up 0.0.0.0:3308->3306/tcp,33060/tcp -mgr-a-3 docker-entrypoint.sh mysql ... Up 0.0.0.0:3309->3306/tcp,33060/tcp -mgr-b-1 docker-entrypoint.sh mysql ... Up 0.0.0.0:3310->3306/tcp,33060/tcp -mgr-b-2 docker-entrypoint.sh mysql ... Up 0.0.0.0:3311->3306/tcp,33060/tcp -mgr-b-3 docker-entrypoint.sh mysql ... Up 0.0.0.0:3312->3306/tcp,33060/tcp -``` - -5.查看两组mgr关系: -``` -[root@localhost]docker-images# docker exec mgr-a-1 mysql -h127.0.0.1 -p3306 -uroot -p123456 \ --e "SHOW STATUS LIKE 'group_replication_primary_member';" \ --e "SELECT * FROM performance_schema.replication_group_members;" - -+----------------------------------+--------------------------------------+ -| Variable_name | Value | -+----------------------------------+--------------------------------------+ -| group_replication_primary_member | 72da84d7-0c4b-11eb-9f0e-0242ac120002 | -+----------------------------------+--------------------------------------+ -+---------------------------+--------------------------------------+-------------+-------------+--------------+ -| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | -+---------------------------+--------------------------------------+-------------+-------------+--------------+ -| group_replication_applier | 72da84d7-0c4b-11eb-9f0e-0242ac120002 | mgr-a-1 | 3306 | ONLINE | -| group_replication_applier | 7314efdd-0c4b-11eb-ba28-0242ac120004 | mgr-a-3 | 3306 | ONLINE | -| group_replication_applier | 733b00fe-0c4b-11eb-bbea-0242ac120003 | mgr-a-2 | 3306 | ONLINE | -+---------------------------+--------------------------------------+-------------+-------------+--------------+ - -[root@localhost]docker-images# docker exec mgr-b-1 mysql -h127.0.0.1 -p3306 -uroot -p123456 \ --e "SHOW STATUS LIKE 'group_replication_primary_member';" \ --e "SELECT * FROM performance_schema.replication_group_members;" - -+----------------------------------+--------------------------------------+ -| Variable_name | Value | -+----------------------------------+--------------------------------------+ -| group_replication_primary_member | 728c327d-0c4b-11eb-9300-0242ac120005 | -+----------------------------------+--------------------------------------+ -+---------------------------+--------------------------------------+-------------+-------------+--------------+ -| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | -+---------------------------+--------------------------------------+-------------+-------------+--------------+ -| group_replication_applier | 728c327d-0c4b-11eb-9300-0242ac120005 | mgr-b-1 | 3306 | ONLINE | -| group_replication_applier | 732c5b3b-0c4b-11eb-9eb1-0242ac120007 | mgr-b-3 | 3306 | ONLINE | -| group_replication_applier | 733c6350-0c4b-11eb-b0fb-0242ac120006 | mgr-b-2 | 3306 | ONLINE | -+---------------------------+--------------------------------------+-------------+-------------+--------------+ -``` -6. 观察dble日志 -进入dble-server容器查看/opt/dble/logs/下的关日志 -``` -[root@localhost]docker-images# docker exec -it dble-server bash -[root@dble-server /]# less /opt/dble/logs/wrapper.log -[root@dble-server /]# less /opt/dble/logs/dble.log -#bootstrap.cnf配置中useOuterHa参数配置为false时,才会有该日志生成 -[root@dble-server /]# less /opt/dble/logs/custom_mysql_ha.log -``` + ``` + [root@localhost]~# cd docker-images + [root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml up + [root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml ps + Name Command State Ports + --------------------------------------------------------------------------------------- + dble-server /opt/dble/bin/wait-for-it. ... Up 0.0.0.0:8066->8066/tcp,0.0.0.0:9066->9066/tcp + mgr-a-1 docker-entrypoint.sh mysql ... Up 0.0.0.0:3307->3306/tcp,33060/tcp + mgr-a-2 docker-entrypoint.sh mysql ... Up 0.0.0.0:3308->3306/tcp,33060/tcp + mgr-a-3 docker-entrypoint.sh mysql ... Up 0.0.0.0:3309->3306/tcp,33060/tcp + mgr-b-1 docker-entrypoint.sh mysql ... Up 0.0.0.0:3310->3306/tcp,33060/tcp + mgr-b-2 docker-entrypoint.sh mysql ... Up 0.0.0.0:3311->3306/tcp,33060/tcp + mgr-b-3 docker-entrypoint.sh mysql ... Up 0.0.0.0:3312->3306/tcp,33060/tcp + ``` + +5. 查看两组mgr关系: + + ``` + [root@localhost]docker-images# docker exec mgr-a-1 mysql -h127.0.0.1 -p3306 -uroot -p123456 \ + -e "SHOW STATUS LIKE 'group_replication_primary_member';" \ + -e "SELECT * FROM performance_schema.replication_group_members;" + + +----------------------------------+--------------------------------------+ + | Variable_name | Value | + +----------------------------------+--------------------------------------+ + | group_replication_primary_member | 72da84d7-0c4b-11eb-9f0e-0242ac120002 | + +----------------------------------+--------------------------------------+ + +---------------------------+--------------------------------------+-------------+-------------+--------------+ + | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | + +---------------------------+--------------------------------------+-------------+-------------+--------------+ + | group_replication_applier | 72da84d7-0c4b-11eb-9f0e-0242ac120002 | mgr-a-1 | 3306 | ONLINE | + | group_replication_applier | 7314efdd-0c4b-11eb-ba28-0242ac120004 | mgr-a-3 | 3306 | ONLINE | + | group_replication_applier | 733b00fe-0c4b-11eb-bbea-0242ac120003 | mgr-a-2 | 3306 | ONLINE | + +---------------------------+--------------------------------------+-------------+-------------+--------------+ + + [root@localhost]docker-images# docker exec mgr-b-1 mysql -h127.0.0.1 -p3306 -uroot -p123456 \ + -e "SHOW STATUS LIKE 'group_replication_primary_member';" \ + -e "SELECT * FROM performance_schema.replication_group_members;" + + +----------------------------------+--------------------------------------+ + | Variable_name | Value | + +----------------------------------+--------------------------------------+ + | group_replication_primary_member | 728c327d-0c4b-11eb-9300-0242ac120005 | + +----------------------------------+--------------------------------------+ + +---------------------------+--------------------------------------+-------------+-------------+--------------+ + | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | + +---------------------------+--------------------------------------+-------------+-------------+--------------+ + | group_replication_applier | 728c327d-0c4b-11eb-9300-0242ac120005 | mgr-b-1 | 3306 | ONLINE | + | group_replication_applier | 732c5b3b-0c4b-11eb-9eb1-0242ac120007 | mgr-b-3 | 3306 | ONLINE | + | group_replication_applier | 733c6350-0c4b-11eb-b0fb-0242ac120006 | mgr-b-2 | 3306 | ONLINE | + +---------------------------+--------------------------------------+-------------+-------------+--------------+ + ``` +6. 观察dble日志, 进入dble-server容器查看/opt/dble/logs/下的关日志 + + ``` + [root@localhost]docker-images# docker exec -it dble-server bash + [root@dble-server /]# less /opt/dble/logs/wrapper.log + [root@dble-server /]# less /opt/dble/logs/dble.log + + #bootstrap.cnf配置中useOuterHa参数配置为false时,才会有该日志生成 + [root@dble-server /]# less /opt/dble/logs/custom_mysql_ha.log + ``` 7. 结束 -``` -[root@dble-server /]# exit -[root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml down -``` + ``` + [root@dble-server /]# exit + [root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml down + ``` ### 0.7.5 验证高可用效果 -0. 前提bootstrap.cnf配置文件中将useOuterHa设置为false(可参考[高可用切换接口](../2.Function/2.12_failover.md)). +0. 前提bootstrap.cnf配置文件中将useOuterHa设置为false(可参考[高可用切换接口](../2.Function/2.12_failover.md)) + 1. 进入dble-server容器,查看/opt/dble/conf/db.xml配置如下: -``` -[root@localhost]docker-images# docker exec -it dble-server bash -[root@dble-server /]# cat /opt/dble/conf/db.xml - - - show slave status - - - - false - - - false - - - -[root@dble-server /]# exit -``` + ``` + [root@localhost]docker-images# docker exec -it dble-server bash + [root@dble-server /]# cat /opt/dble/conf/db.xml + + + show slave status + + + + false + + + false + + + + [root@dble-server /]# exit + ``` 2. 停用mgr-a-1的主实例,进入dble-server容器中查看变化:custom_mysql_ha.log中出现172.18.0.2:3066...is not alive、db.xml中dbGroup1组的主实例为instanceS1: -``` -[root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml stop mgr-a-1 -[root@localhost]docker-images# docker exec -it dble-server bash -[root@dble-server /]# less /opt/dble/logs/custom_mysql_ha.log -... -2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.2:3306 in dbGroup1 is not alive! -2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.3:3306 in dbGroup1 is normal! -2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.4:3306 in dbGroup1 is normal! -2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.5:3306 in dbGroup2 is normal! -2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.6:3306 in dbGroup2 is normal! -2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.7:3306 in dbGroup2 is normal! -... - -[root@dble-server /]# cat /opt/dble/conf/db.xml - - - show slave status - - - - false - - - false - - -``` \ No newline at end of file + + ``` + [root@localhost]docker-images# docker-compose -f docker-compose-mgr.yml stop mgr-a-1 + [root@localhost]docker-images# docker exec -it dble-server bash + [root@dble-server /]# less /opt/dble/logs/custom_mysql_ha.log + ... + 2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.2:3306 in dbGroup1 is not alive! + 2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.3:3306 in dbGroup1 is normal! + 2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.4:3306 in dbGroup1 is normal! + 2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.5:3306 in dbGroup2 is normal! + 2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.6:3306 in dbGroup2 is normal! + 2020-10-12 07:05:08 [DBLEDbGroupsCheck] [INFO] DbInstance 172.18.0.7:3306 in dbGroup2 is normal! + ... + + [root@dble-server /]# cat /opt/dble/conf/db.xml + + + show slave status + + + + false + + + false + + + ``` \ No newline at end of file