1. 搭建一个测试集群,集群有4台机器,配置集群中每一台机器的/etc/hosts文件:
[root@nn .ssh]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.28.3.40 nn nn.Hadoop.plat
172.28.3.41 dn1 dn0.hadoop.plat
172.28.3.42 dn2 dn1.hadoop.plat
172.28.3.43 dn3 dn2.hadoop.plat
2. 配置namenode到datanode ssh免密码登陆:
在nn上执行,ssh-keygen –t rsa
cd ~/.ssh
cat id_rsa.put >> authorized_keys
对集群中每一台data node执行: ssh-copy-id root@dn1 ssh-copy-id root@dn2 ssh-copy-id root@dn13
这样就可以保证,nn节点可以免密码登陆到dn1, dn2, dn3
[root@nn .ssh]# ifconfig
eth0 Link encap:Ethernet HWaddr00:1A:4A:C6:6B:A0
inet addr:172.28.3.40 Bcast:172.28.7.255 Mask:255.255.248.0
inet6 addr: fe80::21a:4aff:fec6:6ba0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1064845 errors:0 dropped:0 overruns:0 frame:0
TX packets:557212 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1578655986 (1.4 GiB) TX bytes:647178854 (617.1 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:103276 errors:0 dropped:0 overruns:0 frame:0
TX packets:103276 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:58108687 (55.4 MiB) TX bytes:58108687 (55.4 MiB)
[root@nn .ssh]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.28.3.40 nn nn.hadoop.plat
172.28.3.41 dn1 dn0.hadoop.plat
172.28.3.42 dn2 dn1.hadoop.plat
172.28.3.43 dn3 dn2.hadoop.plat
[root@nn .ssh]# ssh dn1
SIOCADDRT: File exists
3. 关闭iptables
chkconfig iptables off
/etc/init.d/iptables stop
4. 关闭seLinux
查看selinux状态:
[root@localhost ~]# /usr/sbin/sestatus –v
/usr/sbin/setenforce 0 #使SELinux工作模式变成permissive模式
/usr/sbin/setenforce 1 #使SELinux工作模式变成enforcing模式
这样就可以实时控制SELinux的启用和不启用了。
三个参数介绍介绍
enforcing — The SELinux security policy is enforced.
permissive — The SELinux system prints warnings but does not enforce policy.
disabled — SELinux is fully disabled. SELinux hooks are disengaged from the kernel and the pseudo-file system is unregistered.
永久关闭SELinux
编辑/etc/selinux/config,找到SELINUX 行修改成为:SELINUX=disabled: