美文网首页
zookeeper笔记

zookeeper笔记

作者: 博陵韩少 | 来源:发表于2021-03-01 10:13 被阅读0次

1 概述

分布式系统中的协调系统:配置服务、名字服务、分布式同步、组服务等

2 安装

解压后,bin/zkEnv.sh,增加一行
SERVER_JVMFLAGS=" -Xms3g -Xmx3g"
conf目录下创建配置文件zoo.cfg

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=5
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=2
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
#dataDir=/var/lib/zookeeper
dataDir=/usr/local/zookeeper-3.4.6/data
dataLogDir=/usr/local/zookeeper-3.4.6/log
# 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=6000
#
# 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](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
server.1=10.8.0.1:2888:3888
server.2=10.8.0.2:2888:3888
server.3=10.8.0.3:2888:3888

其中,server.id=host :port :port的配置说明:

server.id:在zoo.cfg文件中配置的配置的 dataDir 路径下(即:/var/lib/zookeeper)创建myid文件,里面写入id值
host:构建zookeeper集群的服务器的ip地址
port:第一个 port 用于连接 leader 服务器,第二个 port 用于 leader election

三台服务器./data下myid分别修改为 1、2、3。

启动本地实例:
./bin/zkServer.sh start

检查启动状态:
yum -y install nc
echo ruok | nc localhost 2181
输出“imok”

3 各种状态的检查方法

查看zk的配置,配置正常返回证明zk service 正常
echo conf| nc localhost 2181

stat 可以查看集群状态
echo stat|nc 127.0.0.1 2181 查看集群状态以及follower或leader角色

echo ruok|nc 127.0.0.1 2181 是否启动了该Server,启动则返回imok

echo dump| nc 127.0.0.1 2181 未经处理的会话和临时节点。

echo kill | nc 127.0.0.1 2181 ,关掉server

echo conf | nc 127.0.0.1 2181 ,输出相关服务配置的详细信息。

echo cons | nc 127.0.0.1 2181 所有连接客户端的完全的连接 / 会话的详细信息。

echo envi |nc 127.0.0.1 2181 ,输出关于服务环境的详细信息(区别于 conf 命令)。

echo reqs | nc 127.0.0.1 2181 ,列出未经处理的请求。

echo wchs | nc 127.0.0.1 2181 ,列出服务器 watch 的详细信息。

echo wchc | nc 127.0.0.1 2181 ,通过 session 列出服务器 watch 的详细信息,它的输出是一个与 watch 相关的会话的列表。

echo wchp | nc 127.0.0.1 2181 ,通过路径列出服务器 watch 的详细信息。 session

相关文章

  • 2019-04-08 Zookeeper学习笔记(一)

    Zookeeper学习笔记(一) 1.zookeeper是什么? 1.1 zookeeper概览 zookeepe...

  • Zookeeper 概念与原理介绍

    中间件:Zookeeper注:本文是作者学习Zookeeper时得笔记和经验总结 1. ZooKeeper 特点 ...

  • 基于zookeeper实现任务调度(3) zk工作原理

    转载<<从paxos到zookeeper>>一书 读书笔记 Zookeeper的基本概念 1.1 角色 Zooke...

  • Zookeeper学习笔记(一):概览

    最近趁着假期看起了Zookeeper,顺手把笔记理上来。 Zookeeper是什么 这个可以通过官网来看https...

  • Zookeeper学习笔记Day1

    zookeeper笔记 0. Zookeeper 管理大量主机的协同服务。 分布式应用,实现分布式读写技术。 zk...

  • zookeeper 分布式运行配置

    本笔记为zookeeper单机多实例配置参考基础安装配置请参考 zookeeper 单机运行配置 查看端口是否可用...

  • zookeeper笔记

    zookeeper复习 Zookeeper概念简介 zookeeper集群机制 安装 zookeeper特性 zo...

  • zookeeper笔记

    zookepper是一种分布式协调服务 分布式协调服务:可以在分布式系统中共享配置,协调锁资源,提供命名服务 Zo...

  • Zookeeper笔记

    应用 统一命名服务image.png 统一配置管理image.png 统一集群管理 服务器动态上下线image.p...

  • Zookeeper笔记

    一、简介 Zookeeper是一个分布式协调服务,即为用户的分布式应用程序提供协调服务。 zk是为别的分布式程序服...

网友评论

      本文标题:zookeeper笔记

      本文链接:https://www.haomeiwen.com/subject/vsrgxltx.html