写点什么

Windows 下 hadoop 环境搭建之 NameNode 启动报错

作者:北桥苏
  • 2023-05-13
    广东
  • 本文字数:2700 字

    阅读完需:约 9 分钟

前言:

​ 因为平时工作和日常接触到的大都是的中型项目,所以少有个性化推荐等涉及大数据的功能。但是后期应该也会在自己项目中添加信息推荐模块,所以就开始关注 spark,hadoop,Thrift 等工具,以下就以 hadoop 先开始,包括环境搭建和配置过程中踩坑过程。


​ 关于 hadoop 的环境搭建,网上也有各种各样的教程。拿来直接按着他们的方法来,前期当前问题不大,但是呢,可能在安装过程中由于每个工具的版本不一致。又或者配置中文件路径不一样等等都很可能导致踩坑无数。不管是开发调测 bug 还是软件环境搭建,我觉得最好的方法就是看日志,看到 error 和 warn 再把错误信息拿去查询,比起 xxxx 启动报错,xxxx 怎么出错了等等确实要快。


环境:

\1. windows10


\2. jdk8


\3. hadoop2.7.7,点击下载


简易搭建:

1. windows 下 jdk8 的安装,略过。


2. hadoop2.7.7 下载完成。



3. hadooponwindows-master.zip 文件包下载。


https://pan.baidu.com/s/1vxtBxJyu7HNmOhsdjLZkYw 提取码:y9a4, 这个是我在网上找的网盘下载地址。hadoop 和 hadooponwindows 全都下载完成后,将 hadooponwindows-master 的 bin 和 etc 替换掉 hadoop2.7.7 的 bin 和 etc 文件。


4. hadoop 环境变量配置,略过。



5. hadoop 配置。


(1). hadoop-env.cmd 配置:


找到 hadoop 的 etc/hadoop 下的 hadoop-env.cmd 并打开,设置本地 jdk 的位置,路径中不能有汉字特殊字符等,如下。



(2). hdfs-site.xml 配置:


找到 hadoop 的 etc/hadoop 下的 hdfs-site.xml 并打开,在 configuration 添加如下参数。特别注意的是 namenode 和 datanode 两个节点数据存储位置,一定要添加 file://协议。并且绝对路径前一定要加“/”,因为这个会导致出现报错的问题,后面再讲。还有 windows 的路径标识“/”,配置如下。


<?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 at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed 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 and limitations under the License. See accompanying LICENSE file.-->
<!-- Put site-specific property overrides in this file. -->
<configuration> <property> <name>dfs.replication</name> <value>1</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///E:/2setsoft/1dev/hadooponwindows/data/namenode</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///E:/2setsoft/1dev/hadooponwindows/data/datanode</value> </property></configuration>
复制代码


(3). core-site.xml 配置:


找到 hadoop 的 etc/hadoop 下的 core-site.xml 并打开,在 configuration 添加如下参数。特别注意的是 hdfs 的端口,因为作为开发本地出现 9000 端口应该很多,所以这里就先强调记得这里是配置端口的就行,以下是配置。


<?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 at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed 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 and limitations under the License. See accompanying LICENSE file.-->
<!-- Put site-specific property overrides in this file. -->
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://127.0.0.1:9500</value> </property> <property> <name>ipc.client.connect.max.retries</name> <value>100</value> <description>Indicates the number of retries a client will make to establish a server connection. </description> </property> <property> <name>ipc.client.connect.retry.interval</name> <value>10000</value> <description>Indicates the number of milliseconds a client will wait for before retrying to establish a server connection. </description> </property> </configuration>
复制代码


6. hadoop 启动。


(1). namenode 格式化:


打开 cmd 面板,输入 hdfs namenode -format。出现需要确认创建 namenode 文件夹的基本上是没问题。




(2). hadoop 启动:


切换到 hadoop 的 sbin 目录下执行 start-all 就会弹出四个窗口,datanode, namenode, resourcemanager, nodemanager。






(3). 检查各节点启动情况:


输入 jps -,出现以下内容表示全部启动成功,以上四个少了一个都是有问题,就需要去对应窗口查看报错信息查询了。



(4). 查看 web 控制台:


hadoop 的 web 控制台:127.0.0.1:50070



yarn 的 web 控制台:127.0.0.1:8088


namenode 启动报错集锦

\1. namenode.FSEditLog: No class configured for E, dfs.namenode.edits.journal-plugin.E is empty


​ 这个报错的原因就是 hdfs-site.xml 配置 namenode 文件位置开头没有加“/”,这个已经在上面配置的时候已经强调了。


\2. common.Util: Path /E:/2setsoft/1dev/hadooponwindows/data/namenode should be specified as a URI in configuration files. P


​ 这个报错的原因还是 hdfs-site.xml 配置 namenode 文件位置时没有添加“file://”,所以上面的配置时最正确的。


\3. ERROR namenode.NameNode: Failed to start namenode. java.net.BindException: Problem binding to [127.0.0.1:9000] java.net.BindException: Address already in use: bind;


​ 这个报错的原因就是 9000 端口已经被绑定了,所以前面强调 core-site.xml 的端口时说的就是这里的错误,解决方法就是修改一个其他的端口就可以了。



用户头像

北桥苏

关注

公众号:ZERO开发 2023-05-08 加入

专注后端实战技术分享,不限于PHP,Python,JavaScript, Java等语言,致力于给猿友们提供有价值,有干货的内容。

评论

发布
暂无评论
Windows下hadoop环境搭建之NameNode启动报错_大数据_北桥苏_InfoQ写作社区