关闭进程:
bash
stop-dfs.sh
格式化:
bash
hadoop namenode -format
出现报错信息:
bash
23/10/03 22:27:04 WARN fs.FileUtil: Failed to delete file or dir [/usr/data/hadoop/tmp/dfs/name/current/fsimage_0000000000000000000.md5]: it still exists.
23/10/03 22:27:04 WARN fs.FileUtil: Failed to delete file or dir [/usr/data/hadoop/tmp/dfs/name/current/seen_txid]: it still exists.
23/10/03 22:27:04 WARN fs.FileUtil: Failed to delete file or dir [/usr/data/hadoop/tmp/dfs/name/current/VERSION]: it still exists.
23/10/03 22:27:04 WARN fs.FileUtil: Failed to delete file or dir [/usr/data/hadoop/tmp/dfs/name/current/fsimage_0000000000000000000]: it still exists.
23/10/03 22:27:04 WARN namenode.NameNode: Encountered exception during format:
java.io.IOException: Cannot remove current directory: /usr/data/hadoop/tmp/dfs/name/current
at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.clearDirectory(Storage.java:358)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:571)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:592)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:185)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:1211)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1655)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1782)
23/10/03 22:27:04 ERROR namenode.NameNode: Failed to start namenode.
java.io.IOException: Cannot remove current directory: /usr/data/hadoop/tmp/dfs/name/current
at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.clearDirectory(Storage.java:358)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:571)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:592)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:185)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:1211)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1655)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1782)
23/10/03 22:27:04 INFO util.ExitUtil: Exiting with status 1: java.io.IOException: Cannot remove current directory: /usr/data/hadoop/tmp/dfs/name/current
根��错误日志,问题出在删除 /usr/data/hadoop/tmp/dfs/name/current
目录上。请尝试以下方法解决该问题:
1.权限检查:确保你拥有足够的权限来删除该目录。使用以下命令以root用户身份删除该目录:
bash
sudo rm -r /usr/data/hadoop/tmp/dfs/name/current
执行完这一步正常情况下就可以直接执行第4步,如果不成功再往下执行
2.检查文件系统:确保文件系统没有被挂载为只读模式。运行以下命令确认文件系统的状态:
bash
mount | grep /usr/data/hadoop
3.清理临时文件:如果以上方法无效,尝试清理掉 /usr/data/hadoop/tmp
目录下的所有文件和子目录。
bash
sudo rm -r /usr/data/hadoop/tmp/*
4.清理完成后,重新启动HDFS并进行格式化操作:
bash
hdfs namenode -format
start-dfs.sh