Hadoop集群中,使用DNS而不是hosts来访问服务器。
1. 安装bind软件
用root用户运行:
yum -y install bind*
2. 配置named.conf文件
vi /etc/named.conf
修改以下部分:
listen-on port 53 { any; };
allow-query { any; };
修改完毕后继续修改/etc下面的另一文件。
3. 添加正向和反向的域名
vi /etc/named.rfc1912.zones zone "." IN { type master; file "hadoop.com.zone"; allow-update { none; }; }; zone "44.168.192.in-addr.arpa" IN { type master; file "192.168.44.zone"; allow-update { none; }; };
4. 编辑正向和反向两个文件
vim /var/named/hadoop.com.zone $TTL 1D @ IN SOA com. root.hadoop.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS @ A 127.0.0.1 AAAA ::1 master IN A 192.168.44.1 secondarynamenode IN A 192.168.44.2 admin IN A 192.168.44.3 hadoop01 IN A 192.168.44.4 hadoop02 IN A 192.168.44.5 hadoop03 IN A 192.168.44.6 hadoop04 IN A 192.168.44.7 hadoop05 IN A 192.168.44.8 hadoop06 IN A 192.168.44.9 hadoop07 IN A 192.168.44.10 hadoop08 IN A 192.168.44.11 hadoop09 IN A 192.168.44.12 hadoop10 IN A 192.168.44.13 hadoop11 IN A 192.168.44.14 hadoop12 IN A 192.168.44.15 hadoop13 IN A 192.168.44.16 hadoop14 IN A 192.168.44.17 hadoop15 IN A 192.168.44.18 hadoop16 IN A 192.168.44.19
vim /var/named/192.168.44.zone $TTL 86400 @ IN SOA hadoop.com. root.hadoop.com. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum @ IN NS hadoop. 1 IN PTR master. 2 IN PTR secondarynamenode. 3 IN PTR admin. 4 IN PTR hadoop01. 5 IN PTR hadoop02. 6 IN PTR hadoop03. 7 IN PTR hadoop04. 8 IN PTR hadoop05. 9 IN PTR hadoop06. 10 IN PTR hadoop07. 11 IN PTR hadoop08. 12 IN PTR hadoop09. 13 IN PTR hadoop10. 14 IN PTR hadoop11. 15 IN PTR hadoop12. 16 IN PTR hadoop13. 17 IN PTR hadoop14. 18 IN PTR hadoop15. 19 IN PTR hadoop16.
5. 重启bind服务
service bind restart