【问题标题】:ssh: Could not resolve hostname. Name or service not knownssh:无法解析主机名。名称或服务未知
【发布时间】:2013-08-10 15:36:26
【问题描述】:

我正在尝试在我的亚马逊实例上的 2 节点集群上设置 hadoop。每个实例都有一个公共 dns,我使用它来引用它们。因此,在两台机器上的 /etc/hosts 文件中,我添加了如下行:

{public dns of 1st instance} node1
{public dns of 2st instance} node2

我还可以通过简单的操作从另一个实例 ssh 到每个实例:

ssh {public dns of the other instance}

在我拥有的第一个实例文件的 hadoop/conf/slaves 中:

localhost
node2

当我启动脚本 bin/start-dfs.sh 它能够在 master 上启动 namenode、datanode 和辅助 namenode,但它说:

node2: ssh: Could not resolve hostname node2: Name or service not known

如果我尝试,它会打印出来:

ssh node2

我想问题是如何告诉它将 node2 与第二个实例的公共 dns 相关联。追加是不是不够

{public dns of 2st instance} node2

/etc/hosts 文件的行? 我必须重启实例吗?

【问题讨论】:

    标签: hadoop ssh amazon-web-services amazon-ec2 hosts


    【解决方案1】:

    /etc/hosts 有点像本地 DNS,当您没有与 IP 地址关联的真实 DNS 时。

    如果您可以直接在从属文件和主文件中使用{public dns of 1st instance},您真的需要{public dns of 1st instance} node1 映射吗?

    此外,最好使用亚马逊实例的私有 IP 地址,而不是使用公共 IP 地址。您可以在每个实例的终端中执行ifconfig 并确定它们的私有 IP 地址(如果有)。他们可能基本上会从 10.x.x.x/172.x.x.x/192.x.x.x 开始?然后,您可能可以将它们映射到每个亚马逊实例的 /etc/hosts 中。

    所以,每台机器上的 /etc/hosts 应该看起来像 -

    机器 1:

    {IP_address_1st_instance} node1
    {IP_address_2st_instance} node2
    

    机器 2:

    {IP_address_1st_instance} node1
    {IP_address_2st_instance} node2
    

    而且,如果您打算映射它们,亚马逊实例(机器)可以相互解析。

    【讨论】:

    • 直接在 master 和 slave 文件中使用 public dns 没有问题。至于使用私有ip,我刚刚在/etc/hosts文件中用相应的私有ip替换了公共dns,在我看到你的答案之前,它给了我同样的错误。
    • 但我确实使用了 ip-10.x.x.x,而不是 10.x.x.x,这可能是问题所在吗?
    • 如果我使用 ssh ip-10.x.x.x.,我可以使用私有 ip 进行 ssh,但不能使用 ssh 10.x.x.x
    • “但我确实使用了 ip-10.x.x.x,而不是 10.x.x.x” - 我没听懂?
    • aws 控制台告诉您私有 ip,但地址前面带有“ip-”
    猜你喜欢
    • 2019-12-18
    • 2022-01-17
    • 2013-12-13
    • 1970-01-01
    • 2014-09-18
    • 2021-08-18
    • 1970-01-01
    • 1970-01-01
    • 2019-04-07
    相关资源
    最近更新 更多