Skip to content

Commit

Permalink
compatible PDF format (actiontech#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenyh1 authored Dec 3, 2020
1 parent e0b3391 commit d6778b7
Showing 1 changed file with 123 additions and 119 deletions.
242 changes: 123 additions & 119 deletions 0.overview/0.7_dble_mgr_quick_start_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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目录:
```
Expand All @@ -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
<dbGroup name="dbGroup1" rwSplitMode="2" delayThreshold="100">
<heartbeat>show slave status</heartbeat>
<dbInstance name="instanceM1" url="172.18.0.2:3306" user="root" password="123456" maxCon="300" minCon="10"
primary="true" readWeight="1" id="xx1">
</dbInstance>
<dbInstance name="instanceS1" url="172.18.0.3:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2">
<property name="testOnCreate">false</property>
</dbInstance>
<dbInstance name="instanceS2" url="172.18.0.4:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2">
<property name="testOnCreate">false</property>
</dbInstance>
</dbGroup>
[root@dble-server /]# exit
```
```
[root@localhost]docker-images# docker exec -it dble-server bash
[root@dble-server /]# cat /opt/dble/conf/db.xml
<dbGroup name="dbGroup1" rwSplitMode="2" delayThreshold="100">
<heartbeat>show slave status</heartbeat>
<dbInstance name="instanceM1" url="172.18.0.2:3306" user="root" password="123456" maxCon="300" minCon="10"
primary="true" readWeight="1" id="xx1">
</dbInstance>
<dbInstance name="instanceS1" url="172.18.0.3:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2">
<property name="testOnCreate">false</property>
</dbInstance>
<dbInstance name="instanceS2" url="172.18.0.4:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2">
<property name="testOnCreate">false</property>
</dbInstance>
</dbGroup>
[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
<dbGroup name="dbGroup1" rwSplitMode="2" delayThreshold="100">
<heartbeat>show slave status</heartbeat>
<dbInstance name="instanceM1" url="172.18.0.2:3306" user="root" password="123456" maxCon="300" minCon="10"
readWeight="1" id="xx1">
</dbInstance>
<dbInstance name="instanceS1" url="172.18.0.3:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2" primary="true">
<property name="testOnCreate">false</property>
</dbInstance>
<dbInstance name="instanceS2" url="172.18.0.4:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2">
<property name="testOnCreate">false</property>
</dbInstance>
</dbGroup>
```

```
[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
<dbGroup name="dbGroup1" rwSplitMode="2" delayThreshold="100">
<heartbeat>show slave status</heartbeat>
<dbInstance name="instanceM1" url="172.18.0.2:3306" user="root" password="123456" maxCon="300" minCon="10"
readWeight="1" id="xx1">
</dbInstance>
<dbInstance name="instanceS1" url="172.18.0.3:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2" primary="true">
<property name="testOnCreate">false</property>
</dbInstance>
<dbInstance name="instanceS2" url="172.18.0.4:3306" user="root" password="123456" maxCon="1000" minCon="10" readWeight="2">
<property name="testOnCreate">false</property>
</dbInstance>
</dbGroup>
```

0 comments on commit d6778b7

Please sign in to comment.