Linux下叢集部署zookeeper
阿新 • • 發佈:2018-12-11
-
環境準備 1. 準備三臺虛擬機器 2. 每臺機器上都安裝好jdk環境 3. 全網統一hosts對映配置 4. 關閉防火牆
-
上傳zookeeper安裝包
-
解壓
[root@hadoop05 local]# tar -zxvf zookeeper-3.4.6.tar.gz [root@hadoop05 local]# ln -s zookeeper-3.4.6 zookeeper (建立軟連線) [root@hadoop05 local]#
-
刪除多餘的檔案(可忽略)
[root@hadoop05 zookeeper]# rm -rf *.txt *.xml docs/ src/ dist-
-
設定環境變數 注意:每臺zookeeper都需要修改
- 開啟環境變數配置檔案
[root@hadoop05 zookeeper]# vim /etc/profile [root@hadoop01 local]#
- 修改環境變數,在profile檔案中加入下面內容
#set zookeeper enviroment export ZOOKEEPER_HOME=/usr/local/zookeeper export PATH=$PATH:${ZOOKEEPER_HOME}/bin
- 載入配置檔案,使之生效
source /etc/profile
- 開啟環境變數配置檔案
-
修改Zookeeper配置檔案
[[email protected] conf]# cp zoo_sample.cfg zoo.cfg [[email protected] conf]# vim zoo.cfg
dataDir=/usr/local/zookeeper/zkdata server.1=mini1:2888:3888 ## (心跳埠、選舉埠) server.2=mini2:2888:3888 server.3=mini3:2888:3888
-
建立資料夾,並在該檔案下建立myid檔案
[[email protected] zookeeper]# mkdir zkdata [[email protected] zookeeper]# cd zkdata/ [[email protected] zkdata]# echo 1 > myid [[email protected] zkdata]# cat myid 1 [[email protected] zkdata]#
-
分發安裝包到其他機器
[[email protected] local]# scp -r /usr/local/zookeeper [email protected]:/usr/local/ [[email protected] local]# scp -r /usr/local/zookeeper [email protected]:/usr/local/ ...
-
修改其他機器的配置檔案 hadoop06上修改myid為:2 hadoop07上修改myid為:3
-
啟動(每臺機器)
[[email protected] local]# zookeeper/bin/zkServer.sh start JMX enabled by default Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [[email protected] local]#
-
zookeeper叢集啟動指令碼
#!/bin/bash for host in hadoop05 hadoop06 hadoop07 do echo "$host zookeeper is starting..." ssh $host "/usr/local/zookeeper/bin/zkServer.sh start" done