在hadoop启动的时候,会出现各种各样的问题,NameNode,JobTracker等各个模块都会有莫名奇妙的问题出现,在这里对hdfs的问题进行一下简单的记录。
注:问题无先后次序,可能这次没遇到下次又遇到,所以统一记录在次
一:HDFS问题
1:HDFS initialized but not ‘healthy’ yet, waiting…
这个日志会在启动hadoop的时候在JobTracker的log日志文件中出现,在这里就是hdfs出现问题,导致DataNode无法启动,这里唯一的解决方式就是把所有的NameNode管理的路径下的文件删除然后重新执行namenode -format,而删除的地方主要有存放临时数据的tmp路径,存放数据的data路径还有name路径,全部删除之后重新format次问题就解决了
2:在执行hadoop程序的时候出现Name node is in safe mode
这个异常一般就直接会在IDE的控制台输出,这个错误的主要导致原因是,datanode不停在丢失数据,所以此时namenode就强制本身进入safe mode模式,在该模式下对数据只可以进行读操作而不能进行写操作。解决此异常很简单,直接执行命令让namenode离开次模式就可以了。./hadoop dfsadmin-safemode leave
3:原来hadoop一直可以正常启动,有天在启动之后查看namenode的log发现如下in_use.lock (Permission denied)错误日志:
INFO namenode.FSNamesystem: isAccessTokenEnabled=false accessKeyUpdateInterval=0 min(s), accessTokenLifetime=0 min(s)
>> 1INFO metrics.FSNamesystemMetrics: Initializing
>> FSNamesystemMetrics using context
>> object:org.apache.hadoop.metrics.spi.NoEmitMetricsContext
ERROR namenode.FSNamesystem: FSNamesystem initialization failed. java.io.FileNotFoundException: /var/lib/hadoop-0.20/cache/hadoop/dfs/name/in_use.lock (Permission denied)
>> at java.io.RandomAccessFile.open(Native Method)
>> at java.io.RandomAccessFile.<init>(RandomAccessFile.java:216)
>> at
>> org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.tryLock(Storage.java:614)
>> at
>> org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.lock(Storage.java:591)
>> at
>> org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.analyzeStorage(Storage.java:449)
>> at
>> org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:304)
>> at
>> org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:110)
>> at
>> org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:372)
>> at
>> org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:335)
>> at
>> org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:271)
>> at
>> org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:467)
>> at
>> org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1330)
>> at
>> org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1339)
这有两种场景出现,
1):在原来正常的时候,有一次突然使用了原来不同的用户启动了一次hadoop。这种场景会产生一个in_use.lock 文件夹在你设置的目录中,这时候可以删除这个文件夹直接,然后重新启动
2):在格式化hadoop的时候和当期启动的用户不是同一个,也会导致该问题。这个时候可以使用格式化hadoop的那个用户重新启动hadoop。也可以解决此错误。
该问题的参考地址:
打开链接
4:namenode 异常
2013-08-20 14:10:08,946 INFO org.apache.hadoop.hdfs.server.common.Storage: Cannot access storage directory /var/lib/hadoop/cache/hadoop/dfs/name
2013-08-20 14:10:08,947 ERROR org.apache.hadoop.hdfs.server.namenode.FSNamesystem: FSNamesystem initialization failed.
org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /var/lib/hadoop/cache/hadoop/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:316)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:104)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:427)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:388)
at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:277)
at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:497)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1298)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1307)
2013-08-20 14:10:08,948 ERROR org.apache.hadoop.hdfs.server.namenode.NameNode: org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /var/lib/hadoop/cache/hadoop/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:316)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:104)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:427)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.<init>(FSNamesystem.java:388)
at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:277)
at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:497)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1298)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1307)
5:格式化HDFS,NameNode时候遇到不能创建文件的问题
java.io.IOException: Cannot create directory /home/hadoop/YarnRun/name1/current
at org.apache.hadoop.hdfs.server.common.Storage$StorageDirectory.clearDirectory(Storage.java:301)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:523)
at org.apache.hadoop.hdfs.server.namenode.NNStorage.format(NNStorage.java:544)
at org.apache.hadoop.hdfs.server.namenode.FSImage.format(FSImage.java:147)
at org.apache.hadoop.hdfs.server.namenode.NameNode.format(NameNode.java:837)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1213)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1320)
格式化HDFS,NameNode时候遇到文件不能重命名的问题
java.io.IOException: Could not rename temporary file /home/hadoop/YarnRun/name1/current/fsimage_0000000000000000000.md5.tmp to /home/hadoop/YarnRun/name1/current/fsimage_0000000000000000000.md5
at org.apache.hadoop.hdfs.util.AtomicFileOutputStream.close(AtomicFileOutputStream.java:77)
at org.apache.hadoop.hdfs.util.MD5FileUtils.saveMD5File(MD5FileUtils.java:145)
at org.apache.hadoop.hdfs.server.namenode.FSImage.saveFSImage(FSImage.java:855)
at org.apache.hadoop.hdfs.server.namenode.FSImage$FSImageSaver.run(FSImage.java:882)
at java.lang.Thread.run(Thread.java:662)
14/02/19 17:16:53 ERROR common.Storage: Error reported on storage directory Storage Directory /home/hadoop/YarnRun/name1
14/02/19 17:16:53 WARN common.Stordfs.namenode.name.dirage: About to remove corresponding storage: /home/hadoop/YarnRun/name1
低级错误
,在定义dfs.namenode.name.dir属性中的value的时候定义了两个文件夹,但是都命名成为了name1,导致格式化的时候错误。解决方法很简单把其中的一个修改为name2就解决了。
7:在部署集群YARN的时候,遇到问题namenode Incompatible clusterIDs
1 #Tue Mar 18 14:25:10 CST 2014
2 storageID=DS-1603563053-192.168.100.5-50011-1392963732616
3 clusterID=CID-8ac29142-6997-4ec2-b518-8ba90e3fd9eb
4 cTime=0
5 storageType=DATA_NODE
6 layoutVersion=-47
~
二:MapReduce问题
1:hadoop /tmp/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1
启动了集群之后发现namenode起来了,但是各个slave节点的datanode却都没起起来。去看namenode日志发现错误日志:
-
INFO org.apache.hadoop.ipc.Server: IPC Server handler
1
on
9000
, call addBlock(/opt/hadoop/tmp/mapred/system/jobtracker.info, DFSClient_502181644) from
127.0
.
0.1
:
2278
: error: java.io.IOException: File /opt/hadoop/tmp/mapred/system/jobtracker.info could only be replicated to
0
nodes, instead of
1
-
java.io.IOException: File /opt/hadoop/tmp/mapred/system/jobtracker.info could only be replicated to
0
nodes, instead of
1
-
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:
1271
) -
at org.apache.hadoop.hdfs.server.namenode.NameNode.addBlock(NameNode.java:
422
) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
-
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39
) -
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25
) -
at java.lang.reflect.Method.invoke(Method.java:
597
) -
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:
508
) -
at org.apache.hadoop.ipc.Server$Handler$
1
.run(Server.java:
959
) -
at org.apache.hadoop.ipc.Server$Handler$
1
.run(Server.java:
955
) - at java.security.AccessController.doPrivileged(Native Method)
-
at javax.security.auth.Subject.doAs(Subject.java:
396
) -
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:
953
)
具体原因还不是很清楚,当防火墙不关闭的时候可能出现,但是当异常宕掉整个系统再重启的时候也会出现。解决办法是master和slave同时重新格式化
2:ERROR mapred.JvmManager: Caught Throwable in JVMRunner. Aborting TaskTracker.
java.lang.OutOfMemoryError: unable to create new native thread
在运行任务的过程中,计算突然停止,去计算节点查看TaskTracker日志,发现在计算的过程中抛出以上错误,经查证是因为你的作业打开的文件个数超过系统设置一个进程可以打开的文件的个数的上限。更改/etc/security/limits.conf的配置加入如下配置
hadoop soft nproc 10000
hadoop hard nproc 64000