1.下载
下载地址:https://repo.huaweicloud.com/apache/zookeeper/
2.解压
tar -zxvf apache-zookeeper-3.5.7-bin.tar.gz
目录
drwxr-xr-x. 2 502 games 232 Feb 10 2020 bin
drwxr-xr-x. 2 502 games 77 Feb 7 2020 conf
drwxr-xr-x. 5 502 games 4096 Feb 10 2020 docs
drwxr-xr-x. 2 root root 4096 Mar 26 14:21 lib
-rw-r--r--. 1 502 games 11358 Sep 13 2018 LICENSE.txt
-rw-r--r--. 1 502 games 432 Feb 10 2020 NOTICE.txt
-rw-r--r--. 1 502 games 1560 Feb 7 2020 README.md
-rw-r--r--. 1 502 games 1347 Feb 7 2020 README_packaging.txt
3.修改配置文件
进入conf
文件中
[root@znhost apache-zookeeper-3.5.7-bin]# cd conf
[root@znhost conf]# ll
total 12
-rw-r--r--. 1 502 games 535 May 4 2018 configuration.xsl
-rw-r--r--. 1 502 games 2712 Feb 7 2020 log4j.properties
-rw-r--r--. 1 502 games 922 Feb 7 2020 zoo_sample.cfg
zoo_sample.cfg使zookeeper的配置文件,但是不会生效,需要改成zoo.cfg
vim zoo.cfg
使用vim进行编辑
tickTime=2000
initLimit=10
syncLimit=5
#dataDir=/tmp/zookeeper
dataDir=/opt/apache-zookeeper-3.5.7-bin/zkdata
clientPort=2181
dataDir,zookeeper的数据存放目录,也可以不修改,按需修改
clientPoer,zookeeper的端口,按需修改
4.启动服务
进入zookeeper的bin目录
-rwxr-xr-x. 1 502 games 232 May 4 2018 README.txt
-rwxr-xr-x. 1 502 games 2067 Feb 7 2020 zkCleanup.sh
-rwxr-xr-x. 1 502 games 1158 Feb 10 2020 zkCli.cmd
-rwxr-xr-x. 1 502 games 1621 Feb 7 2020 zkCli.sh
-rwxr-xr-x. 1 502 games 1766 Feb 7 2020 zkEnv.cmd
-rwxr-xr-x. 1 502 games 3690 Jan 31 2020 zkEnv.sh
-rwxr-xr-x. 1 502 games 1286 Jan 31 2020 zkServer.cmd
-rwxr-xr-x. 1 502 games 4573 Feb 7 2020 zkServer-initialize.sh
-rwxr-xr-x. 1 502 games 9386 Feb 7 2020 zkServer.sh
-rwxr-xr-x. 1 502 games 996 Oct 3 2019 zkTxnLogToolkit.cmd
-rwxr-xr-x. 1 502 games 1385 Feb 7 2020 zkTxnLogToolkit.sh
zkServer.sh
是zookeeper的启动服务
启动命令
./zkServer.sh start
[root@znhost bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
5.查看状态
./zkServer.sh status
[root@znhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone
6.停止服务
./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
查看状态
root@znhost bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/apache-zookeeper-3.5.7-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Error contacting service. It is probably not running.