分散式ZooKeeper-3.4.10叢集安裝
阿新 • • 發佈:2018-11-15
ZooKeeper是一個為分散式應用所設計的開源協調服務,其設計目的是為了減輕分散式應用程式所承擔的協調任務。它可以為使用者提供同步、配置管理、分組和命名等服務。
jstorm需要zk配合使用,記錄安裝文件。
一、基礎環境:
JDK :1.8.0_65 (要求1.6+)
ZooKeeper:3.4.10
主機數:3(要求3+,且必須是奇數,因為ZooKeeper的選舉演算法)
主機名 | IP地址 | JDK | ZooKeeper | myid |
Master | 10.116.33.109 | 1.8.0_65 | server.1 | 1 |
Slave1 | 10.27.185.72 | 1.8.0_65 | server.2 | 2 |
Slave2 | 10.25.203.67 | 1.8.0_65 | server.3 | 3 |
二、節點上安裝配置:
下載並解壓ZooKeeper
wget 'http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz' tar zxvf zookeeper-3.4.10.tar.gz
設定zoo.cfg
$ZOOKEEPER_HOME 路徑: /data/jstorm/zookeeper-3.4.10cd $ZOOKEEPER_HOME/conf/
cp zoo_sample.cfg zoo.cfg
vim 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=/home/fesh/data/zookeeper # the port at which the clients will connect clientPort=2181 server.1=master:2888:3888 server.2=slave1:2888:3888 server.3=slave2:2888:3888
設定myid
在節點配置的dataDir指定的目錄下面,建立一個myid檔案,裡面內容為一個數字,用來標識當前主機,$ZOOKEEPER_HOME/conf/zoo.cfg檔案中配置的server.X,則myid檔案中就輸入這個數字X。(即在每個節點上新建並設定檔案myid,其內容與zoo.cfg中的id相對應)這裡master節點為 1mkdir -p /data/zookeeper
cd /data/zookeeper
touch myid
echo "1" > myid
啟動服務
每臺伺服器上$ZOOKEEPER_HOME/bin目錄下執行 ./zkServer.sh start
檢視狀態
./zkServer.sh status