ITeye博客

hadoop和hbase使用时要特别注意/etc/hosts文件

kabike · 2014-09-01 20:30 · 大数据 · hbase · 开源软件 · Markdown

/etc/hosts文件对hbase有很重要的作用 比如在hbase的master启动的时候,需要在zookeeper里注册自己的hostname,master取得hostname的方法是

 String hostname = Strings.domainNamePointerToHostName(DNS.getDefaultHost(
      conf.get("hbase.master.dns.interface", "default"),
      conf.get("hbase.master.dns.nameserver", "default")));

DNS.getDefaultHost方法为

public static String getDefaultHost(String strInterface, String nameserver)
    throws UnknownHostException {
    if (strInterface.equals("default")) 
      return InetAddress.getLocalHost().getCanonicalHostName();

    if (nameserver != null && nameserver.equals("default"))
      return getDefaultHost(strInterface);

    String[] hosts = getHosts(strInterface, nameserver);
    return hosts[0];
  }

如果/etc/hosts文件中存在以下这样的条目,InetAddress.getLocalHost().getCanonicalHostName()就会返回localhost,那么zookeeper里的master的hostname就成了localhost,那么region server无论如何都不能访问master了

127.0.0.1 localhost dev02

所以要写成

127.0.0.1 localhost 192.168.1.2 dev02

这个问题应该也是同样的原因

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。