根据这个http://www.thegeekstuff.com/2012/02/hadoop-pseudo-distributed-installation/网站尝试在我的笔记本电脑上以伪分发模式安装hadoop 0.21.0时,我遇到了这个例外来格式化namenode:
hadoop@host220:~/hadoop-0.21.0$ bin/hadoop namenode -format DEPRECATED: Use of this script to execute hdfs command is deprecated. Instead use the hdfs command for it. log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.apache.log4j.helpers.Loader.loadClass(Loader.java:179) at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:320) at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:121) at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:664) at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:647) at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:544) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:440) at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:476) at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:471) at org.apache.log4j.LogManager.(LogManager.java:125) at org.apache.log4j.Logger.getLogger(Logger.java:105) at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:289) at org.apache.commons.logging.impl.Log4JLogger.(Log4JLogger.java:109) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1116) at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:914) at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:604) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:336) at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:310) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685) at org.apache.hadoop.conf.Configuration.(Configuration.java:153) at org.apache.hadoop.hdfs.server.namenode.NameNode.(NameNode.java:137) log4j:ERROR Could not instantiate appender named "EventCounter". 12/10/31 10:58:42 INFO namenode.NameNode: STARTUP_MSG: /************************************************************ STARTUP_MSG: Starting NameNode STARTUP_MSG: host = host220/127.0.0.1 STARTUP_MSG: args = [-format] STARTUP_MSG: version = 0.21.0 STARTUP_MSG: classpath = /etc/hadoop:/usr/lib/jvm/java-6-sun/lib/tools.jar:/home/hadoop/hadoop-0.21.0/bin/../lib/*.jar STARTUP_MSG: build = https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.21 -r 985326; compiled by 'tomwhite' on Tue Aug 17 01:02:28 EDT 2010 ************************************************************/ 12/10/31 10:58:43 INFO namenode.FSNamesystem: defaultReplication = 3 12/10/31 10:58:43 INFO namenode.FSNamesystem: maxReplication = 512 12/10/31 10:58:43 INFO namenode.FSNamesystem: minReplication = 1 12/10/31 10:58:43 INFO namenode.FSNamesystem: maxReplicationStreams = 2 12/10/31 10:58:43 INFO namenode.FSNamesystem: shouldCheckForEnoughRacks = false 12/10/31 10:58:43 INFO security.Groups: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000 12/10/31 10:58:43 INFO namenode.FSNamesystem: fsOwner=hadoop 12/10/31 10:58:43 INFO namenode.FSNamesystem: supergroup=supergroup 12/10/31 10:58:43 INFO namenode.FSNamesystem: isPermissionEnabled=true 12/10/31 10:58:43 INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s) 12/10/31 10:58:43 INFO common.Storage: Image file of size 112 saved in 0 seconds. 12/10/31 10:58:43 INFO common.Storage: Storage directory /tmp/hadoop-hadoop/dfs/name has been successfully formatted. 12/10/31 10:58:43 INFO namenode.NameNode: SHUTDOWN_MSG: /************************************************************ SHUTDOWN_MSG: Shutting down NameNode at host220/127.0.0.1 ************************************************************/
最后它成功地格式化了namenode,但有例外。 然后我尝试使用“start-all.sh”启动dfs和mapreduce,但失败了。以下是控制台输出:
hadoop@host220:~/hadoop-0.21.0$ bin/start-all.sh This script is Deprecated. Instead use start-dfs.sh and start-mapred.sh mkdir: cannot create directory `/var/run/hadoop': Permission denied starting namenode, logging to /var/log/hadoop/hadoop/hadoop-hadoop-namenode-host220.out /home/hadoop/hadoop-0.21.0/bin/../bin/hadoop-daemon.sh: line 127: /var/run/hadoop/hadoop-hadoop-namenode.pid: No such file or directory log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) localhost: mkdir: cannot create directory `/var/run/hadoop': Permission denied localhost: starting datanode, logging to /var/log/hadoop/hadoop/hadoop-hadoop-datanode-host220.out localhost: /home/hadoop/hadoop-0.21.0/bin/hadoop-daemon.sh: line 127: /var/run/hadoop/hadoop-hadoop-datanode.pid: No such file or directory localhost: log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. localhost: java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter localhost: at java.net.URLClassLoader$1.run(URLClassLoader.java:202) localhost: at java.security.AccessController.doPrivileged(Native Method) localhost: at java.net.URLClassLoader.findClass(URLClassLoader.java:190) localhost: at java.lang.ClassLoader.loadClass(ClassLoader.java:307) localhost: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) localhost: at java.lang.ClassLoader.loadClass(ClassLoader.java:248) localhost: at java.lang.Class.forName0(Native Method) localhost: at java.lang.Class.forName(Class.java:169) localhost: mkdir: cannot create directory `/var/run/hadoop': Permission denied localhost: starting secondarynamenode, logging to /var/log/hadoop/hadoop/hadoop-hadoop-secondarynamenode-host220.out localhost: /home/hadoop/hadoop-0.21.0/bin/hadoop-daemon.sh: line 127: /var/run/hadoop/hadoop-hadoop-secondarynamenode.pid: No such file or directory localhost: log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. localhost: java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter localhost: at java.net.URLClassLoader$1.run(URLClassLoader.java:202) localhost: at java.security.AccessController.doPrivileged(Native Method) localhost: at java.net.URLClassLoader.findClass(URLClassLoader.java:190) localhost: at java.lang.ClassLoader.loadClass(ClassLoader.java:307) localhost: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) localhost: at java.lang.ClassLoader.loadClass(ClassLoader.java:248) localhost: at java.lang.Class.forName0(Native Method) localhost: at java.lang.Class.forName(Class.java:169) mkdir: cannot create directory `/var/run/hadoop': Permission denied starting jobtracker, logging to /var/log/hadoop/hadoop/hadoop-hadoop-jobtracker-host220.out /home/hadoop/hadoop-0.21.0/bin/../bin/hadoop-daemon.sh: line 127: /var/run/hadoop/hadoop-hadoop-jobtracker.pid: No such file or directory log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) localhost: mkdir: cannot create directory `/var/run/hadoop': Permission denied localhost: starting tasktracker, logging to /var/log/hadoop/hadoop/hadoop-hadoop-tasktracker-host220.out localhost: /home/hadoop/hadoop-0.21.0/bin/hadoop-daemon.sh: line 127: /var/run/hadoop/hadoop-hadoop-tasktracker.pid: No such file or directory localhost: log4j:ERROR Could not instantiate class [org.apache.hadoop.log.metrics.EventCounter]. localhost: java.lang.ClassNotFoundException: org.apache.hadoop.log.metrics.EventCounter localhost: at java.net.URLClassLoader$1.run(URLClassLoader.java:202) localhost: at java.security.AccessController.doPrivileged(Native Method) localhost: at java.net.URLClassLoader.findClass(URLClassLoader.java:190) localhost: at java.lang.ClassLoader.loadClass(ClassLoader.java:307) localhost: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) localhost: at java.lang.ClassLoader.loadClass(ClassLoader.java:248) localhost: at java.lang.Class.forName0(Native Method) localhost: at java.lang.Class.forName(Class.java:169)