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 查看启动状态

猜你喜欢

转载自www.cnblogs.com/syscn/p/10010126.html