zookeeper叢集模式安裝
環境
Linux:Centos Linux 7.3
JDK:jdk1.8.0_181
Hadoop:2.8.5
Zookeeper:3.4.13
伺服器
bigdata01:192.168.1.50 (主節點)
bigdata02:192.168.1.51
bigdata03:192.168.1.52
安裝步驟
1,下載zookeeper安裝包,我下載的是zookeeper-3.4.13.tar.gz。
2,將安裝包上傳到linux伺服器,我是放在/opt目錄下面,然後解壓。
tar -zvxf zookeeper-3.4.13.tar.gz
3,進入zookeeper目錄,建立data和logs兩個目錄用於儲存資料和日誌。
mkdir data
mkdir logs
4,進入zookeeper的conf目錄,將zoo_sample.cfg重新命名為zoo.cfg,修改後zookeeper便可以識別到該檔案。
mv zoo_sample.cfg zoo.cfg
5,編輯zoo.cfg檔案,配置如下:
# The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/opt/zookeeper-3.4.13/data dataLogDir=/opt/zookeeper-3.4.13/logs # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 server.1=bigdata01:2888:3888 server.2=bigdata02:2888:3888 server.3=bigdata03:2888:3888
tickTime:傳送心跳的間隔時間,單位:毫秒
initLimit:leader和follower初始化連線時最長能忍受多少個心跳時間的間隔數
syncLimit:leader和follower之間傳送訊息,請求和應答時間長度,最長不能超過多少個tickTime的時間長度
dataDir:zookeeper儲存資料的目錄
dataLogDir:zookeeper儲存日誌的目錄
clientPort:埠
server.1、server.2、server.3是zookeeper機器列表,server.order這裡的Order依據叢集的機器個數依次進行遞增,這裡的bigdata01、bigdata02、bigdata03表示機器的主機名
6,配置完成後,切換到剛才配置的dataDir下,在此目錄下新建一個myid檔案。
vim myid
檔案中只需要輸入一個數字“1”,這個數字與配置檔案中的order保持一致,zookeeper會根據該檔案來決定zookeeper叢集各個機器的身份分配。
7,將配置好的zookeeper分發到bigdata02和bigdata03。
scp -r zookeeper-3.4.13 [email protected]:/opt
scp -r zookeeper-3.4.13 [email protected]:/opt
8,修改bigdata02和bigdata03上zookeeper中data目錄下的myid檔案,將檔案中的值改成2和3,與配置檔案中的order保持一致。
9,進入zookeeper的bin目錄,啟動三臺機器上的zookeeper。
./zkServer.sh start
10,檢視zookeeper身份
./zkServer.sh status