赞
踩
在[01 - Flink源码编译] 文章中介绍了Flink源码如何编译,这篇文章主要介绍源码编译后的启动验证。
(1)Flink编译后的可执行jar包在flink-dist目录下,具体如下:
查看目录内容:
a. bin目录:Flink的执行命令所在目录
c. conf目录:Flink配置文件所在的目录,主要有flink-conf.yaml(指定Flink配置)、masters(指定JobManager地址)、works(指定TaskManager地址)。
c. lib:Flink的依赖库
(2)启动FLink
Flink在新版本中去掉了start-local.sh脚本,因此如果想要启动编译好的Flink可以执行start-scala-shell.sh或者start-cluster.sh。
cd bin/
./start-scala-shell.sh local
或者
./start-cluster.sh
ps:不要通过“sh start-cluster.sh”或者“sh start-scala-shell.sh local”方式启动,因为这两个脚本指定的是bash解析器,非shell解释器:
编译好之后如果直接启动的话,在log目录中可以看到这个错:
Exception in thread "main" org.apache.flink.util.FlinkException: Could not create the DispatcherResourceManagerComponent. at org.apache.flink.runtime.entrypoint.component.DefaultDispatcherResourceManagerComponentFactory.create(DefaultDispatcherResourceManagerComponentFactory.java:275) at org.apache.flink.runtime.minicluster.MiniCluster.createDispatcherResourceManagerComponents(MiniCluster.java:478) at org.apache.flink.runtime.minicluster.MiniCluster.setupDispatcherResourceManagerComponents(MiniCluster.java:436) at org.apache.flink.runtime.minicluster.MiniCluster.start(MiniCluster.java:380) at org.apache.flink.api.scala.FlinkShell$.createLocalCluster(FlinkShell.scala:355) at org.apache.flink.api.scala.FlinkShell$.createLocalClusterAndConfig(FlinkShell.scala:329) at org.apache.flink.api.scala.FlinkShell$.fetchConnectionInfo(FlinkShell.scala:203) at org.apache.flink.api.scala.FlinkShell$.liftedTree1$1(FlinkShell.scala:158) at org.apache.flink.api.scala.FlinkShell$.startShell(FlinkShell.scala:157) at org.apache.flink.api.scala.FlinkShell$.main(FlinkShell.scala:131) at org.apache.flink.api.scala.FlinkShell.main(FlinkShell.scala) Caused by: java.net.BindException: Could not start rest endpoint on any port in port range 8081 at org.apache.flink.runtime.rest.RestServerEndpoint.start(RestServerEndpoint.java:279) at org.apache.flink.runtime.entrypoint.component.DefaultDispatcherResourceManagerComponentFactory.create(DefaultDispatcherResourceManagerComponentFactory.java:172) ... 10 more
这需要修改conf/flink-conf.yaml,将rest.port从8081改为其他端口:
修改完之后打开浏览器访问:
http://localhost:8082/
看到如下页面说明Flink已启动成功:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。