linux上安装zookeeper

本文详细介绍如何下载并安装ZooKeeper 3.5.1-alpha版本,包括配置环境变量、设置myid文件及启动服务等步骤。适用于希望快速部署ZooKeeper服务的初学者。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载zookeeper http://download.youkuaiyun.com/detail/zhu_xingbang/9377745 资源0分

2.把下载好的zookeeper-3.5.1-alpha.tar.gz文件放入指定目录下,我的在/home/zhuxb 目录下

3.解压zookeeper文件

tar -zxvf zookeeper-3.5.1-alpha.tar.gz

4.进入zookeeper-3.5.1-alpha目录下,创建data文件夹和logs文件夹

mkdir date

mkdir logs

5.进入conf文件夹,复制zoo_sample.cfg文件,命名为“zoo.cfg"

cp zoo_sample.cfg zoo.cfg

6.编辑zoo.cfg

vi zoo.cfg 按i进入编辑模式

# 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=/home/zhuxb/zookeeper-3.5.1-alpha/data
dataLogDir=/home/zhuxb/zookeeper-3.5.1-alpha/logs


# the port at which the clients will connect
clientPort=2181
#
# 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


# 2888,3888 are election port
server.1=本机ip:2888:3888

7.进入data文件夹,创建myid文件,编辑该文件,添加内容为1  该1与上边server.1中的1相对应,如果为集群则需要在其他的服务器上指定相应的编号

8.进入etc目录,编辑/profile文件
export JAVA_HOME=/home/zhuxb/java/jdk1.8.0_65
export ZOOKEEPER_HOME=/home/zhuxb/zookeeper-3.5.1-alpha
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$ZOOKEEPER_HOME/bin:$PATH:$HOME/bin
export PATH

9.启动测试

进入zookeeper-3.5.1-alpha目录下的bin目录,执行命令:

./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/zhuxb/zookeeper/zookeeper-3.5.1-alpha/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

然后产看状态,执行命令

./zkServer.sh status

ZooKeeper JMX enabled by default
Using config: /home/zhuxb/zookeeper/zookeeper-3.5.1-alpha/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost.
Mode: standalone

OK,安装完成,启动正常

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值