1.官方文档:
https://dolphinscheduler.apache.org/zh-cn/docs/3.2.1/guide/installation/standalone#%E9%85%8D%E7%BD%AE%E6%95%B0%E6%8D%AE%E5%BA%93
2.github:
dolphinscheduler/docs/docs/zh/guide/howto/datasource-setting.md at 3.2.1-release · apache/dolphinscheduler · GitHub
3. 场景描述:
启动dolphinscheduler-stand-server版本,并想设置为mysql数据库
4. 问题描述:
由于开源问题 mysql 需要手动打入容器内部,才能启动成功。主要解决此问题,并使用docker-compose 设置env 为mysql 来启动dolphinscheduler-standalone-server
5. 方案:
1. 设置mysql 驱动映射,docker-compse.yml 设置映射,全部映射进去
2. h2数据库启动后,打新镜像。
docker-compose.yml:
version: '3'
services:
zookeeper:
image: bitnami/zookeeper:3.7.1
profiles: ["all"]
environment:
ALLOW_ANONYMOUS_LOGIN: "yes"
ZOO_4LW_COMMANDS_WHITELIST: srvr,ruok,wchs,cons
volumes:
- dolphinscheduler-zookeeper:/bitnami/zookeeper
healthcheck:
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/2181"]
interval: 5s
timeout: 60s
retries: 120
network_mode: "host"
dolphinscheduler:
image: apache/dolphinscheduler-standalone-server:3.2.1
container_name: dolphinscheduler
environment:
SPRING_PROFILES_ACTIVE: "mysql"
TZ: Asia/Shanghai
DATABASE: "mysql"
SPRING_DATASOURCE_URL: "jdbc:mysql://ip:port/dolphinscheduler"
SPRING_DATASOURCE_USERNAME: "root"
SPRING_DATASOURCE_PASSWORD: "password"
SPRING_JACKSON_TIME_ZONE: "UTC"
REGISTRY_ZOOKEEPER_CONNECT_STRING: "localhost:2181"
volumes:
- /data/dolphinscheduler/worker-data:/tmp/dolphinscheduler/
- /data/dolphinscheduler/logs:/opt/dolphinscheduler/logs/
- /data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar:/opt/dolphinscheduler/libs/api-server/mysql-connector-java-8.0.16.jar
- /data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar:/opt/dolphinscheduler/libs/master-server/mysql-connector-java-8.0.16.jar
- /data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar:/opt/dolphinscheduler/libs/alert-server/mysql-connector-java-8.0.16.jar
- /data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar:/opt/dolphinscheduler/libs/worker-server/mysql-connector-java-8.0.16.jar
- /data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar:/opt/dolphinscheduler/libs/standalone-server/mysql-connector-java-8.0.16.jar
- /data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar:/opt/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar
ports:
- "12345:12345"
- "25333:25333"
dolph:
image: apache/dolphinscheduler-standalone-server:3.2.1.0
container_name: dolph
environment:
SPRING_PROFILES_ACTIVE: "mysql"
TZ: Asia/Shanghai
DATABASE: "mysql"
SPRING_DATASOURCE_URL: "jdbc:mysql://ip:port/dolphinscheduler"
SPRING_DATASOURCE_USERNAME: "root"
SPRING_DATASOURCE_PASSWORD: "password"
SPRING_JACKSON_TIME_ZONE: "UTC"
REGISTRY_ZOOKEEPER_CONNECT_STRING: "localhost:2181"
volumes:
- /data/dolphinscheduler/worker-data:/tmp/dolphinscheduler/
- /data/dolphinscheduler/logs:/opt/dolphinscheduler/logs/
ports:
- "12345:12345"
- "25333:25333"
dolph2:
image: apache/dolphinscheduler-standalone-server:3.2.1
container_name: dolph2
ports:
- "12345:12345"
- "25333:25333"
volumes:
dolphinscheduler-zookeeper:
6. 方案1 解决很简单,映射进容器内,就解决了。mysql 下载地址:
Centsdfepository: mysql/mysql-connector-java
然后创建文件夹放入/data/dolphinscheduler/libs/mysql-connector-java-8.0.16.jar
或者修改为你自己docker-compose 路径
启动:docker-compose up -d dolphinscheduler
方案二.步骤:
1.docker-compse 先启动一个h2内置数据库 dolphinscheduler-standalone-server
2. 启动服务后,然后docker cp mysql驱动,到指定位置
3. 将运行服务重新打镜像
步骤1. 首先docker pull 下来官方镜像:
docker pull apache/dolphinscheduler-standalone-server:3.2.1
2. 我使用的docker-compose 启动
docker-compose up -d dolph2
3. 启动成功后 docker cp 进去mysql驱动
docker cp mysql-connector-java-8.0.16.jar dolph2:/opt/dolphinscheduler/libs/api-server
docker cp mysql-connector-java-8.0.16.jar dolph2:/opt/dolphinscheduler/libs/master-server
docker cp mysql-connector-java-8.0.16.jar dolph2:/opt/dolphinscheduler/libs/alert-server
docker cp mysql-connector-java-8.0.16.jar dolph2:/opt/dolphinscheduler/libs/worker-server
docker cp mysql-connector-java-8.0.16.jar dolph2:/opt/dolphinscheduler/libs/standalone-server
docker cp mysql-connector-java-8.0.16.jar dolph2:/opt/dolphinscheduler/libs
4. 可以进入服务校验下是否添加进入
进入容器 docker exec -it dolph2 /bin/bash
5. 运行服务打镜像:
docker commit -m="备注 描述" -a="作者" 运行服务的image_id apache/dolphinscheduler-standalone-server:3.2.1.0
6. 启动这个3.2.1.0版本镜像即可。我也写了个dolph
docker-compose up -d dolph
7. 结束