`
sillycat
  • 浏览: 2560390 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Zookeeper(3) Use Zookeeper in the Application - Clients

 
阅读更多

 

Zookeeper(3) Use Zookeeper in the Application - Clients

 

1. Idea of ZooKeeper

ZNode, we can put data on any node and this node also can have sub nodes.

 

The purpose of zookeeper is not to store DB data, big data, it is only the configuration data, it is always small, several KB, not more than 1MB.

 

There are 2 types of nodes

Ephemeral, if the create close the connection, this type of node will be deleted.

 

Persistent   store the data

 

2. Install the latest Zookeeper

http://zookeeper.apache.org/doc/r3.4.5/

 

Download and get the latest file zookeeper-3.4.5.tar.gz

Soft link the directory

>sudo ln -s /Users/carl/tool/zookeeper-3.4.5 /opt/zookeeper-3.4.5

>sudo ln -s /opt/zookeeper-3.4.5 /opt/zookeeper

 

Add this to the system path

>vi ~/.profile

export PATH=/opt/zookeeper/bin:$PATH

>. ~/.profile

 

Put the default configuration file

>cp conf/zoo_sample.cfg conf/zoo.cfg

 

And start the server like this

>zkServer.sh start zoo.cfg

 

Use JPS to check if the server is running

>jps

1957

10014 QuorumPeerMain

2260

10050 Jps

 

Connecting with client

>zkCli.sh -server localhost:2181

zookeeper>help

zookeeper>quit

 

Stop the server

>zkServer.sh stop

 

There are status, restart, upgrade, start, stop...

 

Configure to Cluster as follow

zoo1.cfg

dataDir=/tmp/zookeeper/zoo1 

server.1=localhost:2888:3888

server.2=localhost:2889:3889

server.3=localhost:2890:3890

clientPort=2181 

 

zoo2.cfg

dataDir=/tmp/zookeeper/zoo2  

server.1=localhost:2888:3888

server.2=localhost:2889:3889

server.3=localhost:2890:3890

clientPort=2182

 

zoo3.cfg

dataDir=/tmp/zookeeper/zoo3  

server.1=localhost:2888:3888

server.2=localhost:2889:3889

server.3=localhost:2890:3890

clientPort=2183 

 

>vi /tmp/zookeeper/zoo1/myid

1

>vi /tmp/zookeeper/zoo2/myid

2

>vi /tmp/zookeeper/zoo3/myid

3

 

Start 3 nodes

>zkServer.sh start zoo1.cfg

>zkServer.sh start zoo2.cfg

>zkServer.sh start zoo3.cfg

 

>jps

 

Or use client to connect

>zkCli.sh -server localhost:2181

 

>zkServer.sh stop zoo1.cfg

>zkServer.sh stop zoo2.cfg

>zkServer.sh stop zoo3.cfg

 

Here is the status of all the server

>zkServer.sh status conf/zoo1.cfg

JMX enabled by default

Using config: conf/zoo1.cfg

Mode: follower

>zkServer.sh status conf/zoo2.cfg

JMX enabled by default

Using config: conf/zoo2.cfg

Mode: leader

>zkServer.sh status conf/zoo3.cfg

JMX enabled by default

Using config: conf/zoo3.cfg

Mode: follower

 

4. Open the ZooInspector

>cd /opt/zookeeper/contrib/ZooInspector

>java -cp zookeeper-3.4.5-ZooInspector.jar:lib/*:/opt/zookeeper/*:/opt/zookeeper/lib/* org.apache.zookeeper.inspector.ZooInspector

 

Or terminatively

>vi inspector.sh

#!/bin/sh

 

java -cp zookeeper-3.4.5-ZooInspector.jar:lib/*:/opt/zookeeper/*:/opt/zookeeper/lib/* org.apache.zookeeper.inspector.ZooInspector

 

>chmod a+x inspector.sh

>./inspector.sh

 

5. Clients

 

Get the source codes

>git clone https://git-wip-us.apache.org/repos/asf/incubator-curator.git

 

It will go on...

 

References:

zookeeper

http://sillycat.iteye.com/blog/1556108

http://sillycat.iteye.com/blog/1556141

http://rdc.taobao.com/team/jm/archives/665

http://blog.javachen.com/hadoop/2013/08/23/publish-proerties-using-zookeeper/

http://rdc.taobao.com/team/jm/archives/tag/zookeeper

https://github.com/alibaba/taokeeper

 

zookeeper client

https://github.com/twitter/scala-zookeeper-client

http://zookeeper.apache.org/doc/trunk/javaExample.html

https://github.com/twitter/util

 

https://github.com/sleberknight/zookeeper-samples

http://curator.incubator.apache.org/

http://braveo.blogspot.com/2013/05/how-to-run-zooinspector.html

http://www.taobaotesting.com/blogs/qa?bid=15305

http://mvnrepository.com/artifact/org.apache.curator/curator-recipes/2.2.0-incubating

https://github.com/sleberknight/zookeeper-samples/blob/master/etc/running-zooinspector.txt

 

 

分享到:
评论

相关推荐

    apache-zookeeper-3.7.1

    apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper-3.7.1 apache-zookeeper...

    zookeeper-3.5.7.zip文件(分享给需要的同学)

    zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 zookeeper-3.5.7.zip文件 ...

    apache-zookeeper(apache-zookeeper-3.7.1-bin.tar.gz)

    apache-zookeeper分布式框架,压缩包内容:(apache-zookeeper-3.7.1-bin.tar.gz、apache-zookeeper-3.7.1.tar.gz、apache-zookeeper-3.6.4-bin.tar.gz、apache-zookeeper-3.6.4.tar.gz、apache-zookeeper-3.5.10-...

    zookeeper-3.8.0安装包下载

    Zookeeper-3.8.0 是该系统的最新版本,提供了更稳定和高效的服务。 Zookeeper 的核心概念包括节点(Znode)、会话(Session)和观察者(Watcher)。Znode 是 Zookeeper 数据存储的基本单位,类似于文件系统中的节点...

    apache-zookeeper-3.5.10-bin 环境搭配

    apache-zookeeper-3.5.10-bin 环境搭配 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,...

    apache-zookeeper-3.5.6-bin.tar

    在 `apache-zookeeper-3.5.6-bin.tar` 这个压缩包中,包含了 Apache ZooKeeper 3.5.6 版本的二进制文件,这是部署和运行 ZooKeeper 服务所必需的。这个版本引入了多项改进和修复,使得 ZooKeeper 更加稳定和高效。 ...

    apache-zookeeper-3.8.4-bin.tar

    1. 解压`apache-zookeeper-3.8.4-bin.tar`到指定目录。 2. 配置`conf/zoo.cfg`,设置服务器ID、数据存储路径、集群配置等。 3. 启动Zookeeper服务,使用`bin/zkServer.sh start`命令。 4. 使用`bin/zkCli.sh`命令行...

    apache-zookeeper-3.5.9-bin.tar.gz

    在"apache-zookeeper-3.5.9-bin.tar.gz"这个压缩包中,包含了Zookeeper 3.5.9版本的二进制发行版,用于在各种操作系统上部署和运行Zookeeper服务。 1. **Zookeeper基本概念** - **Znode**: Zookeeper中的数据存储...

    apache-zookeeper-3.6.4-bin.tar.gz

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、...

    zookeeper3.8 linux安装包

    新功能 ZOOKEEPER-3301-强制执行配额限制 ZOOKEEPER-3601 - 介绍故障注入框架:ZooKeeper 的 Byteman ZOOKEEPER-3907-添加有关指标警报的文档 ZOOKEEPER-4211-向 Prometheus 公开配额指标

    apache-zookeeper-3.7.0

    Apache ZooKeeper 是一个高度可靠的分布式协调服务,广泛应用于云原生环境中的服务发现、配置管理、锁服务等场景。ZooKeeper 的设计目标是简化分布式系统中的数据一致性问题,为分布式应用提供统一的服务目录和配置...

    apache-zookeeper-3.6.3版本的压缩包,直接下载到本地,解压后即可使用

    ZooKeeper 顾名思义 动物园管理员,他是拿来管大象 (Hadoop) 、 蜜蜂 (Hive) 、 小猪 (Pig) 的管理员, Apache Hbase和 Apache Solr 以及LinkedIn sensei 等项目中都采用到了 Zookeeper。

    apache-zookeeper-3.6.3-bin.zip

    打开“系统属性” -> “高级” -> “环境变量”,在“系统变量”部分新建一个变量,变量名为"ZOOKEEPER_HOME",变量值设置为Zookeeper解压后的路径,即"C:\Zookeeper\apache-zookeeper-3.6.3-bin"。 然后,在系统...

    apache-zookeeper-3.5.8.tar.gz-Delete

    - 解压`apache-zookeeper-3.5.8.tar.gz`到指定目录。 - 配置`conf/zoo.cfg`,包括设置数据目录、集群配置等。 - 初始化数据目录,运行`bin/zkServer.sh start-foreground`启动ZooKeeper服务。 6. **Zookeeper在...

    zookeeper-3.4.6.rar

    在本案例中,我们关注的是`zookeeper-3.4.6.rar`这个压缩包,这代表了ZooKeeper的3.4.6版本。ZooKeeper的每个版本都有其特定的功能改进和bug修复,3.4.6是一个稳定且广泛使用的版本,对于Dubbo等分布式服务框架的...

    apache-zookeeper-3.8.4二进制安装包

    apache-zookeeper-3.8.4二进制安装包

    Zookeeper3.7与3.8加kafka2.12-3.1.0

    ZooKeeper是一个开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等。 Kafka目前主要作为一个分布式的发布订阅式的消息系统使用 本资源包括...

    最新版linux apache-zookeeper-3.7.0-bin.tar.gz

    - 解压`apache-zookeeper-3.7.0-bin.tar.gz`到你选择的目录,例如 `/opt`. - 配置`conf/zoo.cfg`,设置数据目录(dataDir)和日志目录(dataLogDir),并根据需求调整其他配置。 - 初始化数据目录,创建myid文件...

    apache-zookeeper-3.6.3-bin.tar的压缩包,解压到本地即可使用,还有zk.sh的脚本以及zoo.cfg

    apache-zookeeper-3.6.3-bin.tar的压缩包,解压到本地即可使用,还有zk.sh的脚本以及zoo.cfg和xsync。ZooKeeper 是一个分布式协调服务 ,由 Apache 进行维护。ZooKeeper 可以视为一个高可用的文件系统。ZooKeeper ...

    zookeeper-3.4.10-API文档-中文版.zip

    赠送jar包:zookeeper-3.4.10.jar; 赠送原API文档:zookeeper-3.4.10-javadoc.jar; 赠送源代码:zookeeper-3.4.10-sources.jar; 赠送Maven依赖信息文件:zookeeper-3.4.10.pom; 包含翻译后的API文档:zookeeper-...

Global site tag (gtag.js) - Google Analytics