1. 程式人生 > >指令碼啟動zookeeper叢集

指令碼啟動zookeeper叢集

必須先配置好ssh

圖2-40  免密登陸原理

(2)生成公鑰和私鑰:

[atguigu@hadoop102 .ssh]$ ssh-keygen -t rsa

然後敲(三個回車),就會生成兩個檔案id_rsa(私鑰)、id_rsa.pub(公鑰)

(3)將公鑰拷貝到要免密登入的目標機器上 

[atguigu@hadoop102 .ssh]$ ssh-copy-id hadoop102

[atguigu@hadoop102 .ssh]$ ssh-copy-id hadoop103

[atguigu@hadoop102 .ssh]$ ssh-copy-id hadoop104

3.    .ssh資料夾下(~/.ssh)的檔案功能解釋

known_hosts

記錄ssh訪問過計算機的公鑰(public key)

id_rsa

生成的私鑰

id_rsa.pub

生成的公鑰

authorized_keys

存放授權過得無密登入伺服器公鑰

 

啟動zookeeper叢集指令碼

#/bin/bash
echo '=======================start zookeeper======================='
for host in hadoop11 hadoop12 hadoop13
  do
        ssh $host "source /etc/profile;/opt/module/zookeeper-3.4.13/bin/zkServer.sh start"
        if [$? -ne 0 ];then
                echo "$host zookeeper 啟動失敗"
        else
           echo "$host zookeeper 啟動成功"
        fi
done