下载压缩包
- 官网地址:zookeeper
下载完成后上传到服务器
安装
- 解压缩文件
tar -zxvf apache-zookeeper-3.7.1-bin.tar.gz
- 修改文件夹名称
mv apache-zookeeper-3.7.1-bin zookeeper_-3.7.1
- 修改配置文件
cd conf cp -a zoo_sample.cfg zoo.cfg
修改文件内容
vim zoo.cfg # 修改文件内容 # 存储路径和日志存储路径 dataDir=/opt/zookeeper-3.7.1/data dataLogDir=/opt/zookeeper-3.7.1/logs # 端口 clientPort=2181 # 选举端口2888 3888 心跳端口 server.1=bigdata1:2888:2888 server.2=bigdata2:2888:2888 server.3=bigdata3:2888:2888
- 创建 dataDir 和 dataLogDir 文件夹
cd .. mkdir data mkdir logs
- 3.5版本后存储路径下没有myid 创建myid文件 所有服务器都要执行
cd data # server.1 echo 1 > myid # server.2 echo 2 > myid # server.3 echo 3 > myid
- 启动服务 每台服务器都执行
cd .. cd bin ./zkServer.sh start
- 查看状态
[root@bigdata3 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zookeeper-3.7.1/bin/../conf/zoo.cfg Client port found: 2888. Client address: localhost. Client SSL: false. Mode: leader
- 失败状态
[root@bigdata3 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zookeeper-3.7.1/bin/../conf/zoo.cfg Client port found: 2888. Client address: localhost. Client SSL: false. Error contacting service. It is probably not running.