SSH:无法解析主机名。名称或服务不知道主机名、名称、SSH

2023-09-11 09:22:24 作者:上课的时候小明被老师点名答题,小明说:谢邀。下面小编分享一些

我试图建立的Hadoop在我的亚马逊实例,一个2节点集群上。每个实例有一个公共的DNS,我用引用它们。因此,在/ etc / hosts文件在两台机器上我附上这样的行文件:

  {第一实例的公共DNS}节点1
{2ST实例的公共DNS}节点2
 

我也能够ssh到从其他每个实例通过简单地做:

  SSH {另一个实例的公共DNS}
 

在Hadoop的/ conf目录/上的第一个实例文件,我的奴隶:

 本地主机
节点2
 
怎么知道自己手机上的主机名

当我启动脚本斌/ start-dfs.sh 它能够启动名称节点,数据节点,并在主二次名称节点,但它说:

 节点2:SSH:无法解析主机名节点2:名称或服务不为人所知
 

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

  SSH节点2
 

我想这个问题是我怎么告诉它到节点相关联的第二个实例的公共DNS。难道还不足以追加

  {2ST实例的公共DNS}节点2
 

行到/ etc / hosts文件? 我一定要重新启动的情况下?

解决方案

/ etc / hosts中善良的行为就像是本地DNS,​​当你没有真正的DNS与IP地址相关联。

你真的需要一个 {第一实例的公共DNS}节点1 映射,如果你可以使用{1日实例的公共DNS}直接在主从设备文件

此外,它更好地使用,而不是使用公共IP地址亚马逊实例的私有IP地址。你可以在每个实例的终端做了的ifconfig 并确定其是否任何私有IP地址。他们可能会基本上将与10.xxx/172.xxx/192.xxx开始?你也许可以再图的,而不是在/ etc / hosts文件中的每个亚马逊实例。

所以,每台机器的/ etc / hosts文件应该是这个样子 -

机1:

  {IP_address_1st_instance}节点1
{IP_address_2st_instance}节点2
 

机2:

  {IP_address_1st_instance}节点1
{IP_address_2st_instance}节点2
 

和,这是为了让亚马逊实例(机)可以化解对方,如果你是无论如何打算映射。

I'm trying to set up hadoop on my amazon instances, on a 2 node cluster. Each instance has a public dns, which I use reference them. So in the /etc/hosts files on both machines I append lines like this:

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

I'm also able to ssh into each instance from the other by simply doing:

ssh {public dns of the other instance}

In the the hadoop/conf/slaves on the first instance file I have:

localhost
node2

When I start the script bin/start-dfs.sh It's able to start the namenode, datanode, and secondary namenode on the master, but it says:

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

The same it printed out if I try:

ssh node2

I guess the question is how do I tell it to associate node2 with the public dns of the second instance. Is it not enough to append the

{public dns of 2st instance} node2

line to the /etc/hosts file? Do I have to reboot the instances?

解决方案

/etc/hosts kind of act like a local DNS, when you don't have real DNS associated with an IP address.

Do you really need a {public dns of 1st instance} node1 mapping if you can use {public dns of 1st instance} directly in the slave and master files?

Moreover, it's better to use the private IP addresses of amazon instances instead of using the public IP addresses. You can do a ifconfig in the terminal of each instances and determine their private IP addresses if any. They will probably basically will start with 10.x.x.x/172.x.x.x/192.x.x.x? You can probably then map those instead in /etc/hosts in each of the amazon instances.

So, your /etc/hosts in each machine should look something like -

Machine-1:

{IP_address_1st_instance} node1
{IP_address_2st_instance} node2

Machine-2:

{IP_address_1st_instance} node1
{IP_address_2st_instance} node2

And, this is so that the Amazon instances(machines) can resolve each other, if you are anyhow planning to map them.