0


Windows安装Flink

环境

window10
flink-1.16.1-bin-scala_2.12

下载

下载链接:https://archive.apache.org/dist/flink/flink-1.16.1/
在这里插入图片描述

安装

1.10版本以后,安装包\bin中不含flink.bat和start-cluster.bat启动文件,需要我们新建或复制1.9版本的文件。
flink.bat

::###############################################################################
::LicensedtotheApacheSoftwareFoundation(ASF) under one
::or more contributor license agreements.  See the NOTICE file
::distributedwiththis work for additional information
::regarding copyright ownership.  TheASF licenses this file
::toyou under the ApacheLicense,Version2.0(the
::"License"); you may not use this file except in compliance
::withtheLicense.  You may obtain a copy of the License at
::::http://www.apache.org/licenses/LICENSE-2.0::::Unless required by applicable law or agreed toin writing, software
::distributed under the License is distributed on an "AS IS"BASIS,::WITHOUTWARRANTIESORCONDITIONSOFANYKIND, either express or implied.::See the Licensefor the specific language governing permissions and
::limitations under the License.::###############################################################################
 
@echo off
setlocal
 
SET bin=%~dp0
SETFLINK_HOME=%bin%..SETFLINK_LIB_DIR=%FLINK_HOME%\lib
SETFLINK_PLUGINS_DIR=%FLINK_HOME%\plugins
 
SETJVM_ARGS=-Xmx512mSETFLINK_JM_CLASSPATH=%FLINK_LIB_DIR%\*
 
java %JVM_ARGS%-cp "%FLINK_JM_CLASSPATH%";org.apache.flink.client.cli.CliFrontend%*
 
endlocal

start-cluster.bat

::###############################################################################
::LicensedtotheApacheSoftwareFoundation(ASF) under one
::or more contributor license agreements.  See the NOTICE file
::distributedwiththis work for additional information
::regarding copyright ownership.  TheASF licenses this file
::toyou under the ApacheLicense,Version2.0(the
::"License"); you may not use this file except in compliance
::withtheLicense.  You may obtain a copy of the License at
::::http://www.apache.org/licenses/LICENSE-2.0::::Unless required by applicable law or agreed toin writing, software
::distributed under the License is distributed on an "AS IS"BASIS,::WITHOUTWARRANTIESORCONDITIONSOFANYKIND, either express or implied.::See the Licensefor the specific language governing permissions and
::limitations under the License.::###############################################################################
 
@echo off
setlocal EnableDelayedExpansionSET bin=%~dp0
SETFLINK_HOME=%bin%..SETFLINK_LIB_DIR=%FLINK_HOME%\lib
SETFLINK_PLUGINS_DIR=%FLINK_HOME%\plugins
SETFLINK_CONF_DIR=%FLINK_HOME%\conf
SETFLINK_LOG_DIR=%FLINK_HOME%\log
 
SETJVM_ARGS=-Xms1024m-Xmx1024mSETFLINK_CLASSPATH=%FLINK_LIB_DIR%\*SET logname_jm=flink-%username%-jobmanager.log
SET logname_tm=flink-%username%-taskmanager.log
SET log_jm=%FLINK_LOG_DIR%\%logname_jm%SET log_tm=%FLINK_LOG_DIR%\%logname_tm%SET outname_jm=flink-%username%-jobmanager.out
SET outname_tm=flink-%username%-taskmanager.out
SET out_jm=%FLINK_LOG_DIR%\%outname_jm%SET out_tm=%FLINK_LOG_DIR%\%outname_tm%SET log_setting_jm=-Dlog.file="%log_jm%"-Dlogback.configurationFile=file:"%FLINK_CONF_DIR%/logback.xml"-Dlog4j.configuration=file:"%FLINK_CONF_DIR%/log4j.properties"SET log_setting_tm=-Dlog.file="%log_tm%"-Dlogback.configurationFile=file:"%FLINK_CONF_DIR%/logback.xml"-Dlog4j.configuration=file:"%FLINK_CONF_DIR%/log4j.properties"::Log rotation (quick and dirty)CD"%FLINK_LOG_DIR%"for/l %%x in (5,-1,1)do(SET/A y =%%x+1RENAME"%logname_jm%.%%x""%logname_jm%.!y!"2> nul
RENAME"%logname_tm%.%%x""%logname_tm%.!y!"2> nul
RENAME"%outname_jm%.%%x""%outname_jm%.!y!"2> nul
RENAME"%outname_tm%.%%x""%outname_tm%.!y!"2> nul
)RENAME"%logname_jm%""%logname_jm%.0"2> nul
RENAME"%logname_tm%""%logname_tm%.0"2> nul
RENAME"%outname_jm%""%outname_jm%.0"2> nul
RENAME"%outname_tm%""%outname_tm%.0"2> nul
DEL"%logname_jm%.6"2> nul
DEL"%logname_tm%.6"2> nul
DEL"%outname_jm%.6"2> nul
DEL"%outname_tm%.6"2> nul
 
for%%X in (java.exe)do(set FOUND=%%~$PATH:X)if not defined FOUND(
    echo java.exe was not found in PATH variable
    goto:eof
)
 
echo Starting a local cluster withoneJobManager process and one TaskManager process.
 
echo You can terminate the processes via CTRL-C in the spawned shell windows.
 
echo Webinterface by default on http://localhost:8081/.
 
start java %JVM_ARGS%%log_setting_jm%-cp "%FLINK_CLASSPATH%";org.apache.flink.runtime.entrypoint.StandaloneSessionClusterEntrypoint--configDir "%FLINK_CONF_DIR%">"%out_jm%"2>&1
start java %JVM_ARGS%%log_setting_tm%-cp "%FLINK_CLASSPATH%";org.apache.flink.runtime.taskexecutor.TaskManagerRunner--configDir "%FLINK_CONF_DIR%">"%out_tm%"2>&1
 
endlocal

运行测试

cmd命令,定位到Flink的安装包bin目录下,执行

.\start-cluster.bat

弹出两个命令行窗口,一个窗口会闪退,即TaskManager进程退出启动失败,JobManager 启动成功。

可以访问后台UI管理界面http://localhost:8081/
在这里插入图片描述
在界面上看不到任何 Task Manager 信息。

用例测试
执行命令 .\flink.bat run D:\Hadoop\flink-1.16.1\examples\batch\WordCount.jar,报错:
在这里插入图片描述
可以看到安装应该是失败了,后续找到解决该问题的方法会继续更新。

(不要参考上面的步骤了,flink 从 1.10开始,windows上跑不起来,各种问题。windows当前能支持的最高版本是1.9.3,直接安装就行)

标签: windows flink java

本文转载自: https://blog.csdn.net/Wolves_howl/article/details/129166648
版权归原作者 皮皮虾的倔强 所有, 如有侵权,请联系我们删除。

“Windows安装Flink”的评论:

还没有评论