配置SSH
1、修改主机名(所有主机)
# hostnamectl set-hostname xxx
/etc/hosts
172.16.2.106 slave106
172.16.2.107 master
172.16.2.108 slave108
2、检查是否安装了ssh相关软件包(所有主机)
[hadoop@master ~]$ yum list installed |grep ssh
libssh2.x86_64 1.4.3-10.el7_2.1 @anaconda
openssh.x86_64 7.4p1-16.el7 @anaconda
openssh-clients.x86_64 7.4p1-16.el7 @anaconda
openssh-server.x86_64 7.4p1-16.el7 @anaconda
2、检查是否启动了sshd进程(所有主机)
[hadoop@master ~]$ ps -Af |grep sshd
root 1032 1635 0 09:52 ? 00:00:00 sshd: hadoop [priv]
hadoop 1036 1032 0 09:52 ? 00:00:00 sshd: hadoop@pts/4
hadoop 1135 1037 0 09:55 pts/4 00:00:00 grep --color=auto sshd
root 1635 1 0 06:15 ? 00:00:00 /usr/sbin/sshd -D
root 38078 1635 0 08:46 ? 00:00:00 sshd: zx [priv]
zx 38082 38078 0 08:46 ? 00:00:01 sshd: zx@pts/1,pts/2,pts/3
root 38433 1635 0 08:53 ? 00:00:09 sshd: root@notty
root 41678 1635 0 09:08 ? 00:00:00 sshd: root@pts/0
3、删除/home/hadoop/.ssh/*(所有主机)
4、在master主机上生成公私秘钥对
$>ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
5、将master的公钥文件 id_ras.pub 远程复制到slave106、slave108以及本机上
$>scp id_rsa.pub hadoop@slave106:/home/hadoop/.ssh/authorized_keys
$>scp id_rsa.pub hadoop@slave108:/home/hadoop/.ssh/authorized_keys
$>scp id_rsa.pub hadoop@master:/home/hadoop/.ssh/authorized_keys
权限问题
集群:106、107、108
用户名:hadoop
1、创建用户:hadoop(-d 指定登陆目录)
useradd -d /home/hadoop hadoop
2、让hadoop用户能够使用root身份执行命令
#visudo
复制: :/m行 co n行
# gpasswd -a hadoop wheel //将hadoop添加到wheel组
...
// Allow root to run any commands anywhere
root ALL=(ALL) ALL
hadoop ALL=(ALL) ALL //添加
...
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
## Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
...
Linux系统管理员对用户和用户组进行管理的相关文件:
- /etc/group -> 存放用户组的所有信息
- /etc/passwd
- /etc/shadow
/etc/group
// 组名:口令:组标识号:组内用户列表
[root@localhost home]# cat /etc/group
hadoop:x:1000:
zx:x:1001:
wheel:x:10:hadoop
/etc/passwd
// 注册名:口令:用户标识号:组标识号:用户名:用户主目录:命令解释程序
hadoop:x:1000:1000::/home/hadoop:/bin/bash
zx:1001:1001::/home/ax:/bin/bash
/etc/shadow
// 冒号分割,9个字段
用户名:密码(已加密)...