說明:
目前安裝了4個Redhat linux操作系統,主機名分別為hadoop01,hadoop02,hadoop03,hadoop04
其中hadoop01為主節點,hadoop02,hadoop03,hadoop04為從節點
四個節點ip地址為192.168.10.61~64.
如果不修改hosts文件,從第二步開始可將hadoop01~04改為所對應的ip地址,如第4步中的scp ~/.ssh/id_rsa.pub root@hadoop02:~命令可改為scp ~/.ssh/id_rsa.pub [email protected]:~
[code]cat /etc/hosts
如果沒有將ip地址與主機名相對應,請按照如上所示,修改hosts文件
[code]vim /etc/hosts
[code]ssh-keygen -t rsa -P ''
[code]cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
在每個節點上可通過輸入兩次ssh 本節點主機名命令來驗證(注意,第一次輸入ssh 本節點主機名會詢問,輸入yes,以後就不需要輸入密碼了)
[code]scp ~/.ssh/id_rsa.pub root@hadoop02:~ scp ~/.ssh/id_rsa.pub root@hadoop03:~ scp ~/.ssh/id_rsa.pub root@hadoop04:~
在從節點中執行如下命令,將主節點的公鑰追加到授權文件中
[code]cat ~/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys rm ~/id_rsa.pub
在主節點中執行如下命令,實現主節點到從節點無密碼訪問
[code]ssh hadoop02 exit ssh hadoop03 exit ssh hadoop04 exit
[code]cd cd .ssh ssh-copy-id -i id_rsa.pub root@hadoop01
在每個從節點上執行如下命令,驗證從節點到主節點無密碼ssh訪問。
[code]ssh hadoop01