如何擦除namenode中的所有文件?

时间:2014-09-22 10:34:26

标签: java hadoop

我使用以下命令格式化了namenode:

sudo service hadoop-hdfs-namenode stop
rm -rf /var/lib/hadoop-hdfs/cache/hdfs/dfs/name
hadoop namenode -format
sudo service hadoop-hdfs-namenode start

但是当我尝试再次浏览namenode格式化后,它会显示文件。为什么不格式化删除所有文件?

hadoop namenode -format输出的最后几行:

14/09/22 03:25:14 INFO util.GSet: 0.029999999329447746% max memory 889 MB = 273.1 KB
14/09/22 03:25:14 INFO util.GSet: capacity      = 2^15 = 32768 entries
14/09/22 03:25:14 INFO namenode.AclConfigFlag: ACLs enabled? false
Re-format filesystem in Storage Directory /var/lib/hadoop-hdfs/cache/cloudera/dfs/name ? (Y or N) Y
14/09/22 03:25:16 INFO namenode.FSImage: Allocated new BlockPoolId: BP-1124575958-0.0.0.0-1411381516246
14/09/22 03:25:16 INFO common.Storage: Storage directory /var/lib/hadoop-hdfs/cache/cloudera/dfs/name has been successfully formatted.
14/09/22 03:25:16 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
14/09/22 03:25:16 INFO util.ExitUtil: Exiting with status 0
14/09/22 03:25:16 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at quickstart.cloudera/0.0.0.0
************************************************************/

格式化后,它仍然显示以前的文件:

[cloudera@quickstart name]$ hadoop fs -ls /
Found 3 items
-rw-r--r--   1 cloudera supergroup       9051 2014-09-22 02:50 /notice.html
drwxr-xr-x   - solr     solr                0 2014-09-19 02:30 /solr
drwxr-xr-x   - hdfs     supergroup          0 2014-09-19 02:26 /user

1 个答案:

答案 0 :(得分:0)

您必须格式化datanode以删除HDFS上的所有文件,这类似于namenode,

根据您的hadoop版本,

hadoop datanode -formathdfs datanode -formathdfs hadoop datanode - 格式。