Zookeeper是一個協調服務,可以用它來作為配置維護、名字服務、分布式部署;
下面,我來分享一下在Linux下安裝Zookeeper的整個步驟,讓大家少走彎路。
一、Zookeeper下載
- [root@localhost 下載]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
- --2017-02-15 13:15:57-- http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz
- 正在解析主機 mirror.bit.edu.cn (mirror.bit.edu.cn)... 114.247.56.117
- 正在連接 mirror.bit.edu.cn (mirror.bit.edu.cn)|114.247.56.117|:80... 已連接。
- 已發出 HTTP 請求,正在等待回應... 200 OK
- 長度:11833706 (11M) [application/octet-stream]
- 正在保存至: “zookeeper-3.3.6.tar.gz”
- 100%[======================================================================================================================================================================================>] 11,833,706 171KB/s 用時 68s
- 2017-02-15 13:17:07 (170 KB/s) - 已保存 “zookeeper-3.3.6.tar.gz” [11833706/11833706])
二、解壓
[root@localhost deploy]# tar -zxvf /home/lk/下載/zookeeper-3.3.6.tar.gz
解壓完之后,會在deploy文件夾下面得到一個zookeeper-3.4.11的文件夾
三、進入到conf目錄
[root@localhost deploy]# cd /opt/deploy/zookeeper-3.4.11/conf
四、拷貝zoo_samle.cfg為zoo.cfg
- [root@localhost conf]# cp zoo_sample.cfg zoo.cfg
五、編輯zoo.cfg文件
- [root@localhost conf]# vi zoo.cfg
修改為:
- # 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.
- dataDir=/usr/zookeeper
- dataLogDir=/usr/zookeeper/log
- # the port at which the clients will connect
- clientPort=2181
- server.1=192.168.147.128:3888
六、設置環境變量
- [root@localhost conf]# export ZOOKEEPER_INSTALL=/opt/deploy/zookeeper-3.3.6
- [root@localhost conf]# export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
七、啟動
- [root@localhost bin]# ./zkServer.sh start
- JMX enabled by default
- Using config: /opt/deploy/zookeeper-3.4.11/bin/../conf/zoo.cfg
- Starting zookeeper ... STARTED
- [root@localhost bin]#
八、測試zookeeper
- [root@localhost bin]# ./zkCli.sh -server 192.168.147.128:2181
如果是本地連接,那么不需要 默認是本地
注意:如果出現拒絕連接,請檢查如下:
1、防火牆是否關閉 systemctl stop firewalld