flink源码-准备
编译flink
下载 Flink 代码到本地。
1 | git clone https://github.com/apache/flink.git |
国内下载慢的话可以使用gitee的镜像仓库:
https://gitee.com/apache/flink.git
maven配置:
1 | <mirrors> |
flink 1.8
源码切换到1.8分支
1 | git checkout release-1.8 |
编译源码:
1 | mvn clean install -DskipTests |
编译结果在flink/flink-dist/target/下。
unsafe 类找不到
1 | 符号: 方法 defineClass(java.lang.String,byte[],int,int,java.lang.ClassLoader,java.security.ProtectionDomain) |
- 设置环境变量JAVA_HOME
- 设置环境变量CLASSPATH,加上unsafe类所在jar包路径。
找不到jar包
1 | [ERROR] Failed to execute goal on project flink-avro-confluent-registry: Could not resolve dependencies for project org.apache.flink:flink-avro-confluent-registry:jar:1.8-SNAPSHOT: Could not find artifact io.confluent:kafka-schema-registry-client:jar:3.3.1 in nexus-aliyun (http://maven.aliyun.com/nexus/content/groups/public) -> [Help 1] |
- 可以在settings.xml中加上如下配置:
1 | <mirror> |
- 也可以手动下载kafka-schema-registry-client-3.3.1.jar.将下载的kafka-schema-registry-client-3.3.1.jar安装到本地仓库:
1 | mvn install:install-file -DgroupId=io.confluent -DartifactId=kafka-schema-registry-client -Dversion=3.3.1 -Dpackaging=jar -Dfile=/home/hadoop/downloads/kafka-schema-registry-client-3.3.1.jar |
flink 1.10-1.12
编译卡在 Running ‘npm ci –cache-max=0 –no-save’
flink 编译中需要安装node 包,在flink-runtime-web/pom.xml 中。
将npm install 部分的argumentsci --cache-max=0 --no-save
修改为 install -registry=https://registry.npm.taobao.org --cache-max=0 --no-save
ng: command not found
环境没有ng命令,使用npm install @angular/cli -registry=https://registry.npm.taobao.org
。
注意在 flink/flink-runtime-web/web-dashboard 目录下执行 npm,目的是在目录下安装 angular/cli
调试
本地调试
flink 在编译完成后可以本地调试,例如使用flink-examples/flink-examples-streaming 下的wordcount任务直接可以debug。
注意,将 run/debug configuration中的before launch设置为
build,no error check
防止出现build中异常导致无法启动。
远程调试
参考资料:
- idea 导入flink
- 从源码构建 Flink