zookeeper使用笔记

143 阅读1分钟

1:linux单机安装使用

​ 软件创建 data 文件夹,进入 conf 目录 ,把 zoo_sample.cfg 改名为 zoo.cfg,默认2181端口

mkdir data
cd conf
mv zoo_sample.cfg zoo.cfg

​ 常用命令,进入 bin 目录

#启动
./zkServer.sh start
#查看状态
./zkServer.sh status

2、zookeeper集群搭建

复制3份zookeeper,修改配置文件zoo.cfg如下,dataDir,dataLogDir,clientPort做相应的调整。

(版本:zookeeper-3.4.8-1)

# 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=E:\zookeeper\zk_2\data
dataLogDir=E:\zookeeper\zk_2\logs

# the port at which the clients will connect
clientPort=2182

server.1=localhost:2287:3387
server.2=localhost:2288:3388
server.3=localhost:2289:3389

data目录下,新建myid文件,内容分别为1,2,3

启动3台zookeeper,zkServer.cmd。集群就配置完成!