Java 连接HBASE ,执行查询超时的解决方法

在连接hbase时,系统默认的rpc超时时间是1分钟,即60000,scanner 超时默认没有设置。因此,但数据量较大、scanner较慢的时候,查询就会报错:
Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:
Wed Sep 07 08:14:48 CST 2016, null, java.net.SocketTimeoutException: callTimeout=60000, callDuration=60316: row '20' on table 'src_customs' at region=src_customs,20,1473065204994.c5296399e88185d6d19e5b600e9376b5., hostname=hadoop-s1,60020,1472804690476, seqNum=2

at org.apache.hadoop.hbase.client.AbstractClientScanner$1.hasNext(AbstractClientScanner.java:97)
at Mysteel.hbase_mobile.HbaseOperator.findRecords(HbaseOperator.java:181)
at Mysteel.hbase_mobile.HbaseOperator.main(HbaseOperator.java:257)
Caused by: org.apache.hadoop.hbase.client.RetriesExhaustedException: Failed after attempts=36, exceptions:
Wed Sep 07 08:14:48 CST 2016, null, java.net.SocketTimeoutException: callTimeout=60000, callDuration=60316: row '20' on table 'src_customs' at region=src_customs,20,1473065204994.c5296399e88185d6d19e5b600e9376b5., hostname=hadoop-s1,60020,1472804690476, seqNum=2

截图如下:


解决办法:在连接的配置中设置超时时长。
public static Configuration getConfig(){
Configuration conf = HBaseConfiguration.create();
conf.addResource("core-site.xml");
conf.addResource("hbase-site.xml");
conf.set("hbase.zookeeper.quorum","hadoop-m,hadoop-s1,hadoop-s2,hadoop-s3");
conf.set("hbase.master", ",hadoop-m:60000");
conf.set("hbase.zookeeper.property.clientPort","2181");
conf.setInt("hbase.rpc.timeout",20000);
conf.setInt("hbase.client.operation.timeout",30000);
conf.setInt("hbase.client.scanner.timeout.period",200000);
return conf;
}

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值