-- 安装wget
[root@k8smaster01 docker]# yum install wget

--下载flink包
wget -p ./ http://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.10.0/flink-1.10.0-bin-scala_2.11.tgz

-- 解压
[root@k8smaster01 flink-1.10.0]# pwd
/home/docker/mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.10.0
[root@k8smaster01 flink-1.10.0]# mv flink-1.10.0-bin-scala_2.11.tgz /home/docker
[root@k8smaster01 docker]# tar xzvf flink-1.10.0-bin-scala_2.11.tgz -C ./
[root@k8smaster01 docker]# vim flink-1.10.0/conf/flink-conf.yaml
jobmanager.rpc.address: flink-jm
taskmanager.numberOfTaskSlots: 10

---配置dockerfile
[root@k8smaster01 docker]# vim dockerfile
FROM centos:centos7
#RUN yum install java-1.8.0-openjdk -y
ADD jre-8u231-linux-x64.tar.gz /usr/java/jdk
ENV JAVA_HOME /usr/java/jdk/jre1.8.0_231
ENV PATH ${PATH}:${JAVA_HOME}/bin
ARG FLINK_VERSION=1.10.0
ARG SCALA_VERSION=2.11
ARG FLINK_TAR_NAME=flink-${FLINK_VERSION}-bin-scala_${SCALA_VERSION}.tgz
ENV FLINK_HOME=/flink-${FLINK_VERSION}
ADD ${FLINK_TAR_NAME} /
#RUN mkdir /home
COPY flink_run.sh /home
EXPOSE 8088
VOLUME $FLINK_HOME/conf
RUN chmod u+x /home/flink_run.sh
#ENTRYPOINT cd /home && sh /home/flink_run.sh

ENTRYPOINT ["/home/flink_run.sh"]

--配置启动tm,jm
[root@k8smaster01 docker]# vim flink_run.sh
#!/bin/bash
FLINK_HOME=/flink-1.10.0
FLINK_JOB_MANAGER_SH=$FLINK_HOME/bin/jobmanager.sh
FLINK_TASK_MANAGER_SH=$FLINK_HOME/bin/taskmanager.sh

case "$1" in
"jobmanager")
$FLINK_JOB_MANAGER_SH start-foreground
;;

"taskmanager")
$FLINK_TASK_MANAGER_SH start-foreground
;;

*)
echo "COMMAND ERROR"
;;
esac


-- build
docker build -f dockerfile -t flink-service:flink1.10.0 ./
-- 创建Flink的network
docker network create flink
-- 启动1个job manager和2个task manager
docker run -itd  --name flink-jm  -p 8081:8081 -v /home/docker/flink-1.10.0/conf:/flink-1.10.0/conf --network flink flink-service:flink1.10.0 jobmanager
docker run -itd  --name flink-tm  -v /home/docker/flink-1.10.0/conf:/flink-1.10.0/conf --network flink flink-service:flink1.10.0 taskmanager
docker run -itd  --name flink-tm2  -v /home/docker/flink-1.10.0/conf:/flink-1.10.0/conf --network flink flink-service:flink1.10.0 taskmanager

-- 查看是否存在flink-jm和flink-tm容器
[root@k8smaster01 docker]# docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS              PORTS                                                            NAMES
a80cfceee5f2        flink-service:flink1.10.0   "/home/flink_run.sh …"   4 seconds ago       Up 3 seconds        8088/tcp                                                         flink-tm
305ac1e1d397        flink-service:flink1.10.0   "/home/flink_run.sh …"   20 seconds ago      Up 19 seconds       0.0.0.0:8081->8081/tcp, 8088/tcp                                 flink-jm
729bfc0cd64c        2497f179cf1d                "/usr/sbin/run-vsftp…"   3 months ago        Up 59 minutes       0.0.0.0:20-21->20-21/tcp, 0.0.0.0:21100-21110->21100-21110/tcp   zhaoolee_vsftpd
[root@k8smaster01 docker]#

外部访问:
http://192.168.108.178:8081/#/overview

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