我试着用一个客户端程序把一些数据写入hbase
HBase @ Hadoop在来自Cloudera @ ubuntu的预配置虚拟机中运行。
客户端在托管虚拟机的系统上运行,并直接在虚拟机中运行客户端。
因此,现在我想使用虚拟机外部的客户端来访问虚拟机上的服务器
我正在使用NAT。为了能够访问像HBase主服务器这样的服务器,我在虚拟机器中配置了端口转发的虚拟机上的HUE..running:

因此,我可以访问HBase大师的概述网站,色调..
为了在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正确的连接日志(直接在虚拟机上运行客户端时)如下所示:
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我发现的唯一提示是在主机(Win7)和虚拟机(Ubuntu)中禁用IPV6 ->,并检查端口->它们是否被正确转发
有谁有主意吗?
发布于 2011-09-27 22:37:48
为了给阅读这篇文章的用户增加价值,这里有一个解决方案:
Could not resolve the DNS name of cloudera-vm要解决这个问题,我只需添加到C:\Windows\System32\drivers\etc\hosts:
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>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>在那之后,我得到了另一个错误(连接被拒绝,尽管所有的连接字符串都是正确的),所以我花了几天的时间寻找原因。
解决方案是通过将以下内容附加到文件中来禁用在虚拟机上运行的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-11-18 15:50:55
我认为您可以在代码中清楚地设置配置,如下面的HbaseConfiguration conf = HbaseConfiguration.create();conf.set("hbase.zookeeper.quorum","ubuntu1,ubuntu2");...也许能帮你..。
发布于 2012-03-20 10:44:06
你有没有尝试过一个简单的方法:
<property name="connectionURL" value="hbase:master.standalone.hostname:60000"/>https://stackoverflow.com/questions/7337457
复制相似问题