1.下载安装包
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.6.0/apache-zookeeper-3.6.0-bin.tar.gz
解压
tar -xcf aparche-zookeeper-3.6.0-bin.tar.gz
2.修改配置
/etc/hosts配置修改
192.168.159.3 dev1.xiayu.com
192.168.159.3 dev2.xiayu.com
192.168.159.3 dev3.xiayu.com
zookeeper配置文件修改
首先复制一份原来的配置文件
cp zoo_sample.cfg zoo.cfg
# The number of milliseconds of each tick
tickTime=2000 #心跳的单元时间 2s
# The number of ticks that the initial
# synchronization phase can take
initLimit=10 #follower和leader开始连接的最长时间 20s
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5 #follower和leader同步的最长时间 10s
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/zookeeper/zk1 #myid所在目录,数据目录
# the port at which the clients will connect
clientPort=2181 #服务端口
server.1=dev1.xiayu.com:2881:3881
server.2=dev2.xiayu.com:2882:3882
server.3=dev3.xiayu.com:2883:3883
#server.1 server.2 server.3代表有3台机器 123要同myid文件对应;
#2881,2882,2883是数据同步端口;
#3881,3882,3883是选举端口
修改三份配置
创建myid文件
3.启动
分别执行
./bin/zkServer.sh start
查看状态
./bin/zkServer.sh status
4.命令行访问
./bin/zkCli.sh -server dev1.xiayu.com:2181,dev2.xiayu.com:2182,dev3.xiayu.com:2183
简单脚本
#/usr/bin/bash
./zookeeper1/bin/zkServer.sh status
./zookeeper2/bin/zkServer.sh status
./zookeeper3/bin/zkServer.sh status
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。