2016年2月25日 星期四

[hadoop] hadoop client failed on connection exception: java.net.ConnectException: Connection refused 解決方法


在 hadoop client 執行 hdfs 的指令 發生了下面的錯誤


[root@vagrant-centos652 conf]# hadoop fs -ls /
ls: Call From vagrant-centos652.vagrantup.com/127.0.0.1 to vagrant-centos65.vagrantup.com:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused



一般來說就是 client 並沒有辦法連結到 namenode ,
  • 先檢查一下 該來電腦 ping 的到 master 嗎?
  • telnet master-host port  
  • telnet  vagrant-centos65.vagrantup.com 8020
vagrant-centos65.vagrantup.com 是我的master 的hostname 已經寫在 /etc/hosts內了。

若是發現 telnet  Connection refused , 回到 namenode node 檢查 ip 是 bind 在哪個 ip 上

[vagrant@vagrant-centos65 ~]$ netstat -anpt  | grep "8020"
(No info could be read for "-p": geteuid()=500 but you should be root.)
tcp        0      0 10.1.193.179:8020           0.0.0.0:*                   LISTEN      -                   
tcp        0      0 10.1.193.179:8020           10.1.193.149:56089          ESTABLISHED -                   
tcp        0      0 10.1.193.179:54539          10.1.193.179:8020           TIME_WAIT   -      

如果  bind 127.0.0.1  可以檢查一下 /etc/hosts內的設定
[vagrant@vagrant-centos65 ~]$ cat /etc/hosts
127.0.0.1   localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.1.193.149  vagrant-centos652.vagrantup.com
10.1.193.179  vagrant-centos65.vagrantup.com

===
查看 hostname 是不是跟 127.0.0.1 寫在一起,有的單機的環境教學會建議寫在 localhost 同一行


其他的 error message 還可能會發生

16/02/24 15:12:35 WARN hdfs.DFSClient: DataStreamer Exception
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /tmp/x1._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and no node(s) are excluded in this operation.


[hdfs@vagrant-centos65 tmp]$ hdfs dfs -put /tmp/x1 /tmp
16/02/24 15:12:35 WARN hdfs.DFSClient: DataStreamer Exception
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /tmp/x1._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and no node(s) are excluded in this operation.
at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.chooseTarget(BlockManager.java:1384)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:2503)
at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.addBlock(NameNodeRpcServer.java:555)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.addBlock(ClientNamenodeProtocolServerSideTranslatorPB.java:387)
at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java:59582)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:585)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:928)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2053)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2049)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2047)

at org.apache.hadoop.ipc.Client.call(Client.java:1347)
at org.apache.hadoop.ipc.Client.call(Client.java:1300)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:206)
at $Proxy9.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:186)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
at $Proxy9.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.addBlock(ClientNamenodeProtocolTranslatorPB.java:330)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.locateFollowingBlock(DFSOutputStream.java:1231)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1078)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
put: File /tmp/x1._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and no node(s) are excluded in this operation.



沒有留言:

張貼留言