第一步、创建zookeeper的安装目录

mkdir -p /usr/local/services/zookeeper

第二步、进入zookeeper目录

cd /usr/local/services/zookeeper

第三步、下载zookeeper-3.4.9.tar.gz

wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz

第四步、解压缩zookeeper-3.4.9.tar.gz

tar -zxvf zookeeper-3.4.9.tar.gz

第五步、进入到/usr/local/services/zookeeper/zookeeper-3.4.9.tar.gz

第六步、进入conf目录

第七步、将zoo_sample.cfg文件复制一份,并重命名为zoo.cfg

第八步、用vim打开zoo.cfg文件,并修改其内容如下:

# 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=/usr/local/service/zookeeper/zookeeper-3.4.9/data

#日志文件夹
dataLogDir=/usr/local/service/zookeeper/zookeeper-3.4.9/logs

# the port at which the clients will connect

#客户端访问zookeeper的端口号
clientPort=2181

# the maximum number of client connections.

按 i 进入编辑插入模式,编辑完成后,按Esc退出,然后执行:wq!命令强制保存

第九步、保存zoo.cfg文件后,进入到bin目录中

第十步、用vim打开/etc/目录下的配置文件profile

vim /etc/profile

然后在其尾部追加如下内容

export ZOOKEEPER_HOME=/usr/local/services/zookeeper/zookeeper-3.4.9/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH

 

第十一步、使/etc/ 目录下的profile文件即时生效

source /etc/profile

第十二步、启动zookeeper服务

使用zkServer.sh start

zkServer.sh status

注:

1、查看zookeeper状态:zkServer.sh status

2、关闭zookeeper服务:zkServer.sh stop

3、重启zookeeper服务:zkServer.sh restart

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