Hadoop集群部署安装(2)

[Hadoop@n1 ~]$ mkdir .ssh

[hadoop@n1 ~]$ chmod 700 .ssh

[hadoop@n1 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

57:f2:fe:1b:e9:21:9f:fa:84:55:4c:13:37:d2:10:48 hadoop@n1

[hadoop@n1 ~]$ ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_dsa.

Your public key has been saved in /home/hadoop/.ssh/id_dsa.pub.

The key fingerprint is:

24:6e:83:17:f0:5d:72:8f:00:9e:8b:7c:ed:28:9d:88 hadoop@n1

[hadoop@n1 ~]$ touch .ssh/authorized_keys

在d1上执行

[hadoop@d1 ~]$ mkdir .ssh

[hadoop@d1 ~]$ chmod 700 .ssh

[hadoop@d1 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

83:bc:0d:3b:fc:b8:53:e6:aa:cc:46:ed:2b:8d:8f:17 hadoop@d1

[hadoop@d1 ~]$ ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_dsa.

Your public key has been saved in /home/hadoop/.ssh/id_dsa.pub.

The key fingerprint is:

86:7b:5e:66:99:22:7f:2c:38:07:08:73:91:70:3a:cb hadoop@d1

在d2上执行

[hadoop@d2 ~]$ mkdir .ssh

[hadoop@d2 ~]$ chmod 700 .ssh

[hadoop@d2 ~]$

[hadoop@d2 ~]$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_rsa.

Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.

The key fingerprint is:

50:c1:c8:fa:8e:c0:0e:3e:eb:26:dc:23:ee:1d:27:fe hadoop@d2

[hadoop@d2 ~]$ ssh-keygen -t dsa

Generating public/private dsa key pair.

Enter file in which to save the key (/home/hadoop/.ssh/id_dsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /home/hadoop/.ssh/id_dsa.

Your public key has been saved in /home/hadoop/.ssh/id_dsa.pub.

The key fingerprint is:

ae:f4:a2:96:2a:f2:24:33:c0:bc:63:08:2c:ef:af:51 hadoop@d2

然后在n1上继续下面的执行。

[hadoop@n1 ~]$ cd .ssh

[hadoop@n1 .ssh]$ ll

total 16

-rw-rw-r-- 1 hadoop hadoop    0 Oct  9 02:49 authorized_keys

-rw------- 1 hadoop hadoop  668 Oct  9 02:48 id_dsa

-rw-r--r-- 1 hadoop hadoop  599 Oct  9 02:48 id_dsa.pub

-rw------- 1 hadoop hadoop 1675 Oct  9 02:48 id_rsa

-rw-r--r-- 1 hadoop hadoop  391 Oct  9 02:48 id_rsa.pub

[hadoop@n1 .ssh]$ ssh n1 cat /home/hadoop/.ssh/id_rsa.pub >> authorized_keys

The authenticity of host 'n1 (192.168.10.101)' can't be established.

RSA key fingerprint is 48:ef:fc:67:3f:43:88:0e:fa:e6:a6:ec:75:b0:c4:7f.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'n1,192.168.10.101' (RSA) to the list of known hosts.

hadoop@n1's password:

[hadoop@n1 .ssh]$ ssh n1 cat /home/hadoop/.ssh/id_dsa.pub >> authorized_keys

hadoop@n1's password:

[hadoop@n1 .ssh]$ ssh d1 cat /home/hadoop/.ssh/id_rsa.pub >> authorized_keys

The authenticity of host 'd1 (192.168.10.102)' can't be established.

RSA key fingerprint is 48:ef:fc:67:3f:43:88:0e:fa:e6:a6:ec:75:b0:c4:7f.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'd1,192.168.10.102' (RSA) to the list of known hosts.

hadoop@d1's password:

[hadoop@n1 .ssh]$ ssh d1 cat /home/hadoop/.ssh/id_dsa.pub >> authorized_keys

hadoop@d1's password:

[hadoop@n1 .ssh]$ ssh d2 cat /home/hadoop/.ssh/id_rsa.pub >> authorized_keys

The authenticity of host 'd2 (192.168.10.103)' can't be established.

RSA key fingerprint is 48:ef:fc:67:3f:43:88:0e:fa:e6:a6:ec:75:b0:c4:7f.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'd2,192.168.10.103' (RSA) to the list of known hosts.

hadoop@d2's password:

[hadoop@n1 .ssh]$ ssh d2 cat /home/hadoop/.ssh/id_dsa.pub >> authorized_keys

hadoop@d2's password:

[hadoop@n1 .ssh]$ ll

total 24

-rw-rw-r-- 1 hadoop hadoop 2970 Oct  9 02:56 authorized_keys

-rw------- 1 hadoop hadoop  668 Oct  9 02:48 id_dsa

-rw-r--r-- 1 hadoop hadoop  599 Oct  9 02:48 id_dsa.pub

-rw------- 1 hadoop hadoop 1675 Oct  9 02:48 id_rsa

-rw-r--r-- 1 hadoop hadoop  391 Oct  9 02:48 id_rsa.pub

-rw-r--r-- 1 hadoop hadoop 1197 Oct  9 02:56 known_hosts

然后,在3个节点上分别执行下面操作。

[hadoop@n1 ~]$ chmod 600 .ssh/authorized_keys

[hadoop@n1 ~]$ exec /ssh-agent $SHELL

-bash: /ssh-agent: No such file or directory

-bash: exec: /ssh-agent: cannot execute: No such file or directory

[hadoop@n1 ~]$ exec ssh-agent $SHELL

[hadoop@n1 ~]$ ssh-add

Identity added: /home/hadoop/.ssh/id_rsa (/home/hadoop/.ssh/id_rsa)

Identity added: /home/hadoop/.ssh/id_dsa (/home/hadoop/.ssh/id_dsa)

使用ssh『机器名』date命令,验证SSH互信的建立。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/19efc44e9877bf4f58b3ed9981200b67.html