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

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-29 08:50   95   0
/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了
[quote] 127.0.0.1 localhost dev02[/quote]

所以要写成
[quote] 127.0.0.1 localhost
192.168.1.2 dev02[/quote]

[url=http://stackoverflow.com/questions/23049777/hbase-regionserver-error-telling-master-we-are-up]这个问题[/url]应该也是同样的原因
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP