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环境操作

linux etc/profile

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/目录下,已经有了默认的配置文件

  • 配置[/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下有很多可执行文件

3 常用命令

3.1 启动

  • 执行命令zkServer

  • zkServer status

  • zkServer start

3.2 查看运行状态

转载于:https://my.oschina.net/JavaEdge/blog/3100381

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值