Distributed | Simple problem repair process encountered in DBLE docker deployment

Author: Yang Taotao

Senior database expert, specializing in MySQL research for more than ten years. Good at MySQL, PostgreSQL, MongoDB and other open source databases related to backup and recovery, SQL tuning, monitoring operation and maintenance, high-availability architecture design, etc. Currently working in Aikesheng, providing MySQL-related technical support and MySQL-related course training for major operators and banking and financial enterprises.

Source of this article: original contribution

*The original content is produced by the open source community of Aikesheng, and the original content shall not be used without authorization. For reprinting, please contact the editor and indicate the source.


First of all, if you completely follow the official website documentation, there is definitely no problem. The DBLE official website documentation has been written in great detail.

It happens that I have the latest MySQL docker image (MySQL 8.0.29) in my environment. I am lazy to change the DBLE background MySQL version to 8.0.29, and the subnet to 172.20.0.0/16 (I already have other docker containers on my machine that occupy the default subnet operation).

After installing DBLE, there are two small problems:
  1. Since the IP address is different from the configuration packaged by the DOCKER image, the subsequent initialization will not be successful.
  2. After modifying the IP address, a library prompts that the administrator does not have permission to create.
Then let's fix these two small problems.
  1. Pull down the latest version of DBLE first.
 root@ytt-large:/home/ytt# docker image ls | grep -E '^action|^mysql'
   mysql                8.0.29    b2500a44757f   8 days ago     524MB
   actiontech/dble      latest    9988614a8e4b   6 months ago   755MB
  1. Create a docker network environment and connect MySQL and DBLE in the background.
 root@ytt-large:/home/ytt# docker network create \
   >  -o "com.docker.network.bridge.name"="dble-net" \
   >   --subnet 172.20.0.0/16 dble-net
   360a9408c35cd8b8d49ad2e58ca447d5518dbea2d954badc0e618ad5d0c072a1
  1. Create two backend MySQL services, the version is MySQL 8.0.29, and the mapped port 3306 is 33061 and 33062 respectively.
 root@ytt-large:/home/ytt# docker run --name backend-mysql1 \

>  --ip 172.20.0.2 -e MYSQL_ROOT_PASSWORD=123456  \
>  -p 33061:3306 --network=dble-net  \
>  -d mysql:8.0.29 --server-id=1
54505aeca71ae7c4553a0fa98e705ee302cdfc08c2b472768afc6170dddf6d37

root@ytt-large:/home/ytt#  docker run --name backend-mysql2 \
>   --ip 172.20.0.3 -e MYSQL_ROOT_PASSWORD=123456 \
>  -p 33062:3306 --network=dble-net \
>  -d mysql:8.0.29 --server-id=2 
5f907b977fc242be35dc01840a5393f2ee754572dd1d59e2fb072032df1ed8d0
  1. After about 30 seconds of MySQL initialization, start DBLE.
 root@ytt-large:/home/ytt# docker run -d -i -t --name dble-server \

>  --ip 172.20.0.5 -p 8066:8066 -p 9066:9066 \
>  --network=dble-net actiontech/dble:latest
df80d0e2451c237afb4792f93e29738579f125288daf0dfee4484ddca8350110
  1. The normal initialization of DBLE needs to load the shard nodes according to the configuration file, and import the sample library table file /opt/dble/conf/template_table.sql. Check the DBLE startup log, the error content is: Failed to connect to service port 8066, it should be that the IP address in the configuration file has not been changed synchronously.
 root@ytt-large:/home/ytt# docker logs dble-server
   dble init&start in docker
   Starting dble-server...
   wait-for-it.sh: waiting 15 seconds for 127.0.0.1:8066
   wait-for-it.sh: 127.0.0.1:8066 is available after 6 seconds
   init shardingNode and execute template_table.sql
   ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104
   ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
   dble init finish
  1. Use docker cp to modify db.xml in the host environment and copy it to the container or enter the container environment and directly modify the url value in db.xml to the correct IP address, then exit the container and restart dble-server.
 root@ytt-large:/home/ytt# docker exec -it dble-server /bin/bash
   
   [root@df80d0e2451c /]# cat /opt/dble/conf/db.xml | grep 172
           <dbInstance name="instanceM1" url="172.20.0.2:3306" user="root" password="123456" maxCon="300" minCon="10"
           <dbInstance name="instanceM2" url="172.20.0.3:3306" user="root" password="123456" maxCon="300" minCon="10"
           
   root@ytt-large:/home/ytt# docker restart dble-server
   dble-server
  1. Check the DBLE log again. There is a new error message: It prompts that the service account does not have permission to access the database testdb2.
 [root@df80d0e2451c /]# dble init&start in docker
   Starting dble-server...
   wait-for-it.sh: waiting 15 seconds for 127.0.0.1:8066
   wait-for-it.sh: 127.0.0.1:8066 is available after 2 seconds
   init shardingNode and execute template_table.sql
   ERROR 1044 (HY000) at line 200 in file: '/opt/dble/conf/template_table.sql': Access denied for user 'root' to database 'testdb2'
   ERROR 1146 (42S02) at line 202 in file: '/opt/dble/conf/template_table.sql': Table 'testdb.tb_test1' doesn't exist in the config of sharding
   ERROR 1146 (42S02) at line 207 in file: '/opt/dble/conf/template_table.sql': Table 'testdb.tb_test1' doesn't exist
   ERROR 1146 (42S02) at line 210 in file: '/opt/dble/conf/template_table.sql': Table 'testdb.tb_test2' doesn't exist in the config of sharding
   ERROR 1146 (42S02) at line 215 in file: '/opt/dble/conf/template_table.sql': Table 'testdb.tb_test2' doesn't exist
   dble init finish
  1. Connect DBLE to check and find that the permissions are sufficient. That should be the logic library is not added in the user configuration file.
 root@ytt-large:/home/ytt# mysql -uroot -p123456 -P8066 -h 127.0.0.1 -e "show grants for root" -s |grep 'CREATE'
