hdfs:Name node is in safe mode 安全模式问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_38750084/article/details/91410199

将本地文件拷贝到hdfs上去,结果上错误:Name node is in safe mode

[root@sparkproject1 hadoop-mapreduce1-secure]# hadoop dfsadmin -safemode get
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

19/06/09 15:28:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Safe mode is ON
[root@sparkproject1 hadoop-mapreduce1-secure]# hadoop dfsadmin -safemode leave
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

这是因为在分布式文件系统启动的时候,开始的时候会有安全模式,当分布式文件系统处于安全模式的情况下,文件系统中的内容不允许修改也不允许删除,直到安全模式结束。安全模式主要是为了系统启动的时候检查各个DataNode上数据块的有效性,同时根据策略必要的复制或者删除部分数据块。运行期通过命令也可以进入安全模式。在实践过程中,系统启动的时候去修改和删除文件也会有安全模式不允许修改的出错提示,只需要等待一会儿即可。

可以通过以下命令来手动离开安全模式:

bin/hadoop dfsadmin -safemode leave  

用户可以通过dfsadmin -safemode value 来操作安全模式,参数value的说明如下:
enter - 进入安全模式
leave - 强制NameNode离开安全模式
get - 返回安全模式是否开启的信息
wait - 等待,一直到安全模式结束。

但是始终关闭不了,我猜是立马又启动安全模式了。

改hdfs-site.xml文件,重启n次也不行。

然后参考:

https://www.e-learn.cn/content/wangluowenzhang/1656603

Does this happen always Or only at the beginning only when you start hadoop?

If only at the beginning, then wait for sometime in order for NameNode to check if everything is okay before you access hdfs. If it's not leaving safemode after a considerable amount of time, that means there is some imbalance in the filesystem (e.g. under replicated or corrupted blocks). Under replicated blocks will be automatically balanced after some time. For corrupted blocks, you can have a look at output of this command:

hdfs fsck -list-corruptfileblocks

And try to delete corrupted blocks using:

hdfs fsck / -delete

然后赶紧查下磁盘,果然是满了。 

[root@sparkproject1 hadoop]# df -lh
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_sparkproject1-lv_root
                      5.5G  5.2G   41M 100% /
tmpfs                 504M     0  504M   0% /dev/shm
/dev/sda1             485M   30M  430M   7% /boot
[root@sparkproject1 hadoop]# 

清楚无用文件后再次执行:

[root@sparkproject1 hadoop-mapreduce1-secure]# hadoop dfsadmin -safemode leave
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

19/06/09 15:53:45 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Safe mode is OFF
[root@sparkproject1 hadoop-mapreduce1-secure]# hadoop dfsadmin -safemode get
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

19/06/09 15:53:49 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Safe mode is OFF
[root@sparkproject1 hadoop-mapreduce1-secure]# 
[root@sparkproject1 hadoop-mapreduce1-secure]# 
[root@sparkproject1 hadoop-mapreduce1-secure]#

看到安全模式已经关闭了。

猜你喜欢

转载自blog.csdn.net/weixin_38750084/article/details/91410199