Eclipse 如何设置hbase HMaster主机?
我在Eclipse中编写了一个程序来测试与HBase的远程连接。这是从中修改的。它做一些非常基本的事情:连接到hbase,删除一个表(如果存在),然后创建一个新表。代码如下:Eclipse 如何设置hbase HMaster主机?,eclipse,client,hbase,Eclipse,Client,Hbase,我在Eclipse中编写了一个程序来测试与HBase的远程连接。这是从中修改的。它做一些非常基本的事情:连接到hbase,删除一个表(如果存在),然后创建一个新表。代码如下: public class TableTest { private static Configuration conf = null; static{ conf = HBaseConfiguration.create(); conf.set("hbase.zookeeper
public class TableTest {
private static Configuration conf = null;
static{
conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum","192.168.12.120");
conf.set("hbase.zookeeper.property.clientPort","2181");
//conf.set("hbase.master", "192.168.12.120:12000"); // not work
}
public static void main(String[] args){
String tableName = "hbase_table";
try {
Connection connection = ConnectionFactory.createConnection(conf);
Admin admin = connection.getAdmin();
HTableDescriptor table = new HTableDescriptor(TableName.valueOf(tableName));
table.addFamily(new HColumnDescriptor("info"));
if(admin.tableExists(table.getTableName())){
admin.disableTable(table.getTableName());
admin.deleteTable(table.getTableName());
}
admin.createTable(table);
} catch (IOException e) {
e.printStackTrace();
}
}
}
但是,我在连接时遇到了一些问题。消息如下。一方面,程序在端口16020的192.168.12.120
处搜索HRegionServer,另一方面,它在端口12000的localhost127.0.0.1
处搜索HMaster。这中断了连接,因为HRegionServer和HMaster都运行在192.168.12.120
1294 DEBUG [2015-08-21 11:08:49] Use SIMPLE authentication for service ClientService, sasl=false
1311 DEBUG [2015-08-21 11:08:49] Connecting to /192.168.12.120:16020
1357 DEBUG [2015-08-21 11:08:49] Reading reply sessionid:0x14f39c8a9f20060, packet:: clientPath:null serverPath:null finished:false header:: 5,3 replyHeader:: 5,1210,0 request:: '/hbase,F response:: s{4,4,1439021727692,1439021727692,0,116,0,0,0,16,1191}
1360 DEBUG [2015-08-21 11:08:49] Reading reply sessionid:0x14f39c8a9f20060, packet:: clientPath:null serverPath:null finished:false header:: 6,4 replyHeader:: 6,1210,0 request:: '/hbase/master,F response:: #ffffffff000146d61737465723a3132303030ffffffc4ffffffbbffffffbcffffffd251ffffffb2ffffffe0ffffffb950425546a15a96c6f63616c686f737410ffffffe05d18ffffff89ffffffc5ffffffa1fffffff1fffffff42910018ffffff8a7d,s{1170,1170,1440125319355,1440125319355,0,0,0,94357651205521495,57,0,1170}
1369 DEBUG [2015-08-21 11:08:49] Use SIMPLE authentication for service MasterService, sasl=false
1369 DEBUG [2015-08-21 11:08:49] Connecting to localhost/127.0.0.1:12000
那么,如何将hbase主机设置为192.168.12.120
?有人能帮忙吗?以下是配置的两个文档: