ZooKeeper使用
来源:互联网 发布:直播讲课哪个软件 编辑:程序博客网 时间:2024/04/27 14:32
配置
1.将conf目录下的zoo_sample.cfg重名为zoo.cfg。
2.配置server.1=localhost:2888:3888。其中“1”代表集群中的节点序号。
3.在dataDir下面创建myid文件,内容为“1”。
配置如下:
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/var/lib/zookeeper# the port at which the clients will connectclientPort=2181# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60server.1=localhost:2888:3888
启动服务
sudo ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.7/bin/../conf/zoo.cfg
Starting zookeeper … STARTED
测试启动成功
telnet 127.0.0.1 2181
停止服务
sudo sh zkServer.sh stop
客服端脚本
启动客服端命令终端:
sudo sh zkCli.sh
或者:
sudo sh zkCli.sh -server ip:port
创建数据节点
create [-s] [-e] path data acl
-s 代表顺序,-e代表临时节点。默认为持久节点。
实例:
[zk: localhost:2181(CONNECTED) 11] create -s /test fooCreated /test0000000001
列出节点
ls path [watch]
实例:
[zk: localhost:2181(CONNECTED) 8] ls /[example, zookeeper]
查看数据节点
get path [watch]
实例:
[zk: localhost:2181(CONNECTED) 9] get /exampleinitcZxid = 0x5ctime = Sun Jan 24 11:09:58 CST 2016mZxid = 0x5mtime = Sun Jan 24 11:09:58 CST 2016pZxid = 0x5cversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 4numChildren = 0
更新数据节点
set path data [version]
实例:
[zk: localhost:2181(CONNECTED) 6] set /test barcZxid = 0xectime = Sun Jan 24 15:09:33 CST 2016mZxid = 0xfmtime = Sun Jan 24 15:10:04 CST 2016pZxid = 0xecversion = 0dataVersion = 1aclVersion = 0ephemeralOwner = 0x0dataLength = 3numChildren = 0
删除
delete path [version]
实例:
[zk: localhost:2181(CONNECTED) 8] delete /test
1 0
- zookeeper使用
- ZooKeeper使用
- Zookeeper 使用
- ZooKeeper使用
- zookeeper使用
- 为什么要使用ZooKeeper
- ZooKeeper的使用
- zookeeper典型使用场景
- 使用zookeeper监控服务
- Zookeeper使用和探究
- zookeeper使用体验
- zookeeper原理 使用场景
- Zookeeper使用详解
- 为什么要使用zookeeper
- zookeeper的使用场景
- zookeeper 使用场景介绍
- Zookeeper集群使用注意事项
- 为什么要使用ZooKeeper
- String和StringBuffe之可变与不可变
- Volley框架的使用
- 77. Count and Say
- 如何做系列(3)-Java数据类型和MySql数据类型对照表
- iOS开发UI篇:核心动画
- ZooKeeper使用
- The BulkProcessor class offers a simple interface to flush bulk operations automatically based on th
- 开始
- It’s Time to Move to a Four-Tier Application Architecture
- java2 -宏观了解
- 2014年第五届蓝桥杯C/C++程序设计本科B组省赛 切面条(结果填空)
- IOS 小技巧
- C#面向对象编程初步 :字段与属性
- C#学习之ArrayList