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 卡住
发布评论