系统Ubuntu18
1.拉取镜像
#默认拉取最新版本
docker pull flink:1.14.4-scala_2.12-java8
#检查镜像
docker images | grep flink
2.编写flink的yaml文件
注意:云服务器需要设置安全策略放行8081端口,否则访问失败
注意2:docker-compose 版本要在2以上-。
查看版本命令:
docker-compose -v
结果如下:
docker-compose version 1.18.0, build 8dd22a9
可以看出版本是1.几,升级一下
apt install python3.6
apt install python3-pip
pip3 install -U docker-compose==1.23.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
编写yaml配置文件 docker-compose.yaml
- version: "3.7"
- services:
- FlinkJobManager: # define the job manager service
- image: flink:1.14.4-scala_2.12-java8
- container_name: FlinkJobManager
- hostname: FlinkJobManager
- expose:
- - "6123"
- ports:
- - "8081:8081" # map port 8081 of container to port 8081 of localhost
- command: jobmanager
- environment:
- - |
- FLINK_PROPERTIES=
- jobmanager.rpc.address: FlinkJobManager
-
- FlinkTaskManager: # define the task manager service
- image: flink:1.14.4-scala_2.12-java8
- #container_name: FlinkTaskManager
- #hostname: FlinkTaskManager
- expose:
- - "6121"
- - "6122"
- depends_on:
- - FlinkJobManager # ensure the sequence of docker composing
- command: taskmanager
- #scale: 2 # replica #wrong
- deploy:
- replicas: 2 # bakcount
- links:
- - "FlinkJobManager:jobmanager" # link to job manager service
- environment:
- - |
- FLINK_PROPERTIES=
- jobmanager.rpc.address: FlinkJobManager
- taskmanager.numberOfTaskSlots: 2
3.执行docker-compose.yaml文件
注意:docker-compose.yaml文件同级目录执行
#运行flink服务
docker-compose up -d
#检查flink的docker容器是否启动
docker ps | grep flink
#查看进程是否存在
netstat -anltp|grep 8081
#检查日志是否正常
docker logs -f -t --tail 100 flink_FlinkTaskManager
4.登陆flink页面
注意:如果使用云服务器需要设置安全策略放行8081端口,否则访问失败
http://你的Docker服务器的ip:8081