-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhbase_test.java
More file actions
36 lines (30 loc) · 1.38 KB
/
hbase_test.java
File metadata and controls
36 lines (30 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package hbase;
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.HBaseAdmin;
public class hbase_test {
public static void main(String[] args) throws IOException,
MasterNotRunningException,ZooKeeperConnectionException{
// 取得一个数据库连接的配置参数对象
org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();
// 设置连接参数:HBase数据库所在的主机IP
conf.set("hbase.zookeeper.quorum", "192.168.10.59,192.168.10.61,192.168.10.63");
System.out.println("---------------连接1-----------------");
// 设置连接参数:HBase数据库使用的端口
conf.set("hbase.zookeeper.property.clientPort", "2181");
System.out.println("---------------连接2-----------------");
//conf.set("hbase.master", "192.168.10.59:60000");
// 取得一个数据库连接对象
//connection = ConnectionFactory.createConnection(conf);
//System.out.println("---------------连接3-----------------");
try{
HBaseAdmin.checkHBaseAvailable(conf);
System.out.println("connecten made!");
} catch (Exception error){
System.err.println("Error connecting HBase:"+error);
System.exit(1);
}
}
}