Linux系列——ZooKeeper的安装与测试

简介: Linux系列——ZooKeeper的安装与测试

前言

Linux版本:CentOS-6.7-x86_64-bin-DVD1.iso  (链接:点击打开链接 密码:h51u)

JDK版本:1.8(JDK安装过程参考:点击打开链接

Zookeeper版本:3.4.6

注:本文安装的是单机模式,适合初学者进行


安装

step1 下载Zookeeper并解压

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


tar -zxvf zookeeper-3.4.6.tar.gz


mv zookeeper-3.4.6 zookeeper (修改根目录名字)


step2 添加文件夹和文件


在Zookeeper根目录下添加两个文件夹data、logs

mkdir data

mkdir logs

进入到data文件夹下,添加一个文件myid,里面的内容先填写1,后面会讲怎么填写!


step3 修改配置文件

在conf文件夹下面新建一个文件,命名为zoo.cfg,内容如下(注意修改dataDir和dataLogDir路径):

# 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= /usr/local/zookeeper/data
dataLogDir= /usr/local/zookeeper/logs
# 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.
#
# 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=zookeeper:2888:38888



参照zoo.cfg里面最后一行server.1,在data/myid里面加入一个数字:1;


里面就一个数字,用来唯一标识这个服务!!!


server.A=B:C:D;其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper 实例通信端口号不能一样,所以要给它们分配不同的端口号。


step4 添加环境变量

/etc/profile文件中设置PATH,注意修改路径

export ZOOKEEPER_HOME=/usr/local/zookeeper

export PATH=$ZOOKEEPER_HOME/bin:$PATH

export PATH


step5 测试

执行

zkServer.sh start

出现下列信息表示启动成功:

扩展

Zookeeper启动关闭相关命令

zkServer.sh status     ---查询状态

zkServer.sh stop      ---关闭

zkServer.sh restart   ---重启

OK, GAME OVER!

相关文章
|
5月前
|
Ubuntu Linux
计算机基础知识:linux系统怎么安装?
在虚拟机软件中创建一个新的虚拟机,并选择相应操作系统类型和硬盘空间大小等参数。将下载的 ISO 镜像文件加载到虚拟机中。启动虚拟机,进入安装界面,并按照步骤进行安装。安装完成后,可以在虚拟机中使用 Linux 系统。
|
3月前
|
安全 Linux iOS开发
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
264 6
Nessus Professional 10.10 Auto Installer for RHEL 10, AlmaLinux 10, Rocky Linux 10 - Nessus 自动化安装程序
|
3月前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
226 1
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
|
3月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
265 1
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
|
4月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
370 2
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
|
4月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
452 1
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
|
3月前
|
消息中间件 Kafka Linux
Linux下安装Kafka 3.9.1
本文介绍Kafka 3.9.1版本的安装与配置,包括通过ZooKeeper或KRaft模式启动Kafka。涵盖环境变量设置、日志路径修改、集群UUID生成、存储格式化及服务启停操作,适用于Linux环境下的部署实践。
476 0
|
5月前
|
运维 Linux 开发者
Linux系统中使用Python的ping3库进行网络连通性测试
以上步骤展示了如何利用 Python 的 `ping3` 库来检测网络连通性,并且提供了基本错误处理方法以确保程序能够优雅地处理各种意外情形。通过简洁明快、易读易懂、实操性强等特点使得该方法非常适合开发者或系统管理员快速集成至自动化工具链之内进行日常运维任务之需求满足。
373 18
|
4月前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
597 0
|
5月前
|
网络协议 关系型数据库 Linux
【App Service Linux】在Linux App Service中安装 tcpdump 并抓取网络包
在App Service for Linux环境中,无法像Windows一样直接使用网络排查工具抓包。本文介绍了如何通过TCPDUMP在Linux环境下抓取网络包,包括SSH进入容器、安装tcpdump、执行抓包命令及下载分析文件的完整操作步骤。
284 5