> 文章列表 > CDH 集成 Flink-1.14.3 过程与踩坑记录

CDH 集成 Flink-1.14.3 过程与踩坑记录

CDH 集成 Flink-1.14.3 过程与踩坑记录

一、资源准备与配置

1.1 项目文件下载与配置

#下载 flink-parcel 项目文件
[root@hadoop105 ~]# git clone https://github.com/pkeropen/flink-parcel.git
[root@hadoop105 ~]# cd flink-parcel/
#编辑下载地址,看自己需求哪个版本
[root@hadoop105 flink-parcel]# vi flink-parcel.properties 
#FLINK 下载地址
FLINK_URL=https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz#flink版本号
FLINK_VERSION=1.14.3#扩展版本号
EXTENS_VERSION=BIN-SCALA_2.12#操作系统版本,以centos为例
OS_VERSION=7#CDH 小版本
CDH_MIN_FULL=5.2
CDH_MAX_FULL=6.3.2#CDH大版本
CDH_MIN=5
CDH_MAX=6
#给与 build.sh 文件执行权限
[root@hadoop105 flink-parcel]# chmod 755 build.sh#查看默认文件
[root@hadoop105 flink-parcel-master]# ll
总用量 32
-rwxr-xr-x 1 root root  5886 4月  17 14:39 build.sh
drwxr-xr-x 5 root root    53 1月  14 2020 flink-csd-on-yarn-src
drwxr-xr-x 5 root root    53 1月  14 2020 flink-csd-standalone-src
-rw-r--r-- 1 root root   522 4月  19 10:29 flink-parcel.properties
drwxr-xr-x 3 root root    85 1月  14 2020 flink-parcel-src
-rw-r--r-- 1 root root 11357 1月  14 2020 LICENSE
-rw-r--r-- 1 root root  4334 1月  14 2020 README.md

二、生成相关 parcel 和 csd 文件

2.1 生成 parcel 文件

