入坑Flink - Flink源码编译

准备工作

参考官网:
https://ci.apache.org/projects/flink/flink-docs-release-1.8/flinkDev/building.html

1、jdk

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

2、maven

Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-05T03:00:29+08:00)
Maven home: /usr/maven
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /usr/java/jdk1.8.0_171/jre
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.5.1.el7.x86_64", arch: "amd64", family: "unix"

修改setting文件,添加阿里镜像(避免出现包下载不了的情况)

<mirror>
        <id>nexus-aliyunid>
        <mirrorOf>centralmirrorOf>
        <name>Nexus aliyunname>
        <url>http://maven.aliyun.com/nexus/content/groups/publicurl>
mirror>

详细配置可参考:
https://blog.csdn.net/yitian_z/article/details/90312508

3、源码包

1、下载源码包
https://archive.apache.org/dist/flink/flink-1.8.2/flink-1.8.2-src.tgz
2、解压
tar -zxvf flink-1.8.2-src.tgz

编译

0、在flink目录下执行

mvn clean install -DskipTests -Pvendor-repos -Dfast -Dhadoop.version=3.0.0-cdh6.0.0

1、进入 flink-dist 目录下

cd flink-dist

2、执行

mvn clean install -DskipTests -Pvendor-repos -Dfast -Dhadoop.version=3.0.0-cdh6.0.0

编译出现异常整理
1、Could not resolve dependencies for project org.apache.flink:flink-dist_2.11:jar:1.8.2: Failed to collect dependencies at org.apache.flink:flink-examples-streaming-state-machine_2.11:jar:1.8.2

[ERROR] Failed to execute goal on project flink-dist_2.11: Could not resolve dependencies for project org.apache.flink:flink-dist_2.11:jar:1.8.2: Failed to collect dependencies at org.apache.flink:flink-examples-streaming-state-machine_2.11:jar:1.8.2: Failed to read artifact descriptor for org.apache.flink:flink-examples-streaming-state-machine_2.11:jar:1.8.2: Could not transfer artifact org.apache.flink:flink-examples-streaming-state-machine_2.11:pom:1.8.2 from/to mapr-releases (https://repository.mapr.com/maven/): sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

这4个jar包一直下不下来

org.apache.flink:flink-examples-streaming-state-machine_2.11:jar:1.8.2
org.apache.flink:flink-examples-streaming-twitter_2.11:jar:1.8.2
org.apache.flink:flink-ml-uber_2.11:jar:1.8.2
org.apache.flink:flink-oss-fs-hadoop:jar:1.8.2

原因如下:

The dependency shading mechanism was recently changed in Maven and requires users to build Flink slightly differently, depending on their Maven version:
Maven 3.0.x, 3.1.x, and 3.2.x It is sufficient to call mvn clean install -DskipTests in the root directory of Flink code base.
Maven 3.3.x The build has to be done in two steps: First in the base directory, then in the distribution project:

你可能感兴趣的:(flink)