源码的重要性
- 贴近需求,进行定制化开发
- 深入理解原理,知其然也要知其所以然
编译过程
-
环境 linux系统
-
jdk1.8,安装过程略,记住最后要添加path
-
安装maven
-
wget https://mirrors.cnnic.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz --no-check-certificate
-
下载后解压 tar xzf apache-maven-3.5.4-bin.tar.gz
-
添加个链接方便版本管理 ln -s apache-maven-3.5.4 mvn
-
添加路径 用户目录下的.profile 的末尾加上以下内容,并source一下
export MAVEN_HOME=~/mvn export PATH=$MAVEN_HOME/bin:$PATH -
把默认镜像改成阿里云镜像,可以加快速度。setting.xml 中加上
<mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>*</mirrorOf> </mirror>
-
-
下载flink源码
-
wget http://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.9.1/flink-1.9.1-bin-scala_2.11.tgz
-
解压 tar xzf flink-1.9.1-bin-scala_2.11.tgz
-
添加链接ln -s flink-1.9.1 flink
-
添加路径 ,保存后 source ~/.profile
export FLINK_HOME=~/flink export PATH=$FLINK_HOME/bin:$PATH
-
-
开始编译
- 进入flink 然后执行 mvn clean package -DskipTests -Drat.skip=true -Dhadoop.version=2.8.3
- 后面的参数一定要添加,-DskipTests可以忽略测试用例的编译,源码中有很多测试用例必须有特定的环境才能跑通,这个忽略可以省很多事。
- -Dhadoop.version=2.8.3 必须指定版本,不然flink-s3-fs-hadoop这个工程会报错。
- -Drat.skip=true是对license的忽略,但是如果该项目将用于大型的商业开发且后续还打算开源的话,最好还是不要加这个选项,不然有可能会给自己的公司挖坑。如果不加这个选项,那就需要采取另一种解决方案了,即在报错日志中找到对应的类,在类头加上如下一段内容
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
``
- 网络不好的,可能会卡死在下载node-10.9.0-win-x64.zip的过程中,可以预先下载好,然后根据控制台打印出的日志放入对应路径
- 编译flink-runtime-web工程的时候,可能用时稍长,因为会下载很多依赖modules,如果出错请删除node_modules文件夹后再编译一次
- 该版本有个必报错:找不到kafka-schema-registry-client-3.3.1.jar,解决方法如下:
- 自行下载 wget http://packages.confluent.io/maven/io/confluent/kafka-schema-registry-client/3.3.1/kafka-schema-registry-client-3.3.1.jar
- mvn install:install-file -DgroupId=io.confluent -DartifactId=kafka-schema-registry-client -Dversion=3.3.1 -Dpackaging=jar -Dfile=kafka-schema-registry-client-3.3.1.jar
- 然后再次编译即可
- 建议花钱买个vpn,然后再编译,这样可以不用配置阿里镜像,编译过程的波折可以少很多。
本文详细介绍了如何在Linux环境下编译Flink源码,包括安装JDK和Maven,修改Maven镜像,下载并编译Flink源码,解决编译过程中遇到的问题,如设置Hadoop版本、跳过测试用例、处理缺失依赖等。
源码编译&spm=1001.2101.3001.5002&articleId=103744335&d=1&t=3&u=47a43a06648f466da147da12589a7d78)
972

被折叠的 条评论
为什么被折叠?



