Hadoop:将多个IP地址绑定到集群NameNode

11
我在Softlayer上有一个四节点的Hadoop集群。主节点(NameNode)有一个公共IP地址用于外部访问和一个私有IP地址用于集群访问。从节点(datanodes)有私有IP地址,我试图连接到主节点而不需要为每个从节点分配公共IP地址。
我意识到将fs.defaultFS设置为NameNode的公共地址允许外部访问,但是NameNode仅侦听该地址的传入连接,而不是私有地址。因此,当数据节点尝试使用NameNode的私有IP地址进行连接时,我会在日志中看到ConnectionRefused异常。
我想到的解决方案可能是将公共和私有IP地址都设置为NameNode,以便保留外部访问并允许我的从节点连接。
那么,有办法将这两个地址绑定到NameNode,以便它将同时侦听两个地址?
编辑:Hadoop版本2.4.1。

1
你可以把你自己的修改作为答案发布,那么我就可以给它点赞了。 - Jeremy Hajek
@ikradex 你好,谢谢你的解决方案,但我仍然遇到一个问题,就是节点管理器仍然无法连接到资源管理器,即使我将“yarn.nodemanager.bind-host”的值设置为0.0.0.0。对此有什么建议吗? - Arnab
@StarLord 请避免使用注释来提出(跟进)问题。如果您有问题,可以提出新的问题。当然,您可能需要参考这个答案,但请确保问题本身已经正确地书写。 - Dennis Jaheruddin
2个回答

3
在hdfs-site.xml中,将dfs.namenode.rpc-bind-host的值设置为0.0.0.0,Hadoop将同时监听私有和公共网络接口,允许远程访问和数据节点访问。

2

HDFS支持多宿主网络并且是在Cloudera HDFS支持多宿主网络上完成的。Hortonworks的多宿主参数

<property>
  <name>dfs.namenode.rpc-bind-host</name>
  <value>0.0.0.0</value>
  <description>
    The actual address the RPC server will bind to. If this optional address is
    set, it overrides only the hostname portion of dfs.namenode.rpc-address.
    It can also be specified per name node or name service for HA/Federation.
    This is useful for making the name node listen on all interfaces by
    setting it to 0.0.0.0.
  </description>
</property>

此外,建议更改 dfs.namenode.rpc-bind-hostdfs.namenode.servicerpc-bind-hostdfs.namenode.http-bind-hostdfs.namenode.https-bind-host。默认情况下,HDFS 端点指定为主机名或 IP 地址。在任何一种情况下,HDFS 守护程序将绑定到单个 IP 地址,使得守护程序无法从其他网络访问。解决方案是为服务器端点设置单独的设置,以强制绑定通配符 IP 地址 INADDR_ANY,即 0.0.0.0。不要使用这些设置中的任何一个提供端口号。注意:在主/从配置文件中,最好使用主机名而不是 IP 地址。
<property>
  <name>dfs.namenode.rpc-bind-host</name>
  <value>0.0.0.0</value>
  <description>
    The actual address the RPC server will bind to. If this optional address is
    set, it overrides only the hostname portion of dfs.namenode.rpc-address.
    It can also be specified per name node or name service for HA/Federation.
    This is useful for making the name node listen on all interfaces by
    setting it to 0.0.0.0.
  </description>
</property>

<property>
  <name>dfs.namenode.servicerpc-bind-host</name>
  <value>0.0.0.0</value>
  <description>
    The actual address the service RPC server will bind to. If this optional address is
    set, it overrides only the hostname portion of dfs.namenode.servicerpc-address.
    It can also be specified per name node or name service for HA/Federation.
    This is useful for making the name node listen on all interfaces by
    setting it to 0.0.0.0.
  </description>
</property>

<property>
  <name>dfs.namenode.http-bind-host</name>
  <value>0.0.0.0</value>
  <description>
    The actual adress the HTTP server will bind to. If this optional address
    is set, it overrides only the hostname portion of dfs.namenode.http-address.
    It can also be specified per name node or name service for HA/Federation.
    This is useful for making the name node HTTP server listen on all
    interfaces by setting it to 0.0.0.0.
  </description>
</property>

<property>
  <name>dfs.namenode.https-bind-host</name>
  <value>0.0.0.0</value>
  <description>
    The actual adress the HTTPS server will bind to. If this optional address
    is set, it overrides only the hostname portion of dfs.namenode.https-address.
    It can also be specified per name node or name service for HA/Federation.
    This is useful for making the name node HTTPS server listen on all
    interfaces by setting it to 0.0.0.0.
  </description>
</property>

注意:在开始修改之前,请按以下方式停止代理和服务器:
1. service cloudera-scm-agent stop 2. service cloudera-scm-server stop 如果您的集群配置了主要和次要NameNodes,则此修改需要在两个节点上进行。修改是在“服务器和代理停止”的情况下完成的。
在完成并保存hdfs-site.xml文件后,使用以下命令启动NameNodes上的服务器和代理以及DataNodes上的代理(如果也这样做,不会对集群造成伤害):
1. service cloudera-scm-agent start 2. service cloudera-scm-server start
IBM BigInsights也可以实现相同的解决方案。
    To configure HDFS to bind to all the interfaces , add the following configuration variable using Ambari under the section HDFS
-> Configs ->Advanced -> Custom hdfs-site


    dfs.namenode.rpc-bind-host = 0.0.0.0

    Restart HDFS to apply the configuration change . 

    Verify if port 8020 is bound and listening to requests from all the interfaces using the following command. 

    netstat -anp|grep 8020
    tcp 0 0 0.0.0.0:8020 0.0.0.0:* LISTEN 15826/java

IBM BigInsights: 如何配置Hadoop客户端端口8020以绑定到所有网络接口?

在HDFS配置中,Cloudera有一个名为Bind NameNode to Wildcard Address的属性,只需勾选该框即可将服务绑定在0.0.0.0上。

然后重新启动hdfs服务

 On the Home > Status tab, click  to the right of the service
 name and select Restart. Click Start on the next screen to confirm.
 When you see a Finished status, the service has restarted.

开始,停止,刷新和重启集群启动,停止和重新启动服务


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接