Не удается подключиться к HBase (Zookeeper), работающему на Vagrant

У меня есть простая бродячая машина, у которой есть отдельный экземпляр на HBase. Когда я запускаю hbase, я могу получить доступ к URL-адресу информации hbase http://192.168.99.101:16010/master-status.

Но когда я пытаюсь подключиться через java, я не могу подключиться к Zookeeper.

Бродячий файл

Vagrant.configure("2") do |config|
  config.vm.box = "hbase-phoenix"  # A simple HBase phoenix box
  config.vm.box_check_update = false
  config.vbguest.auto_update = false
  config.vm.define "hbase_pnx" do |hbase_pnx|
    hbase_pnx.vm.hostname = "hbasepnx"
    hbase_pnx.vm.network "private_network", ip: "192.168.99.101"
    hbase_pnx.vm.network "forwarded_port", guest: 2181, host: 2181
    hbase_pnx.vm.network "forwarded_port", guest: 16010, host: 16010
  end
end

Хост-файл на виртуальной машине выглядит так

vagrant@hbasepnx:~$ cat /etc/hosts
192.168.99.101  hbasepmx        hbasepnx
192.168.99.101  hbase-vm        hbase-vm
192.168.99.101  localhost
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

hbase-site.xml выглядит так

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:///home/vagrant/data/hbase</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/vagrant/data/zookeeper</value>
  </property>
  <property>
    <name>hbase.cluster.distributed</name>
    <value>false</value>
  </property>
</configuration>

Простой тестовый код выглядит так

public void testHBaseCRUD() throws Exception {
        Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum", "192.168.99.101");
        config.set("hbase.zookeeper.property.clientPort", "2181");
        try (HTable htable = new HTable(config, tableName)) {
            int total = 100;
            long t1 = System.currentTimeMillis();
            for (int i = 0; i < total; i++) {
                int userid = i;
                String email = "user-" + i + "@foo.com";
                String phone = "555-1234";

                byte[] key = Bytes.toBytes(userid);
                Put put = new Put(key);

                put.add(Bytes.toBytes(familyName), Bytes.toBytes("FIRST_NAME"), Bytes.toBytes(email));  // <-- email goes here
                put.add(Bytes.toBytes(familyName), Bytes.toBytes("LAST_NAME"), Bytes.toBytes(phone));  // <-- phone goes here
                htable.put(put);

        }
        long t2 = System.currentTimeMillis();
        System.out.println("inserted " + total + " users  in " + (t2 - t1) + " ms");

    }

Версия Hbase — hbase-1.1.9.

2017-03-28 10:06:01,422 INFO  [main-SendThread(192.168.99.101:2181)] zookeeper.ClientCnxn (ClientCnxn.java:primeConnection(852)) - Socket connection established to 192.168.99.101/192.168.99.101:2181, initiating session
2017-03-28 10:06:01,427 INFO  [main-SendThread(192.168.99.101:2181)] zookeeper.ClientCnxn (ClientCnxn.java:onConnected(1235)) - Session establishment complete on server 192.168.99.101/192.168.99.101:2181, sessionid = 0x15b1534b9900009, negotiated timeout = 40000
2017-03-28 10:06:50,084 INFO  [hconnection-0x4206a205-metaLookup-shared--pool2-t1] client.RpcRetryingCaller (RpcRetryingCaller.java:callWithRetries(142)) - Call exception, tries=10, retries=35, started=48438 ms ago, cancelled=false, msg=row 'user,    ,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hbasepmx,37628,1490709431477, seqNum=0
2017-03-28 10:07:02,605 INFO  [hconnection-0x4206a205-metaLookup-shared--pool2-t1] client.RpcRetryingCaller (RpcRetryingCaller.java:callWithRetries(142)) - Call exception, tries=11, retries=35, started=60963 ms ago, cancelled=true, msg=row 'user,    ,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hbasepmx,37628,1490709431477, seqNum=0
2017-03-28 10:07:48,168 INFO  [hconnection-0x4206a205-metaLookup-shared--pool2-t2] client.RpcRetryingCaller (RpcRetryingCaller.java:callWithRetries(142)) - Call exception, tries=10, retries=35, started=46421 ms ago, cancelled=false, msg=row 'user,    ,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hbasepmx,37628,1490709431477, seqNum=0
2017-03-

Любая помощь будет оценена. Спасибо


person Dave    schedule 28.03.2017    source источник


Ответы (1)


По-видимому, на этот вопрос есть ответ в Невозможно для подключения к автономному серверу HBase из удаленного клиента Windows

Проблема в том, что Zookeeper подключается только по имени хоста, а не по IP.

поэтому в моем хост-файле Windows мне нужно добавить

192.168.99.101  hbasepmx        hbasepnx
192.168.99.101  hbase-vm        hbase-vm

И в коде изменение,

config.set("hbase.zookeeper.quorum", "hbase-vm");
person Dave    schedule 28.03.2017