centos Hadoop安装实战

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 t1.dky.com t1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.130 t1
192.168.1.131 n1
192.168.1.132 n2
192.168.1.133 n3
"/etc/hosts" 8L, 269C written
[root@t1 hadoop]# su hadoop
[hadoop@t1 ~]$ ping t1
PING t1.dky.com (127.0.0.1) 56(84) bytes of data.
64 bytes from t1.dky.com (127.0.0.1): icmp_seq=1 ttl=64 time=0.084 ms
64 bytes from t1.dky.com (127.0.0.1): icmp_seq=2 ttl=64 time=0.027 ms

--- t1.dky.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.027/0.055/0.084/0.029 ms
[hadoop@t1 ~]$ ping n1
PING n1 (192.168.1.131) 56(84) bytes of data.
64 bytes from n1 (192.168.1.131): icmp_seq=1 ttl=64 time=0.932 ms

--- n1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.932/0.932/0.932/0.000 ms
[hadoop@t1 ~]$ ping n2
PING n2 (192.168.1.132) 56(84) bytes of data.
64 bytes from n2 (192.168.1.132): icmp_seq=1 ttl=64 time=1.10 ms

--- n2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.100/1.100/1.100/0.000 ms
[hadoop@t1 ~]$ ping n3
PING n3 (192.168.1.133) 56(84) bytes of data.
64 bytes from n3 (192.168.1.133): icmp_seq=1 ttl=64 time=0.905 ms

--- n3 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.905/0.905/0.905/0.000 ms
[hadoop@t1 ~]$ pwd
/home/hadoop
[hadoop@t1 ~]$ ls
hadoop-1.0.1 hadoop-1.0.1.tar.gz jdk-7u3-linux-i586.tar.gz
[hadoop@t1 ~]$ cd .ssh
[hadoop@t1 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
[hadoop@t1 .ssh]$ more authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwKSBap8HeYRtoMvCrDZc8GchzHRo6xqga5GBiGUzYo/K6v8qMubhaFWYTXU+64Fn

myqm/s0TfG+L+9K5UrK1+B0z7QariiXZuKXMmL69iKAIhCpDalspSj0mgG12VJ3yxzn5SpyP7Ugj1k54zaLNZQA9mBjWBABO0igJ

sr/84kYViSfZCv3nS5mYvAncfWGmePw3DMduhLRhaINo5JqPOe7nmmsJ2c7cgdNB8ZjUms3+rrbcToHdzEeyKdXRsOq8soCh8fAg

ZnExTcXO5EOtuslfmdQRsgM6e5vZg05zSglvw89BiYEKuEjsGnkv8bRIdPSmNOg70Djz0bSIKST7cQ== hadoop@t1.dky.com
[hadoop@t1 .ssh]$ scp authorized_keys n1:/home/hadoop/.ssh/
The authenticity of host 'n1 (192.168.1.131)' can't be established.
RSA key fingerprint is 25:65:35:a9:c5:03:be:8e:86:04:cb:d7:cc:3f:1d:51.
Connection to n1 closed.
[hadoop@t1 .ssh]$

--------------------------------------

hadoop@n1 ~]$ssh-keygen -t rsa -P ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
Created directory '/home/hadoop/.ssh'.
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:
44:2a:85:94:45:03:25:8b:7e:86:11:f9:f3:38:df:6a hadoop@n1.dky.com
[hadoop@n1 ~]$ pwd
/home/hadoop
[hadoop@n1 ~]$ ls
[hadoop@n1 ~]$ cd .ssh
[hadoop@n1 .ssh]$ ls
id_rsa id_rsa.pub
[hadoop@n1 .ssh]$ cat id_rsa.pub >> authorized_keys

-----------------------------

[hadoop@t1 .ssh]$ scp authorized_keys n1:/home/hadoop/.ssh/
hadoop@n1's password:
authorized_keys 100% 399 0.4KB/s 00:00
[hadoop@t1 .ssh]$ scp authorized_keys n2:/home/hadoop/.ssh/
hadoop@n2's password:
authorized_keys 100% 399 0.4KB/s 00:00
[hadoop@t1 .ssh]$ scp authorized_keys n3:/home/hadoop/.ssh/
hadoop@n3's password:
authorized_keys 100% 399 0.4KB/s 00:00

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 n1.dky.com n1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.1.130 t1
192.168.1.131 n1
192.168.1.132 n2
192.168.1.133 n3
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/hosts" 8L, 269C written
[root@n1 hadoop]# exit
exit
[hadoop@n1 ~]$ ls
hadoop-1.0.1.tar.gz id_rsa_n3.pub id_rsa.pub jdk-7u3-linux-i586.tar.gz
[hadoop@n1 ~]$ pwd
/home/hadoop
[hadoop@n1 ~]$ rm id_rsa*
[hadoop@n1 ~]$ ls
hadoop-1.0.1.tar.gz jdk-7u3-linux-i586.tar.gz
[hadoop@n1 ~]$ cd .ssh
[hadoop@n1 .ssh]$ ls
id_rsa id_rsa.pub
[hadoop@n1 .ssh]$ scp id_rsa.pub t1:/home/hadoop/id_rsa_n1.pub
The authenticity of host 't1 (192.168.1.130)' can't be established.
RSA key fingerprint is 9e:ee:07:38:43:4c:b5:ae:f0:7c:9a:ab:5e:89:b3:06.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 't1,192.168.1.130' (RSA) to the list of known hosts.
hadoop@t1's password:
id_rsa.pub 100% 399 0.4KB/s 00:00
[hadoop@n1 .ssh]$ ls
id_rsa id_rsa.pub known_hosts
[hadoop@n1 .ssh]$ cd ..
[hadoop@n1 ~]$ ls
hadoop-1.0.1.tar.gz id_rsa_all.pub jdk-7u3-linux-i586.tar.gz
[hadoop@n1 ~]$ cat id_rsa_all.pub >> .ssh/authorized_keys
[hadoop@n1 ~]$ cd .ssh
[hadoop@n1 .ssh]$ ks
-bash: ks: command not found
[hadoop@n1 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
[hadoop@n1 .ssh]$ ls -l
鎬昏 32
-rw-rw-r-- 1 hadoop hadoop 1596 05-10 06:08 authorized_keys
-rw------- 1 hadoop hadoop 1675 05-10 05:42 id_rsa
-rw-r--r-- 1 hadoop hadoop 399 05-10 05:42 id_rsa.pub
-rw-r--r-- 1 hadoop hadoop 398 05-10 05:59 known_hosts
[hadoop@n1 .ssh]$ chmod 644 authorized_keys
[hadoop@n1 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
[hadoop@n1 .ssh]$ ls -l
鎬昏 32
-rw-r--r-- 1 hadoop hadoop 1596 05-10 06:08 authorized_keys
-rw------- 1 hadoop hadoop 1675 05-10 05:42 id_rsa
-rw-r--r-- 1 hadoop hadoop 399 05-10 05:42 id_rsa.pub
-rw-r--r-- 1 hadoop hadoop 398 05-10 05:59 known_hosts
[hadoop@n1 .ssh]$

注:

1) 将authorized_keys 的所有者改成hadoop;
2) 确保authorized_keys的权限为644即:-rw-r--r--

原文地址:https://www.cnblogs.com/powerxu/p/2491688.html