从镜像下载zookeeper的地址 , 这个镜像可以自行选择,笔者选择的是稳定版(stable)
wget https://mirrors.cnnic.cn/apache/zookeeper/stable/apache-zookeeper-3.6.3-bin.tar.gz
创建log,data目录在zookeeper目录下面,与bin目录平级
[root@iZuf64fa3s2az73p556he0Z apache-zookeeper-3.6.3]# ll
total 192
drwxr-xr-x 2 1000 1000 4096 Nov 3 14:03 bin
-rw-r--r-- 1 1000 1000 2692 Apr 9 2021 checkstyle-simple.xml
-rw-r--r-- 1 1000 1000 17804 Apr 9 2021 checkstyle-strict.xml
-rw-r--r-- 1 1000 1000 1538 Apr 9 2021 checkstyleSuppressions.xml
drwxr-xr-x 2 1000 1000 4096 Nov 3 14:41 conf
drwxr-xr-x 5 root root 4096 Nov 3 14:26 data
drwxr-xr-x 3 1000 1000 4096 Apr 9 2021 dev
-rw-r--r-- 1 1000 1000 347 Apr 9 2021 excludeFindBugsFilter.xml
-rw-r--r-- 1 1000 1000 2649 Apr 9 2021 Jenkinsfile
-rw-r--r-- 1 1000 1000 1776 Apr 9 2021 Jenkinsfile-owasp
-rw-r--r-- 1 1000 1000 1892 Apr 9 2021 Jenkinsfile-PreCommit
-rw-r--r-- 1 1000 1000 11358 Apr 9 2021 LICENSE.txt
drwxr-xr-x 5 root root 4096 Nov 3 14:43 log
-rw-r--r-- 1 1000 1000 432 Apr 9 2021 NOTICE.txt
-rw-r--r-- 1 1000 1000 2019 Apr 9 2021 owaspSuppressions.xml
-rwxr-xr-x 1 1000 1000 35189 Apr 9 2021 pom.xml
-rw-r--r-- 1 1000 1000 1963 Apr 9 2021 README.md
-rw-r--r-- 1 1000 1000 3166 Apr 9 2021 README_packaging.md
-rw-r--r-- 1 1000 1000 21474 Apr 9 2021 zk-merge-pr.py
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-assembly
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-client
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-compatibility-tests
drwxr-xr-x 12 1000 1000 4096 Nov 3 14:03 zookeeper-contrib
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-docs
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-it
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-jute
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-metrics-providers
drwxr-xr-x 5 1000 1000 4096 Nov 3 14:03 zookeeper-recipes
drwxr-xr-x 3 1000 1000 4096 Nov 3 14:03 zookeeper-server
创建data/zoo/myid文件,里面信息为zookeeper的编号,
[root@iZuf64fa3s2az73p556he0Z apache-zookeeper-3.6.3]# cd data
[root@iZuf64fa3s2az73p556he0Z data]# ls
zoo zoo-2 zoo-3
[root@iZuf64fa3s2az73p556he0Z data]# cd zoo
[root@iZuf64fa3s2az73p556he0Z zoo]# ls
myid
[root@iZuf64fa3s2az73p556he0Z zoo]# cat myid
1
[root@iZuf64fa3s2az73p556he0Z zoo]#
创建zoo目录在log目录下面
[root@iZuf64fa3s2az73p556he0Z apache-zookeeper-3.6.3]# cd log/
[root@iZuf64fa3s2az73p556he0Z log]# ls
zoo zoo-2 zoo-3
[root@iZuf64fa3s2az73p556he0Z log]# cd zoo
[root@iZuf64fa3s2az73p556he0Z zoo]# pwd
/usr/local/software/apache-zookeeper-3.6.3/log/zoo
[root@iZuf64fa3s2az73p556he0Z zoo]#
创建conf文件,在conf目录,文件名zoo.cfg,修改datadir和datalogdir路径
# 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/local/apache-zookeeper-3.6.3/data/zoo
dataLogDir=/usr/local/apache-zookeeper-3.6.3/log/zoo
# the port at which the clients will connect
clientPort=2181
#nodelist
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888
# 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
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
笔者集群ip
139.196.72.48 zoo1
47.102.128.87 zoo2
114.55.103.145 zoo3
7 笔者启动之后报错了,
在logs目录下面看到具体的报错信息如下
翻找资料说是ip的端口
## 在zoo.cfg配置中添加
quorumListenOnAllIPs=true