1. 程式人生 > >centos安裝zookeeper,並叢集配置

centos安裝zookeeper,並叢集配置

所有機器操作都一樣!

注:zookeeper配置叢集時 需把防火牆關掉 或者暴露配置檔案裡配置的埠,

並且在dataDir目錄下要有myid檔案

 

1 下載

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

 

2 解壓

tar -zxvf  zookeeper-3.4.10.tar.gz

 

3 修改配置檔案

複製配置檔案 zoo_sample.cfg 到zoo.cfg

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/log/zookeeper # 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.purgeInterv server.0=192.168.174.128:2888:3888 server.1=192.168.174.129:2888:3888

 

4  在  dataDir=/home/log/zookeeper  目錄下新建 myid 檔案

寫入一個字元 0

儲存。

 

5 啟動 ./zkServer.sh start

ZooKeeper JMX enabled by default
Using config: /home/service/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

 

6 檢視啟動狀態 ./zkServer.sh status

  

ZooKeeper JMX enabled by default
Using config: /home/service/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: leader

 

 

 

 

 zookeeper命令

./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}

start 啟動

start-foreground 有啟動過程的啟動

stop 停止

restart 重啟

status 檢視啟動狀態