异常一:could only be replicated to 0 nodes, instead of 1
方法一
错误 :(hadoop)could only be replicated to 0 nodes, instead of 1
现象:namenode端的namenodelog一直报could only be replicated to 0 nodes, instead of 1 错误,表示没有一个可用的节点 。datanode端一直报错:Server at /10.0.0.21:54310 not available yet, Zzzzz...2011-03-03 11:33:10,047 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: /10.0.0.21:54310,一直尝试连接master但连接不上 。
改正:在namenode中配置master 和 jobtracker的ip时使用的是localhost ,将这两个改成namenode以及jobtracker本机的实际ip后,问题得以解决 。 具体的原因我也不太明白 。
当然这个错误还有其他的几个原因(摘自网上):
dfs的空间不足 。
namenode运行在safemodel下。
namenode所在机器的防火墙开着是的datanode无法访问master 。
这几个问题详见:http://hi.baidu.com/itdreams2009/blog/item/62a5ef18fbbe854e42a9ad13.html
问 题描述:三台机子搭建的hadoop集群,一台是namenode,另外两台是datanode。今天执行hadoop fs -copyFromLocal 的时候报错。File /home/hexianghui/tmp/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1 由这个可以认为是没有找到datanode。我用jps查看进程都正常。但是用web查看的话,live nodes为0. 这说明datanode没有正常启动,但是datanode进程又启动了,这是为何?网友可以跟帖提出意见或者指导……
2009-12-30 22:02:19,190 INFO org.apache.hadoop.mapred.JobTracker: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting JobTracker
STARTUP_MSG: host = hexianghui/192.168.0.4
STARTUP_MSG: args = []
STARTUP_MSG: version = 0.20.1
STARTUP_MSG: build = http://svn.apache.org/repos/asf/hadoop/common/tags/release-0.20.1-rc1 -r 810220; compiled by 'oom' on Tue Sep 1 20:55:56 UTC 2009
************************************************************/
2009-12-30 22:02:19,280 INFO org.apache.hadoop.mapred.JobTracker: Scheduler configured with (memSizeForMapSlotOnJT, memSizeForReduceSlotOnJT, limitMaxMemForMapTasks, limitMaxMemForReduceTasks) (-1, -1, -1, -1)
2009-12-30 22:02:19,322 INFO org.apache.hadoop.ipc.metrics.RpcMetrics: Initializing RPC Metrics with hostName=JobTracker, port=9001
2009-12-30 22:02:24,544 INFO org.mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
2009-12-30 22:02:24,691 INFO org.apache.hadoop.http.HttpServer: Port returned by webServer.getConnectors()[0].getLocalPort() before open() is -1. Opening the listener on 50030
2009-12-30 22:02:24,692 INFO org.apache.hadoop.http.HttpServer: listener.getLocalPort() returned 50030 webServer.getConnectors()[0].getLocalPort() returned 50030
2009-12-30 22:02:24,692 INFO org.apache.hadoop.http.HttpServer: Jetty bound to port 50030
2009-12-30 22:02:24,692 INFO org.mortbay.log: jetty-6.1.14
2009-12-30 22:04:01,351 INFO org.mortbay.log: Started
2009-12-30 22:04:01,353 INFO org.apache.hadoop.metrics.jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
2009-12-30 22:04:01,353 INFO org.apache.hadoop.mapred.JobTracker: JobTracker up at: 9001
2009-12-30 22:04:01,353 INFO org.apache.hadoop.mapred.JobTracker: JobTracker webserver: 50030
2009-12-30 22:04:01,468 INFO org.apache.hadoop.mapred.JobTracker: Cleaning up the system directory
2009-12-30 22:04:01,511 INFO org.apache.hadoop.mapred.CompletedJobStatusStore: Completed job store is inactive
2009-12-30 22:04:01,555 WARN org.apache.hadoop.hdfs.DFSClient: DataStreamer Exception: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /home/hexianghui/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:1267)
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:50
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)
at org.apache.hadoop.ipc.Client.call(Client.java:739)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at $Proxy4.addBlock(Unknown Source)
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.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
at $Proxy4.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock(DFSClient.java:2904)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2786)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2076)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2262)
2009-12-30 22:04:01,555 WARN org.apache.hadoop.hdfs.DFSClient: Error Recovery for block null bad datanode[0] nodes == null
2009-12-30 22:04:01,555 WARN org.apache.hadoop.hdfs.DFSClient: Could not get block locations. Source file "/home/hexianghui/tmp/mapred/system/jobtracker.info" - Aborting...
2009-12-30 22:04:01,556 WARN org.apache.hadoop.mapred.JobTracker: Writing to filehdfs://hexianghui:9000/home/hexianghui/tmp/mapred/system/jobtracker.info failed!
2009-12-30 22:04:01,556 WARN org.apache.hadoop.mapred.JobTracker: FileSystem is not ready yet!
2009-12-30 22:04:01,568 WARN org.apache.hadoop.mapred.JobTracker: Failed to initialize recovery manager.
org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /home/hexianghui/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:1267)
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:50
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)
at org.apache.hadoop.ipc.Client.call(Client.java:739)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at $Proxy4.addBlock(Unknown Source)
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.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
at $Proxy4.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock(DFSClient.java:2904)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2786)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2076)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2262)
2009-12-30 22:04:11,569 WARN org.apache.hadoop.mapred.JobTracker: Retrying...
以下是我在网上找的解决方法集锦:
方案1:
是否是防火墙未关闭,查看。确实忘记关闭防火墙了,因为我换了几台机器,以前是在虚拟机下用的是redhat,现在用的是ubuntu8.0.4。所以跟这个很可能相关。关闭iptables后,出现的错误信息没那么多了,但是还有错误。如下:
2010-01-03 22:08:25,073 INFO org.apache.hadoop.ipc.Server: IPC Server handler 8 on 9000, call addBlock(/user/hexianghui/input/file01, DFSClient_105866075) from 192.168.0.4:53604: error: java.io.IOException: File /user/hexianghui/input/file01 could only be replicated to 0 nodes, instead of 1
java.io.IOException: File /user/hexianghui/input/file01 could only be replicated to 0 nodes, instead of 1
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1267)
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:50
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)
2010-01-03 22:08:25,087 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem.audit: ugi=hexianghui,hexianghui,adm,dialout,cdrom,floppy,audio,dip,video,plugdev,fuse,lpadmin,admin ip=/192.168.0.4 cmd=create src=/user/hexianghui/input/file02 dst=null perm=hexianghui:supergroup:rw-r--r--
2010-01-03 22:08:25,088 INFO org.apache.hadoop.ipc.Server: IPC Server handler 2 on 9000, call addBlock(/user/hexianghui/input/file02, DFSClient_105866075) from 192.168.0.4:53604: error: java.io.IOException: File /user/hexianghui/input/file02 could only be replicated to 0 nodes, instead of 1
java.io.IOException: File /user/hexianghui/input/file02 could only be replicated to 0 nodes, instead of 1
虽然有类似的信息:could only be replicated to 0 nodes, instead of 1。但情况不一样了,可以对照上面的错误信息。继续接着找……
方案2:Hadoop DFSClient警告NotReplicatedYetException信息
有时,当你申请到一个HOD集群后马上尝试上传文件到HDFS时,DFSClient会警告NotReplicatedYetException。通常会有一个这样的信息 -
WARN hdfs.DFSClient: NotReplicatedYetException sleeping <filename> retries left 3 08/01/25 16:31:40 INFO hdfs.DFSClient: org.apache.hadoop.ipc.RemoteException:java.io.IOException: File <filename> could only be replicated to 0 nodes, instead of 1
当你向一个DataNodes正在和NameNode联络的集群上传文件的时候,这种现象就会发生。在上传新文件到HDFS之前多等待一段时间就可以解决这个问题,因为这使得足够多的DataNode启动并且联络上了NameNode。
PS:我的实践:等待了几分钟,还是依然报错,此法不通。
方案3:http://trac.nchc.org.tw/cloud/wiki/waue/2009/0709
這個錯誤訊息意思是,他想要放檔案,但沒半個node可以給存取,因此我們需要檢查:
1. 系統或hdfs是否還有空間 (像我就是)
2. datanode數是否正常
3. 是否在safemode
4. 讀寫的權限
• 什麼都檢查過都正常的話,也只好砍掉重練了
PS: 检查上面几个,1)系统空间够。df -hl查看。 2)datanode数是2.datanode用jps查看进程,都启动了。3,是否在safemode下。hadoop dfsadmin -safemode leave.使用后,可以正常拷贝了。也许之前的操作和这一步操作起作用了。
至此,问题解决……
方法二
今天安装了hadoop cluster (参考 http://hadoop.apache.org/common/docs/current/cluster_setup.html),
当执行 #bin/hadoop dfs -put input input 时,报错 ...,could only be replicated to 0 nodes, instead of 1,网上查了查,最后确定应该是iptables问题。
如果你的 conf/core-site.xml的配置是:
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://machine1:9000/</value>
</property>
</configuration>
那么你应该将machine1的9000端口打开:
#iptables -I INPUT -p tcp --dport 9000 -j ACCEPT
然后可以查看
http://machine1:50070/dfshealth.jsp (你应该将500070端口也打开)
再执行,又报别的错:hdfs.DFSClient: Exception in createBlockOutputStream java.net.ConnectException: Connection refused
应该是datanode上的端口不能访问,到datanode上修改iptables:
#iptables -I INPUT -s machine1 -p tcp -j ACCEPT
OK 了!
异常二:hdfs.DFSClient: Could not obtain block
dfs.datanode.max.xcievers
An Hadoop HDFS datanode has an upper bound on the number of files that it will serve at any one time. The upper bound parameter is called xcievers (yes, this is misspelled). Again, before doing any loading, make sure you have configured Hadoop's conf/hdfs-site.xml setting the xceivers value to at least the following:
<property> <name>dfs.datanode.max.xcievers</name> <value>4096</value> </property>
Be sure to restart your HDFS after making the above configuration.
Not having this configuration in place makes for strange looking failures. Eventually you'll see a complain in the datanode logs complaining about the xcievers exceeded, but on the run up to this one manifestation is complaint about missing blocks. For example: 10/12/08 20:10:31 INFO hdfs.DFSClient: Could not obtain block blk_XXXXXXXXXXXXXXXXXXXXXX_YYYYYYYY from any node: java.io.IOException: No live nodes contain current block. Will get new block locations from namenode and retry...
异常三:hadoop运行程序是出现java heap space
方法1:修改hadoop环境配置文件conf/hadoop-env.sh,加入下面两行:
export HADOOP_HEAPSIZE=2000
export HADOOP_CLIENT_OPTS="-Xmx1024m $HADOOP_CLIENT_OPTS"
方法2:以上方法是对所有程序有效,如果只针对某一个程序,可以在运行时加入参数,例如:
bin/hadoop jar hadoop-examples-*.jar grep -D mapred.child.java.opts=-Xmx1024M input output 'dfs[a-z.]+'
异常四:No locks available
遇到datanode无法启动的情况,datanode日志报错如下:
ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: No locks available
网上有许多说需要format,个人感觉是扯淡,因为我同样的添加节点,添加的其他节点没有问题,只有一个有问题,所以问题一定不在是否 format身上,而且如果format后hdfs内的数据就会全部丢失,我也不会去尝试这种方法。详细看了一下,apache的邮件列表有这样一段内 容:
No locks available can mean that you are trying to use hadoop on a filesystem that does not support file level locking. Are you trying to run your name node storage in NFS space?
这里提到文件级锁的情况,使用
$ /etc/init.d/nfs status
命令查看网络文件系统的情况,都是关闭的。另外使用df -Th或者mount命令可以查看文件系统的类型,得到的结果确实是NFS文件系统的问题。不能使用挂在的网络文件系统,因为又貌似只读的情况,即便不是只读情况,也像上边说的,是不支持file级锁的。
最后解决办法,可以尝试给nfs添加文件级的锁。我这里就是修改dfs.data.dir,不使用nfs完事了。
参见daliy record,nfs挂载,按文件夹挂载,按分区挂载,均不行,报错,上述错误!!!
异常五:Hadoop 解除 "Name node is in safe mode"
运行hadoop的命令时可能会出现如下的错误信息:
org.apache.hadoop.hdfs.server.namenode.SafeModeException: Command Error Message.Name node is in safe mode.
解决方法:
bin/hadoop dfsadmin -safemode leave #关闭safe mode
异常六:namenode格式化失败
可能的原因:dfs.name.dir指定的目录已经存在(格式化要求该目录不能存在);VERSION中指定的namespaceID由于重复格式化而产生变化,新格式化的namenode和datanode中namespaceID不一致。
解决方法:删除dfs.name.dir指定的目录;删除VERSION文件。
ERROR org.apache.Hadoop.hdfs.server.datanode.DataNode: java.io.IOException:
Call to master/192.168.106.251:9091 failed on local exception: java.net.NoRouteToHost Exception: No route to host
可能是master的监听端口未开启成功,或者被master主机的防火墙阻止。尝试查看master上的监听端口这关闭防火墙以解决问题
异常七:Hadoop启动之后datanode节点自动关闭
在执行start-all.sh命令后,datanode中检查到服务已经启动,但是不久后就自动关闭。
可能是datanode与master通信失败造成的。
解决方法同上一条所述。
异常八:HTTP ERROR: 404 /jobtracker.jsp RequestURI=/jobtracker.jsp
访问监控网页,没有显示,如下图所示:
系统重启之后,Hadoop的Administrator那个界面就不能访问了,显示:
HTTP ERROR: 404
/jobtracker.jsp
RequestURI=/jobtracker.jsp
Powered by Jetty://
访问的形式:master-IP:50030
和master-IP:50070
已知:
端口已打开,且没被其它程序占用;
jps查看各服务正常运行,且集群运行也没问题,只是不能查看;
./hadoop dfsadmin -report 查看集群节点也没问题;
查询得,两个回答:
第一
我也遇到这个问题,
buid本地库存后,应该把build目录删除,否则启动脚本会把目录重定向到build目录中,导致web管理页面打不开
启动脚本中,如果有build目录,就将路径转到build下.
if [ -d "$HADOOP_HOME/build/webapps" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_HOME/build
fi
在datanode上没有发现build文件夹,在namenode发现有build文件夹,其下有子文件夹webapps,在start-all.sh脚本中加入上述if判断条件,重启集群,仍无法访问。
第二
刚解决这个问题,和LYG105504说的一样,问题出在build 目录下面的webapps目录存在。我随便重新命名了build:move build build.bak。然后重新启动start-all.sh。(注意所有的datanode也要全部重新命名,否则还是会有问题),接没有问题了。
在namenode的hadoop用户下的hadoop文件夹中,有build文件夹,将其更名为build.bak,没有更改datanode的名字,重启集群,可以访问监控网页!!
异常九:Browse the filesystem链接打不开
查得:
http://yymmiinngg.iteye.com/blog/706909
以上是我们安装完成,并且正常运行后的HDFS状态页面(访问地址:http://210.66.44.88:50070/dfshealth.jsp),其中的Browse the filesystem 是查看文件系统的入
口,但是有可能会出现无法访问的问题,我就遇到过,上网查了很久的解决办法都无果,后
来我通过firebug拦截请求发现,Browse the filesystem这个链接的页面会跳转到另外一个页
面,而这个页面的地址是
http://192.168.1.164:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=%2F
( 192.168.1.164是服务器的内网地址,在masters和slaves文件中配置的是局域网IP),但
是需要通过外网才能访问(类似于
http://210.66.44.88:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=%2F才行),这
就是问题所在。
从代码可以看出,当我们点击Browse the filesystem 时后台会将请求随机转发到一台DataNode节点,使用的是slaves文件中配置的服务器列表所反解的域名或主机名,而通过局域网IP未能反解出域名和主机名,所以用的是IP,这样就出问题了,解决办法有两个:视redirectToRandomDataNode方法内生成的URL而定,如果反转域名是主机名的话,你只需要修改本地HOSTS映射就可以了;如果反转出的域名是主机局域网IP的话,那就需要配置slaves和masters使用域名或外网IP
在190的linux环境下访问“browse the filysystem”,随机跳转到一个datanode上,浏览到的是整个hdfs的文件结构,有几个datanode可以访问,有几个不能访问。
反转域名看到是主机名,小写的,而节点自身的hostname有大写的,将hostname中的大写改为小写,仍不行,该问题未能解决。
异常十:DFSOutputStream ResponseProcessor exception for blockblk_*java.net.SocketTimeoutException: 66000 millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=…WARN org.apache.hadoop.hdfs.DFSClient: DFSOutputStream ResponseProcessor exception for block blk_7400268305159146046_1226436java.net.SocketTimeoutException: 66000 millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=/ ip:38201 remote=/ip:50010]
at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:164)
at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:155)
at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:12
at java.io.DataInputStream.readFully(DataInputStream.java:17
at java.io.DataInputStream.readLong(DataInputStream.java:399)
at org.apache.hadoop.hdfs.protocol.DataTransferProtocol$PipelineAck.readFields(DataTransferProtocol.java:124)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$ResponseProcessor.run(DFSClient.java:2964)
2012-06-06 08:12:09,333 WARN org.apache.hadoop.hdfs.DFSClient: Error Recovery for block blk_7400268305159146046_1226436 bad datanode[0] ip :50010
这是一个写HDF超时问题,在 hdfs-site.xml 增大dfs.datanode.socket.write.timeout和dfs.socket.timeout两个配置项即可。
在数据上传的客户端hadoop-site.xml里修改配置参数 dfs.socket.timeout(默认十分钟),之后重新运行大批量的数据上传操作,问题不再重现:)
方法一
错误 :(hadoop)could only be replicated to 0 nodes, instead of 1
现象:namenode端的namenodelog一直报could only be replicated to 0 nodes, instead of 1 错误,表示没有一个可用的节点 。datanode端一直报错:Server at /10.0.0.21:54310 not available yet, Zzzzz...2011-03-03 11:33:10,047 INFO org.apache.hadoop.ipc.Client: Retrying connect to server: /10.0.0.21:54310,一直尝试连接master但连接不上 。
改正:在namenode中配置master 和 jobtracker的ip时使用的是localhost ,将这两个改成namenode以及jobtracker本机的实际ip后,问题得以解决 。 具体的原因我也不太明白 。
当然这个错误还有其他的几个原因(摘自网上):
dfs的空间不足 。
namenode运行在safemodel下。
namenode所在机器的防火墙开着是的datanode无法访问master 。
这几个问题详见:http://hi.baidu.com/itdreams2009/blog/item/62a5ef18fbbe854e42a9ad13.html
问 题描述:三台机子搭建的hadoop集群,一台是namenode,另外两台是datanode。今天执行hadoop fs -copyFromLocal 的时候报错。File /home/hexianghui/tmp/mapred/system/jobtracker.info could only be replicated to 0 nodes, instead of 1 由这个可以认为是没有找到datanode。我用jps查看进程都正常。但是用web查看的话,live nodes为0. 这说明datanode没有正常启动,但是datanode进程又启动了,这是为何?网友可以跟帖提出意见或者指导……
2009-12-30 22:02:19,190 INFO org.apache.hadoop.mapred.JobTracker: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting JobTracker
STARTUP_MSG: host = hexianghui/192.168.0.4
STARTUP_MSG: args = []
STARTUP_MSG: version = 0.20.1
STARTUP_MSG: build = http://svn.apache.org/repos/asf/hadoop/common/tags/release-0.20.1-rc1 -r 810220; compiled by 'oom' on Tue Sep 1 20:55:56 UTC 2009
************************************************************/
2009-12-30 22:02:19,280 INFO org.apache.hadoop.mapred.JobTracker: Scheduler configured with (memSizeForMapSlotOnJT, memSizeForReduceSlotOnJT, limitMaxMemForMapTasks, limitMaxMemForReduceTasks) (-1, -1, -1, -1)
2009-12-30 22:02:19,322 INFO org.apache.hadoop.ipc.metrics.RpcMetrics: Initializing RPC Metrics with hostName=JobTracker, port=9001
2009-12-30 22:02:24,544 INFO org.mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
2009-12-30 22:02:24,691 INFO org.apache.hadoop.http.HttpServer: Port returned by webServer.getConnectors()[0].getLocalPort() before open() is -1. Opening the listener on 50030
2009-12-30 22:02:24,692 INFO org.apache.hadoop.http.HttpServer: listener.getLocalPort() returned 50030 webServer.getConnectors()[0].getLocalPort() returned 50030
2009-12-30 22:02:24,692 INFO org.apache.hadoop.http.HttpServer: Jetty bound to port 50030
2009-12-30 22:02:24,692 INFO org.mortbay.log: jetty-6.1.14
2009-12-30 22:04:01,351 INFO org.mortbay.log: Started
2009-12-30 22:04:01,353 INFO org.apache.hadoop.metrics.jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
2009-12-30 22:04:01,353 INFO org.apache.hadoop.mapred.JobTracker: JobTracker up at: 9001
2009-12-30 22:04:01,353 INFO org.apache.hadoop.mapred.JobTracker: JobTracker webserver: 50030
2009-12-30 22:04:01,468 INFO org.apache.hadoop.mapred.JobTracker: Cleaning up the system directory
2009-12-30 22:04:01,511 INFO org.apache.hadoop.mapred.CompletedJobStatusStore: Completed job store is inactive
2009-12-30 22:04:01,555 WARN org.apache.hadoop.hdfs.DFSClient: DataStreamer Exception: org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /home/hexianghui/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:1267)
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:50
![](http://www.eeqee.com/jforum//images/smilies/b2eb59423fbf5fa39342041237025880.gif)
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)
at org.apache.hadoop.ipc.Client.call(Client.java:739)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at $Proxy4.addBlock(Unknown Source)
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.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
at $Proxy4.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock(DFSClient.java:2904)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2786)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2076)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2262)
2009-12-30 22:04:01,555 WARN org.apache.hadoop.hdfs.DFSClient: Error Recovery for block null bad datanode[0] nodes == null
2009-12-30 22:04:01,555 WARN org.apache.hadoop.hdfs.DFSClient: Could not get block locations. Source file "/home/hexianghui/tmp/mapred/system/jobtracker.info" - Aborting...
2009-12-30 22:04:01,556 WARN org.apache.hadoop.mapred.JobTracker: Writing to filehdfs://hexianghui:9000/home/hexianghui/tmp/mapred/system/jobtracker.info failed!
2009-12-30 22:04:01,556 WARN org.apache.hadoop.mapred.JobTracker: FileSystem is not ready yet!
2009-12-30 22:04:01,568 WARN org.apache.hadoop.mapred.JobTracker: Failed to initialize recovery manager.
org.apache.hadoop.ipc.RemoteException: java.io.IOException: File /home/hexianghui/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:1267)
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:50
![](http://www.eeqee.com/jforum//images/smilies/b2eb59423fbf5fa39342041237025880.gif)
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)
at org.apache.hadoop.ipc.Client.call(Client.java:739)
at org.apache.hadoop.ipc.RPC$Invoker.invoke(RPC.java:220)
at $Proxy4.addBlock(Unknown Source)
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.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:82)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:59)
at $Proxy4.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.locateFollowingBlock(DFSClient.java:2904)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2786)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2076)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2262)
2009-12-30 22:04:11,569 WARN org.apache.hadoop.mapred.JobTracker: Retrying...
以下是我在网上找的解决方法集锦:
方案1:
是否是防火墙未关闭,查看。确实忘记关闭防火墙了,因为我换了几台机器,以前是在虚拟机下用的是redhat,现在用的是ubuntu8.0.4。所以跟这个很可能相关。关闭iptables后,出现的错误信息没那么多了,但是还有错误。如下:
2010-01-03 22:08:25,073 INFO org.apache.hadoop.ipc.Server: IPC Server handler 8 on 9000, call addBlock(/user/hexianghui/input/file01, DFSClient_105866075) from 192.168.0.4:53604: error: java.io.IOException: File /user/hexianghui/input/file01 could only be replicated to 0 nodes, instead of 1
java.io.IOException: File /user/hexianghui/input/file01 could only be replicated to 0 nodes, instead of 1
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:1267)
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:50
![](http://www.eeqee.com/jforum//images/smilies/b2eb59423fbf5fa39342041237025880.gif)
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)
2010-01-03 22:08:25,087 INFO org.apache.hadoop.hdfs.server.namenode.FSNamesystem.audit: ugi=hexianghui,hexianghui,adm,dialout,cdrom,floppy,audio,dip,video,plugdev,fuse,lpadmin,admin ip=/192.168.0.4 cmd=create src=/user/hexianghui/input/file02 dst=null perm=hexianghui:supergroup:rw-r--r--
2010-01-03 22:08:25,088 INFO org.apache.hadoop.ipc.Server: IPC Server handler 2 on 9000, call addBlock(/user/hexianghui/input/file02, DFSClient_105866075) from 192.168.0.4:53604: error: java.io.IOException: File /user/hexianghui/input/file02 could only be replicated to 0 nodes, instead of 1
java.io.IOException: File /user/hexianghui/input/file02 could only be replicated to 0 nodes, instead of 1
虽然有类似的信息:could only be replicated to 0 nodes, instead of 1。但情况不一样了,可以对照上面的错误信息。继续接着找……
方案2:Hadoop DFSClient警告NotReplicatedYetException信息
有时,当你申请到一个HOD集群后马上尝试上传文件到HDFS时,DFSClient会警告NotReplicatedYetException。通常会有一个这样的信息 -
WARN hdfs.DFSClient: NotReplicatedYetException sleeping <filename> retries left 3 08/01/25 16:31:40 INFO hdfs.DFSClient: org.apache.hadoop.ipc.RemoteException:java.io.IOException: File <filename> could only be replicated to 0 nodes, instead of 1
当你向一个DataNodes正在和NameNode联络的集群上传文件的时候,这种现象就会发生。在上传新文件到HDFS之前多等待一段时间就可以解决这个问题,因为这使得足够多的DataNode启动并且联络上了NameNode。
PS:我的实践:等待了几分钟,还是依然报错,此法不通。
方案3:http://trac.nchc.org.tw/cloud/wiki/waue/2009/0709
這個錯誤訊息意思是,他想要放檔案,但沒半個node可以給存取,因此我們需要檢查:
1. 系統或hdfs是否還有空間 (像我就是)
2. datanode數是否正常
3. 是否在safemode
4. 讀寫的權限
• 什麼都檢查過都正常的話,也只好砍掉重練了
PS: 检查上面几个,1)系统空间够。df -hl查看。 2)datanode数是2.datanode用jps查看进程,都启动了。3,是否在safemode下。hadoop dfsadmin -safemode leave.使用后,可以正常拷贝了。也许之前的操作和这一步操作起作用了。
至此,问题解决……
方法二
今天安装了hadoop cluster (参考 http://hadoop.apache.org/common/docs/current/cluster_setup.html),
当执行 #bin/hadoop dfs -put input input 时,报错 ...,could only be replicated to 0 nodes, instead of 1,网上查了查,最后确定应该是iptables问题。
如果你的 conf/core-site.xml的配置是:
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://machine1:9000/</value>
</property>
</configuration>
那么你应该将machine1的9000端口打开:
#iptables -I INPUT -p tcp --dport 9000 -j ACCEPT
然后可以查看
http://machine1:50070/dfshealth.jsp (你应该将500070端口也打开)
再执行,又报别的错:hdfs.DFSClient: Exception in createBlockOutputStream java.net.ConnectException: Connection refused
应该是datanode上的端口不能访问,到datanode上修改iptables:
#iptables -I INPUT -s machine1 -p tcp -j ACCEPT
OK 了!
异常二:hdfs.DFSClient: Could not obtain block
dfs.datanode.max.xcievers
An Hadoop HDFS datanode has an upper bound on the number of files that it will serve at any one time. The upper bound parameter is called xcievers (yes, this is misspelled). Again, before doing any loading, make sure you have configured Hadoop's conf/hdfs-site.xml setting the xceivers value to at least the following:
<property> <name>dfs.datanode.max.xcievers</name> <value>4096</value> </property>
Be sure to restart your HDFS after making the above configuration.
Not having this configuration in place makes for strange looking failures. Eventually you'll see a complain in the datanode logs complaining about the xcievers exceeded, but on the run up to this one manifestation is complaint about missing blocks. For example: 10/12/08 20:10:31 INFO hdfs.DFSClient: Could not obtain block blk_XXXXXXXXXXXXXXXXXXXXXX_YYYYYYYY from any node: java.io.IOException: No live nodes contain current block. Will get new block locations from namenode and retry...
异常三:hadoop运行程序是出现java heap space
方法1:修改hadoop环境配置文件conf/hadoop-env.sh,加入下面两行:
export HADOOP_HEAPSIZE=2000
export HADOOP_CLIENT_OPTS="-Xmx1024m $HADOOP_CLIENT_OPTS"
方法2:以上方法是对所有程序有效,如果只针对某一个程序,可以在运行时加入参数,例如:
bin/hadoop jar hadoop-examples-*.jar grep -D mapred.child.java.opts=-Xmx1024M input output 'dfs[a-z.]+'
异常四:No locks available
遇到datanode无法启动的情况,datanode日志报错如下:
ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: No locks available
网上有许多说需要format,个人感觉是扯淡,因为我同样的添加节点,添加的其他节点没有问题,只有一个有问题,所以问题一定不在是否 format身上,而且如果format后hdfs内的数据就会全部丢失,我也不会去尝试这种方法。详细看了一下,apache的邮件列表有这样一段内 容:
No locks available can mean that you are trying to use hadoop on a filesystem that does not support file level locking. Are you trying to run your name node storage in NFS space?
这里提到文件级锁的情况,使用
$ /etc/init.d/nfs status
命令查看网络文件系统的情况,都是关闭的。另外使用df -Th或者mount命令可以查看文件系统的类型,得到的结果确实是NFS文件系统的问题。不能使用挂在的网络文件系统,因为又貌似只读的情况,即便不是只读情况,也像上边说的,是不支持file级锁的。
最后解决办法,可以尝试给nfs添加文件级的锁。我这里就是修改dfs.data.dir,不使用nfs完事了。
参见daliy record,nfs挂载,按文件夹挂载,按分区挂载,均不行,报错,上述错误!!!
异常五:Hadoop 解除 "Name node is in safe mode"
运行hadoop的命令时可能会出现如下的错误信息:
org.apache.hadoop.hdfs.server.namenode.SafeModeException: Command Error Message.Name node is in safe mode.
解决方法:
bin/hadoop dfsadmin -safemode leave #关闭safe mode
异常六:namenode格式化失败
可能的原因:dfs.name.dir指定的目录已经存在(格式化要求该目录不能存在);VERSION中指定的namespaceID由于重复格式化而产生变化,新格式化的namenode和datanode中namespaceID不一致。
解决方法:删除dfs.name.dir指定的目录;删除VERSION文件。
ERROR org.apache.Hadoop.hdfs.server.datanode.DataNode: java.io.IOException:
Call to master/192.168.106.251:9091 failed on local exception: java.net.NoRouteToHost Exception: No route to host
可能是master的监听端口未开启成功,或者被master主机的防火墙阻止。尝试查看master上的监听端口这关闭防火墙以解决问题
异常七:Hadoop启动之后datanode节点自动关闭
在执行start-all.sh命令后,datanode中检查到服务已经启动,但是不久后就自动关闭。
可能是datanode与master通信失败造成的。
解决方法同上一条所述。
异常八:HTTP ERROR: 404 /jobtracker.jsp RequestURI=/jobtracker.jsp
访问监控网页,没有显示,如下图所示:
系统重启之后,Hadoop的Administrator那个界面就不能访问了,显示:
HTTP ERROR: 404
/jobtracker.jsp
RequestURI=/jobtracker.jsp
Powered by Jetty://
访问的形式:master-IP:50030
和master-IP:50070
已知:
端口已打开,且没被其它程序占用;
jps查看各服务正常运行,且集群运行也没问题,只是不能查看;
./hadoop dfsadmin -report 查看集群节点也没问题;
查询得,两个回答:
第一
我也遇到这个问题,
buid本地库存后,应该把build目录删除,否则启动脚本会把目录重定向到build目录中,导致web管理页面打不开
启动脚本中,如果有build目录,就将路径转到build下.
if [ -d "$HADOOP_HOME/build/webapps" ]; then
CLASSPATH=${CLASSPATH}:$HADOOP_HOME/build
fi
在datanode上没有发现build文件夹,在namenode发现有build文件夹,其下有子文件夹webapps,在start-all.sh脚本中加入上述if判断条件,重启集群,仍无法访问。
第二
刚解决这个问题,和LYG105504说的一样,问题出在build 目录下面的webapps目录存在。我随便重新命名了build:move build build.bak。然后重新启动start-all.sh。(注意所有的datanode也要全部重新命名,否则还是会有问题),接没有问题了。
在namenode的hadoop用户下的hadoop文件夹中,有build文件夹,将其更名为build.bak,没有更改datanode的名字,重启集群,可以访问监控网页!!
异常九:Browse the filesystem链接打不开
查得:
http://yymmiinngg.iteye.com/blog/706909
以上是我们安装完成,并且正常运行后的HDFS状态页面(访问地址:http://210.66.44.88:50070/dfshealth.jsp),其中的Browse the filesystem 是查看文件系统的入
口,但是有可能会出现无法访问的问题,我就遇到过,上网查了很久的解决办法都无果,后
来我通过firebug拦截请求发现,Browse the filesystem这个链接的页面会跳转到另外一个页
面,而这个页面的地址是
http://192.168.1.164:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=%2F
( 192.168.1.164是服务器的内网地址,在masters和slaves文件中配置的是局域网IP),但
是需要通过外网才能访问(类似于
http://210.66.44.88:50075/browseDirectory.jsp?namenodeInfoPort=50070&dir=%2F才行),这
就是问题所在。
从代码可以看出,当我们点击Browse the filesystem 时后台会将请求随机转发到一台DataNode节点,使用的是slaves文件中配置的服务器列表所反解的域名或主机名,而通过局域网IP未能反解出域名和主机名,所以用的是IP,这样就出问题了,解决办法有两个:视redirectToRandomDataNode方法内生成的URL而定,如果反转域名是主机名的话,你只需要修改本地HOSTS映射就可以了;如果反转出的域名是主机局域网IP的话,那就需要配置slaves和masters使用域名或外网IP
在190的linux环境下访问“browse the filysystem”,随机跳转到一个datanode上,浏览到的是整个hdfs的文件结构,有几个datanode可以访问,有几个不能访问。
反转域名看到是主机名,小写的,而节点自身的hostname有大写的,将hostname中的大写改为小写,仍不行,该问题未能解决。
异常十:DFSOutputStream ResponseProcessor exception for blockblk_*java.net.SocketTimeoutException: 66000 millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=…WARN org.apache.hadoop.hdfs.DFSClient: DFSOutputStream ResponseProcessor exception for block blk_7400268305159146046_1226436java.net.SocketTimeoutException: 66000 millis timeout while waiting for channel to be ready for read. ch : java.nio.channels.SocketChannel[connected local=/ ip:38201 remote=/ip:50010]
at org.apache.hadoop.net.SocketIOWithTimeout.doIO(SocketIOWithTimeout.java:164)
at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:155)
at org.apache.hadoop.net.SocketInputStream.read(SocketInputStream.java:12
![](http://www.eeqee.com/jforum//images/smilies/b2eb59423fbf5fa39342041237025880.gif)
at java.io.DataInputStream.readFully(DataInputStream.java:17
![](http://www.eeqee.com/jforum//images/smilies/b2eb59423fbf5fa39342041237025880.gif)
at java.io.DataInputStream.readLong(DataInputStream.java:399)
at org.apache.hadoop.hdfs.protocol.DataTransferProtocol$PipelineAck.readFields(DataTransferProtocol.java:124)
at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$ResponseProcessor.run(DFSClient.java:2964)
2012-06-06 08:12:09,333 WARN org.apache.hadoop.hdfs.DFSClient: Error Recovery for block blk_7400268305159146046_1226436 bad datanode[0] ip :50010
这是一个写HDF超时问题,在 hdfs-site.xml 增大dfs.datanode.socket.write.timeout和dfs.socket.timeout两个配置项即可。
在数据上传的客户端hadoop-site.xml里修改配置参数 dfs.socket.timeout(默认十分钟),之后重新运行大批量的数据上传操作,问题不再重现:)