File tree Expand file tree Collapse file tree
docs/deploy/tool/zookeeper Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # ZooKeeper 安装部署
2+
3+ <!-- TOC depthFrom:2 depthTo:3 -->
4+
5+ - [ 下载解压 ZooKeeper] ( #下载解压-zookeeper )
6+ - [ 创建配置文件] ( #创建配置文件 )
7+ - [ 启动 ZooKeeper 服务器] ( #启动-zookeeper-服务器 )
8+ - [ 启动 CLI] ( #启动-cli )
9+ - [ 停止 ZooKeeper 服务器] ( #停止-zookeeper-服务器 )
10+
11+ <!-- /TOC -->
12+
13+ 在安装 ZooKeeper 之前,请确保你的系统是在以下任一操作系统上运行:
14+
15+ - ** 任意 Linux OS** - 支持开发和部署。适合演示应用程序。
16+ - ** Windows OS** - 仅支持开发。
17+ - ** Mac OS** - 仅支持开发。
18+
19+ 环境要求:JDK6+
20+
21+ 安装步骤如下:
22+
23+ ## 下载解压 ZooKeeper
24+
25+ 进入官方下载地址:http://zookeeper.apache.org/releases.html#download ,选择合适版本。
26+
27+ 解压到本地:
28+
29+ ```
30+ $ tar -zxf zookeeper-3.4.6.tar.gz
31+ $ cd zookeeper-3.4.6
32+ ```
33+
34+ ## 创建配置文件
35+
36+ 你必须创建 ` conf/zoo.cfg ` 文件,否则启动时会提示你没有此文件。
37+
38+ 初次尝试,不妨直接使用 Kafka 提供的模板配置文件 ` conf/zoo_sample.cfg ` :
39+
40+ ```
41+ $ cp conf/zoo_sample.cfg conf/zoo.cfg
42+ ```
43+
44+ ## 启动 ZooKeeper 服务器
45+
46+ 执行以下命令
47+
48+ ```
49+ $ bin/zkServer.sh start
50+ ```
51+
52+ 执行此命令后,你将收到以下响应
53+
54+ ```
55+ $ JMX enabled by default
56+ $ Using config: /Users/../zookeeper-3.4.6/bin/../conf/zoo.cfg
57+ $ Starting zookeeper ... STARTED
58+ ```
59+
60+ ## 启动 CLI
61+
62+ 键入以下命令
63+
64+ ```
65+ $ bin/zkCli.sh
66+ ```
67+
68+ 键入上述命令后,将连接到 ZooKeeper 服务器,你应该得到以下响应。
69+
70+ ```
71+ Connecting to localhost:2181
72+ ................
73+ ................
74+ ................
75+ Welcome to ZooKeeper!
76+ ................
77+ ................
78+ WATCHER::
79+ WatchedEvent state:SyncConnected type: None path:null
80+ [zk: localhost:2181(CONNECTED) 0]
81+ ```
82+
83+ ## 停止 ZooKeeper 服务器
84+
85+ 连接服务器并执行所有操作后,可以使用以下命令停止 zookeeper 服务器。
86+
87+ ```
88+ $ bin/zkServer.sh stop
89+ ```
90+
91+ > 本节安装内容参考:[ Zookeeper 安装] ( https://www.w3cschool.cn/zookeeper/zookeeper_installation.html )
You can’t perform that action at this time.
0 commit comments