flink学习之旅(二)

news/2025/2/14 0:00:10/

  目前flink中的资源管理主要是使用的hadoop圈里的yarn,故此需要先搭建hadoop环境并启动yarn和hdfs,由于看到的教程都是集群版,现实是只有1台机器,故此都是使用这台机器安装。

1.下载对应hadoop安装包

https://dlcdn.apache.org/hadoop/common/hadoop-3.3.5/hadoop-3.3.5.tar.gz

2.解压到指定路径比如这里我选择的如下:

3.修改hadoop相关配置

cd  /root/dxy/hadoop/hadoop-3.3.5/etc/hadoop

vi core-site.xml  核心配置文件

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
--><!-- Put site-specific property overrides in this file. --><configuration>
<!-- 指定NameNode的地址 --><property><name>fs.defaultFS</name><value>hdfs://10.26.141.203:8020</value></property><!-- hadoop数据的存储目录 --><property><name>hadoop.tmp.dir</name><value>/root/dxy/hadoop/hadoop-3.3.5/datas</value></property><property><name>hadoop.http.staticuser.user</name><value>root</value></property>
</configuration>

 vi  hdfs-site.xml 修改hdfs配置文件


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
--><!-- Put site-specific property overrides in this file. --><configuration>
<!-- 指定NameNode的外部web访问地址 --><property><name>dfs.namenode.http-address</name><value>10.26.141.203:9870</value></property><!-- 指定secondary NameNode的外部web访问地址 --><property><name>dfs.namenode.secondary.http-address</name><value>10.26.141.203:9868</value></property>
</configuration>

vi yarn-site.xml 修改yarn配置

<?xml version="1.0"?>
<!--Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. See accompanying LICENSE file.
-->
<configuration><!-- Site specific YARN configuration properties -->
<!--指定MR走shuffle --><property><name>yarn.nodemanager.aux-services</name><value>mapreduce_shuffle</value></property><!--指定ResourceManager的地址--><property><name>yarn.resourcemanager.hostname</name><value>10.26.141.203</value></property><!--环境变量的继承--><property><name>yarn.nodemanager.env-whitelist</name><value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value></property></configuration>
~                             

 vim mapred-site.xml  

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><configuration><!-- 指定MapReduce程序运行在Yarn上 --><property><name>mapreduce.framework.name</name><value>yarn</value></property>
</configuration>

vi workers 填上 服务器ip 如:

10.26.141.203

修改环境变量:

export HADOOP_HOME=/root/dxy/hadoop/hadoop-3.3.5
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin

export HADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
export HADOOP_CLASSPATH=`hadoop classpath`

source /etc/profile

完成后可以执行hadoop version 查看是否配置成功如下:

hdfs第一次启动时需要格式化

hdfs namenode -format

启动yarn和hdfs 

 sbin/start-dfs.sh 

        sbin/start-yarn.sh

使用界面访问是否启动成功:

使用application运行flink任务并提交到yarn上如下:

bin/flink run-application -t yarn-application -c com.dxy.learn.demo.SocketStreamWordCount FlinkLearn-1.0-SNAPSHOT.jar 


http://www.ppmy.cn/news/1363426.html

相关文章

Adobe Premiere Pro 引入AI提升对话音质;Stable Diffusion:AI图像生成简介

&#x1f989; AI新闻 &#x1f680; Adobe Premiere Pro 引入AI提升对话音质 摘要&#xff1a;Adobe公司最近发布了一项更新&#xff0c;为其视频编辑软件Premiere Pro&#xff08;22.4版本&#xff09;新增了一个名为Enhance Speech的功能&#xff0c;通过AI技术自动调节对…

‘vue/max-attributes-per-line‘报错属性应该单独一行,prettier可能也报错。

原因 一般是vscode和项目里设置不一致造成的。设置了保存自动格式化&#xff0c;这个是优先使用vscode里的设置的。所以要注意保持一致。 相关设置 项目里eslint配置.eslintrc.js&#xff0c;singleline这个设置表示一行最多放几个属性。设置几个都很难配合prettier的printW…

opengles 背面剔除介绍(十二)

文章目录 前言一、OpenGL ES 剔除功能简介二、Opengl ES 剔除功能相关的API1.使能剔除功能2. 配置面剔除模式3. 设置剔除面的顺序4. 禁用剔除功能总结参考资料前言 本文主要介绍 opengles3.0 中的背面剔除相关知识,对于绘制3d 图形, 经常会用到它,并且它能提升渲染效率 软硬…

Vue+SpringBoot打造开放实验室管理系统

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、研究内容2.1 实验室类型模块2.2 实验室模块2.3 实验管理模块2.4 实验设备模块2.5 实验订单模块 三、系统设计3.1 用例设计3.2 数据库设计 四、系统展示五、样例代码5.1 查询实验室设备5.2 实验放号5.3 实验预定 六、免责说明 一、摘…

c#压缩文件函数

/// <summary> /// 压缩文件 /// </summary> /// <param name"sourceFile">要压缩的文件名</param> /// <param name"destFile">压缩后的文件名</param> …

启动spark-shell时报错java.lang.NumberFormatException: For input string: “0x100“

一、问题描述 安装完Spark后&#xff0c;启动spark shell时报错 java.lang.NumberFormatException: For input string: "0x100" 如下图&#xff1a; 二、解决办法 1.更换scala的版本 2.更改环境变量 使用vim编辑器打开用户的环境变量配置文件 vim ~/.bashrc s…

web前端框架设计-准备课

web前端框架设计-准备课 一.预习笔记 1.标签 div/span/a/img/button 2.CSS 基础样式&#xff1a;width、height、id 文字样式&#xff1a;font-size/color/letter-spacing 背景样式: background/background-repeat 盒子样式: margin/padding/border 定位:position 3.J…

php伪协议 [SWPUCTF 2022 新生赛]ez_ez_php(revenge)

打开题目 题目源代码如下 <?php error_reporting(0); if (isset($_GET[file])) {if ( substr($_GET["file"], 0, 3) "php" ) {echo "Nice!!!";include($_GET["file"]);} else {echo "Hacker!!";} }else {highlight_fi…