使用java api操作HBase,创建表时卡住,不报错但是显示在一直运行
我用一台虚拟机,搭建一个单节点的Hadoop开发环境,然后在宿主机上写代码,操作HBase创建表时,卡住不报错显示一直在运行,但是直接用hbase shell 命令操作表示可以的。有没有大神遇到过这个问题,求帮助
这是所写的类
public class HBaseTest {
/**
* 配置ss
*/
static Configuration conf = null;
private Connection conn = null;
private Table table = null;
@Before
public void init() throws Exception{
conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "192.168.209.129");
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.set("hbase.master", "192.168.209.129:60000");
conn = ConnectionFactory.createConnection(conf);
table = conn.getTable(TableName.valueOf("user"));
}
@SuppressWarnings("resource")
@Test
public void createTable() throws Exception{
//创建表管理类
@SuppressWarnings("deprecation")
HBaseAdmin admin = new HBaseAdmin(conf);
//创建表描述类
TableName tableName = TableName.valueOf("test1");
HTableDescriptor desc = new HTableDescriptor(tableName);
//创建列族的描述类
HColumnDescriptor family = new HColumnDescriptor("info1");
//将列族添加到表中
desc.addFamily(family);
HColumnDescriptor family2 = new HColumnDescriptor("info2");
//将列族添加到表中
desc.addFamily(family2);
admin.createTable(desc);
System.out.println("create table " + tableName + " ok.");
}
}
这是hbase-site.xml配置文件
<configuration>
<property>
<name>hbase.master</name>
<value>192.168.209.129:60000</value>
</property>
<property>
<name>hbase.master.maxclockskew</name>
<value>180000</value>
</property>
<property>
<name>hbase.rootdir</name>
<value>hdfs://192.168.209.129:9000/hbase</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/usr/local/hbase/tmp/zookeeper</value>
</property>
</configuration>