2011-09-07 86 views
6

上運行與客戶端我嘗試與客戶端程序HBase的訪問在VM主機系統

HBase的寫一些數據到HBase的@ Hadoop的一個預配置的虛擬機從Cloudera的@ Ubuntu的運行。

客戶端在託管虛擬機的系統上運行,並直接在虛擬機中運行客戶端。

所以現在我想使用的客戶端虛擬機之外的訪問在VM

我使用NAT服務器。 爲了能夠訪問像HBase的主服務器,HUE..running在VM我在配置虛框端口轉發:enter image description here

因此我能達到HBase的主,HUE的概述網站..

若要對虛擬機上的服務器,客戶端,我創建 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> 

所以我預計,轉發作品:

錯誤信息S中的日誌中運行的客戶端時的樣子:

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 

正確的連接日誌(直接在虛擬機上運行的客戶端時)看起來像:

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 

所以我現在只在日誌中看到

Opening socket connection to server localhost/127.0.0.1:2181 

只:第一個問題是連接的URL是不正確的端口正確轉發,但IP仍然是本地主機,而不是爲10.0.2.15配置端口轉發設置前行提示我發現禁用IPV6 - >在主機(win7)和虛擬機(Ubuntu) 禁用,並檢查端口 - >他們正確轉發

有沒有人有想法?

+1

你的端口,似乎我錯了。 你的日誌說localhost:2181雖然你配置了9997.我在我的Virtual Box羣集上嘗試了相同的設置,它工作正常。實際上你不必設置其他端口,在虛擬機上保持不變。 =>沒有混淆:) 如果這不是問題,您可以轉發端口22,並通過putty打開SSH連接並隧道您的端口。 –

回答

5

只給增值用戶讀這篇文章,這裏是解決方案:

Could not resolve the DNS name of cloudera-vm 

爲了解決這個問題我簡單地添加到C:\ WINDOWS \ SYSTEM32 \ DRIVERS \等\主機:

192.168.56.101 cloudera-vm 

因此,無論何時使用cloudera-vm,它都會解析爲適當的IP。 虛擬機現在以主機專用網絡模式運行,現在分配給192.168.56.101。 所以不需要端口轉發。

就比較:

HBase的-site.xml中

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

持久性。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 

重啓後一切都連接和工作正常:)

+0

基督徒,你的禁用IPV6的建議非常有幫助。謝謝。 –

0

我認爲你可以在代碼中清楚地設置配置,如下所示: HbaseConfiguration conf = HbaseConfiguration.create(); conf.set(「hbase.zookeeper.quorum」,「ubuntu1,ubuntu2」); ... 也許幫助你..

+0

請注意,這個問題有一個多月前接受的答案。 – Amy

0

你嘗試過一個簡單的:

<property name="connectionURL" value="hbase:master.standalone.hostname:60000"/>