hadoop集群-使用DNS代替hosts文件 weir 2014-12-26 11:01:56.0 java,hadoop 1799 主机名 IP H1 192.168.137.11 H2 192.168.137.12 H3 192.168.137.13 H4 192.168.137.14 H5 192.168.137.15 H6 192.168.137.16 1.安装DNS在h1上面 检查命令 : rpm –q bind rpm -q bind-chroot 安装命令: yum -y install bind bind-chroot 修改/etc/named.conf listen-on port 53 { any; }; allow-query { any; }; // // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { any; }; listen-on-v6 port 53 { ::1; }; directory “/var/named”; dump-file “/var/named/data/cache_dump.db”; statistics-file “/var/named/data/named_stats.txt”; memstatistics-file “/var/named/data/named_mem_stats.txt”; allow-query { any; }; recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file “/etc/named.iscdlv.key”; managed-keys-directory “/var/named/dynamic”; }; logging { channel default_debug { file “data/named.run”; severity dynamic; }; }; zone “.” IN { type hint; file “named.ca”; }; include “/etc/named.rfc1912.zones”; include “/etc/named.root.key”; 修改/etc/named.rfc1912.zones 正反配置 // named.rfc1912.zones: // // Provided by Red Hat caching-nameserver package // // ISC BIND named zone configuration for zones recommended by // RFC 1912 section 4.1 : localhost TLDs and address zones // and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt // (c)2007 R W Franks // // See /usr/share/doc/bind*/sample/ for example named configuration files. // zone “localhost.localdomain” IN { type master; file “named.localhost”; allow-update { none; }; }; zone “localhost” IN { type master; file “named.localhost”; allow-update { none; }; }; zone “1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa” IN { type master; file “named.loopback”; allow-update { none; }; }; zone “1.0.0.127.in-addr.arpa” IN { type master; file “named.loopback”; allow-update { none; }; }; zone “0.in-addr.arpa” IN { type master; file “named.empty”; allow-update { none; }; }; zone “weir.com” IN { type master; file “weir.com.zone”; allow-update { none; }; }; zone “137.168.192.in-addr.arpa” IN { type master; file “137.168.192.in-addr.zone”; allow-update { none; }; }; 4.在/var/named目录下创建weir.com.zone和137.168.192.in-addr.zon文件 这里是将named.localhost 拷贝之后做的修改 cp -p named.localhost weir.com.zone cp -p named.localhost 137.168.192.in-addr.zone weir.com.zone文件内容: $TTL 86400 @ IN SOA h1.weir.com. chizk.www.weir.com. ( 0 ; serial (d. adams) 1D ; refresh 1H ; retry 1W ; expiry 3H ) ; minimum @ IN NS h1.weir.com. h1.weir.com. IN A 192.168.137.11 h2.weir.com. IN A 192.168.137.12 h3.weir.com. IN A 192.168.137.13 h4.weir.com. IN A 192.168.137.14 h5.weir.com. IN A 192.168.137.15 h6.weir.com. IN A 192.168.137.16 137.168.192.in-addr.zone文件内容: $TTL 86400 @ IN SOA h1.weir.com. chizk.www.weir.com. ( 0 ; serial (d. adams) 1D ; refresh 1H ; retry 1W ; expiry 3H ) ; minimum @ IN NS h1.weir.com. 11 IN PTR h1.weir.com. 12 IN PTR h2.weir.com. 13 IN PTR h3.weir.com. 14 IN PTR h4.weir.com. 15 IN PTR h5.weir.com. 16 IN PTR h6.weir.com. 修改正向文件和反向文件属组 [root@h1 named]# chgrp named weir.com.rev [root@h1 named]# chgrp named weir.com.zone 添加DNS域名服务器ip(这里注意修改/etc/resolv.conf是没用的,重启电脑就失效了) 先说h1电脑,因为是DNS服务器所以我没有配置这一项 ,这里可能与我的网络连接有关系 下面说其他节点: 这里需要找到/etc/sysconfig/network-scripts/ifcfg-eth0 主要是加入DNS1=192.168.137.11 DEVICE=eth0 TYPE=Ethernet UUID=5a32d5ab-af65-44bc-9d21-c757fb44add3 ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.137.12 PREFIX=16 GATEWAY=192.168.137.1 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME=”System eth0″ HWADDR=08:00:27:17:25:7F LAST_CONNECT=1402057925 DNS1=192.168.137.11 6.启动DNS(防火墙关闭) service named start 自动开启: 查看:chkconfig –list named 设置启动级别:chkconfig –level 123456 named on 7.测试: nslookup h1.weir.com nslookup 192.168.137.12 host h1.weir.com host 192.168.137.12