1. 程式人生 > 其它 >ZooKeeper 單點服務部署

ZooKeeper 單點服務部署

下載解壓
進入官方下載地址:http://zookeeper.apache.org/releases.html#download 

解壓到本地:

tar -zxf zookeeper-3.4.6.tar.gz
cd zookeeper-3.4.6


環境變數
執行 vim /etc/profile,新增環境變數:

export ZOOKEEPER_HOME=/usr/app/zookeeper-3.4.14
export PATH=$ZOOKEEPER_HOME/bin:$PATH

再執行 source /etc/profile , 使得配置的環境變數生效。


修改配置
必須建立 conf/zoo.cfg 檔案,否則啟動時會提示你沒有此檔案。

初次嘗試,不妨直接使用 Kafka 提供的模板配置檔案 conf
/zoo_sample.cfg: cp conf/zoo_sample.cfg conf/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=/usr/local/zookeeper/data dataLogDir=/usr/local/zookeeper/log # 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 配置引數說明: tickTime:用於計算的基礎時間單元。比如 session 超時:N*tickTime; initLimit:用於叢集,允許從節點連線並同步到 master 節點的初始化連線時間,以 tickTime 的倍數來表示; syncLimit:用於叢集, master 主節點與從節點之間傳送訊息,請求和應答時間長度(心跳機制); dataDir:資料儲存位置; dataLogDir:日誌目錄; clientPort:用於客戶端連線的埠,預設 2181 啟動服務 執行以下命令 bin/zkServer.sh start 執行此命令後,你將收到以下響應 JMX enabled by default Using config: /Users/../zookeeper-3.4.6/bin/../conf/zoo.cfg Starting zookeeper ... STARTED 停止服務 可以使用以下命令停止 zookeeper 伺服器。 bin/zkServer.sh stop