zookeeper 进入客户端_Windows下ZooKeeper的配置和启动步骤——单机模式

本文介绍了在Windows环境下配置和启动ZooKeeper的步骤,包括下载ZooKeeper和JDK,配置cfg文件,设置dataDir和clientPort,以及启动ZooKeeper服务器端和客户端的详细过程。特别强调了启动顺序,客户端启动依赖于服务器端。
摘要由CSDN通过智能技术生成

1. 序

ZooKeeper的工作模式有三种:单机模式、集群模式、伪集群模式

2. 下载

2.1 zookeeper

可去ZooKeeper官网下载ZooKeeper的稳定版:zookeeper官网

2.2 jdk

由于Zookeeper使用Java编写,因此运行ZooKeeper之前需安装Java环境——配置JDK,且JDK版本应大于等于1.6

3 ZooKeeper配置

解压后,可得到如下目录:

zookeeper.png

3.1 cfg文件配置

进入conf文件夹,打开zoo_sample.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=/tmp/zookeeper

# the port at which the clients will connect

clientPort=2181

# 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

在该文件夹下新建“zoo.cfg”文件(ZooKeeper启动时会找名为“zoo.cfg”文件并将其作为默认配置文件),并将zoo_sample.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=D:/zookeeper-3.4.9/data

# the port at which the clients will connect

clientPort=2181

# 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

至此,ZooKeeper在Windows中的安装配置完毕。

4 启动ZooKeeper

进入bin文件夹,可得如下目录:

bin.png

4.1 启动ZooKeeper服务器端

在Windows中双击“zkServer.cmd”;

4.2 启动ZooKeeper客户端

在Windows中双击“zkCli.cmd”;

注意:

上面两个步骤不能颠倒,否则ZooKeeper客户端不能成功启动。

5 添加系统变量

ZOOKEEPER_HOME:D:/zookeeper-3.4.9

Path: 在现有的值后面添加 “;%ZOOKEEPER_HOME%\bin;”

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值