zookeeper(目前只有安装)

安装

流程

学kafka的时候安装

Apache ZooKeeper

安装地址:https://archive.apache.org/dist/zookeeper/zookeeper-3.5.7/apache-zookeeper-3.5.7-bin.tar.gz

解压

复制代码
tar -zxvf kafka_2.12-3.0.0.tgz -C /export/server/

改配置

XML 复制代码
cd config
cp zoo_sample.cfg zoo.cfg
vim zoo.cfg 

# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/export/server/zookeeper-3.5.7/zkdata


# 这里和server.几 和下面的myid匹配上
# 2888是正常leader端口,3888是备用端口
server.1=hadoop1:2888:3888
server.2=hadoop2:2888:3888
server.3=hadoop3:2888:3888

:wq

在设置的dataDir目录下创建一个名字叫myid的文件(必须叫myid!!!)

写入一个数(几都行,只要三个集群别一样)

root@hadoop1 zkdata# echo 1 > myid

root@hadoop2 zkdata# echo 2 > myid

root@hadoop3 zkdata# echo 3 > myid

fenfa

zoo.cfg配置解毒

XML 复制代码
# 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.
# 快照所在的目录。不使用/ tmp为存储、/ tmp这里只是例子的缘故。
dataDir=/export/server/zookeeper-3.5.7/zkdata
# 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
# dataDir中要保留的快照数量
#autopurge.snapRetainCount=3

# Purge task interval in hours
# Set to "0" to disable auto purge feature
# 清除任务间隔(小时)  设置为"0"表示禁用自动清除功能
#autopurge.purgeInterval=1

原神启动

hadoop1启动

root@hadoop1 zookeeper-3.5.7# bin/zkServer.sh start

ZooKeeper JMX enabled by default

Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED
root@hadoop1 zookeeper-3.5.7# bin/zkServer.sh status

ZooKeeper JMX enabled by default

Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg

Client port found: 2181. Client address: localhost.

Error contacting service. It is probably not running.

一看状态居然失败了?因为另外两个没启动,不过半没法选出来leader

hadoop2/3也启动

bin/zkServer.sh start

现在hadoop1状态

root@hadoop1 zookeeper-3.5.7# bin/zkServer.sh status

ZooKeeper JMX enabled by default

Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg

Client port found: 2181. Client address: localhost.

Mode: follower

root@hadoop2 zookeeper-3.5.7# bin/zkServer.sh status

ZooKeeper JMX enabled by default

Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg

Client port found: 2181. Client address: localhost.
Mode: leader(hadoop2成leader了)

root@hadoop3 zookeeper-3.5.7# bin/zkServer.sh status

ZooKeeper JMX enabled by default

Using config: /export/server/zookeeper-3.5.7/bin/../conf/zoo.cfg

Client port found: 2181. Client address: localhost.

Mode: follower

批量启动脚本

复制代码
#!/bin/bash
case $1 in
start)
    for i in hadoop1 hadoop2 hadoop3
    do
        echo ----------------  zookeeper $i start ----------------
        ssh $i "/export/server/zookeeper-3.5.7/bin/zkServer.sh start"
    done
    ;;
stop)
    for i in hadoop1 hadoop2 hadoop3
    do
        echo ----------------  zookeeper $i stop ----------------
        ssh $i "/export/server/zookeeper-3.5.7/bin/zkServer.sh stop"
    done
    ;;
status)
    for i in hadoop1 hadoop2 hadoop3
    do
        echo ----------------  zookeeper $i status ----------------
        ssh $i "/export/server/zookeeper-3.5.7/bin/zkServer.sh status"
    done
    ;;
*)
    echo "Usage: $0 {start|stop|status}"
    ;;
esac

chmod 777 zk

相关推荐
时间售卖铺10 小时前
触发器与函数实战:MySQL高效编程秘诀
运维·数据库·mysql·云原生
云-缩影15 小时前
拆解函数计算 Serverless GPU 部署 AI 模型:Flux 生图和语音复刻怎么跑的
人工智能·云原生·serverless
螺蛳粉 螺蛳粉20 小时前
第 02 篇:镜像分层与 containerd 2.x 实战:SystemdCgroup 与 pause 镜像配置踩坑(底座认知 02)
docker·云原生·容器·kubernetes·etcd·containerd·kube-apiserver
技术党21 小时前
大模型训练平台推荐问答:九章云极的DCU计费、全栈Serverless和Token交付分别适合谁
云原生·serverless
时间售卖铺1 天前
Oracle DQL精髓:从基础到高级实战
运维·数据库·云原生·oracle
NiceZack1 天前
Hadoop 部署全流程教程:从新装 CentOS 到伪分布式与完全分布式
hadoop·分布式·centos
傻啦嘿哟1 天前
分布式爬虫架构:Redis+Scrapy打造企业级爬虫系统
分布式·爬虫·架构
小白的码BUG之路1 天前
K8s -- 搭建过程中经常遇到的问题
云原生·容器·kubernetes
大腾智能1 天前
普通笔记本跑CAD,云原生和本地安装差在哪
云原生·国产cad·cad软件·云原生cad
螺蛳粉 螺蛳粉1 天前
第 03 篇:为什么 K8s 的最小调度单元是 Pod 而不是容器:pause 容器与边车模式(底座认知 03)
docker·云原生·容器·kubernetes·etcd·运维排障·kube-apiserver