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
相关推荐
A小辣椒2 天前
TShark:Wireshark CLI 功能
linux
A小辣椒2 天前
TShark:基础知识
linux
AlfredZhao2 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao3 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334663 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪3 天前
linux 拷贝文件或目录到指定的位置
linux
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
bush44 天前
嵌入式linux学习记录十四、术语
linux·嵌入式
载数而行5204 天前
Linux 11 动态监控指令top
linux
不会C语言的男孩4 天前
Linux 系统编程 · 第 8 章:进程基础
linux·c语言