编译 CDH-6.3.1 版本的 Flink 1.10

  Apache Flink官网下载安装包不能支持CDH,需要编译后进行安装,参照网上很多资料,尝试了多天,终于成功,供大家参考。

1、环境
Jdk 1.8、centos7.6、Maven 3.6.2和Scala-2.12

2、源码和CDH 版本
Flink 1.10.0 、 CDH 6.3.1(Hadoop 3.0.0)

3、配置maven源

  <mirrors>
        <mirror>
                <id>alimaven</id>
                <mirrorOf>central</mirrorOf>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>
        <mirror>
                <id>alimaven</id>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
                <id>central</id>
                <name>Maven Repository Switchboard</name>
                <url>http://repo1.maven.org/maven2/</url>
                <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
                <id>repo2</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://repo2.maven.org/maven2/</url>
        </mirror>
        <mirror>
                <id>ibiblio</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        </mirror>
        <mirror>
                <id>jboss-public-repository-group</id>
                <mirrorOf>central</mirrorOf>
                <name>JBoss Public Repository Group</name>
                <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </mirror>
        <mirror>
                <id>google-maven-central</id>
                <name>Google Maven Central</name>
                <url>https://maven-central.storage.googleapis.com
                </url>
                <mirrorOf>central</mirrorOf>
        </mirror>
        <!-- 中央仓库在中国的镜像 -->
        <mirror>
                <id>maven.net.cn</id>
                <name>oneof the central mirrors in china</name>
                <url>http://maven.net.cn/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
        </mirror>
  </mirrors>

4、下载依赖的 flink-shaded 源码
不同的 Flink 版本使用的 Flink-shaded不同,1.10 版本使用 10.0
https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-shaded-10.0/flink-shaded-10.0-src.tgz

解压后,在 pom.xml 中,添加如下,加入到标签中

<profile>
        <id>vendor-repos</id>
        <activation>
                <property>
                        <name>vendor-repos</name>
                </property>
        </activation>
        <!-- Add vendor maven repositories -->
        <repositories>
                <!-- Cloudera -->
                <repository>
                        <id>cloudera-releases</id>
                        <url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
                        <releases>
                                <enabled>true</enabled>
                        </releases>
                        <snapshots>
                                <enabled>false</enabled>
                        </snapshots>
                </repository>
                <!-- Hortonworks -->
                <repository>
                        <id>HDPReleases</id>
                        <name>HDP Releases</name>
                        <url>https://repo.hortonworks.com/content/repositories/releases/</url>
                        <snapshots><enabled>false</enabled></snapshots>
                        <releases><enabled>true</enabled></releases>
                </repository>
                <repository>
                        <id>HortonworksJettyHadoop</id>
                        <name>HDP Jetty</name>
                        <url>https://repo.hortonworks.com/content/repositories/jetty-hadoop</url>
                        <snapshots><enabled>false</enabled></snapshots>
                        <releases><enabled>true</enabled></releases>
                </repository>
                <!-- MapR -->
                <repository>
                        <id>mapr-releases</id>
                        <url>https://repository.mapr.com/maven/</url>
                        <snapshots><enabled>false</enabled></snapshots>
                        <releases><enabled>true</enabled></releases>
                </repository>
        </repositories>
</profile>

编译对应的 flink-shaded 版本

$ mvn -T2C clean install -DskipTests -Pvendor-repos -Dhadoop.version=3.0.0-cdh6.3.1 -Dscala-2.12 -Drat.skip=true

(2)下载 Apache Flink 1.10.0

https://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.10.0/flink-1.10.0-src.tgz

(3)解压编译 Flink 源码

$mvn clean install -DskipTests -Dfast -Drat.skip=true -Dhaoop.version=3.0.0-cdh6.3.1 -Pvendor-repos -Dinclude-hadoop -Dscala-2.12 -T2C
在这里插入图片描述

(5)提取出 flink-1.10.0 二进制包即可
目录地址:
flink-1.10.0/flink-dist/target/flink-1.10.0-bin

(6)测试
./bin/flink run -m yarn-cluster -ynm test_wordcount ./examples/batch/WordCount.jar --input hdfs://cluster_name/tmp/words.txt

参考(感谢!):
https://blog.csdn.net/high2011/article/details/102612080
https://blog.csdn.net/u013385925/article/details/104516805

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值