Zookeeper在Windows与Linux下的安装

xiaoxiao2021-02-28  76

Zookeeper版本下载地址:http://apache.fayea.com/zookeeper/

说明:安装Zookeeper之前需要安装JDK。

一、Linux系统下的安装

(一)版本说明

Linux版本:CentOS7 64位;

JDK版本:1.7.0_79;

Zookeeper版本:zookeeper-3.4.9

(二)安装

 1、创建 /usr/local/services/zookeeper 文件夹:

mkdir -p /usr/local/services/zookeeper

2、进入到 /usr/local/services/zookeeper 目录中:

cd /usr/local/services/zookeeper

3、下载 zookeeper-3.4.9.tar.gz(也可将压缩包下载以后放至该目录下):

wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz

4、解压缩 zookeeper-3.4.9.tar.gz:

tar -zxvf zookeeper-3.4.9.tar.gz

5、进入到 /usr/local/services/zookeeper/zookeeper-3.4.9/conf 目录中:

cd zookeeper-3.4.9/conf/

6、复制 zoo_sample.cfg 文件的并命名为为 zoo.cfg:

cp zoo_sample.cfg zoo.cfg

7、用 vim 打开 zoo.cfg 文件

vi zoo.cfg 8、修改其内容为如下: # The number of milliseconds of each tick # zookeeper 定义的基准时间间隔,单位:毫秒 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=/tmp/zookeeper # 数据文件夹 dataDir=/usr/local/services/zookeeper/zookeeper-3.4.9/data # 日志文件夹 # dataLogDir=/usr/local/services/zookeeper/zookeeper-3.4.9/logs # the port at which the clients will connect # 客户端访问 zookeeper 的端口号 clientPort=2181

9、保存并关闭 zoo.cfg 文件:先按“Esc”键,再按“shift”+“:”,左下角出现冒号以后,输入“wq”回车即可。

10、进入到 /usr/local/services/zookeeper/zookeeper-3.4.9/bin 目录中:

cd ../bin/

11、用 vim 打开 /etc/ 目录下的配置文件 profile:

vim /etc/profile

在其尾部追加如下内容:

# idea - zookeeper-3.4.9 config start - 2017-07-08 export ZOOKEEPER_HOME=/usr/local/services/zookeeper/zookeeper-3.4.9/ export PATH=$ZOOKEEPER_HOME/bin:$PATH export PATH # idea - zookeeper-3.4.9 config start - 2017-07-08

12、使 /etc/ 目录下的 profile 文件即可生效:

source /etc/profile

13、启动 zookeeper 服务:

sh zkServer.sh start

  如打印如下信息则表明启动成功:

ZooKeeper JMX enabled by default Using config: /usr/local/services/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg Starting zookeeper ... STARTED

14、查询 zookeeper 状态:

zkServer.sh status

15、关闭 zookeeper 服务:

zkServer.sh stop

如打印如下信息则表明成功关闭:

ZooKeeper JMX enabled by default Using config: /usr/local/services/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED

16、重启 zookeeper 服务:

zkServer.sh restart 如打印如下信息则表明重启成功: ZooKeeper JMX enabled by default Using config: /usr/local/services/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg ZooKeeper JMX enabled by default Using config: /usr/local/services/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg Stopping zookeeper ... STOPPED ZooKeeper JMX enabled by default Using config: /usr/local/services/zookeeper/zookeeper-3.4.9/bin/../conf/zoo.cfg Starting zookeeper ... STARTED

安装完毕。

参考自: http://www.linuxidc.com/Linux/2016-09/135052.htm

二、Windows系统下的安装

(一)版本说明

Windows版本:Win10;

JDK版本:1.7.0_79 ;

Zookeeper版本:3.4.6(点此进入下载界面);

(二)安装

1.把下载的zookeeper的文件解压到指定目录:

E:\beauxie\dubbo\zookeeper-3.4.6

2.解压文件以后,在conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg.

3.修改zoo.cfg中的内容:

# 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=E:\\beauxie\\dubbo\\zookeeper-3.4.6\\data #dataLogDir=E:\\beauxie\\dubbo\\zookeeper-3.4.6\\log # the port at which the clients will connect 客户端连接的端口 clientPort=2181

4.进入到bin目录,并且启动zkServer.cmd,这个脚本中会启动一个Java进程

在bin目录下打开cmd命令窗口(按住shift,鼠标右键,选择在此处打开命令窗口),运行:zkServer.cmd,如下:

5.启动jps可以看到QuorumPeerMain的进程

E:\beauxie\dubbo\zookeeper-3.4.6\bin>jps 

   启动客户端运行查看一下

E:\beauxie\dubbo\zookeeper-3.4.6\bin>zkCli.cmd -server 127.0.0.1:2181

安装完毕。 参考自: http://blog.csdn.net/morning99/article/details/40426133
转载请注明原文地址: https://www.6miu.com/read-49597.html

最新回复(0)