首页 > 代码库 > zk 配置 笔记

zk 配置 笔记

[root@power_centos_6 ~]# cd /home/downloads/zookeeper-3.4.6

[root@power_centos_6 zookeeper-3.4.6]# cd conf

[root@power_centos_6 conf]# cat zk1.cfg 

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/home/apache/zoo/zk1

clientPort=2181

server.1=10.6.212.188:2888:3888

server.2=10.6.212.188:2889:3889

server.3=10.6.212.188:2890:3890

[root@power_centos_6 conf]# cat zk2.cfg 

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/home/apache/zoo/zk2

clientPort=2182

server.1=10.6.212.188:2888:3888

server.2=10.6.212.188:2889:3889

server.3=10.6.212.188:2890:3890

[root@power_centos_6 conf]# cat zk3.cfg 

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/home/apache/zoo/zk3

clientPort=2183

server.1=10.6.212.188:2888:3888

server.2=10.6.212.188:2889:3889

server.3=10.6.212.188:2890:3890

[root@power_centos_6 conf]# ls

configuration.xsl  log4j.properties  zk1.cfg  zk2.cfg  zk3.cfg  _zoo.cfg  zoo_sample.cfg

[root@power_centos_6 conf]# tree /home/apache/zoo/

/home/apache/zoo/

├── zk1

│   ├── myid

│   └── version-2

│       ├── acceptedEpoch

│       ├── currentEpoch

│       ├── log.100000001

│       └── snapshot.0

├── zk2

│   ├── myid

│   └── version-2

│       ├── acceptedEpoch

│       ├── currentEpoch

│       └── log.100000001

└── zk3

    ├── myid

    └── version-2

        ├── acceptedEpoch

        ├── currentEpoch

        ├── log.100000001

        └── snapshot.100000000


6 directories, 14 files

[root@power_centos_6 conf]# 



启动三个zookeeper 服务器:

bin/zkServer.sh start conf/zk1.cfg

bin/zkServer.sh start conf/zk2.cfg

bin/zkServer.sh start conf/zk3.cfg


查看zookeeper谁是leader谁是follewer:

bin/zkServer.sh status conf/zk1.cfg

JMX enabled by default

Using config: conf/zk1.cfg

Mode: follower


bin/zkServer.sh status conf/zk2.cfg

JMX enabled by default

Using config: conf/zk2.cfg

Mode: leader


bin/zkServer.sh status conf/zk3.cfg

JMX enabled by default

Using config: conf/zk3.cfg

Mode: follower


很明显2是leader

zk 配置 笔记