简体   繁体   English

EC2上的Hadoop配置:为什么公共DNS有效但公共IP不起作用?

[英]Hadoop config on EC2: why public DNS works but not public IP?

I am setting up Hadoop on EC2. 我正在EC2上设置Hadoop。 For the fs.default.name , fs.defaultFS , if I use the DNS for the name node, everything works. 对于fs.default.namefs.defaultFS ,如果我将DNS用作名称节点,则一切正常。 But if I use the public IP, name node cannot start with the except Problem binding to [54.210.86.207:9000] java.net.BindException: Cannot assign requested address; 但是,如果我使用公共IP,则名称节点无法以“ Problem binding to [54.210.86.207:9000] java.net.BindException: Cannot assign requested address;开头,无法开始Problem binding to [54.210.86.207:9000] java.net.BindException: Cannot assign requested address; . Any explanation why the public DNS works but not the public IP? 为什么公共DNS有效但公共IP不起作用?

  <property>
    <name>fs.default.name</name>
    <value>hdfs://54.210.86.207:9000</value>
    <!-- <value>hdfs://ec2-54-210-86-207.compute-1.amazonaws.com:9000</value> -->
  </property>

  <property>
    <name>fs.defaultFS</name>
    <value>hdfs://54.210.86.207:9000</value>
    <!-- <value>hdfs://ec2-54-210-86-207.compute1.amazonaws.com:9000</value> -->
 </property>  

Inside VPC, a DNS query of your instance's public IP address's public hostname does something useful -- and documented -- but otherwise potentially unexpected: it resolves to the machine's private IP address. 在VPC内,对实例的公共IP地址的公共主机名进行DNS查询会做一些有用的事情-并记录在案-但可能会意外:它将解析为计算机的私有 IP地址。 Queries from outside, of course, resolve to the public address. 当然,来自外部的查询会解析为公共地址。

We resolve a public DNS hostname to the public IPv4 address of the instance outside the network of the instance, and to the private IPv4 address of the instance from within the network of the instance. 我们将公共DNS主机名解析为实例网络外部实例的公共IPv4地址,并解析为实例网络内部的实例私有IPv4地址。

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html

That's exactly why this works. 这就是为什么它起作用。

The public IP address of a machine inside EC2 is not actually bound to the IP stack of the instance's OS -- only the private IP address is. EC2内部计算机的公用IP地址实际上并未绑定到实例OS的IP堆栈上-只是专用IP地址。 The Internet Gateway handles the 1:1 translation between public and private addresses as traffic traverses it in the way to and from the instance. 当流量以往返于实例的方式穿越时,Internet网关处理公共地址和私有地址之间的1:1转换。

And, this is desirable behavior, because you don't want instances talking to other instances (or to themselves!) using their public addresses, since you pay a transport charge for data that hairpins out and back on through the Internet Gateway. 而且,这是理想的行为,因为您不希望实例使用其公共地址与其他实例(或与他们自己!)交谈,因为您需要为通过Internet网关发回的数据支付传输费。 Within a single availability zone, you don't pay for traffic between instances when the private IP address is used. 在单个可用区内,使用私有IP地址时,您无需为实例之间的流量付费。 Additionally, when two instances communicate with each other via public IP, the identity of the source security group is necessarily lost, which means you can't use the source security-group-id for ingress control. 此外,当两个实例通过公共IP相互通信时,源安全组的标识必定丢失,这意味着您不能使用源安全组ID进行入口控制。

I haven't worked for hadoop for a while, but when I was working with it, there was no way to reference the namenode or datanodes with only an IP (I think it had something to do with discouraging users to hard code IP addresses in case of failures, but I could be wrong). 我已经有一段时间没有为hadoop工作了,但是当我使用hadoop时,没有办法仅使用IP来引用namenode或datanode(我认为这与阻止用户在IP地址中硬编码IP地址有关。失败的情况,但我可能是错的)。 It's a bad practice to use raw IP addresses, but having this limitation does make messing around with hadoop harder. 使用原始IP地址是一种不好的做法,但是具有此限制确实会使搞混hadoop变得更加困难。 This is the closest thing I can find to a real source: https://issues.apache.org/jira/browse/HADOOP-685 这是我能找到的最接近真实来源的东西: https : //issues.apache.org/jira/browse/HADOOP-685

To get around it, you could either host your own dns server (dnsmasq) and us that or add entries to /etc/hosts of all the machines to make 'fake' names, and use those in the configuration instead. 为了解决这个问题,您可以托管自己的dns服务器(dnsmasq)和我们,也可以将条目添加到所有计算机的/ etc / hosts中以创建“假”名称,然后在配置中使用这些名称。 Sorry I don't have a better solution for you... 抱歉,您没有更好的解决方案...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM