HBase: Connection refused: no further information, Call to localhost/127.0.0.1:16020 failed

由于安全问题,HBase集群不能外网连接,但又有业务需求,自己就在虚拟机里搭建了Hadoop和HBase,在进行API操作连接时,出现以下错误:

Exception in thread "main" org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:
Fri Nov 22 17:56:26 CST 2019, null, java.net.SocketTimeoutException: callTimeout=60000, callDuration=76608: Call to localhost/127.0.0.1:16020 failed on connection exception: java.net.ConnectException: Connection refused: no further information row 'stu,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=localhost,16020,1574415614027, seqNum=0

    at org.apache.hadoop.hbase.client.RpcRetryingCallerWithReadReplicas.throwEnrichedException(RpcRetryingCallerWithReadReplicas.java:329)
    at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:242)
    at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas.call(ScannerCallableWithReplicas.java:58)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithoutRetries(RpcRetryingCaller.java:219)
    at org.apache.hadoop.hbase.client.ClientScanner.call(ClientScanner.java:275)
    at org.apache.hadoop.hbase.client.ClientScanner.loadCache(ClientScanner.java:436)
    at org.apache.hadoop.hbase.client.ClientScanner.next(ClientScanner.java:310)
    at org.apache.hadoop.hbase.MetaTableAccessor.fullScan(MetaTableAccessor.java:639)
    at org.apache.hadoop.hbase.MetaTableAccessor.tableExists(MetaTableAccessor.java:366)
    at org.apache.hadoop.hbase.client.HBaseAdmin.tableExists(HBaseAdmin.java:409)
    at org.apache.hadoop.hbase.client.HBaseAdmin.tableExists(HBaseAdmin.java:419)
    at HBaseSample.main(HBaseSample.java:26)
Caused by: java.net.SocketTimeoutException: callTimeout=60000, callDuration=76608: Call to localhost/127.0.0.1:16020 failed on connection exception: java.net.ConnectException: Connection refused: no further information row 'stu,,' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=localhost,16020,1574415614027, seqNum=0
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:178)
    at org.apache.hadoop.hbase.client.ResultBoundedCompletionService$QueueingFuture.run(ResultBoundedCompletionService.java:80)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.net.ConnectException: Call to localhost/127.0.0.1:16020 failed on connection exception: java.net.ConnectException: Connection refused: no further information
    at org.apache.hadoop.hbase.ipc.IPCUtil.wrapException(IPCUtil.java:165)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.onCallFinished(AbstractRpcClient.java:389)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.access$100(AbstractRpcClient.java:94)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient$3.run(AbstractRpcClient.java:409)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient$3.run(AbstractRpcClient.java:405)
    at org.apache.hadoop.hbase.ipc.Call.callComplete(Call.java:103)
    at org.apache.hadoop.hbase.ipc.Call.setException(Call.java:118)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callMethod(AbstractRpcClient.java:422)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callBlockingMethod(AbstractRpcClient.java:327)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.access$200(AbstractRpcClient.java:94)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient$BlockingRpcChannelImplementation.callBlockingMethod(AbstractRpcClient.java:571)
    at org.apache.hadoop.hbase.protobuf.generated.ClientProtos$ClientService$BlockingStub.scan(ClientProtos.java:37059)
    at org.apache.hadoop.hbase.client.ScannerCallable.openScanner(ScannerCallable.java:405)
    at org.apache.hadoop.hbase.client.ScannerCallable.call(ScannerCallable.java:274)
    at org.apache.hadoop.hbase.client.ScannerCallable.call(ScannerCallable.java:62)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithoutRetries(RpcRetryingCaller.java:219)
    at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas$RetryingRPC.call(ScannerCallableWithReplicas.java:388)
    at org.apache.hadoop.hbase.client.ScannerCallableWithReplicas$RetryingRPC.call(ScannerCallableWithReplicas.java:362)
    at org.apache.hadoop.hbase.client.RpcRetryingCaller.callWithRetries(RpcRetryingCaller.java:142)
    ... 4 more
Caused by: java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739)
    at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:531)
    at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:495)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection.setupConnection(BlockingRpcConnection.java:256)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection.setupIOstreams(BlockingRpcConnection.java:437)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection.writeRequest(BlockingRpcConnection.java:540)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection.tracedWriteRequest(BlockingRpcConnection.java:520)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection.access$200(BlockingRpcConnection.java:85)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection$4.run(BlockingRpcConnection.java:724)
    at org.apache.hadoop.hbase.ipc.HBaseRpcControllerImpl.notifyOnCancel(HBaseRpcControllerImpl.java:240)
    at org.apache.hadoop.hbase.ipc.BlockingRpcConnection.sendRequest(BlockingRpcConnection.java:699)
    at org.apache.hadoop.hbase.ipc.AbstractRpcClient.callMethod(AbstractRpcClient.java:420)
    ... 15 more

通过仔细查看错误日志,发现程序一直连接localhost//127.0.0.1:16020,代码里填写的是IP而不是机器名,也就不存在映射关系的问题,然后又查看虚拟机里的配置,发现IP设置无错,hbase-site及Zookeeper中都是填写的IP,在shell中进行hbase操作没有错。

防火墙也处于关闭状态。

分析后,查询表的名称应该是只读取了master信息,而表的具体信息就需要读取regionserver的信息了,master把regionserver的本地IP返回给远程java程序,但是此处返回的IP为什么是localhost/127.0.0.1?

在虚拟机中执行:netstat -nautlp|grep 16020,发现:

tcp        0      0 ::ffff:127.0.0.1:16020      :::*                        LISTEN      24349/java

16020端口号并没有绑定到IP上

netstat -nautlp|grep 16000,也是同样的结果,端口绑定的也是本地地址,而不是设定的IP。

发现自己机器名为localhost, 查看/etc/hostname和 /etc/hosts,更改机器名,重启后连接成功。

你可能感兴趣的:(hadoop学习)