在hadoop群集安装结束后,进行格式测试出现问题如下
格式化
cd /data/hadoop/bin
./hdfs namenode -format
15/01/21 05:21:17 WARN fs.FileUtil: Failed to delete file or dir [/data/hadoop/dfs/name/current]: it still exists.
15/01/21 05:21:17 WARN namenode.NameNode: Encountered exception during format:
java.io.IOException: Cannot remove current directory: /data/hadoop/dfs/name/current
at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.clearDirectory(Storage.java:332)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:546)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:567)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:148)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:899)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1310)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1424)
15/01/21 05:21:17 FATAL namenode.NameNode: Exception in namenode join
java.io.IOException: Cannot remove current directory: /data/hadoop/dfs/name/current
at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.clearDirectory(Storage.java:332)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:546)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:567)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:148)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:899)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1310)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1424)
然后在hadoop,jps显示的结果是5432 Jps
主要原因是在配置hadoop是使用的root用户,然而格式化测试使用的是hadoop用户,所以出现以上的问题!
解决办法是将hadoop的安装目录的owner更改成hadoop,然后重新格式化就可以了
具体操作是chown -R hadoop /data/hadoop
注释:如果去掉-R就是更改一个文件或者文件夹,如果有-R就把整个文件目录下的文件都更改过来了