hbase client无法连接到本地hbase server

今天下午浪费了不少时间在搞本地hbase server测试,测试代码如下:

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;

public class MyHbaseTester {

	public static void main(String[] args) throws IOException {

		Configuration config = HBaseConfiguration.create();
		config.set("hbase.zookeeper.quorum", "localhost");
		config.set("hbase.zookeeper.property.clientPort", "2181");
		HBaseAdmin.checkHBaseAvailable(config);
		HTable table = new HTable(config, "mytable");
		System.out.println("Table testTable obtained!");

	}
}

一直报一些莫名其妙的错误:



 



 

后来发现原来是java client的版本和server的版本不对,修改正确的依赖版本,问题解决:

	<dependency>
	  <groupId>org.apache.hbase</groupId>
	  <artifactId>hbase</artifactId>
	  <version>0.94.2</version>
	</dependency>
	
	<dependency>
	  <groupId>org.apache.hadoop</groupId>
	  <artifactId>hadoop-core</artifactId>
	  <version>1.0.0</version>
	</dependency>

猜你喜欢

转载自san-yun.iteye.com/blog/1995104