Chr*_*fer 6 hadoop hbase virtualbox cloudera
我尝试用客户端程序将一些数据写入hbase
HBase @ Hadoop在Cloudera @ ubuntu的预配置VM中运行.
客户端在托管VM的系统上运行,并直接在VM中运行客户端.
所以现在我想使用vm之外的客户端来访问vm上的服务器
我正在使用NAT.为了能够访问像HBase Master这样的服务器,HUE ...在vm上运行我在虚拟框中配置了端口转发:
因此,我可以访问HBase Master的概述站点,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>
Run Code Online (Sandbox Code Playgroud)
所以我期望转发工作:
运行客户端时日志中的错误消息如下所示:
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
Run Code Online (Sandbox Code Playgroud)
正确的连接日志(直接在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
Run Code Online (Sandbox Code Playgroud)
所以我现在只在第一个问题之前在日志行中看到连接url不正确,因为端口被正确转发但是IP仍然是localhost而不是端口转发设置中配置的10.0.2.15:
Opening socket connection to server localhost/127.0.0.1:2181
Run Code Online (Sandbox Code Playgroud)
只有我发现的提示是禁用IPV6 - >在主机(win7)和vm(Ubuntu)中禁用并检查端口 - >它们被正确转发
有人有想法吗?
只是为阅读此内容的用户提供附加值,以下是解决方案:
Could not resolve the DNS name of cloudera-vm
Run Code Online (Sandbox Code Playgroud)
要解决这个问题,我只需添加到C:\ Windows\System32\drivers\etc\hosts:
192.168.56.101 cloudera-vm
Run Code Online (Sandbox Code Playgroud)
因此,每当使用cloudera-vm时,它都会被解析为适当的IP.VM现在以仅主机网络模式运行,现在分配给192.168.56.101.因此不需要端口转发.
仅供比较:
HBase的-site.xml中
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>cloudera-vm</value>
</property>
</configuration>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
之后我又收到了一个错误(连接被拒绝了,虽然所有的连接字符串都是正确的)因此我研究了几天的原因.
解决方案是通过将以下内容附加到文件来禁用在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
Run Code Online (Sandbox Code Playgroud)
重启后一切都连接并正常工作:)
| 归档时间: |
|
| 查看次数: |
8279 次 |
| 最近记录: |