flink1.17源码编译及Idea下的flink环境

官方参考:Building Flink from Source

1、获取源码包:

flink-1.17.1-src.tgz

2、编译打包命令

mvn clean package -DskipTests -Dfast

说明:

        -DskipTests:跳过测试

        -Dfast:跳过QAplugins、JavaDocs等过程

基于不同的网络环境,package等待中....,最终效果如图

3、基于IDEA本地启动flink环境

本地启动flink环境便于理解FlinkCluster架构,官图如下,至少需启动JobManager和TaskManager

3.1 flink-deamon.sh脚本片段

从bin/flink-deamon.sh脚本中,可以获取对应组件的启动入口

case $DAEMON in
    (taskexecutor)
        CLASS_TO_RUN=org.apache.flink.runtime.taskexecutor.TaskManagerRunner
    ;;

    (zookeeper)
        CLASS_TO_RUN=org.apache.flink.runtime.zookeeper.FlinkZooKeeperQuorumPeer
    ;;

    (historyserver)
        CLASS_TO_RUN=org.apache.flink.runtime.webmonitor.history.HistoryServer
    ;;

    (standalonesession)
        CLASS_TO_RUN=org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint
    ;;

    (standalonejob)
        CLASS_TO_RUN=org.apache.flink.container.entrypoint.StandaloneApplicationClusterEntryPoint
    ;;

    (sql-gateway)
        CLASS_TO_RUN=org.apache.flink.table.gateway.SqlGateway
        SQL_GATEWAY_CLASSPATH="`findSqlGatewayJar`":"`findFlinkPythonJar`"
    ;;

    (*)
        echo "Unknown daemon '${DAEMON}'. $USAGE."
        exit 1
    ;;
esac

3.2 启动JobManager

# ClusterEntrypoint

org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint

# VM options

-Dlog.file=${FLINK_SLOURCE_HOME}/build-target/log/flink-jobmanager-1.local.log
-Dlog4j.configuration=file:${FLINK_SLOURCE_HOME}/build-target/conf/log4j.properties
-Dlog4j.configurationFile=file:${FLINK_SLOURCE_HOME}/build-target/conf/log4j.properties
-Dlogback.configurationFile=file:${FLINK_SLOURCE_HOME}/build-target/conf/logback.xml
-classpath
:${FLINK_SLOURCE_HOME}/build-target/lib/flink-cep-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-connector-files-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-csv-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-dist-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-json-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-scala_2.12-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-table-api-java-uber-1.17.1.jar.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-table-planner-loader-1.17.1.jar.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-table-runtime-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-1.2-api-2.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-api-2.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-core-2.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-slf4j-impl-2.17.1.jar:

-- program arguments

-c ${FLINK_SLOURCE_HOME}/build-target/conf

说明:

        ${FLINK_SLOURCE_HOME}为实际idea编译构建源代码地址

启动成功后,即可在${FLINK_SLOURCE_HOME}/build-target/log目录下查看到对应的jobmanager日志文件,访问默认8081端口即可查看对应WebUI界面

3.3 启动TaskManager

# 启动入口

org.apache.flink.runtime.taskexecutor.TaskManagerRunner

# VM options

-Dlog.file=${FLINK_SLOURCE_HOME}/build-target/log/flink-taskmanager-1.local.log
-Dlog4j.configuration=file:${FLINK_SLOURCE_HOME}/build-target/conf/log4j.properties
-Dlog4j.configurationFile=file:${FLINK_SLOURCE_HOME}/build-target/conf/log4j.properties
-Dlogback.configurationFile=file:${FLINK_SLOURCE_HOME}/build-target/conf/logback.xml
-classpath
:${FLINK_SLOURCE_HOME}/build-target/lib/flink-cep-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-connector-files-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-csv-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-dist-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-json-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-scala_2.12-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-table-api-java-uber-1.17.1.jar.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-table-planner-loader-1.17.1.jar.jar:${FLINK_SLOURCE_HOME}/build-target/lib/flink-table-runtime-1.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-1.2-api-2.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-api-2.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-core-2.17.1.jar:${FLINK_SLOURCE_HOME}/build-target/lib/log4j-slf4j-impl-2.17.1.jar:

-- program arguments

-c ${FLINK_SLOURCE_HOME}/build-target/conf

-D taskmanager.memory.framework.off-heap.size=134217728b

-D taskmanager.memory.network.max=134217730b

-D taskmanager.memory.network.min=134217730b

-D taskmanager.memory.framework.heap.size=134217728b

-D taskmanager.memory.managed.size=536870920b

-D taskmanager.cpu.cores=4

-D taskmanager.memory.task.heap.size=402653174b

-D taskmanager.memory.task.off-heap.size=0b

-D taskmanager.memory.jvm-metaspace.size=268435456b

-D taskmanager.memory.jvm-overhead.max=201326592b

-D taskmanager.memory.jvm-overhead.min=201326592b

启动成功后,刷新8081端口,即可见TaskManager已经注册上去

3.4 任务提交测试

#  用自带的example快速验证

./bin/flink run ./examples/streaming/WordCount.jar 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值