1、启动Hadoop
- ubuntu@ubuntu:~/hadoop-1.0.4/bin$ ./start-all.sh
- starting namenode, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-namenode-ubuntu.out
- localhost: starting datanode, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-datanode-ubuntu.out
- localhost: starting secondarynamenode, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-secondarynamenode-ubuntu.out
- starting jobtracker, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-jobtracker-ubuntu.out
- localhost: starting tasktracker, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-tasktracker-ubuntu.out
2、访问localhost:50070失败,说明namenode启动失败
3、查看namenode启动日志
- ubuntu@ubuntu:~/hadoop-1.0.4/bin$ cd ../logs
- ubuntu@ubuntu:~/hadoop-1.0.4/logs$ view hadoop-ubuntu-namenode-ubuntu.log
- /************************************************************
- STARTUP_MSG: Starting NameNode
- STARTUP_MSG: host = ubuntu/127.0.1.1
- STARTUP_MSG: args = []
- STARTUP_MSG: version = 1.0.4
- STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1393290; compiled by 'hortonfo' on Wed Oct 3 05:13:58 UTC 2012
- ************************************************************/
- 2013-01-24 07:05:46,936 INFO org.apache.hadoop.metrics2.impl.MetricsConfig: loaded properties from hadoop-metrics2.properties
- 2013-01-24 07:05:46,945 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source MetricsSystem,sub=Stats registered.
- 2013-01-24 07:05:46,945 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Scheduled snapshot period at 10 second(s).
- 2013-01-24 07:05:46,945 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system started
- 2013-01-24 07:05:47,053 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source ugi registered.
- 2013-01-24 07:05:47,058 WARN org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Source name ugi already exists!
- 2013-01-24 07:05:47,064 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source jvm registered.
- 2013-01-24 07:05:47,064 INFO org.apache.hadoop.metrics2.impl.MetricsSourceAdapter: MBean for source NameNode registered.
- 2013-01-24 07:05:47,092 INFO org.apache.hadoop.hdfs.util.GSet: VM type = 32-bit
- 2013-01-24 07:05:47,092 INFO org.apache.hadoop.hdfs.util.GSet: 2% max memory = 19.33375 MB
- 2013-01-24 07:05:47,092 INFO org.apache.hadoop.hdfs.util.GSet: capacity = 2^22 = 4194304 entries
- 2013-01-24 07:05:47,092 INFO org.apache.hadoop.hdfs.util.GSet: recommended=4194304, actual=4194304
- 2013-01-24 07:05:47,140 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: fsOwner=ubuntu
- 2013-01-24 07:05:47,140 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: supergroup=supergroup
- 2013-01-24 07:05:47,140 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: isPermissionEnabled=true
- 2013-01-24 07:05:47,143 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: dfs.block.invalidate.limit=100
- 2013-01-24 07:05:47,143 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s)
- 2013-01-24 07:05:47,154 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem: Registered FSNamesystemStateMBean and NameNodeMXBean
- 2013-01-24 07:05:47,169 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: Caching file names occuring more than 10 times
- 2013-01-24 07:05:47,174 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.
- java.io.IOException: NameNode is not formatted.
- at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:330)
- at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:100)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:388)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:362)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:276)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:496)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1279)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1288)
- 2013-01-24 07:05:47,175 ERROR org.apache.hadoop.hdfs.server.namenode.NameNode: java.io.IOException: NameNode is not formatted.
- at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:330)
- at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:100)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:388)
- at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:362)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:276)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:496)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1279)
- at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1288)
其中"2013-01-24 07:05:47,174 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.
java.io.IOException: NameNode is not formatted."一行显示,namenode未初始化。
4、初始化namenode,却提示是否重新初始化namenode,于是输入Y。
- ubuntu@ubuntu:~/hadoop-1.0.4$ bin/hadoop namenode -format
- 13/01/24 07:05:08 INFO namenode.NameNode: STARTUP_MSG:
- /************************************************************
- STARTUP_MSG: Starting NameNode
- STARTUP_MSG: host = ubuntu/127.0.1.1
- STARTUP_MSG: args = [-format]
- STARTUP_MSG: version = 1.0.4
- STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1393290; compiled by 'hortonfo' on Wed Oct 3 05:13:58 UTC 2012
- ************************************************************/
- Re-format filesystem in /home/ubuntu/hadoop-1.0.4/tmp/dfs/name ? (Y or N) y
- Format aborted in /home/ubuntu/hadoop-1.0.4/tmp/dfs/name
- 13/01/24 07:05:12 INFO namenode.NameNode: SHUTDOWN_MSG:
- /************************************************************
- SHUTDOWN_MSG: Shutting down NameNode at ubuntu/127.0.1.1
- ************************************************************/
5、初始化后,重新启动hadoop,localhost:50070仍然访问失败。查看namenode启动日志,依然报namenode没有初始化的错误。
6、于是删除core-site.xml配置文件中配置的tmp目录下的所有文件;
将hadoop所有服务停止;
再次启动hadoop,访问localhost:50070成功。
- ubuntu@ubuntu:~/hadoop-1.0.4/tmp$ rm -rf *
- ubuntu@ubuntu:~/hadoop-1.0.4/tmp$ cd ../bin
- ubuntu@ubuntu:~/hadoop-1.0.4/bin$ ./stop-all.sh
- stopping jobtracker
- localhost: stopping tasktracker
- no namenode to stop
- localhost: stopping datanode
- localhost: stopping secondarynamenode
- ubuntu@ubuntu:~/hadoop-1.0.4/bin$ hadoop namenode -format
- 13/01/24 07:10:45 INFO namenode.NameNode: STARTUP_MSG:
- /************************************************************
- STARTUP_MSG: Starting NameNode
- STARTUP_MSG: host = ubuntu/127.0.1.1
- STARTUP_MSG: args = [-format]
- STARTUP_MSG: version = 1.0.4
- STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1393290; compiled by 'hortonfo' on Wed Oct 3 05:13:58 UTC 2012
- ************************************************************/
- 13/01/24 07:10:46 INFO util.GSet: VM type = 32-bit
- 13/01/24 07:10:46 INFO util.GSet: 2% max memory = 19.33375 MB
- 13/01/24 07:10:46 INFO util.GSet: capacity = 2^22 = 4194304 entries
- 13/01/24 07:10:46 INFO util.GSet: recommended=4194304, actual=4194304
- 13/01/24 07:10:46 INFO namenode.FSNamesystem: fsOwner=ubuntu
- 13/01/24 07:10:46 INFO namenode.FSNamesystem: supergroup=supergroup
- 13/01/24 07:10:46 INFO namenode.FSNamesystem: isPermissionEnabled=true
- 13/01/24 07:10:46 INFO namenode.FSNamesystem: dfs.block.invalidate.limit=100
- 13/01/24 07:10:46 INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s)
- 13/01/24 07:10:46 INFO namenode.NameNode: Caching file names occuring more than 10 times
- 13/01/24 07:10:46 INFO common.Storage: Image file of size 112 saved in 0 seconds.
- 13/01/24 07:10:46 INFO common.Storage: Storage directory /home/ubuntu/hadoop-1.0.4/tmp/dfs/name has been successfully formatted.
- 13/01/24 07:10:46 INFO namenode.NameNode: SHUTDOWN_MSG:
- /************************************************************
- SHUTDOWN_MSG: Shutting down NameNode at ubuntu/127.0.1.1
- ************************************************************/
- ubuntu@ubuntu:~/hadoop-1.0.4/bin$ ./start-all.sh
- starting namenode, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-namenode-ubuntu.out
- localhost: starting datanode, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-datanode-ubuntu.out
- localhost: starting secondarynamenode, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-secondarynamenode-ubuntu.out
- starting jobtracker, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-jobtracker-ubuntu.out
- localhost: starting tasktracker, logging to /home/ubuntu/hadoop-1.0.4/libexec/../logs/hadoop-ubuntu-tasktracker-ubuntu.out
7、原来是修改了配置文件中的tmp目录后没有对hdfs做初始化,导致启动hadoop时报namenode没有初始化的错误。