mysql: [Warning] Using a password on the command line interface can be insecure.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE,... ON *.* TO `root`@`%` WITH GRANT OPTION
  1. Similar to step 6, add the logic library testdb2 to the DBLE configuration file user.xml, exit the container and restart dble-server when finished.
 [root@df80d0e2451c ~]# cat /opt/dble/conf/user.xml | grep 'testdb2'
   <shardingUser name="root" password="123456" schemas="testdb,testdb2" readOnly="false" blacklist="blacklist1" maxCon="20"/>
       
root@ytt-large:/home/ytt# docker restart dble-server
dble-server
  1. Check the log content again, there is no error.
 root@ytt-large:/home/ytt# docker logs dble-server | tail -n 6
    Starting dble-server...
    Removed stale pid file: /opt/dble/dble.pid
    wait-for-it.sh: waiting 15 seconds for 127.0.0.1:8066
    wait-for-it.sh: 127.0.0.1:8066 is available after 2 seconds
    init shardingNode and execute template_table.sql
    dble init finish
  1. Connect to the service port and check the logical library: It has been created normally.
 root@ytt-large:/home/ytt# mysql -uroot -p123456 -h127.0.0.1 -P8066 -e "show databases"
mysql: [Warning] Using a password on the command line interface can be insecure.
    +----------+
    | DATABASE |
    +----------+
    | testdb   |
    | testdb2  |
    +----------+

MySQL分布式中间件DBLE
DBLE是一个基于MySQL的高可扩展性的分布式中间件,适用于高并发及TB级海量数据处理场景。

中国领先的企业数据处理技术整体解决方案提供商,开源数据库领域优秀企业。为大型行业用户的特定场景提...

371 声望
180 粉丝
0 条评论
推荐阅读
源码分析 | MySQL 的 commit 是怎么 commit 的?
MySQL 的 commit 命令提交事务时,内部会进行两阶段(Prepare 和 Commit)提交,这篇文章基于 MySQL 8.0.33 对 MySQL 的两阶段提交进行源码分析,带你了解提交事务过程中都经历了什么。

爱可生云数据库阅读 38

Aliyun-使用Docker方式安装Jenkins
之前自己在阿里云ECS上面安装了Jekins(安装jenkins的文章),最近因为服务器中了挖矿木马于是准备重新安装一下,但是想到每次安装jenkins都要手动安装jdk、maven、docker、kubectl,感觉好麻烦,于是使用官方推荐...

Awbeci2阅读 2.1k

Win10 安装Docker以及Jenkins(超级详细篇)
安装Docker下载地址:[链接] ,按照它的指引教程,无脑下一步即可。安装成功后电脑会重启。打开docker桌面端,会显示进入链接,下载WSL 安装包进行无脑安装即可。安装 Linux 内核更新包 (重启电脑)重启 Docker ...

九旬3阅读 1.1k

Redis集群容器化安装
主从复制在数据库中很常见,一般用来做读写分离,Redis中也是如此。要求只有1个Master(主节点),可以有N个slaver(从节点),而且Slaver也可以有自己的Slaver,由于这种主从的关系决定他们是在配置阶段就要指定...

KerryWu2阅读 2.3k

Java项目是不是分布式,真有那么重要吗?
「微服务」「分布式」在我刚毕业的时候还是比较关注的,那时候还入门了一把SpringCloud,写了一篇很长的文章,还是很顶的,有不少的大号都给我转载了,在知乎又获得了很多的赞。

Java3y2阅读 593评论 1

qiankun微前端从搭建到部署大型踩坑记录片(一镜到底)
前言近两年一直会有遇到需要微前端框架的需求,同时在招聘上,微前端的需求也是挺多的,最近整理了一下之前经手过的几个qiankun微前端项目,分享给大家。

蹦擦擦12阅读 844评论 8

HTAP 数据库如何实现?浅析 KaiwuDB 中的列存引擎
TP 与 AP 融合的 HTAP 数据库正成为业内的发展趋势。但由于大规模数据场景下 TP 与 AP 系统本身的复杂性,要在一套数据库系统中融合两种使用场景的功能并不容易。浪潮推出的 HTAP KaiwuDB 采用多模存储引擎的方案...

KaiwuDB阅读 2.9k

中国领先的企业数据处理技术整体解决方案提供商,开源数据库领域优秀企业。为大型行业用户的特定场景提...

371 声望
180 粉丝
宣传栏