1)使用DNS而不是hosts文件解析主机名
2)使用NFS共享密钥文件,而不是逐个手工拷贝添加密钥
3)复制Hadoop时使用批量拷贝脚本而不是逐台复制
1)
修改namedconf
[root@centos-linux-dns keon]# vim /etc/namedconf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dumpdb";
statistics-file "/var/named/data/named_statstxt";
memstatistics-file "/var/named/data/named_mem_statstxt";
allow-query { any; };
修改namedrfc1912zones
zone "hadoopcom" IN {
type master;
file "dnscom";
allow-update { none; };
};
zone "5521110in-addrarpa" IN {
type master;
file "5521110zone";
allow-update { none; };
};
修改正向域名解析和逆向域名解析文件
[root@centos-linux-dns keon]# cd /var/named/
[root@centos-linux-dns named]# ls
5521110zone data dynamic namedempty namedloopback
chroot dnscom namedca namedlocalhost slaves
正向域名解析
[root@centos-linux-dns named]# vim dnscom
$TTL 1D
@ IN SOA h1hadoopcom roothadoopcom (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
h1 A 10211556
h2 A 10211558
h3 A 10211557
逆向域名解析
[root@centos-linux-dns named]# vim 5521110zone
$TTL 1D
@ IN SOA h1hadoopcom roothadoopcom (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS h1hadoopcom
6 IN PTR h1hadoopcom
7 IN PTR h3hadoopcom
8 IN PTR h2hadoopcom
重启服务
[root@centos-linux-dns named]# service named restart
Redirecting to /bin/systemctl restart namedservice
客户端设置好dns后,进行验证
[keon@centos-linux ssh]$ nslookup h1hadoopcom
Server: 10211559
Address: 10211559#53
Name: h1hadoopcom
Address: 10211556
[keon@centos-linux ssh]$ nslookup h2hadoopcom
Server: 10211559
Address: 10211559#53
Name: h2hadoopcom
Address: 10211558
[keon@centos-linux ssh]$ nslookup h3hadoopcom
Server: 10211559
Address: 10211559#53
Name: h3hadoopcom
Address: 10211557
2)
拷贝公匙到nfs服务器authorized_keys
[keon@centos-linux-dns ssh]$ ssh h1hadoopcom cat ~/ssh/id_ rsapub >> authorized_keys
keon@h1hadoopcom 's password:
[keon@centos-linux-dns ssh]$ ssh h2hadoopcom cat ~/ssh/id_ rsapub >> authorized_keys
keon@h2hadoopcom 's password:
Permission denied, please try again
keon@h2hadoopcom 's password:
[keon@centos-linux-dns ssh]$ ssh h3hadoopcom cat ~/ssh/id_ rsapub >> authorized_keys
keon@h3hadoopcom 's password:
[keon@centos-linux-dns ssh]$ cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOSlH2/75Xjd4Zt5Qhvtp6WmeLqKpMdHOFbq5ExWp48cLfb7nUU7K78sgbXECXCExd0q5nq1teKrDzZKgOvONJXh4y/lsmX8ElMJf49rgYUqVCjR0Y8g3xZ1771bhd0SI1a3ZNAPBnhgcwO7HeQeZ+P1YJnZVDhbfjdMojWYv3NRwRVwCiSqM9hjuIXQw8ru8VDqT5cBpq9uF3MpDxi0kWV+FsYzdqDJPaBJf6NmzerEtZ0Cwj5wp1UYi6iAZbhFWi8IjOZ1+gOgVw0wBaUlgZikEC0fdueftCNQeHM0Pf8lmHvEU5ywXB61L26nQ8WkN3r29zGrqGEYt5qzRSXaX5 keon@centos-linuxshared
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCtHp30oU/B5TCV8K7ZZ5BxM0Kcui2iP/BHwbZ2XmrTHLvb8SJEYWa0UXFtb5Y/EvWLoz2xdy6JN16LBiCo3YslYzNENfSeG2OBw0wtlJ7xokStd6Byw+YtBegjGsgQUOXntLlegcSHr1C5NcgcUcH3skxsjgqyPDYKljamWMHqiF6FU1MMl2T2qUFw9Zu2uyeJ+k8Vd3xkxBYYW8E4dfsuO688mfk0D9eMlFcVhq20LVJZEz3VnHl33H+YAXRUJdvg+2rLVh2vGhX573/8fIgnZK+JcaDdmkYG0mTWIMIjJsJMSq+KvOBlMNFpFN40KiFHF+OzXqe/jzRy0lFhfKYv keon@centos-linuxshared
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGHgm8i9uR7KTioctxFlNiqdEwQ8KTLZTHwEuj+3d5gK+xCUi4khFNjBojZviJlTW45TMuv5MNTS3bZqb0rfVNsrMTqHaVP8Y4UhfOhqRgg1nSQKZQmzGELeTokzjGxvE9cG5IVmY+5VWOXdYtq21hp+H0klubcqqOJe/ds621VQz2fz4IWrke3SLxt78h5Kn/W1R+LzNIo1n+h3+r/46w2vagPMRnoltrk0EQQ2rNtMg7XWs/pOwzJXVCWNyNIHkB3JiItSgmMVB/iBiu9HjXhuHX04YDdY/5s3qtGPqnXz3osEPwF1TDYQVPMou93cX1AAzIDAFubDw223QZBl7n keon@centos-linuxshared
设置共享目录
[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 rpcbindservice
==== AUTHENTICATING FOR orgfreedesktopsystemd1manage-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 nfsservice
==== AUTHENTICATING FOR orgfreedesktopsystemd1manage-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 10211559:/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_rsapub
-rw-r--r-- 1 keon keon 1544 Aug 21 16:44 known_hosts
3)
根据slaves,用awk命令生成批量执行的脚本
[keon@centos-linux test]$ cat slaves
h2hadoopcom
h3hadoopcom
[keon@centos-linux test]$ cat /slaves | awk '{print "scp -rp /hadoop-272 keon@"$1":/home/keon"}'>>uploadHadoop
[keon@centos-linux test]$ cat uploadHadoop
scp -rp /hadoop-272 keon@h2hadoopcom :/home/keon
scp -rp /hadoop-272 keon@h3hadoopcom :/home/keon
添加执行权限。
[keon@centos-linux test]$ chmod a+x uploadHadoop
[keon@centos-linux test]$ /uploadHadoop
JDK同理
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)