ZooKeeper分布式实战(一) - 基本安装配置

本文涉及的产品
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
简介: ZooKeeper分布式实战(一) - 基本安装配置

1 概述

1.1 zookeeper 简介

  • 中间件,提供协调服务
  • 作用于分布式系统,发挥其优势,可以为大数据服务
  • 支持 Java, 提供 Java 和 C语言的客户端 API

1.2 什么是分布式系统

  • 很多台计算机组成一个整体,一个整体一致对外并且处理同一请求
  • 内部的每台计算机都可以相互通信(REST/RPC)
  • 客户端到服务端的一次请求到响应结束会经历多台计算机

1.3 分布式系统的瓶颈

1.3.1 zookeeper 的特性

  • 一致性
    数据一致性,数据按照顺序分批入库
  • 原子性
    事务要么成功要么失败,不会局部化
  • 单一视图
    客户端连接集群中的任一 zk 节点,数据都是一致的
  • 可靠性
    每次对 zk的操作状态都会保存在服务端
  • 实时性
    客户端可以读取到 zk 服务端的最新数据

2 下载、安装以及配置

安装 JDK

2.1 单机模式

2.1.1 Linux环境操作

image.png

image.png

image.png

image.png

2.1.2 Mac OS操作

$brew install zookeeper
==> Downloading https://homebrew.bintray.com/bottles/zookeeper-3.4.6_1.mavericks.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring zookeeper-3.4.6_1.mavericks.bottle.2.tar.gz
==> Caveats
To have launchd start zookeeper at login:
  ln -sfv /usr/local/opt/zookeeper/*.plist ~/Library/LaunchAgents
Then to load zookeeper now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.zookeeper.plist
Or, if you don't want/need launchctl, you can just run:
  zkServer start
==> Summary

安装后,在/usr/local/etc/zookeeper/目录下,已经有了默认的配置文件

image.png

配置[/usr/local/etc/zookeeper/zoo.cfg] 文件

# 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/var/run/zookeeper/data
# 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

在bin下有很多可执行文件

image.png

3 常用命令

3.1 启动

执行命令zkServer

image.png

zkServer status

image.png

zkServer start

image.png

3.2 查看运行状态

image.png


相关实践学习
基于MSE实现微服务的全链路灰度
通过本场景的实验操作,您将了解并实现在线业务的微服务全链路灰度能力。
目录
相关文章
|
13天前
|
监控 负载均衡 Cloud Native
ZooKeeper分布式协调服务详解:面试经验与必备知识点解析
【4月更文挑战第9天】本文深入剖析ZooKeeper分布式协调服务原理,涵盖核心概念如Server、Client、ZNode、ACL、Watcher,以及ZAB协议在一致性、会话管理、Leader选举中的作用。讨论ZooKeeper数据模型、操作、会话管理、集群部署与管理、性能调优和监控。同时,文章探讨了ZooKeeper在分布式锁、队列、服务注册与发现等场景的应用,并在面试方面分析了与其它服务的区别、实战挑战及解决方案。附带Java客户端实现分布式锁的代码示例,助力提升面试表现。
30 2
|
1月前
|
监控 NoSQL Java
Zookeeper分布式锁
Zookeeper分布式锁
90 1
|
2月前
|
消息中间件 RocketMQ 微服务
RocketMQ 分布式事务消息实战指南
RocketMQ 分布式事务消息实战指南
269 1
|
2月前
|
Docker 容器
在docker中安装zookeeper,并且阿里云服务器配置
在docker中安装zookeeper,并且阿里云服务器配置
204 1
|
2月前
|
Java 数据库连接 API
分布式事物【XA强一致性分布式事务实战、Seata提供XA模式实现分布式事务】(五)-全面详解(学习总结---从入门到深化)
分布式事物【XA强一致性分布式事务实战、Seata提供XA模式实现分布式事务】(五)-全面详解(学习总结---从入门到深化)
60 0
|
6天前
|
Linux
ZooKeeper的安装(Linux版)
ZooKeeper的安装(Linux版)
17 1
|
27天前
|
缓存 应用服务中间件 数据库
【分布式技术专题】「缓存解决方案」一文带领你好好认识一下企业级别的缓存技术解决方案的运作原理和开发实战(多级缓存设计分析)
【分布式技术专题】「缓存解决方案」一文带领你好好认识一下企业级别的缓存技术解决方案的运作原理和开发实战(多级缓存设计分析)
31 1
|
1月前
|
消息中间件 SpringCloudAlibaba Java
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(八)Config服务配置+bus消息总线+stream消息驱动+Sleuth链路追踪
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(八)Config服务配置+bus消息总线+stream消息驱动+Sleuth链路追踪
783 0
|
2月前
|
Java Linux Spring
Zookeeper实现分布式服务配置中心
Zookeeper实现分布式服务配置中心
48 0
|
2月前
|
存储 安全 Nacos
使用KMS为MSE-Nacos敏感配置加密的最佳实践
本文主要介绍通过KMS密钥管理服务产生的密钥对敏感的AK等数据进行加密之后可以有效解决泄漏带来的安全风险问题,其次通过KMS凭据托管的能力直接将MSE的主AK进行有效管理,保障全链路无AK的业务体验,真正做到安全、可控。
92272 3

热门文章

最新文章