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!

相关文章
|
3月前
|
Linux Shell
linux自动崩溃,模拟测试
该脚本创建一个 systemd 服务和定时器,在系统启动3分钟后触发崩溃。通过向 /proc/sysrq-trigger 写入 "c" 来实现内核崩溃,用于测试系统崩溃后的恢复机制。
77 4
|
16天前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
158 2
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
|
16天前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
260 1
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
|
26天前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
412 0
|
2月前
|
运维 Linux 开发者
Linux系统中使用Python的ping3库进行网络连通性测试
以上步骤展示了如何利用 Python 的 `ping3` 库来检测网络连通性,并且提供了基本错误处理方法以确保程序能够优雅地处理各种意外情形。通过简洁明快、易读易懂、实操性强等特点使得该方法非常适合开发者或系统管理员快速集成至自动化工具链之内进行日常运维任务之需求满足。
142 18
|
18天前
|
存储 安全 Linux
Kali Linux 2025.3 发布 (Vagrant & Nexmon) - 领先的渗透测试发行版
Kali Linux 2025.3 发布 (Vagrant & Nexmon) - 领先的渗透测试发行版
269 0
|
安全 Linux 测试技术
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
116 0
|
1月前
|
缓存 安全 Linux
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
110 0
|
3月前
|
安全 Linux iOS开发
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
368 0
Burp Suite Professional 2025.7 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
|
4月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.7-2025061201 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025061201 (Linux, Windows) - 专业渗透测试框架
137 3
Metasploit Pro 4.22.7-2025061201 (Linux, Windows) - 专业渗透测试框架