gpt4 book ai didi

docker - 无法从Docker容器外部访问Namenode

转载 作者:行者123 更新时间:2023-12-02 20:27:17 26 4
gpt4 key购买 nike

我通过docker开发了Hadoop应用程序,出于明显的原因,我试图从容器外部访问namenode。

我使用以下方法将端口与Dockerfile一起公开:

EXPOSE 2122 9000

然后,我以以下内容启动容器:
$ docker run -dit --rm --privileged --pid=host -p 2122:2122 -p 9000:9000 --name hnode ns/hnode

2122启用我用于SSH的端口。我已经安装了SSH服务器,对其进行了尝试,然后通过 可以从容器外部通过SSH进行连接。

我还向Hadoop添加了选项,以便将此SSH端口与 ENV HADOOP_SSH_OPTS="-p 2122"一起使用。

使用以下core-site.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>

当我尝试从容器内部telnet 9000时,一切都很好:
[hadoop@1f5c7934fe45 hadoop]$ telnet localhost 9000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

|��☼►☻↑ ")org.apache.hadoop.ipc.RPC$VersionMismatch*>Server IPC version 9 cannot communicate with client version 130♫: @☺Connection closed by foreign host.

您可以清楚地看到它是另一端的namenode。

但是,当我尝试使用主机ip从容器内部远程登录namenode所使用的9000端口时,我得到:
[hadoop@1f5c7934fe45 hadoop]$ telnet 172.17.0.2 9000
Trying 172.17.0.2...
telnet: connect to address 172.17.0.2: Connection refused

即使SSH正常运行:
[hadoop@1f5c7934fe45 hadoop]$ telnet 172.17.0.2 2122
Trying 172.17.0.2...
Connected to 172.17.0.2.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4

Protocol mismatch.
Connection closed by foreign host.

为什么SSH有效,但Hadoop的namenode不起作用?

最佳答案

实际上,我只需要将主机的IP放在core-site.xml而不是localhost中:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://172.17.0.2:9000</value>
</property>
</configuration>

这样,我能够使用外部路由从内部telnet namenode:
[hadoop@1f5c7934fe45 hadoop]$ telnet 172.17.0.2 9000
Trying 172.17.0.2...
Connected to 172.17.0.2.
Escape character is '^]'.

|��☼►☻↑ ")org.apache.hadoop.ipc.RPC$VersionMismatch*>Server IPC version 9 cannot communicate with client version 100♫: @☺Connection closed by foreign host.

甚至从外面:
λ curl 192.168.56.1:9000
It looks like you are making an HTTP request to a Hadoop IPC port. This is not the correct port for the web interface on this daemon.

我知道这些是错误,但是它们确认守护程序已回答并且可以访问。

关于docker - 无法从Docker容器外部访问Namenode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55648861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com