CentOS7系统Zookeeper中间件部署

#确保服务器上已经搭建完成JDK

安装zookeeper:
1.准备
zookeeper官网地址:Apache ZooKeeper

https://zookeeper.apache.org/releases.html

下载安装方式

使用wget命令行下载
wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.12.tar.gz
采用下载安装包的方式:Index of /zookeeper/stable
由于要安装在远程服务器上,故采用第一种方式安装;

注意:要下载源码包,否则启动客户端是启动失败;后缀带-bin.tar.gz
启动报错如下:
ZooKeeper JMX enabled by default Using config: /opt/software/zookeeper/bin/../conf/zoo.cfg Starting zookeeper ... FAILED TO START
看下zookeeper日志文件具体报错信息:
错误: 找不到或无法加载主类 org.apache.zookeeper.ZooKeeperMain

2、安装与配置
创建和解压
tar -zxvf apache-zookeeper-3.5.9.tar.gz
重命名:mv apache-zookeeper-3.5.9 zookeeper

创建数据存储目录与日志目录
进入zookeeper解压缩后的目录,新建数据文件夹dataDir和日志文件夹dataLogDir
命令:mkdir dataDir和mkdir dataLogDir

conf配置文件
进入配置目录,赋值拷贝样本文件
命令:cp zoo_sample.cfg zoo.cfg

修改 zoo.cfg文件内容
1.修改数据存储文件地址,按照上面建立的目录,小编的如下/opt/software/zookeeper/dataLogDir

[root@localhost kafka-logs]# cat /opt/zk/apache-zookeeper-3.8.0-bin/conf/zoo.cfg
# The number of milliseconds of each tick
tickTime=2000 #服务心跳时间
# The number of ticks that the initial
# synchronization phase can take
initLimit=10 #投票选举新leader的初始化时间
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5 #leader与follower心跳检测最大容忍时间
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/opt/zk/apache-zookeeper-3.8.0-bin/data #数据目录
dataLogDir=/opt/zk/apache-zookeeper-3.8.0-bin/log #日志目录
pidfile=/var/run/zookeeper.pid
# the port at which the clients will connect
clientPort=2181 #zk端口
# 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.
#
# https://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

## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
配置环境变量

打开/etc/profile 文件:vim /etc/profile
新增以下配置:
#ZOOKEEPER_HOME
export ZOOKEEPER_HOME=/opt/software/zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH
3.重新加载配置:source /etc/profile

3、运行
启动命令:./zkServer.sh start
停止命令:./zkServer.sh stop
查看运行状态:./zkServer.sh status

posted @ 2023-03-11 20:51  呼长喜  阅读(28)  评论(0编辑  收藏  举报