1 面向生产环境的大集群模式重新安装实施Hadoop,要求
1)使用DNS而不是hosts文件解析主机名
2)使用NFS共享密钥文件,而不是逐个手工拷贝添加密钥
3)复制Hadoop时使用批量拷贝脚本而不是逐台复制
1)
修改named.conf
[root@centos-linux-dns keon]# vim /etc/named.conf
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; };
修改named.rfc1912.zones
zone "hadoop.com" IN {
type master;
file "dns.com";
allow-update { none; };
};
zone "55.211.10.in-addr.arpa" IN {
type master;
file "55.211.10.zone";
allow-update { none; };
};
修改正向域名解析和逆向域名解析文件
[root@centos-linux-dns keon]# cd /var/named/
[root@centos-linux-dns named]# ls
55.211.10.zone data dynamic named.empty named.loopback
chroot dns.com named.ca named.localhost slaves
正向域名解析
[root@centos-linux-dns named]# vim dns.com
$TTL 1D
@ IN SOA h1.hadoop.com. root.hadoop.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS h1.hadoop.com.
h1 A 10.211.55.6
h2 A 10.211.55.8
h3 A 10.211.55.7
逆向域名解析
[root@centos-linux-dns named]# vim 55.211.10.zone
$TTL 1D
@ IN SOA h1.hadoop.com. root.hadoop.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS h1.hadoop.com.
6 IN PTR h1.hadoop.com.
7 IN PTR h3.hadoop.com.
8 IN PTR h2.hadoop.com.
重启服务
[root@centos-linux-dns named]# service named restart
Redirecting to /bin/systemctl restart named.service
客户端设置好dns后,进行验证
[keon@centos-linux .ssh]$ nslookup h1.hadoop.com
Server: 10.211.55.9
Address: 10.211.55.9#53
Name: h1.hadoop.com
Address: 10.211.55.6
[keon@centos-linux .ssh]$ nslookup h2.hadoop.com
Server: 10.211.55.9
Address: 10.211.55.9#53
Name: h2.hadoop.com
Address: 10.211.55.8
[keon@centos-linux .ssh]$ nslookup h3.hadoop.com
Server: 10.211.55.9
Address: 10.211.55.9#53
Name: h3.hadoop.com
Address: 10.211.55.7
2)
拷贝公匙到nfs服务器authorized_keys
[keon@centos-linux-dns .ssh]$ ssh h1.hadoop.com cat ~/.ssh/id_rsa.pub >> authorized_keys
[email protected]'s password:
[keon@centos-linux-dns .ssh]$ ssh h2.hadoop.com cat ~/.ssh/id_rsa.pub >> authorized_keys
[email protected]'s password:
Permission denied, please try again.
[email protected]'s password:
[keon@centos-linux-dns .ssh]$ ssh h3.hadoop.com cat ~/.ssh/id_rsa.pub >> authorized_keys
[email protected]'s password:
[keon@centos-linux-dns .ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOSlH2/75Xjd4Zt5Qhvtp6WmeLqKpMdHOFbq5ExWp48cLfb7nUU7K78sgbXECXCExd0q5nq1teKrDzZKgOvONJXh4y/lsmX8ElMJf49rgYUqVCjR0Y8g3xZ1771bhd0SI1a3ZNAPBnhgcwO7HeQeZ+P1YJnZVDhbfjdMojWYv3NRwRVwCiSqM9hjuIXQw8ru8VDqT5cBpq9uF3MpDxi0kWV+FsYzdqDJPaBJf6NmzerEtZ0Cwj5wp1UYi6iAZbhFWi8IjOZ1+gOgVw0wBaUlgZikEC0fdueftCNQeHM0Pf8lmHvEU5ywXB61L26nQ8WkN3r29zGrqGEYt5qzRSXaX5 [email protected]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtHp30oU/B5TCV8K7ZZ5BxM0Kcui2iP/BHwbZ2XmrTHLvb8SJEYWa0UXFtb5Y/EvWLoz2xdy6JN16LBiCo3YslYzNENfSeG2OBw0wtlJ7xokStd6Byw+YtBegjGsgQUOXntLlegcSHr1C5NcgcUcH3skxsjgqyPDYKljamWMHqiF6FU1MMl2T2qUFw9Zu2uyeJ+k8Vd3xkxBYYW8E4dfsuO688mfk0D9eMlFcVhq20LVJZEz3VnHl33H+YAXRUJdvg+2rLVh2vGhX573/8fIgnZK+JcaDdmkYG0mTWIMIjJsJMSq+KvOBlMNFpFN40KiFHF+OzXqe/jzRy0lFhfKYv [email protected]
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGHgm8i9uR7KTioctxFlNiqdEwQ8KTLZTHwEuj+3d5gK+xCUi4khFNjBojZviJlTW45TMuv5MNTS3bZqb0rfVNsrMTqHaVP8Y4UhfOhqRgg1nSQKZQmzGELeTokzjGxvE9cG5IVmY+5VWOXdYtq21hp+H0klubcqqOJe/ds621VQz2fz4IWrke3SLxt78h5Kn/W1R+LzNIo1n+h3+r/46w2vagPMRnoltrk0EQQ2rNtMg7XWs/pOwzJXVCWNyNIHkB3JiItSgmMVB/iBiu9HjXhuHX04YDdY/5s3qtGPqnXz3osEPwF1TDYQVPMou93cX1AAzIDAFubDw223QZBl7n [email protected]
设置共享目录
[root@centos-linux-dns .ssh]# vim /etc/exports
/home/keon/ *(rw,sync,no_root_squash
启动服务
[keon@centos-linux-dns .ssh]$ service rpcbind restart
Redirecting to /bin/systemctl restart rpcbind.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: jian dong (keon)
Password:
==== AUTHENTICATION COMPLETE ===
[keon@centos-linux-dns .ssh]$ service nfs restart
Redirecting to /bin/systemctl restart nfs.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: jian dong (keon)
Password:
==== AUTHENTICATION COMPLETE ===
本机共享目录
[root@centos-linux-dns .ssh]# showmount -e localhost
Export list for localhost:
/home/keon *
客户端挂载
[root@centos-linux /]# mkdir /nfs_share
[root@centos-linux /]# mount -t nfs 10.211.55.9:/home/keon/ /nfs_share/
[root@centos-linux /]# su keon
[keon@centos-linux /]$ cd /
bin/ home/ media/ proc/ srv/ var/
boot/ lib/ mnt/ root/ sys/
dev/ lib64/ nfs_share/ run/ tmp/
etc/ lost+found/ opt/ sbin/ usr/
[keon@centos-linux /]$ cd /nfs_share/
[keon@centos-linux nfs_share]$ ls
Desktop Downloads Music Public Videos
Documents fontconfig Pictures Templates
创建authorized_keys软链接
[keon@centos-linux .ssh]$ mv authorized_keys authorized_keys1
[keon@centos-linux .ssh]$ ln -s /nfs_share/.ssh/authorized_keys
[keon@centos-linux .ssh]$ ls -l
total 16
lrwxrwxrwx. 1 keon keon 31 Aug 21 22:29 authorized_keys -> /nfs_share/.ssh/authorized_keys
-rw-r--r--. 1 keon keon 406 Aug 21 21:01 authorized_keys1
-rw-------. 1 keon keon 1679 Aug 1 22:53 id_rsa
-rw-r--r--. 1 keon keon 406 Aug 1 22:53 id_rsa.pub
-rw-r--r--. 1 keon keon 1544 Aug 21 16:44 known_hosts
3)
根据slaves,用awk命令生成批量执行的脚本
[keon@centos-linux test]$ cat slaves
h2.hadoop.com
h3.hadoop.com
[keon@centos-linux test]$ cat ./slaves | awk '{print "scp -rp ./hadoop-2.7.2 keon@"$1":/home/keon"}'>>uploadHadoop
[keon@centos-linux test]$ cat uploadHadoop
scp -rp ./hadoop-2.7.2 [email protected]:/home/keon
scp -rp ./hadoop-2.7.2 [email protected]:/home/keon
添加执行权限。
[keon@centos-linux test]$ chmod a+x uploadHadoop
[keon@centos-linux test]$ ./uploadHadoop
JDK同理