Linux Zookeeper 安装配置

安装 zookeeper 服务

前提准备

  1. CentOS服务器一台
  2. 建议购买阿里云香港服务器(点击领取优惠券)

zookeeper安装

  1. 创建 /usr/local/services/zookeeper 文件夹:
mkdir -p /usr/local/zookeeper
  1. 进入到 /usr/local/services/zookeeper 目录中:
cd /usr/local/zookeeper
  1. 下载 zookeeper-3.4.12.tar.gz:
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.12/zookeeper-3.4.12.tar.gz
  1. 解压缩 zookeeper-3.4.12.tar.gz:
tar -zxvf zookeeper-3.4.12.tar.gz
  1. 进入到 /usr/local/zookeeper/zookeeper-3.4.12/conf 目录中:
cd zookeeper-3.4.12/conf/
  1. 复制 zoo_sample.cfg 文件的并命名为为 zoo.cfg:
cp zoo_sample.cfg zoo.cfg
  1. 用 vim 打开 zoo.cfg 文件并修改其内容为如下:
# 数据文件夹
dataDir=/usr/local/zookeeper/zookeeper-3.4.12/data
 
# 日志文件夹
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.12/logs
  1. 保存并关闭 zoo.cfg 文件

  2. 进入到 /usr/local/zookeeper/zookeeper-3.4.11/bin 目录中:

cd ../bin/
  1. 用 vim 打开 /etc/ 目录下的配置文件 profile:
vim /etc/profile

并在其尾部追加如下内容:

# idea - zookeeper-3.4.12 config start - 2019-3-7
 
export ZOOKEEPER_HOME=/usr/local/zookeeper/zookeeper-3.4.12/
export PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH
 
# idea - zookeeper-3.4.12 config start - 2019-3-7
  1. 使 /etc/ 目录下的 profile 文件即可生效:
source /etc/profile
  1. 启动 zookeeper 服务:
zkServer.sh start

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

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
  1. 查询 zookeeper 状态:
zkServer.sh status
  1. 关闭 zookeeper 服务:
zkServer.sh stop

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

ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/zookeeper-3.4.12/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
  1. 重启 zookeeper 服务:
zkServer.sh restart

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

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

你可能感兴趣的:(服务器,JAVA)