SSH免密登录

1 各集群节点创建用户hadoop,UID、GID设为一致

sudo groupadd -g 730 hadoop
sudo useradd -u 730 -g 730 -m -s /bin/bash hadoop

2 添加hadoop到用户组sudo

sudo gpasswd -a hadoop sudo

3 设置hadoop密码

sudo passwd hadoop

1 切换到hadoop用户

su hadoop
cd ~

2 生成密钥对

ssh-keygen -t rsa -P ""
cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys

3 复制到集群各节点

scp ~/.ssh/id_rsa.pub hadoop@master:/home/hadoop/
scp ~/.ssh/id_rsa.pub hadoop@slave1:/home/hadoop/
scp ~/.ssh/id_rsa.pub hadoop@slave2:/home/hadoop/

4 添加秘钥&删除

cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
rm ~/id_rsa.pub

5 验证

ssh master
ssh slave1
ssh slave2
vi /etc/hosts
121.36.97.33    master
121.36.8.254    slave1
121.36.39.117   slave2

你可能感兴趣的:(Linux)