flink-1.10.1文件:https://archive.apache.org/dist/flink/flink-1.10.1/flink-1.10.1-bin-scala_2.11.tgz
Hadoop依赖包:https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.7.5-10.0/flink-shaded-hadoop-2-uber-2.7.5-10.0.jar
cd /tmp
tar -zxvf flink-1.10.1-bin-scala_2.11.tgz -C /opt/
<property>
<name>yarn.resourcemanager.am.max-attemptsname>
<value>4value>
property>
# 配置主节点的host
jobmanager.rpc.address: node-00
# 将host改为主节点的
node-00:8081
#添加所有计算节点的host
node-00
node-01
node-02
node-03
scp -r /opt/flink-1.10.1 node-01:/opt
scp -r /opt/flink-1.10.1 node-02:/opt
scp -r /opt/flink-1.10.1 node-03:/opt
cd /opt/flink-1.10.1/bin
bash start-cluster.sh
node-00:8081
Configs->Advanced->Anvanced hdfs-site->dfs.permissions.enabled
修改值为false
修改完成要重启所有节点上的组件才能生效,在HDSF管理页面弹出来的:Restart Required: 10 Components on 4 Hosts,选择Restart->Restart All Affected
然后等待重启
hdfs dfs -mkdir /test
hdfs dfs -mkdir /test/input
hdfs dfs -mkdir /test/output
hdfs dfs -put /tmp/wordcount.txt /test/input
cd /opt/flink-1.10.1/bin
bash flink run ../examples/batch/WordCount.jar --input hdfs://node-00:8020/test/input/wordcount.txt --output hdfs://node-00:8020/test/output/result.txt
如果出现如下或者类似的报错
Protocol message end-group tag did not match expected tag.; Host Details : local host is: "node-00.hdp/192.168.10.100"; destination host is: "node-00":8020
很可能是hdfs的链接地址出现了错误,运行
hdfs getconf -confkey fs.default.name
输出的链接地址为hdfs的真实地址,替换上面命令中的地址即可
hdfs dfs -cat /test/output/result.txt
Jobs->Completed Jobs
查看已完成的任务
先清除之前运行的结果文件
hdfs dfs -rm /test/output/result.txt
其他不变,运行代码改为
bash flink run -m yarn-cluster ../examples/batch/WordCount.jar --input hdfs://node-00:8020/test/input/wordcount.txt --output hdfs://node-00:8020/test/output/result.txt
运行情况在Flink管理界面上是看不到的,需要到YARN的web界面才能看到,因为已经放给YARN管理了,进入YARN web界面
http://YARN服务安装节点的ip地址:8088
这个问题网上找了好久,最后感谢此贴给出正确解决方法:https://blog.csdn.net/qq_41398614/article/details/107635391
如果碰到如下或者类似的报错
java.lang.NoClassDefFoundError: com/sun/jersey/core/util/FeaturesAndProperties
那很可能是因为找不到 jersey 类要安装依赖包,需要到如下地址下载三个包
https://repo1.maven.org/maven2/com/sun/jersey/jersey-core/1.9/jersey-core-1.9.jar
https://repo1.maven.org/maven2/com/sun/jersey/jersey-server/1.9/jersey-server-1.9.jar
https://repo1.maven.org/maven2/com/sun/jersey/jersey-client/1.9/jersey-client-1.9.jar
放到/opt/flink-1.10.1/lib 文件夹下面同时分发给子节点,重启flink即可,如果flink重启还是不行就重启整个集群