一.zookeeper安装-linux环境下
zookeeper安装-linux环境下
Zookeeper是一个协调服务,可以用它来作为配置维护、名字服务、分布式部署;
下面,我来分享一下在Linux下安装Zookeeper的整个步骤,让大家少走弯路。
1.下载zookeeper
进入官网下载地址
http://mirrors.hust.edu.cn/apache/zookeeper/
进入stable/目录 选择稳定版本的zookeeper-3.4.12.tar.gz
[[email protected] xjb]# wget http://mirrors.hust.edu.cn/apache/zookeeper/stable/zookeeper-3.4.12.tar.gz
2.解压
切换到压缩包同级目录下解压
[[email protected] xjb]#tar -zxvf zookeeper-3.4.12.tar.gz
解压完之后,会在同级文件夹下面得到一个zookeeper-3.4.12的文件夹
3.进入到conf目录
[[email protected] zookeeper-3.4.12]#cd conf
4.拷贝zoo_samle.cfg为zoo.cfg
[[email protected] conf]#cp zoo_sample.cfg zoo.cfg
5.编辑zoo.cfg文件
[[email protected] 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
#Network IP of this machine
server.1=192.168.75.134:2888:3888
6.设置环境变量
ZOOKEEPER_INSTALL为本机zookeeper安装目录
[[email protected] conf]# export ZOOKEEPER_INSTALL=/usr/local/xjb/zookeeper-3.4.12
[[email protected] conf]#export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
7.启动zookeeper
进入zookeeper-3.4.12目录的bin目录下
[[email protected] bin]# ./zkServer.sh start
JMX enabled by default
Using config: /usr/local/xjb/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[[email protected] bin]#
8.测试zookeeper
[[email protected] bin]# ./zkCli.sh -server 192.168.147.128:2181
如果是本地连接,那么不需要 默认是本地
注意:如果出现拒绝连接,请检查如下:
1、防火墙是否关闭 systemctl stop firewalld