[root@nn01 bin]# ./hadoop namenode -format
12/05/21 06:13:51 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = nn01/127.0.0.1
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 0.20.2
STARTUP_MSG: build =
https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20 -r 911707; compiled by ‘chrisdo‘ on Fri Feb 19 08:07:34 UTC 2010
************************************************************/
Re-format filesystem in /tmp/hadoop-root/dfs/name ? (Y or N) Y
12/05/21 06:14:01 INFO namenode.FSNamesystem: fsOwner=root,root,bin,daemon,sys,adm,disk,wheel
12/05/21 06:14:01 INFO namenode.FSNamesystem: supergroup=supergroup
12/05/21 06:14:01 INFO namenode.FSNamesystem: isPermissionEnabled=true
12/05/21 06:14:01 INFO common.Storage: Cannot lock storage /tmp/hadoop-root/dfs/name. The directory is already locked.
12/05/21 06:14:01 ERROR namenode.NameNode: java.io.IOException: Cannot lock storage /tmp/hadoop-root/dfs/name. The directory is already locked.
at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.lock(Storage.java:510)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:1087)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:1110)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:856)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:948)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:965)
12/05/21 06:14:01 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at nn01/127.0.0.1
./hadoop namenode -format 命令是格式化命名空间。一定是在未启动 hadoop 服务的时候才干执行。出现这个错误提示是由于 hadoop 的服务是子执行状态。