PS:需要提前安装JDK,linux下安装JDK
#下载压缩包
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
#解压
tar -zxvf zookeeper-3.4.14.tar.gz
修改conf文件
# 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.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/zookeeper
dataLogDir=/usr/zookeeper/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
server.1=192.168.80.128:2888:3888
server.2=192.168.80.131:2888:3888
server.3=192.168.80.132:2888:3888
/usr/zookeeper下创建myid文件,通过vim分别写下id(分别为1、2、3)
设置环境变量
[root@localhost conf]# export ZOOKEEPER_INSTALL=/opt/deploy/zookeeper-3.4.14
[root@localhost conf]# export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
#启动
./zkServer.sh start
#测试zookeeper
./zkCli.sh -server 192.168.80.128:2181
注意:如果出现拒绝连接,请检查如下:
1、防火墙是否关闭 systemctl stop firewalld
把虚拟机中的防火墙清一下
sudo iptables -F