首页 > 代码库 > zookeeper安装

zookeeper安装

# zookeeper
http://zookeeper.apache.org/

# zookeeper下载地址
http://mirror.bit.edu.cn/apache/zookeeper/  
http://mirrors.cnnic.cn/apache/zookeeper/

# zookeeper安装
```
VERSION=3.4.8
MIRRORSURL=http://mirrors.cnnic.cn/apache/zookeeper/
wget ${MIRRORSURL}/zookeeper-${VERSION}/zookeeper-${VERSION}.tar.gz
tar -zxvf zookeeper-${VERSION}.tar.gz -C /usr/local

##zookeeper配置文件
cat > /usr/local/zookeeper-${VERSION}/conf/zoo.cfg << END
## 自动清理日志,单位:小时
autopurge.purgeInterval=1
## 日志保留的文件数目,默认3
autopurge.snapRetainCount=3
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper
## clientPort是客户端连接端口
clientPort=2182
## 5888为通讯端口
## 6888为主节点选举端口
server.1=192.168.1.92:5888:6888
server.2=192.168.1.93:5888:6888
server.3=192.168.1.94:5888:6888
END

#在对应服务器上的dataDir下创建myid文件,指定配置的对应server.ID
echo "1" > /data/zookeeper/myid
echo "2" > /data/zookeeper/myid
echo "3" > /data/zookeeper/myid
```

# zookeeper进程运行命令
```
cd /PATH/TO/ZOOKHOME/bin
./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
```

# zookeeper进程运行命令,去连接某个端口
```
cd /PATH/TO/ZOOKHOME/
bin/zkCli.sh -server 127.0.0.1:2181
```



本文出自 “9383764” 博客,转载请与作者联系!

zookeeper安装