首页 > 系统相关 >Linux安装zookeeper(伪集群)

Linux安装zookeeper(伪集群)

时间:2023-12-30 21:11:38浏览次数:30  
标签:bin cfg zookeeper zoo 集群 conf Linux data

环境:

系统: Alibaba Cloud Linux 3 (Soaring Falcon)

jdk: jdk8

1.下载安装包

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

找到对应版本,这里以稳定版 3.8.3 为例,在节点上下载

# wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.3/apache-zookeeper-3.8.3-bin.tar.gz  --no-check-certificate

 2.解压对应压缩包

# tar -xzvf apache-zookeeper-3.8.3-bin.tar.gz

将路径添加到环境变量中

# pwd
/home/apache-zookeeper-3.8.3-bin

编辑 /etc/profile,添加 

export ZOOKEEPER_HOME=/home/apache-zookeeper-3.8.3-bin

使之生效

source /etc/profile

3.数据及日志文件准备

创建数据存放目录

mkdir -p ./data/zk/data ./data/zk1/data ./data/zk2/data

创建日志目录

mkdir -p ./data/zk/dataLog ./data/zk1/dataLog ./data/zk2/dataLog

4.配置文件

修改配置文件

复制./conf/zoo_sample.cfg 并命名为 ./conf /zoo.cfg

cp ./conf/zoo_sample.cfg ./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
# 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=${ZOOKEEPER_HOME}/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.
#
# 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
server.1=127.0.0.1:2001:3001
server.2=127.0.0.1:2002:3002
server.3=127.0.0.1:2003:3003

[root@iZbp1eruj60nrojc5y3u39Z conf]# vim zoo.cfg
[root@iZbp1eruj60nrojc5y3u39Z conf]# cat zoo.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=/home/apache-zookeeper-3.8.3-bin/data/zk/data
dataLogData=/home/apache-zookeeper-3.8.3-bin/data/zk/dataLog
# 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.
#
# 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
server.1=127.0.0.1:2001:3001
server.2=127.0.0.1:2002:3002
server.3=127.0.0.1:2003:3003

同理复制并修改为 zoo1.cfg 和 zoo2.cfg,并修改数据存放文件夹、日志文件夹和端口号

 

在每个zookeeper下创建 myid文件,内容为 1、2、3, 就是每台zookeeper的机器ID.

echo 1 >${ZOOKEEPER_HOME}/data/zk/data/myid
echo 2 >${ZOOKEEPER_HOME}/data/zk1/data/myid
echo 3 >${ZOOKEEPER_HOME}/data/zk2/data/myid

5.启动

启动命令:

./bin/zkServer.sh start ./conf/zoo.cfg
./bin/zkServer.sh start ./conf/zoo1.cfg
./bin/zkServer.sh start ./conf/zoo2.cfg

成功提示:

# ./bin/zkServer.sh start ./conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: ./conf/zoo.cfg
Starting zookeeper ... STARTED

如安装失败,可查看安装日志目录 ${ZOOKEEPER_HOME}/logs 里面的out日志

查看状态

./bin/zkServer.sh status ./conf/zoo.cfg
./bin/zkServer.sh status ./conf/zoo1.cfg
./bin/zkServer.sh status ./conf/zoo2.cfg

状态提示:

follower:

# ./bin/zkServer.sh status ./conf/zoo.cfg
ZooKeeper JMX enabled by default
Using config: ./conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower

leader:

# ./bin/zkServer.sh status ./conf/zoo1.cfg
ZooKeeper JMX enabled by default
Using config: ./conf/zoo1.cfg
Client port found: 2182. Client address: localhost. Client SSL: false.
Mode: leader

 

标签:bin,cfg,zookeeper,zoo,集群,conf,Linux,data
From: https://www.cnblogs.com/chencoolandclear/p/17936536.html

