第一步 CDH6.3.2集成自制Flink1.12.7

 一共分两步走:

        第一步:CDH制作Flink1.12.7

        第二步:CDH集成Flink1.12.7

前提说明

早期CDH6.3.2集成的Flink1.12存在log4j漏洞,所以需要重新编译

这是之前Flink1.12的log4j版本为1.12,(受影响的版本:Apache Log4j 2.x <= 2.15.0-rc1)

第一步 CDH6.3.2集成自制Flink1.12.7_第1张图片

Flink官方针对历史版本也给出了修复log4j漏洞的紧急版本,其中就有Flink1.12.7,当然还有1.11.6,1.13.5和1.14.2。这是官方说明链接

下载最新的Flink1.12.7源码,打开pom.xml检查下log4j版本为2.16,确定下载的版本没错。接下来开始重新编译

第一步 CDH6.3.2集成自制Flink1.12.7_第2张图片

准备环境

  1. 虚拟机,系统CentOS7.6
  2. jdk1.8
  3. maven3.6.1
  4. parcel制作工具 flink-parcel.zip
  5. flink-1.12.7-bin-scala_2.12.tgz

1. 准备制作环境

安装 jdk1.8 , Maven3.6.3 ,httpd

[root@cdhuser ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

# 安装jdk
[root@cdhuser ~]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

# 安装maven
[root@cdhuser src]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/src/apache-maven-3.6.3
Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: /usr/local/src/jdk1.8.0_221/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1062.el7.x86_64", arch: "amd64", family: "unix"

# 安装httpd
[root@cdhuser html]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 四 2022-06-09 19:22:24 CST; 1h 1min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 6634 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
 Main PID: 1318 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
    Tasks: 6
   Memory: 5.8M
   CGroup: /system.slice/httpd.service
           ├─1318 /usr/sbin/httpd -DFOREGROUND
           ├─6635 /usr/sbin/httpd -DFOREGROUND
           ├─6636 /usr/sbin/httpd -DFOREGROUND
           ├─6637 /usr/sbin/httpd -DFOREGROUND
           ├─6638 /usr/sbin/httpd -DFOREGROUND
           └─6639 /usr/sbin/httpd -DFOREGROUND

6月 09 19:22:24 cdhuser systemd[1]: Starting The Apache HTTP Server...
6月 09 19:22:24 cdhuser httpd[1318]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.137.31. Set the 'ServerName' directive globally to suppress this message
6月 09 19:22:24 cdhuser systemd[1]: Started The Apache HTTP Server.
6月 09 20:16:01 cdhuser systemd[1]: Reloading The Apache HTTP Server.
6月 09 20:16:01 cdhuser httpd[6634]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.137.31. Set the 'ServerName' directive globally to suppress this message
6月 09 20:16:01 cdhuser systemd[1]: Reloaded The Apache HTTP Server.

2. 下载Flink1.12.7 和 制作工具

Flink1.12.7最新下载地址:

https://dlcdn.apache.org/flink/flink-1.12.7/flink-1.12.7-bin-scala_2.12.tgz

CDH的parcel制作工具地址:

https://github.com/cloudera/cm_ext # 制作cloudera-manager扩展包的工具

https://github.com/pkeropen/flink-parcel # 制作flink包的工具

Flink-shaded下载地址:

https://archive.apache.org/dist/flink/flink-shaded-10.0/flink-shaded-10.0-src.tgz

相关的制作工具我已经准备好,自行取用

链接:百度网盘 请输入提取码 提取码:up8n

3. 制作parcel

制作httpd本地仓库,将Flink1.12.7安装包拷贝到本地仓库中。后续制作时使用

mkdir /var/www/html/flink-1.12.7 &&
mv /root/flink-1.12.7-bin-scala_2.12.tgz /var/www/html/flink-1.12.7 &&
curl http://cdhuser/flink-1.12.7/

结果:


 
  Index of /flink-1.12.7
 
 

Index of /flink-1.12.7

[ICO]NameLast modifiedSizeDescription

[PARENTDIR]Parent Directory   -  
[   ]flink-1.12.7-bin-sca..>2022-06-09 20:09 309M 

修改工具配置

tar -zxvf /root/flink-parcel-master.tar &&
tar -zxvf /root/cm_ext.tar &&
cp -r /root/cm_ext /root/flink-parcel-master &&
cd /root/flink-parcel-master &&
mv flink-parcel.properties flink-parcel.properties.bak &&
(cat <> flink-parcel.properties &&
chmod u+x build.sh &&										# 给编译文件添加权限
sed -i "s/https:/git:/g" build.sh &&
./build.sh parcel &&										# 生成FLINK-1.12.7-BIN-SCALA_2.12_build文件夹
./build.sh csd_on_yarn &&								# 生成FLINK_ON_YARN-1.12.7.jar文件
tar -cvf ./flink-1.12.7-bin-scala_2.12.tar ./FLINK-1.12.7-BIN-SCALA_2.12_build/			# 将FLINK-1.12.7-BIN-SCALA_2.12_build/打包

最终生成的flink-1.12.7-bin-scala_2.12.tar 和 FLINK_ON_YARN-1.12.7.jar 就是目标文件

4. 编译flink-shaded版本

如果Flink报错:缺少Hadoop依赖时,需要编译以下jar包

tar -zxvf /root/flink-shaded-10.0-src.tgz &&
cd /root/flink-shaded-10.0 &&
vim pom.xml 

# 在里面的profiles中添加如下配置参数:

    vendor-repos
    
        
            vendor-repos
        
    
    
    
        
        
            cloudera-releases
            https://repository.cloudera.com/artifactory/cloudera-repos
            
                true
            
            
                false
            
        
        
        
            HDPReleases
            HDP Releases
            https://repo.hortonworks.com/content/repositories/releases/
            false
            true
        
        
            HortonworksJettyHadoop
            HDP Jetty
            https://repo.hortonworks.com/content/repositories/jetty-hadoop
            false
            true
        
        
        
            mapr-releases
            https://repository.mapr.com/maven/
            false
            true
        
    

在flink-shaded-10.0目录下进行编译

# 开始编译
mvn clean install -DskipTests -Pvendor-repos -Dhadoop.version=3.0.0-cdh6.3.2 -Dscala-2.12 -Drat.skip=true -T10C

# 编译成功后,生成的目标文件位置:
/root/flink-shaded-10.0/flink-shaded-hadoop-2-parent/flink-shaded-hadoop-2-uber/target/flink-shaded-hadoop-2-uber-3.0.0-cdh6.3.2-10.0.jar

耐心等待编译,可能会失败多次,重复执行命令编译就行

第一步 CDH6.3.2集成自制Flink1.12.7_第3张图片

5. 制作完成

将最终目标文件拷贝出来

编译后的目标文件我也已经准备好,自行取用:

链接:百度网盘 请输入提取码 提取码:cct5

[root@cdhuser cdh_parcel]# ll
总用量 374648
-rw-r--r-- 1 root root 324198400 6月  10 09:37 flink-1.12.7-bin-scala_2.12.tar
-rw-r--r-- 1 root root      8259 6月  10 09:37 FLINK_ON_YARN-1.12.7.jar
-rw-r--r-- 1 root root  59427729 6月  10 09:36 flink-shaded-hadoop-2-uber-3.0.0-cdh6.3.2-10.0.jar

# flink-1.12.7-bin-scala_2.12.tar内容:
总用量 316600
-rw-r--r-- 1 root root 324189375 6月   9 22:10 FLINK-1.12.7-BIN-SCALA_2.12-el7.parcel
-rw-r--r-- 1 root root        41 6月   9 22:10 FLINK-1.12.7-BIN-SCALA_2.12-el7.parcel.sha
-rw-r--r-- 1 root root       583 6月   9 22:10 manifest.json

报错列表

1. 缺少Hadoop依赖包

启动时报以下错误,表示缺少Hadoop依赖

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/yarn/exceptions/YarnException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.yarn.exceptions.YarnException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

需要在布置Flink-Yarn的节点上上传flink-shaded-hadoop-2-uber-3.0.0-cdh6.3.2-10.0

将其上传到/opt/cloudera/parcels/FLINK/lib/flink/lib目录下

第一步 CDH6.3.2集成自制Flink1.12.7_第4张图片

参考资料

CDH整合Flink(CDH6.3.2+Flink1.12.0)

基于CentOS 7.2的CDH 6.3.2 Flink编译源码

自制Flink Parcel集成CDH(Flink1.12.0 + CDH6.3.2)

CDH6.3.2添加安装flink-yarn服务

你可能感兴趣的:(CDH,Flink,apache,docker,flink,大数据,cloudera)