当前位置:   article > 正文

AWS EC2 通过docker安装DolphinScheduler史上最全教程

docker安装dolphinscheduler

1.安装dokcer

sudo yum install -y docker
sudo usermod -a -G docker sudouser
sudo service docker start
docker -v

Docker version 20.10.17, build 100c701

设置镜像源:
sudo vim /etc/docker/daemon.json
{
    "registry-mirrors": [
        "http://hub-mirror.c.163.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com"
    ]
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

2.上传dolphinscheduler到服务器

部署计划:
1、 将dolphinscheduler解压
2、 把master-server放到/opt/software/dolphinscheduler/master/路径下
3、把worker-server放到/opt/software/dolphinscheduler/worker/路径下
4、把api-server放到/opt/software/dolphinscheduler/api/路径下
5、把alert-server放到/opt/software/dolphinscheduler/alert/路径下
目的:
这样做的目的是把docker起来后,将以上的路径统一挂载到docker的/opt/dolphinscheduler路径下(运行镜像的 -v参数)
统一使用CMD [ “/bin/bash”, “/opt/dolphinscheduler/bin/start.sh” ] 这个命令运行

3.定制镜像

master

vim dockerfile 

FROM openjdk:8-jre-slim-buster
ENV DOCKER true
ENV TZ Asia/Shanghai
ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler
WORKDIR $DOLPHINSCHEDULER_HOME

EXPOSE 12345

RUN apt update ; \
    apt install -y curl sudo ; \
    rm -rf /var/lib/apt/lists/*
    
CMD [ "/bin/bash", "/opt/dolphinscheduler/bin/start.sh" ]

docker build -t dolphinscheduler-master:v1 .

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

worker

vim dockerfile 


FROM openjdk:8-jre-slim-buster

ENV DOCKER true
ENV TZ Asia/Shanghai
ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler

RUN apt update ; \
    apt-get update ; \
    apt install -y curl sudo ssh vim telnet net-tools; \
    rm -rf /var/lib/apt/lists/*

WORKDIR $DOLPHINSCHEDULER_HOME

EXPOSE 1235

CMD [ "/bin/bash", "/opt/dolphinscheduler/bin/start.sh" ]


docker build -t dolphinscheduler-worker:v1 .
--worker需要带有curl sudo ssh vim telnet net-tools,其他节点不需要
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

api-server

vim dockerfile 

FROM openjdk:8-jre-slim-buster
ENV DOCKER true
ENV TZ Asia/Shanghai
ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler

RUN apt update ; \
    apt install -y curl ; \
    rm -rf /var/lib/apt/lists/*

WORKDIR $DOLPHINSCHEDULER_HOME
EXPOSE 12345 25333
CMD [ "/bin/bash", "/opt/dolphinscheduler/bin/start.sh" ]

docker build -t dolphinscheduler-api-server:v1 .

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

alert-server

vim dockerfile 

FROM openjdk:8-jre-slim-buster

ENV DOCKER true
ENV TZ Asia/Shanghai
ENV DOLPHINSCHEDULER_HOME /opt/dolphinscheduler

RUN apt update ; \
    apt install -y curl ; \
    rm -rf /var/lib/apt/lists/*

WORKDIR $DOLPHINSCHEDULER_HOME

EXPOSE 50052 50053

CMD [ "/bin/bash", "/opt/dolphinscheduler/bin/start.sh" ]

docker build -t dolphinscheduler-alert-server:v1 .
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

4.安装zk

wget https://dlcdn.apache.org/zookeeper/zookeeper-3.7.1/apache-zookeeper-3.7.1-bin.tar.gz
tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
mv apache-zookeeper-3.7.1-bin ../software/zookeeper
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
修改zk数据目录 /opt/software/zookeeper/data


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

5.运行镜像

1.master

docker run -d --name dolphinscheduler-master \
    -e DATABASE="mysql" \
    -e SPRING_DATASOURCE_URL="jdbc:mysql://x.x.x.x:3306/dolphinscheduler?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true" \
    -e SPRING_DATASOURCE_USERNAME="x.x.x.x" \
    -e SPRING_DATASOURCE_PASSWORD="x.x.x.x" \
    -e REGISTRY_ZOOKEEPER_CONNECT_STRING="localhost:2181" \
    -v /opt/software/dolphinscheduler/master/:/opt/dolphinscheduler/   \
    --net host \
    -d dolphinscheduler-master:v1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

2.worker

docker run -d --name dolphinscheduler-worker \
    -e DATABASE="mysql" \
    -e SPRING_DATASOURCE_URL="jdbc:mysql://x.x.x.x:3306/dolphinscheduler?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true" \
    -e SPRING_DATASOURCE_USERNAME="x.x.x.x" \
    -e SPRING_DATASOURCE_PASSWORD="x.x.x.x" \
    -e REGISTRY_ZOOKEEPER_CONNECT_STRING="localhost:2181" \
    -v /opt/software/dolphinscheduler/worker/:/opt/dolphinscheduler/   \
    --hostname x.x.x.x \
    --network=docker-mynet \
    --ip x.x.x.x \
    -d dolphinscheduler-worker:v1
    
    


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

3.api-server

docker run -d --name dolphinscheduler-api \
    -e DATABASE="mysql" \
    -e SPRING_DATASOURCE_URL="jdbc:mysql://x.x.x.x:3306/dolphinscheduler?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true" \
    -e SPRING_DATASOURCE_USERNAME="x.x.x.x" \
    -e SPRING_DATASOURCE_PASSWORD="x.x.x.x" \
    -e REGISTRY_ZOOKEEPER_CONNECT_STRING="localhost:2181" \
    -v /opt/software/dolphinscheduler/api/:/opt/dolphinscheduler/   \
    --net host \
    -d dolphinscheduler-api-server:v1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

4.alert-server

docker run -d --name dolphinscheduler-alert-server \
    -e DATABASE="mysql" \
    -e SPRING_DATASOURCE_URL="jdbc:mysql://x.x.x.x:3306/dolphinscheduler?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true" \
    -e SPRING_DATASOURCE_USERNAME="x.x.x.x" \
    -e SPRING_DATASOURCE_PASSWORD="x.x.x.x" \
    -e REGISTRY_ZOOKEEPER_CONNECT_STRING="localhost:2181" \
    -v /opt/software/dolphinscheduler/alert/:/opt/dolphinscheduler/   \
    --net host \
    -d dolphinscheduler-alert-server:v1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

常用命令

1. 列出所有的容器 ID:

docker ps -aq
  • 1

2. 停止所有的容器:

docker stop $(docker ps -aq)
  • 1

3. 删除所有的容器:

docker rm $(docker ps -aq)
  • 1

4. 删除所有的镜像:

docker rmi $(docker images -q)
  • 1

5.查看容器日志

docker logs -f -t --since="20187-7-30" --tail=10 docker_container_name
 
--since : 此参数指定了输出日志开始日期,即只输出指定日期之后的日志。
 
-f : 查看实时日志
 
-t : 查看日志产生的日期
 
-tail=10 : 查看最后的10条日志。
 
docker_container_name : 容器名称
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

6.进入容器内部

docker exec -it 5b1304e1159e /bin/bash
  • 1

7.容器后台执行

 CMD ["tail","-f","/dev/null"]
  • 1

8.将容器打成镜像

docker commit -m "save images" fb044b8fc877 dolphinscheduler-worker:v2.0
  • 1

9.创建网络

docker network create --subnet=172.172.0.0/24 docker-mynet
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/587481
推荐阅读
相关标签
  

闽ICP备14008679号