- 1、Flink虚拟机环境部署
- 2.1、standalone模式
- 2.2、on yarn模式
- 2.3、高可用zookeeper
- 3.1、部署遇到的问题:
- hdfs操作提示:Permission denied: user=dr.who, access=WRITE, inode=“/“:root:supergroup:drwxr-xr-x
- 解决Hadoop Browse Directory Couldn‘t upload the file 错误.无法上传文件
- 报错Filefile:/root/.flink/application_1651585577100_0002/application_1651585577100_0002-flink-conf.yaml5570135192338677571.tmp does not exist
| 软件 | 版本 |
|---|---|
| flink | 1.12.5 |
| jdk | 1.8 |
| zookeeper | 要是不开启高可用可以不配置 |
| hadoop | 2.8…3 |
| 机器名称 | 担任角色 |
|---|---|
| node01 | jobmanager |
| node02-06 | taskmanager |
下载安装软件:
tar -zxvf xxxx软件名称
环境部署:
export JAVA_HOME="/home/soft/jdk1.8.0_271/" export FLINK_HOME="/home/soft/flink-1.12.5/" PATH=".$PATH:$JAVA_HOME/bin:$FLINK_HOME/bin"
让环境生效:
source /etc/profile
hosts文件:
即机器名称hostname和ip地址的对应
node01和其他机器node2-6之间需要ssh免密链接–shell脚本(至少需要node01对其他所有机器ssh免密链接):(需要虚拟机有expect 、spawn 命令)
#!/bin/bash echo "start....." hosts="ip ip" password="xxxxx" for host in $hosts do echo "--------$host--------" expect <"yes/no" { send "yesn"; exp_continue } "password" { send "$passwordn" } } expect eof EOF done
-------------------------------------脚本问题没有请忽略------------------
参考链接:https://www.cnblogs.com/qingmuchuanqi48/p/14709432.html
/bin/bash^M: 解释器错误: 没有那个文件或目录 使用命令: ./start.sh 错误: bash: ./start_ui_ai.sh:/bin/sh^M:解释器错误: 没有那个文件或目录 原因一:dos / windows 和 unix / linux 换行格式编码问题导致,dos / windows 『nr 』表示换行 unix / linux 『n』 表示换行 原因可能是因为我在win下操作的时候,修改到了此文件。 在win下编辑的时候,换行结尾是nr , 而在linux下 是n,所以才会有 多出来的r用指令: sed -i 's/r$//' build.sh 会把 build.sh文件 中的r 替换成空白!
如果虚拟机没有联网或者没有安装expect 、spawn 命令: 可以直接在node01(jobmanager)机器上用命令: ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa 自身生成私钥和公钥 ssh-copy-id root@192.168.1.2 将公钥发送给所有slave机器 其中需要和命令行交互: 输入yes和密码
修改配置文件:
flink.yaml:
修改JobManager的主机名 jobmanager.rpc.address: node01 jobmanager.memory.process.size 主节点可用内存大小 taskmanager.memory.process.size 从节点可用内存大小 taskmanager.numberOfTaskSlots 从节点可以启动的进程数量,建议设置为从节可用的cpu数量 parallelism.default Flink任务的默认并行度
master文件:
node01:8081
worker(有的版本叫做slave):
node02 node03 node04 node05 node06
启动flink集群的命令
start-cluster.sh
然后访问ip:8081:
然后测试一下:(要确保words.txt文件在每个taskmanager虚拟机机器上能够找到)
flink run /xxxx/flink/examples/batch/WordCount.jar -input words.txt2.2、on yarn模式
Flink ON YARN模式就是使用客户端的方式,直接向Hadoop集群提交任务即可。不需要单独启动Flink进程。
需要先安装hadoop,然后启动yarn
https://blog.csdn.net/Taylor_Ocean/article/details/123414523?spm=1001.2014.3001.5501
---------------------------记录一下配置hadoop的时候出现的小纰漏------------------------
1.配置文件hadoop2和3版本的一些配置文件中配置项有所出入 2.启动后 web管理界面打不开:可以从这几个方面排查 1.防火墙 2.端口没有开启 3.打开/etc/hosts 文件: [root@venn05 hadoop]# more /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 venn05 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 发现,在127.0.0.1 后面配置了一个主机名,会导致在yarn-site.xml 中配置的resourcemanager 的hostname指向 127.0.0.1 修改hosts文件,去掉127.0.0.1 后面的主机名
--------------------------xxx----------------------------------------------------------------------------
因为yarn-session模式需要hadoop的jar支持,需要将flink对应的jar包放入flink中的lib目录下:
否则报错:参考链接:https://www.cnblogs.com/javazyh/p/12170151.html
https://flink.apache.org/downloads.html进行下载
然后在再启动flink-session
yarn-session.sh --detached
yarn kill 进程。 在yarn节点上执行: $ yarn application -kill application_Id2.3、高可用zookeeper
https://blog.csdn.net/a772304419/article/details/107136576
修改配置${FLINK_HOME}/conf/flink-conf.yaml文件,修改的地方如下:
high-availability: zookeeper high-availability.cluster-id: /flink-cluster high-availability.storageDir: hdfs://vmcluster/flink/ha/ high-availability.zookeeper.quorum: node-1:2181,node-2:2181,node-3:2181 state.backend: filesystem state.checkpoints.dir: hdfs://vmcluster/flink-checkpoints state.savepoints.dir: hdfs://vmcluster/flink-savepoints jobmanager.execution.failover-strategy: region jobmanager.archive.fs.dir: hdfs://vmcluster/completed-jobs/ historyserver.archive.fs.dir: hdfs://vmcluster/completed-jobs/3.1、部署遇到的问题: hdfs操作提示:Permission denied: user=dr.who, access=WRITE, inode=“/“:root:supergroup:drwxr-xr-x
https://blog.csdn.net/weixin_44575660/article/details/118687993 权限问题: hadoop fs -chmod 777 / 解决Permission denied: user=root, access=WRITE, inode=“/“:root:supergroup:drwxr-xr-x问题解决Hadoop Browse Directory Couldn‘t upload the file 错误.无法上传文件
https://blog.csdn.net/weixin_47127933/article/details/115580518 hdfs 的web界面上传文件时报错 :Couldn't upload the file data.txt: https://blog.51cto.com/u_8433245/4940441报错Filefile:/root/.flink/application_1651585577100_0002/application_1651585577100_0002-flink-conf.yaml5570135192338677571.tmp does not exist
就是权限不足: chmod 777 /root



