软件下载地址:http://apache.fayea.com/zookeeper/,下载最新版zookeeper
cd /root/zookeeper/zkcluster
wget http://apache.fayea.com/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
mkdir 6001 6002 6003
分别解压到zookeeper-3.4.10.tar.gz 6001 6002 6003三个目录
并添加配置如下:
6001/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/root/zookeeper/zkcluster/6001/data
dataLogDir=/root/zookeeper/zkcluster/6001/logs
clientPort=6001
server.1=192.168.2.133:2888:3888
server.2=192.168.2.133:2889:3889
server.3=192.168.2.133:2890:3890
6002/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/root/zookeeper/zkcluster/6002/data
dataLogDir=/root/zookeeper/zkcluster/6002/logs
clientPort=6002
server.1=192.168.2.133:2888:3888
server.2=192.168.2.133:2889:3889
server.3=192.168.2.133:2890:3890
6003/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/root/zookeeper/zkcluster/6003/data
dataLogDir=/root/zookeeper/zkcluster/6003/logs
clientPort=6003
server.1=192.168.2.133:2888:3888
server.2=192.168.2.133:2889:3889
server.3=192.168.2.133:2890:3890
生成pid文件
vi /root/zookeeper/zkcluster/6001/data/myid
内容:1
vi /root/zookeeper/zkcluster/6002/data/myid
内容:2
vi /root/zookeeper/zkcluster/6003/data/myid
内容:3
启动服务
6001/bin/zkServer.sh start
6002/bin/zkServer.sh start
6003/bin/zkServer.sh start
查看服务状态
6001/bin/zkServer.sh status
6002/bin/zkServer.sh status
6003/bin/zkServer.sh status
在dubbo中使用zookeeper集群,配置方式
address="192.168.2.133:6002,192.168.2.133:6001,192.168.2.133:6003"