TOP

Java 连接HBASE ,执行查询超时的解决方法
2018-12-22 13:49:19 】 浏览:543
Tags: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;
}


Java 连接HBASE ,执行查询超时的解决方法 https://www.cppentry.com/bencandy.php?fid=118&id=200068

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇spark-structstreaming-结果数据.. 下一篇Spark 读取Hbase表数据并实现类似..