HBase Java API 问题之put 卡住

编程入门 行业动态 更新时间:2024-10-11 09:22:59

HBase <a href=https://www.elefans.com/category/jswz/34/1770091.html style=Java API 问题之put 卡住"/>

HBase Java API 问题之put 卡住

搭建好Hbase集群环境,熟悉其基本原理后,下载eclipse后,编写代码,操作hbase API,往Hbase中添加数据,卡在了put。

public static void insertData() throws IOException{//put对象 数据插入的操作对象System.out.println("insertData begin");String rowkey="000001";String cf = "C1";String cn = "testdata";String value = "2022/05/12";Put put = new Put(Bytes.toBytes(rowkey));//给put对象赋值put.addColumn(Bytes.toBytes(cf), Bytes.toBytes(cn), Bytes.toBytes(value));//插入数据System.out.println("put begin");table.put(put);System.out.println("put end");//关闭表连接//table.close();System.out.println("insertData end");}
conf.set("hbase.zookeeper.quorum", "mu01:2181,cu01:2181,cu02:2181");上面是我的代码段,mu01,cu01,cu02是集群的地址。使用getTable可以获取到Table。当时感觉奇怪,windows怎么会识别这些域名呢,想着表都获取了,就以为没问题了。
put的时候出问题了。。。。。。

很长一段时间后,报错新信息如下:

org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException: Failed 1 action: RetriesExhaustedException: 1 time, servers with issues: null
closed success!at org.apache.hadoop.hbase.client.AsyncProcess$BatchErrors.makeException(AsyncProcess.java:295)at org.apache.hadoop.hbase.client.AsyncProcess$BatchErrors.access$2300(AsyncProcess.java:271)at org.apache.hadoop.hbase.client.AsyncProcess.waitForAllPreviousOpsAndReset(AsyncProcess.java:1924)at org.apache.hadoop.hbase.client.BufferedMutatorImpl.backgroundFlushCommits(BufferedMutatorImpl.java:303)at org.apache.hadoop.hbase.client.BufferedMutatorImpl.flush(BufferedMutatorImpl.java:266)at org.apache.hadoop.hbase.client.HTable.flushCommits(HTable.java:1477)at org.apache.hadoop.hbase.client.HTable.put(HTable.java:1024)at hbase_test1.testconnection.insertData(testconnection.java:96)at hbase_test1.testconnection.main(testconnection.java:108)

上网查询资料,提到hosts文件,才恍然大悟,需要修改windows(windows下安装的eclipse,调用的Hbase java API)下的hosts文件,添加Hbase集群域名地址。windows下的hosts文件路径:  C:\Windows\System32\drivers\etc\hosts

更多推荐

HBase Java API 问题之put 卡住

本文发布于:2024-03-06 21:48:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1716458.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Java   HBase   put   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!