Linux安装zookeeper

1, 下载

Apache ZooKeeperhttps://zookeeper.apache.org/releases.htmlhttps://zookeeper.apache.org/releases.htmlhttps://zookeeper.apache.org/releases.htmlhttps://zookeeper.apache.org/releases.htmlhttps://zookeeper.apache.org/releases.htmlhttps://zookeeper.apache.org/releases.html从Apache官网下载 最新可用版本 apache-zookeeper-3.8.4-bin.tar.gz。

上传到linux 虚拟机 某个路径 /opt/software

2, 解压缩

解压缩,并且重命名。

bash 复制代码
cd /opt/software

tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz -C /usr/local/applications/

cd /usr/local/applications/

mv apache-zookeeper-3.8.4-bin zookeeper-3.8.4

3, 配置

环境变量

三台linux server同时配置 /etc/profile

bash 复制代码
vi /etc/profile


#zookeeper_config
ZOOKEEPER_HOME=/usr/local/applications/zookeeper-3.8.4
PATH=$PATH:$ZOOKEEPER_HOME/bin
export ZOOKEEPER_HOME PATH


source /etc/profile

配置zookeeper

1, myid

bash 复制代码
cd /usr/local/applications/zookeeper-3.8.4/

mkdir data
mkdir logs

cd data

echo 1 > myid

2, zoo.conf

bash 复制代码
cd /usr/local/applications/zookeeper-3.8.4/conf

mv zoo_sample.cfg zoo.cfg

vi zoo.cfg

dataDir=/usr/local/applications/zookeeper-3.8.4/data
dataLogDir=/usr/local/applications/zookeeper-3.8.4/logs

server.1=localhost1:2888:3888
server.2=localhost2:2888:3888
server.3=localhost3:2888:3888

3, 将配置好的zookeeper 远程复制到另外两台server

bash 复制代码
cd /usr/local/applications

scp -r zookeeper-3.8.4 root@localhost2:/usr/local/applications/zookeeper-3.8.4
scp -r zookeeper-3.8.4 root@localhost3:/usr/local/applications/zookeeper-3.8.4

4, 修改另外两台server的"myid"文件中的内容

localhost1是1,localhost2是2,localhost3是3

4,Linux时钟同步

安装ntpd
bash 复制代码
yum install ntp
启动并启用ntpd服务
bash 复制代码
systemctl start ntpd
systemctl enable ntpd
同步时区
bash 复制代码
timedatectl set-timezone Asia/Shanghai

5, 启动zookeeper

三台Linux server 分别执行启动

bash 复制代码
cd /usr/local/applications/zookeeper-3.8.4/bin

./zkServer.sh start

关闭命令

bash 复制代码
./zkServer.sh stop

查看状态

bash 复制代码
[root@localhost1 zookeeper-3.8.4]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/applications/zookeeper-3.8.4/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower


[root@localhost2 zookeeper-3.8.4]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/applications/zookeeper-3.8.4/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader


[root@localhost3 zookeeper-3.8.4]# bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/applications/zookeeper-3.8.4/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower
相关推荐
xu_yule5 分钟前
网络和Linux网络-5(应用层)HTTP协议(方法+报头+状态码)
linux·网络·网络协议·http
lhyzws34 分钟前
CENTOS上的网络安全工具(三十二) Portainer Kafka-Clickhouse部署(1)
linux·kafka·centos
q***04632 小时前
Linux环境下Tomcat的安装与配置详细指南
linux·运维·tomcat
BD_Marathon2 小时前
【Zookeeper】zk_客户端API_创建节点
分布式·zookeeper·云原生
BD_Marathon2 小时前
【Zookeeper】监听器原理
linux·分布式·zookeeper
稚辉君.MCA_P8_Java2 小时前
Gemini永久会员 快速排序(Quick Sort) 基于分治思想的高效排序算法
java·linux·数据结构·spring·排序算法
x***44012 小时前
linux 设置tomcat开机启动
linux·运维·tomcat
正在努力的小河3 小时前
Linux 块设备驱动实验
linux·运维·服务器
代码游侠4 小时前
学习笔记——数据结构学习
linux·开发语言·数据结构·笔记·学习
j***49564 小时前
Linux(CentOS)安装 Nginx
linux·nginx·centos