编译 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源

  
        
                alimaven
                central
                aliyun maven
                http://maven.aliyun.com/nexus/content/repositories/central/
        
        
                alimaven
                aliyun maven
                http://maven.aliyun.com/nexus/content/groups/public/
                central
        
        
                central
                Maven Repository Switchboard
                http://repo1.maven.org/maven2/
                central
        
        
                repo2
                central
                Human Readable Name for this Mirror.
                http://repo2.maven.org/maven2/
        
        
                ibiblio
                central
                Human Readable Name for this Mirror.
                http://mirrors.ibiblio.org/pub/mirrors/maven2/
        
        
                jboss-public-repository-group
                central
                JBoss Public Repository Group
                http://repository.jboss.org/nexus/content/groups/public
        
        
                google-maven-central
                Google Maven Central
                https://maven-central.storage.googleapis.com
                
                central
        
        
        
                maven.net.cn
                oneof the central mirrors in china
                http://maven.net.cn/content/groups/public/
                central
        
  

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 中,添加如下,加入到标签中


        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 版本

$ 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
编译 CDH-6.3.1 版本的 Flink 1.10_第1张图片

(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

你可能感兴趣的:(flink)