如何设置hbase HMaster主机?

时间:2015-08-21 04:43:36

标签: eclipse client hbase

我在Eclipse中编写了一个程序来测试与HBase的远程连接。这是从HBase Example API Usage修改的。它做了非常基本的事情:连接到hbase,如果存在则删除表,然后创建一个新表。这是代码:

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 ,另一方面,它在端口上的localhost 127.0.0.1搜索 HMaster 12000.这打破了连接,因为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

那么如何在192.168.12.120设置hbase主控主机?有人可以帮忙吗? 这里有两个配置文档:

0 个答案:

没有答案