相关文章

  • 深入解析Linux中的df命令:轻松掌握磁盘空间使用情况
    当我们使用Linux系统时,经常会遇到需要查看磁盘空间使用情况的情况。df命令是一个非常有用的工具,可以帮助我们了解文件系统的磁盘使用情况。在这篇博客文章中,我们将深入探讨df命令的使用方法以及如何解读其输出。什么是df命令?df是磁盘空间查看命令,用于显示文件系统的磁盘使用情况......
  • linux 中 ll -h列出文件、目录信息的含义
     001、[root@pc1test1]#ll-h##ll-h命令或者ls-l命令total20M-rw-rw-r--.2rootroot6.6MDec3017:52a.txt-rw-r--r--.1rootroot6.6MDec3017:53b.txtdrwxr-xr-x.2rootroot6Dec3017:57dir1drwxr-xr-x.3rootroot22Dec301......
  • Linux命令-mdadm管理软磁盘阵列
    一、命令概要1.1命令介绍mdadm(multipledevicesadmin)命令的主要功能是用来管理RAID磁盘阵列组,linux系统中实现软RAID设备的命令,可以进行创建,调整,监控,删除等全套管理操作1.2语法格式mdadm命令的格式是:mdadm【模式】【磁盘阵列】【参数】设备名SYNOPSIS    mdadm[mode]<......
  • 记一次 Arch Linux 滚完无法开机的解决过程
    滚的时候说空间满了,我没在意。直到没法开机我才意识到事情的严重性。先进安装时用的LiveCD,将/home下的重要文件都备份好。df-lh一看,鉴定为/满了,开始扩容。fdisk/dev/nvme0n1查看磁盘。我的分区是/boot,/,/home,所以先删掉/home和/,再(从/的原起始位置)新建分区,保......
  • EasyCVR在Linux中开启硬件探测配置后,无法启动该如何解决?
    有用户反馈,可视化监控云平台EasyCVR智能边缘网关在Linux系统上开启硬件探测配置后,无法正常启动程序,如下图:收到用户反馈后,技术人员立即开展排查和解决。1)由反馈可见,报错为“LocalMachineCheckError!本地机器检查错误!”此错误是因为程序在校验硬件盒子内程序出错;2)于是排查智能边缘......
  • linux下好玩的shell程序与玩法
    1主要包括如下程序: sudoaptinstalllolcataewancowsayjp2alinuxlogoneoftechfortunepvcmatrixcbonsai2fortune:人们喜欢阅读随机的预测或说法,该工具用来缓解无聊的时光。上边是没有lolcat的效果,下边是加了lolcat的效果就是彩色的。3lolcat:无条件将输入涂上五颜......
  • Linux驱动开发之Linux内核中的中断处理以及相关API和例程分析
    中断是计算机中实现异步事件处理的一种关键机制。当中断发生时,CPU会暂停当前的任务,转去运行中断服务例程。中断处理完成后,CPU再返回到原来的任务。这使得中断处理具有很高的实时性和响应速度。在Linux内核中,充分利用了中断机制来响应各种硬件和软件事件。在Linux操作系统中,中断......
  • linux 中 ls -F选项
     linux中ls-F选项,F表示文件类型。文件末尾追加*表示是可执行文件;文件末尾/表示是目录文件末尾是@表示是软链接文件 001、[root@pc1test]#ls##测试目录a.txtb.txtdir1dir2dir3dir4file1file2file3file4[root@pc1test]#ls-l......
  • linux 中实现仅对指定目录下的目录或者文件单独进行迭代
     001、测试目录如下,分别包含目录、文件[root@pc1test]#ls##测试目录dir1dir2dir3dir4file1file2file3file4 002、仅对目录进行迭代 a、[root@pc1test]#ls##测试目录dir1dir2di......
  • CentOS For Linux搭建过程
    在搭建CentOSLinux的过程中,首先需要准备的软件是VMwareWorkstation虚拟机软件,它是在搭建CentOSLinux的过程中,首先需要准备的软件是VMwareWorkstation虚拟机软件,它是用于创建和运行虚拟机的常用工具。然后你需要下载CentOS7的镜像文件,它是一款免费开源的Linux操作系统,广泛应用......