#编译生成 parcel 文件(该过程比较长)
[root@hadoop105 flink-parcel]# ./build.sh parcel
......
+ git clone https://github.com/cloudera/cm_ext.git
正克隆到 'cm_ext'...
remote: Enumerating objects: 1785, done.
remote: Total 1785 (delta 0), reused 0 (delta 0), pack-reused 1785
接收对象中: 100% (1785/1785), 870.71 KiB | 725.00 KiB/s, done.
处理 delta 中: 100% (861/861), done.
+ '[' '!' -f cm_ext/validator/target/validator.jar ']'
+ cd cm_ext
+ mvn install -Dmaven.test.skip=true
./build.sh:行32: mvn: 未找到命令#这里提示没有 mvn 命令,安装 maven 即可 
[root@hadoop105 flink-parcel]# yum install -y maven
#重新执行
[root@hadoop105 flink-parcel]# ./build.sh parcel......
[INFO] ------------------------------------------------------------------------
+ cd ..
+ build_flink_parcel
+ '[' -f FLINK-1.14.3-BIN-SCALA_2.12_build/FLINK-1.14.3-BIN-SCALA_2.12-el7.parcel ']'
+ '[' '!' -d FLINK-1.14.3-BIN-SCALA_2.12 ']'
+ get_flink
+ '[' '!' -f flink-1.14.3-bin-scala_2.12.tgz ']'
+ wget https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz
--2023-04-14 14:37:21--  https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... 已连接。
错误: 无法验证 mirrors.tuna.tsinghua.edu.cn 的由 “/C=US/O=Let's Encrypt/CN=R3” 颁发的证书:颁发的证书已经过期。
要以不安全的方式连接至 mirrors.tuna.tsinghua.edu.cn,使用“--no-check-certificate”。#这里又提示要使用 “--no-check-certificate”,编辑 build.sh 文件,在 wget url 后面加上参数
[root@hadoop105 flink-parcel]# vi build.sh
......
function get_flink {if [ ! -f "$flink_archive" ]; thenwget $FLINK_URL --no-check-certificatefi
......#重新执行
[root@hadoop105 flink-parcel]# ./build.sh parcel
+ wget https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz --no-check-certificate
--2023-04-14 14:56:49--  https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz
正在解析主机 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.15.130, 2402:f000:1:400::2
正在连接 mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.15.130|:443... 已连接。
警告: 无法验证 mirrors.tuna.tsinghua.edu.cn 的由 “/C=US/O=Let's Encrypt/CN=R3” 颁发的证书:颁发的证书已经过期。
已发出 HTTP 请求,正在等待回应... 404 Not Found
2023-04-14 14:56:49 错误 404:Not Found#报404错误,说明没有这个链接的文件,更换一个下载源(该链接不是国内的,比较满),文件下载下来了,放到最后提供
-rw-r--r-- 1 root root  4334 4月  14 13:48 README.md
[root@hadoop105 flink-parcel]# vi flink-parcel.properties 
#FLINK 下载地址
#FLINK_URL=https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz
FLINK_URL=https://archive.apache.org/dist/flink/flink-1.14.3/flink-1.14.3-bin-scala_2.12.tgz#如果你执行到如下位置跑不动了,就是你的网络访问不了github,后面我把cm.ext目录和flink文件一并提供,放到当前目录即可
+ git clone https://github.com/cloudera/cm_ext.git
正克隆到 'cm_ext'...#将提供的文件放到当前目录下
[root@hadoop105 flink-parcel-master]# ll
总用量 332576
-rwxr-xr-x 1 root root      5886 4月  17 14:39 build.sh
-rw-r--r-- 1 root root    816428 4月  17 14:50 cm_ext-master.zip
-rw-r--r-- 1 root root 339705501 4月  19 10:40 flink-1.14.3-bin-scala_2.12.tgz
drwxr-xr-x 5 root root        53 1月  14 2020 flink-csd-on-yarn-src
drwxr-xr-x 5 root root        53 1月  14 2020 flink-csd-standalone-src
-rw-r--r-- 1 root root       522 4月  19 10:45 flink-parcel.properties
drwxr-xr-x 3 root root        85 1月  14 2020 flink-parcel-src
-rw-r--r-- 1 root root     11357 1月  14 2020 LICENSE
-rw-r--r-- 1 root root      4334 1月  14 2020 README.md
#解压cm_ext
[root@hadoop105 flink-parcel-master]# unzip cm_ext-master.zip
#重命名目录
[root@hadoop105 flink-parcel-master]# mv cm_ext-master cm_ext
#继续执行生成parcel文件命令
[root@hadoop105 flink-parcel]# ./build.sh parcel
#不出意外的话,当前目录会生成一个 FLINK-1.14.3-BIN-SCALA_2.12_build 目录,parcel 文件都在里面
[root@hadoop105 flink-parcel-master]# ll
总用量 332576
-rwxr-xr-x 1 root root      5886 4月  17 14:39 build.sh
drwxr-xr-x 5 root root       130 8月  24 2016 cm_ext
-rw-r--r-- 1 root root    816428 4月  17 14:50 cm_ext-master.zip
drwxr-xr-x 4 root root        29 4月  19 10:53 FLINK-1.14.3-BIN-SCALA_2.12
drwxr-xr-x 2 root root       123 4月  19 10:54 FLINK-1.14.3-BIN-SCALA_2.12_build
-rw-r--r-- 1 root root 339705501 4月  19 10:40 flink-1.14.3-bin-scala_2.12.tgz
drwxr-xr-x 5 root root        53 1月  14 2020 flink-csd-on-yarn-src
drwxr-xr-x 5 root root        53 1月  14 2020 flink-csd-standalone-src
-rw-r--r-- 1 root root       522 4月  19 10:45 flink-parcel.properties
drwxr-xr-x 3 root root        85 1月  14 2020 flink-parcel-src
-rw-r--r-- 1 root root     11357 1月  14 2020 LICENSE
-rw-r--r-- 1 root root      4334 1月  14 2020 README.md-rw-r--r-- 1 root root      4334 1月  14 2020 README.md
[root@hadoop105 flink-parcel-master]# ll FLINK-1.14.3-BIN-SCALA_2.12_build
总用量 331424
-rw-r--r-- 1 root root 339366311 4月  19 10:54 FLINK-1.14.3-BIN-SCALA_2.12-el7.parcel
-rw-r--r-- 1 root root        41 4月  19 10:54 FLINK-1.14.3-BIN-SCALA_2.12-el7.parcel.sha
-rw-r--r-- 1 root root       583 4月  19 10:54 manifest.json

2.2 生成 csd 文件


[root@hadoop105 flink-parcel]# ./build.sh csd_on_yarn
[root@hadoop105 flink-parcel]# ./build.sh csd_standalone

2.3 获得的相关文件

[root@hadoop105 flink-parcel-master]# ll
总用量 332588
drwxr-xr-x 2 root root       123 4月  19 10:54 FLINK-1.14.3-BIN-SCALA_2.12_build
-rw-r--r-- 1 root root      8256 4月  19 10:59 FLINK_ON_YARN-1.14.3.jar[root@hadoop105 flink-parcel-master]# ll FLINK-1.14.3-BIN-SCALA_2.12_build
总用量 331424
-rw-r--r-- 1 root root 339366311 4月  19 10:54 FLINK-1.14.3-BIN-SCALA_2.12-el7.parcel
-rw-r--r-- 1 root root        41 4月  19 10:54 FLINK-1.14.3-BIN-SCALA_2.12-el7.parcel.sha
-rw-r--r-- 1 root root       583 4月  19 10:54 manifest.json

三、CDH 中集成 Flink 服务

3.1 拷贝相关文件到指定目录

[root@hadoop105 flink-parcel-master]# cp FLINK-1.14.3-BIN-SCALA_2.12_build/* 
[root@hadoop105 flink-parcel-master]# cp FLINK_ON_YARN-1.14.3.jar /opt/cloudera/csd/

3.2 分配与激活

  3.3 启动与错误处理

 (1)查看 stderr 完整日志,得到如下错误信息:

[19/Apr/2023 13:54:57 +0000] 15463 MainThread redactor     INFO     Started launcher: /opt/cloudera/cm-agent/service/csd/csd.sh start
[19/Apr/2023 13:54:57 +0000] 15463 MainThread redactor     ERROR    Redaction rules file doesn't exist, not redacting logs. file: redaction-rules.json, directory: /run/cloudera-scm-agent/process/952-flink_on_yarn-FLINK_YARN
[19/Apr/2023 13:54:57 +0000] 15463 MainThread redactor     INFO     Re-exec watcher: /opt/cloudera/cm-agent/bin/cm proc_watcher 15471
......
......
......
+ exec /opt/cloudera/parcels/FLINK/lib/flink/bin/flink-yarn.sh --container 1 --streaming
/opt/cloudera/parcels/FLINK/lib/flink/bin/flink-yarn.sh:行17: rotateLogFilesWithPrefix: 未找到命令
[20/Apr/2023 10:13:37 +0000] 20279 MainThread redactor     INFO     Started launcher: /opt/cloudera/cm-agent/service/csd/csd.sh start
[20/Apr/2023 10:13:37 +0000] 20279 MainThread redactor     ERROR    Redaction rules file doesn't exist, not redacting logs. file: redaction-rules.json, directory: /run/cloudera-scm-agent/process/959-flink_on_yarn-FLINK_YARN
[20/Apr/2023 10:13:37 +0000] 20279 MainThread redactor     INFO     Re-exec watcher: /opt/cloudera/cm-agent/bin/cm proc_watcher 20289
#(1)编辑文件:
[root@hadoop105 ~]# vi /opt/cloudera/parcels/FLINK/lib/flink/bin/flink-yarn.sh
#注释掉这一行:
#rotateLogFilesWithPrefix "$FLINK_LOG_DIR" "$FLINK_LOG_PREFIX"#(2)下载jar文件
[root@hadoop105 ~]# cd /opt/cloudera/parcels/FLINK/lib/flink/lib
[root@hadoop105 lib]# wget https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.6.5-9.0/flink-shaded-hadoop-2-uber-2.6.5-9.0.jar
#编辑环境变量:
[root@hadoop105 ~]# vi /etc/profile
#新增如下内容:
export HADOOP_CLASSPATH=/opt/cloudera/parcels/FLINK/lib/flink/lib
#生效变量:
[root@hadoop105 ~]# source /etc/profile

(2)此时报错依然存在,我们查看 flink 的输出日志

[root@hadoop105 lib]# tail -f /var/log/flink/flink-yarn.out
#错误信息如下:
ERROR StatusLogger Reconfiguration failed: No configuration found for '6d6f6e28' at 'null' in 'null'
10:50:09.222 [main] ERROR org.apache.flink.yarn.cli.FlinkYarnSessionCli - Error while running the Flink session.
org.apache.flink.configuration.IllegalConfigurationException: Kerberos login configuration is invalid: keytab [/etc/keytab/flink.keytab] doesn't exist!at org.apache.flink.runtime.security.SecurityConfiguration.validate(SecurityConfiguration.java:151) ~[flink-dist_2.12-1.14.3.jar:1.14.3]at org.apache.flink.runtime.security.SecurityConfiguration.<init>(SecurityConfiguration.java:97) ~[flink-dist_2.12-1.14.3.jar:1.14.3]at org.apache.flink.runtime.security.SecurityConfiguration.<init>(SecurityConfiguration.java:69) ~[flink-dist_2.12-1.14.3.jar:1.14.3]at org.apache.flink.yarn.cli.FlinkYarnSessionCli.main(FlinkYarnSessionCli.java:858) [flink-dist_2.12-1.14.3.jar:1.14.3]

(3)打开 flink-yarn 配置

 (4)将这两行删除掉并保存配置

 (5)最后重新启动 flink 即可

3.4 获取 flink 监控状态

(1)默认启动完成之后我们获取不到 flink 的监控状态

提示:select integral(events_informational_rate) where entityName="flink_on_yarn"' 中未找到与筛选器 'entityName = "flink_on_yarn"' 匹配的实体

 (2)重启一下 cdh 集群和 Cloudera Management Service 即可

四、资源分享

文件:flink-1.14.3-bin-scala_2.12.tgz、cm_ext-master.zip
链接:https://pan.baidu.com/s/1IB0J2kbqoMLDd_gucucLQA 
提取码:cs0b