首页 > 技术文章 > hadoop format 重新格式化

zhf123 2019-12-13 11:13 原文

前文:如果格式化完之后,使用jps命令发现进程都已经启动,但是使用web页面打不开hadoop的网页,可能原因就是防火墙没关或者是哪个配置过程配错了。

1.关闭防火墙

一般最好是关闭防火墙比较关闭。 systemctl  stop   firewalld.service 关闭防火墙;  禁止自动启动就用 systemctl  disable  firewalld.service  . 就可以了。

     还有个防火墙是selinux: 要设置为  vi  /etc/selinux.config    

 关闭再重新访问网页还是不行,需要检查配置是否出错。

(我在配置的过程中是因为忘记把hdfs-site.xml.template文件重命名为hdfs-site.xml)。

每次格式化后,名称结点 的clusterID(集群ID)会被新建,而数据结点的clusterID还是原来的,造成名称结点和数据节点的clusterID不一致。

2. 停止Hadoop所有进程

$ stop-all.sh

3. 删除在core-site.xml和hdfs-site.xml中指定的data文件夹下面的数据

[root@zhf123 tmp]# pwd
/opt/module/cdh/hadoop-2.5.0-cdh5.3.6/data/tmp
[root@zhf123 tmp]# ls
dfs  nm-local-dir
[root@zhf123 tmp]# rm -rf ./*

4. 删除$HADOOP_HOME目录下的logs和tmp目录(关键步骤)

$ cd $HADOOP_HOME
$ ls
bin include libexec logs README.txt share
etc lib LICENSE.txt NOTICE.txt sbin tmp
$ rm -rf logs tmp

5. 重新格式化文件系统

$ hdfs namenode -format

6. 启动Hadoop进程

$ start-all.sh

7. 确认Hadoop进程是否已开启

$ jps
7366 NameNode
8278 Jps
7640 SecondaryNameNode
7849 ResourceManager
7482 DataNode
7967 NodeManager

8.重新使用浏览器访问hdfs页面

 

 OK,没问题了,大功告成。

参考链接:

https://blog.csdn.net/qq_42881421/article/details/82958839

https://blog.csdn.net/hylpeace/article/details/88371411

推荐阅读