7

クライアントプログラムでhbaseにデータを書き込もうとしています

HBase @ Hadoop は、Cloudera @ ubuntu から事前構成された VM で実行されます。

クライアントは、VM をホストするシステム上で実行され、VM 内で直接クライアントを実行します。

だから今私はvmの外のクライアントを使ってvm上のサーバーにアクセスしたい

NATを使用しています。HBase Master、HUE などのサーバーにアクセスできるようにするために、仮想ボックスでポート転送を構成した vm で実行されています。ここに画像の説明を入力

このようにして、HBase マスター、HUE の概要サイトにアクセスできます。

vm 上のサーバーに対してクライアントを実行するために、コンテンツを含む hbase-site.xml を作成しました。

<configuration>
    <property>
        <name>hbase.zookeeper.quorum</name>
        <value>localhost</value>
    </property>
    <property>
        <name>hbase.zookeeper.property.clientPort</name>
        <value>9997</value>
    </property>
    <property>
        <name>hbase.master</name>
        <value>localhost:9999</value>
    </property>
</configuration>

したがって、転送が機能することを期待していました:

クライアント実行時のログのエラー メッセージは次のようになります。

11/09/07 17:48:00 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
11/09/07 17:48:00 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181
11/09/07 17:48:01 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
11/09/07 17:48:01 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
11/09/07 17:48:01 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.SocketException: Address family not supported by protocol family: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:500)
    at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1050)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1077)
11/09/07 17:48:03 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181
11/09/07 17:48:04 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:567)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1119)
11/09/07 17:48:04 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
11/09/07 17:48:04 WARN zookeeper.ClientCnxn: Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.SocketException: Address family not supported by protocol family: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:500)
    at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:1050)
    at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1077)
11/09/07 17:48:05 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181

正しい接続ログ (vm でクライアントを直接実行している場合) は次のようになります。

11/09/07 09:05:29 INFO zookeeper.ZooKeeper: Initiating client connection, connectString=localhost:2181 sessionTimeout=180000 watcher=hconnection
11/09/07 09:05:29 INFO zookeeper.ClientCnxn: Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181
11/09/07 09:05:29 INFO zookeeper.ClientCnxn: Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
11/09/07 09:05:29 INFO zookeeper.ClientCnxn: Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x132449d36df0006, negotiated timeout = 40000

したがって、ポートが正しく転送されているため、接続 URL が正しくないという最初の問題の前に、ログ行にのみ表示されますが、IP はまだ localhost であり、ポート転送設定で構成されている 10.0.2.15 ではありません。

Opening socket connection to server localhost/127.0.0.1:2181

私が見つけた唯一のヒントは、IPV6を無効にすることです->ホスト(win7)およびvm(Ubuntu)で無効になり、ポートをチェックします->それらは正しく転送されます

誰かアイデアはありますか?

4

3 に答える 3

5

これを読んでいるユーザーに付加価値を与えるために、ここに解決策があります:

Could not resolve the DNS name of cloudera-vm

これを修正するには、 C:\Windows\System32\drivers\etc\hosts に追加するだけです:

192.168.56.101  cloudera-vm

そのため、cloudera-vm が使用されるたびに、適切な IP に解決されます。VM は現在、ホストオンリー ネットワーク モードで実行されており、現在 192.168.56.101 に割り当てられています。したがって、ポート転送は必要ありません。

比較のために:

hbase-site.xml

<configuration>
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>cloudera-vm</value>
  </property>
</configuration>

persistence.xml

<persistence
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">

    <persistence-unit name="hbase-addressbook"
        transaction-type="RESOURCE_LOCAL">

        <properties>
            <property name="datanucleus.ConnectionURL" value="hbase:cloudera-vm" />
            <property name="datanucleus.ConnectionUserName" value="" />
            <property name="datanucleus.ConnectionPassword" value="" />
            <property name="datanucleus.autoCreateSchema" value="true" />
            <property name="datanucleus.validateTables" value="false" />
            <property name="datanucleus.Optimistic" value="false" />
            <property name="datanucleus.validateConstraints" value="false" />
        </properties>
    </persistence-unit>
</persistence>

その後、別のエラー (すべての接続文字列が正しいにもかかわらず、接続が拒否された) が発生したため、原因を何日も調査しました。

解決策は、ファイルに以下を追加して、VM で実行されている Ubuntu の IPV6 を無効にすることでした: /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

再起動後、すべてが接続され、正しく動作します:)

于 2011-09-27T14:37:47.673 に答える
0

簡単なことを試しましたか:

<property name="connectionURL" value="hbase:master.standalone.hostname:60000"/>
于 2012-03-20T02:44:05.703 に答える