我正在尝试从我的电脑上的Java客户端(Windows Server 2008)上的ec2连接hbase独立版(0.94.27)。
这是我的代码片段
HBaseChatConfiguration conf = HBaseChatConfiguration.getInstance();
conf.set("hbase.zookeeper.quorum", "my ec2 IP Address");
HTablePool tablePool = null;
try {
tablePool = new HTablePool(conf.getConfiguration(), 10);
HTableInterface table = tablePool.getTable(Bytes.toBytes("helloTable"));
System.out.println("table initiated");
Put p = new Put(Bytes.toBytes("testRow1"));
p.add(Bytes.toBytes("cf1"), Bytes.toBytes("cfs"), Bytes.toBytes("test"));
table.put(p);
但java应用程序打印出异常,
Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hbase.client.NoServerForRegionException: Unable to find region for helloTable,,99999999999999 after 10 tries.
at org.apache.hadoop.hbase.client.HTableFactory.createHTableInterface(HTableFactory.java:38)
at org.apache.hadoop.hbase.client.HTablePool.createHTable(HTablePool.java:265)
at org.apache.hadoop.hbase.client.HTablePool.findOrCreateTable(HTablePool.java:195)
at org.apache.hadoop.hbase.client.HTablePool.getTable(HTablePool.java:174)
at org.apache.hadoop.hbase.client.HTablePool.getTable(HTablePool.java:213)
at kr.stocktalk.chat.ChatServer.main(ChatServer.java:42)
Caused by: org.apache.hadoop.hbase.client.NoServerForRegionException: Unable to find region for helloTable,,99999999999999 after 10 tries.
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:955)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:860)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegionInMeta(HConnectionManager.java:962)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:864)
at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.locateRegion(HConnectionManager.java:821)
at org.apache.hadoop.hbase.client.HTable.finishSetup(HTable.java:234)
at org.apache.hadoop.hbase.client.HTable.<init>(HTable.java:174)
at org.apache.hadoop.hbase.client.HTableFactory.createHTableInterface(HTableFactory.java:36)
... 5 more
但我可以访问本地shell上的表
hbase(main):001:0> describe 'helloTable'
DESCRIPTION ENABLED
'helloTable', {NAME => 'cf1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'NONE', REPLICATION_SCO true
PE => '0', VERSIONS => '3', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_D
ELETED_CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', ENCODE_ON_DISK => 'true', BLOC
KCACHE => 'true'}
1 row(s) in 0.9700 seconds
如何从java客户端应用程序访问?
编辑:
这是hbase日志
2016-03-26 06:37:11,607 INFO org.apache.hadoop.hbase.master.LoadBalancer: Skipping load balancing because balanced cluster; servers=1 regions=1 average=1.0 mostloaded=1 leastloaded=1
2016-03-26 06:37:11,612 DEBUG org.apache.hadoop.hbase.client.MetaScanner: Scanning .META. starting at row= for max=2147483647 rows using org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@6b171477
2016-03-26 06:37:11,615 DEBUG org.apache.hadoop.hbase.master.CatalogJanitor: Scanned 1 catalog row(s) and gc'd 0 unreferenced parent region(s)
2016-03-26 06:38:12,490 INFO org.apache.zookeeper.server.NIOServerCnxnFactory: Accepted socket connection from /106.249.235.42:64629
2016-03-26 06:38:12,490 INFO org.apache.zookeeper.server.ZooKeeperServer: Client attempting to establish new session at /106.249.235.42:64629
2016-03-26 06:38:12,495 INFO org.apache.zookeeper.server.ZooKeeperServer: Established session 0x153b183d8e6000c with negotiated timeout 40000 for client /106.249.235.42:64629
2016-03-26 06:42:02,390 DEBUG org.apache.hadoop.hbase.io.hfile.LruBlockCache: Stats: total=2.04 MB, free=245.89 MB, max=247.92 MB, blocks=1, accesses=30, hits=29, hitRatio=96.66%, , cachingAccesses=30, cachingHits=29, cachingHitsRatio=96.66%, , evictions=0, evicted=0, evictedPerRun=NaN
2016-03-26 06:42:11,608 INFO org.apache.hadoop.hbase.master.LoadBalancer: Skipping load balancing because balanced cluster; servers=1 regions=1 average=1.0 mostloaded=1 leastloaded=1
2016-03-26 06:42:11,613 DEBUG org.apache.hadoop.hbase.client.MetaScanner: Scanning .META. starting at row= for max=2147483647 rows using org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@6b171477
2016-03-26 06:42:11,616 DEBUG org.apache.hadoop.hbase.master.CatalogJanitor: Scanned 1 catalog row(s) and gc'd 0 unreferenced parent region(s)
2016-03-26 06:47:02,391 DEBUG org.apache.hadoop.hbase.io.hfile.LruBlockCache: Stats: total=2.04 MB, free=245.89 MB, max=247.92 MB, blocks=1, accesses=30, hits=29, hitRatio=96.66%, , cachingAccesses=30, cachingHits=29, cachingHitsRatio=96.66%, , evictions=0, evicted=0, evictedPerRun=NaN
2016-03-26 06:47:11,608 INFO org.apache.hadoop.hbase.master.LoadBalancer: Skipping load balancing because balanced cluster; servers=1 regions=1 average=1.0 mostloaded=1 leastloaded=1
2016-03-26 06:47:11,614 DEBUG org.apache.hadoop.hbase.client.MetaScanner: Scanning .META. starting at row= for max=2147483647 rows using org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@6b171477
2016-03-26 06:47:11,617 DEBUG org.apache.hadoop.hbase.master.CatalogJanitor: Scanned 1 catalog row(s) and gc'd 0 unreferenced parent region(s)
2016-03-26 06:49:06,196 WARN org.apache.zookeeper.server.NIOServerCnxn: Exception causing close of session 0x153b183d8e6000c due to java.io.IOException: Connection reset by peer
2016-03-26 06:49:06,196 INFO org.apache.zookeeper.server.NIOServerCnxn: Closed socket connection for client /106.249.235.42:64629 which had sessionid 0x153b183d8e6000c
2016-03-26 06:49:46,000 INFO org.apache.zookeeper.server.ZooKeeperServer: Expiring session 0x153b183d8e6000c, timeout of 40000ms exceeded
2016-03-26 06:49:46,000 INFO org.apache.zookeeper.server.PrepRequestProcessor: Processed session termination for sessionid: 0x153b183d8e6000c