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

centos安裝zookeeper,並集群配置

修改配置文件 home connect 目錄 read purge top html feature

所有機器操作都一樣!

註: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 查看啟動狀態

centos安裝zookeeper,並集群配置