版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
下载
到官网去下载你想要的版本 官网下载地址
上传解压
用你想得到的一切方法(ps:可以在linux中使用rz上传命令),把你刚才下载的文件,上传到Linux文件系统中。然后解压:
[root@localhost tmp]#tar -zxvf zookeeper-3.4.10.tar.gz
- 1
将解压后的文件复制到/usr/local
目录下,并重命名为zookeeper
:
[root@localhost tmp]# cp zookeeper-3.4.10 /usr/local/zookeeper -r //复制所有文件到zookeeper 文件夹下
[root@localhost tmp]# cd /usr/local/zookeeper //切换到/usr/local/zookeeper目录下
- 1
- 2
配置
切换到zookeeper
目录下的conf
目录下,重新复制一份zoo_sample.cfg
文件并命名为zoo.cfg
:
[root@localhost zookeeper]# cd conf //切换到目录下
[root@localhost conf]# ll //显示目录下的信息
总用量 12
-rw-r--r--. 1 root root 535 5月 8 18:17 configuration.xsl
-rw-r--r--. 1 root root 2161 5月 8 18:17 log4j.properties
-rw-r--r--. 1 root root 922 5月 8 18:17 zoo_sample.cfg
[root@localhost conf]# cp zoo_sample.cfg zoo.cfg //copy一份到当前目录下,并命名为zoo.cfg
[root@localhost conf]# ll
总用量 16
-rw-r--r--. 1 root root 535 5月 8 18:17 configuration.xsl
-rw-r--r--. 1 root root 2161 5月 8 18:17 log4j.properties
-rw-r--r--. 1 root root 922 5月 8 18:29 zoo.cfg
-rw-r--r--. 1 root root 922 5月 8 18:17 zoo_sample.cfg
[root@localhost conf]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
修改zoo.cfg
文件如下:
[root@localhost conf]# vi zoo.cfg
- 1
前提是要创建/tmp/zookeeper
和/tmp/zookeeper/log
目录,不然启动时会报错。
最后一步配置环境变量:
[root@localhost zookeeper]# vi /etc/profile //编辑文件
[root@localhost zookeeper]# source /etc/profile //使生效
- 1
- 2
添加如下内容:
export ZOOKEEPER=/usr/local/zookeeper
export PATH=$PATH:$ZOOKEEPER/bin
- 1
- 2
启动Zookeeper
因为配置了环境变量,所以在任意目录下都可以运行以下启动命令启动Zookeeper。
[root@localhost ~]# zkServer.sh start //启动
[root@localhost ~]# zkServer.sh status //查看运行状态
- 1
- 2
- 3
启动客户端:
[root@localhost ~]# zkCli.sh //启动客户端
- 1
另外,你也可以查看看 https://blog.youkuaiyun.com/She_lock/article/details/100133782 这篇文章。这里有如何更加优雅的启动zookeeper方法。
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-e9f16cbbc2.css" rel="stylesheet">
</div>