Flink 1.16 idea intellij中运行web ui
创始人
2025-05-28 14:05:16

  1. 在pom.xml文件中添加flink-runtime-web依赖


org.apache.flink
flink-runtime-web
1.16.1
provided
  1. 在初始化执行环境时传入的配置中添加rest.port项

public static void main(String[] args) throws Exception {
//获取Flink的运行环境
Configuration conf = new Configuration();
conf.setInteger(RestOptions.PORT, 0);//设置为0 每次启动端口都不一样 也可以设置一个固定的端口 如8081
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
//checkpoint配置
env.enableCheckpointing(5000);
env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);
env.getCheckpointConfig().setMinPauseBetweenCheckpoints(500);
env.getCheckpointConfig().setCheckpointTimeout(60000);
env.getCheckpointConfig().setMaxConcurrentCheckpoints(1);

这样启动后就可以在日志中看到web ui的链接了:

15:26:07.833 [main] INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - Web frontend listening at http://localhost:40673.15:26:07.833 [mini-cluster-io-thread-1] INFO org.apache.flink.runtime.dispatcher.DispatcherRestEndpoint - http://localhost:40673 was granted leadership with leaderSessionID=f08dd1d9-359f-4403-84af-79d2e7e41c9b15:26:07.834 [mini-cluster-io-thread-1] INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Received confirmation of leadership for leader http://localhost:40673 , session=f08dd1d9-359f-4403-84af-79d2e7e41c9b15:26:07.843 [main] INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender LeaderContender: DefaultDispatcherRunner15:26:07.844 [main] INFO org.apache.flink.runtime.resourcemanager.ResourceManagerServiceImpl - Starting resource manager service.15:26:07.844 [main] INFO org.apache.flink.runtime.highavailability.nonha.embedded.EmbeddedLeaderService - Proposing leadership to contender LeaderContender: ResourceManagerServiceImpl15:26:07.844 [mini-cluster-io-thread-2] INFO org.apache.flink.runtime.dispatcher.runner.DefaultDispatcherRunner - DefaultDispatcherRunner was granted leadership with leader id 07b5356f-c8c9-4b20-99b0-7491f48c89b4. Creating new DispatcherLeaderProcess.15:26:07.845 [pool-3-thread-1] INFO

在浏览器中访问对应链接就可以看到web ui了

Flink 1.16.1亲测可用, 先前的版本可能还需要使用

Configurationconf=newConfiguration();env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);

但这样发布运行时还需要改下代码,1.16.1的代码里看了下createLocalEnvironmentWithWebUI方法:

做的事情也无非就时往配置项里添加了个rest.port.

所以调用getExecutionEnvironment(conf) 时直接设置下这个参数就行了,需要发布运行时也不用再修改代码。

相关内容

热门资讯

分享给玩家(来玩德州app)透... 亲,来玩德州app这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户的牌特别...
分享给玩家(WPK线上)透明挂... 分享给玩家(WPK线上)透明挂辅助助手(透视)详细教程(有挂详情)-哔哩哔哩亲,有的,ai轻松简单,...
讲解教程!微信怎么购买斗牛房卡... 讲解教程!微信怎么购买斗牛房卡微信斗牛房卡链接哪里有要素一(KK)咨询房/卡添加微信:【560013...
分享给玩家(wpkplus)透... 您好.wpkplus这款游戏可以开挂的,确实是有挂的,需要了解加微【97762250】很多玩家在这款...
分享给玩家(hhpoker德州... 自定义hhpoker德州系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器,不...