Hbase远程连接到独立实例

时间:2017-06-06 14:52:17

标签: hbase

我第一次尝试设置HBase。我能够在服务器上成功运行本机Hbase shell。但我无法通过客户端远程连接。

我在主机上使用以下命令启动Hbase: /home/kirill/hbase/hbase-1.2.5/bin/start-hbase.sh

要从客户端连接,我在Python(Anaconda)中运行以下命令:

>>> import happybase
>>> co = happybase.Connection('192.168.0.18',2181)
>>> co.tables()

尝试使用co.tables()列出表格时出现以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\soft\miniconda2\lib\site-packages\happybase\connection.py", line 242, in tables
    names = self.client.getTableNames()
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\thrift.py", line 198, in _req
    return self._recv(_api)
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\thrift.py", line 210, in _recv
    fname, mtype, rseqid = self._iprot.read_message_begin()
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\protocol\binary.py", line 372, in read_message_begin
    self.trans, strict=self.strict_read)
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\protocol\binary.py", line 164, in read_message_begin
    sz = unpack_i32(inbuf.read(4))
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\transport\__init__.py", line 32, in read
    return readall(self._read, sz)
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\transport\__init__.py", line 14, in readall
    chunk = read_fn(sz - have)
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\transport\buffered\__init__.py", line 39, in _read
    self._rbuf = BytesIO(self._trans.read(max(sz, self._buf_size)))
  File "C:\soft\miniconda2\lib\site-packages\thriftpy\transport\socket.py", line 125, in read
    message='TSocket read 0 bytes')
thriftpy.transport.TTransportException: TTransportException(message='TSocket read 0 bytes', type=4)

以下是Hbase日志的最后3行:

它表示接受来自192.168.0.11(客户端IP)的连接,但在此之后它会抛出Exception causing close of session

2017-06-06 10:48:10,634 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxnFactory: Accepted socket connection from /192.168.0.11:58052
2017-06-06 10:48:11,841 WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxn: Exception causing close of session 0x0 due to java.io.IOException: Len error -2147418111
2017-06-06 10:48:11,842 INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181] server.NIOServerCnxn: Closed socket connection for client /192.168.0.11:58052 (no session established for client)

非常感谢任何帮助。这是主机设置:

Hbase设置:

主机运行Hbase :Ubuntu Server,Ubuntu 16.04.1 LTS(GNU / Linux 4.4.0-31-generic x86_64)

Hbase bin文件夹的路径:/home/kirill/hbase/hbase-1.2.5/bin

主机IP :192.168.0.18

CONF / HBase的-site.xml中

<configuration>

    <property>
        <name>hbase.rootdir</name>
        <value>file:///home/kirill/hbase/hbase-1.2.5/</value>
    </property>

    <property>
        <name>hbase.zookeeper.property.dataDir</name>
        <value>/home/kirill/zookeeper</value>
    </property>

    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>2181</value>
    </property>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>192.168.0.18</value>
    </property>

</configuration>

的/ etc /主机

127.0.0.1   localhost
192.168.0.18    ubuntu

1 个答案:

答案 0 :(得分:0)

发现此问题已为happybase python包打开:https://github.com/wbolster/happybase/issues/6

现在有效。 需要采取不同的方式做两件事:

  1. hbase必须像Thrift一样启动: /home/kirill/hbase/hbase-1.2.5/bin/hbase thrift start -threadpool

  2. 我不应该连接到hbase.zookeeper.property.clientPort下指定的端口2181,而是连接到happybase Connection()函数中使用的默认端口,我相信它是9090。

  3. 我还将/ etc / hosts文件更改为:

    192.168.0.18 ubuntu.ubuntu-domain ubuntu localhost