zookeeper服务集群安装+测试+命令
来源:互联网 发布:网络在生活中的应用 编辑:程序博客网 时间:2024/05/19 19:33
zookeeper的安装测试
1.下载zookeeper。//选择一个版本下载
2.搭建多台linux虚拟机(各个虚拟机对应的hosts为m1,s1,s2)。
3.把下载的zookeeper.tar.gz包拷贝到自己的目录下。执行tar –zvxf zookeeper.tar.gz
4.修改环境变量
vim/vi /etc/profile
在最后面添加:
- export ZOOKEEPER_HOME=/usr/local/program/zookeeper
- export PATH=$ZOOKEEPER_HOME/bin:$PATH
5.在解压后的zookeeper的目录下进入conf目录修改配置文件
更名操作:mv zoo_sample.cfg zoo.cfg
6.编辑zoo.cfg (vi zoo.cfg)
修改dataDir=/home/hadoop/zookeeper/data/自己指定zookeeper的数据目录(这个目录必须存在且必须有myid文件,
myid的值对应的是server.0=m1:2888:3888中的server.0中的0.不同的server上的myid的值不同)
新增server.0=m1:2888:3888//m1位liunx虚拟机的映射名称;2888为leader的对外接口;3888为flower的对外接口
server.1=s1:2888:3888
server.2=s2:2888:3888
下面是zoo.cfg的配置文件详解:zoo.cfg配置信息详解
# The number of milliseconds of each ticktickTime=2000 ##ZooKeeper的最小时间单元,单位毫秒(ms),默认值为3000# The number of ticks that the initial # synchronization phase can takeinitLimit=10 ##Leader服务器等待Follower启动并完成数据同步的时间,默认值10,表示tickTime的10倍# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5 ##Leader服务器和Follower之间进行心跳检测的最大延时时间,默认值5,表示tickTime的5倍# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/tmp/zookeeper ##ZooKeeper服务器存储快照文件的目录,必须配值,建议放置在var目录下# the port at which the clients will connectclientPort=2181 ## 服务器对外服务端口,默认值为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=17.到此为止 m1上的配置就已经完成;接下来配置s1和s2.
zookeeper四字命令的使用
需要在linux系统中安装nc服务。yum install -y nczookeeper
四字命令
功能描述
conf
输出相关服务配置的详细信息。
cons
列出所有连接到服务器的客户端的完全的连接 /会话的详细信息。包括“接受 / 发送”的包数量、会话 id 、操作延迟、最后的操作执行等等信息。
dump
列出未经处理的会话和临时节点。
envi
输出关于服务环境的详细信息(区别于 conf命令)。
reqs
列出未经处理的请求
ruok
测试服务是否处于正确状态。如果确实如此,那么服务返回“imok ”,否则不做任何相应。
stat
输出关于性能和连接的客户端的列表。
wchs
列出服务器 watch的详细信息。
wchc
通过 session列出服务器 watch的详细信息,它的输出是一个与watch相关的会话的列表。
wchp
通过路径列出服务器 watch的详细信息。它输出一个与 session相关的路径
zkServer.sh命令详解
[root@rocket zookeeper-server1]# bin/zkServer.sh help
JMX enabled by default
Using config: /usr/local/zookeeper-server1/bin/../conf/zoo.cfg
Usage: bin/zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}
zkCli.sh命令详解
stat path [watch]
set path data [version]
ls path [watch]
delquota [-n|-b] path
ls2 path [watch]
setAcl path acl
setquota -n|-b val path
history
redo cmdno
printwatches on|off
delete path [version]
sync path
listquota path
rmr path
get path [watch]
create [-s] [-e] path data acl
addauth scheme auth
quit
getAcl path
close
connect host:port
常用命令:
1)查看当前节点列表
[zk: localhost:2181(CONNECTED) 1] ls /
[zookeeper]
2)创建节点
[zk: localhost:2181(CONNECTED) 2] create /test "test"
Created /test
[zk: localhost:2181(CONNECTED) 3] ls /
[zookeeper, test]
3)查看节点数据
[zk: localhost:2181(CONNECTED) 4] get /test
"test"
cZxid = 0x300000007
ctime = Thu Sep 24 05:54:51 PDT 2015
mZxid = 0x300000007
mtime = Thu Sep 24 05:54:51 PDT 2015
pZxid = 0x300000007
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
4)设置节点数据
[zk: localhost:2181(CONNECTED) 7] set /test "111111"
cZxid = 0x300000007
ctime = Thu Sep 24 05:54:51 PDT 2015
mZxid = 0x300000008
mtime = Thu Sep 24 05:57:40 PDT 2015
pZxid = 0x300000007
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 8
numChildren = 0
[zk: localhost:2181(CONNECTED) 8] get /test
"111111"
cZxid = 0x300000007
ctime = Thu Sep 24 05:54:51 PDT 2015
mZxid = 0x300000008
mtime = Thu Sep 24 05:57:40 PDT 2015
pZxid = 0x300000007
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 8
numChildren = 0
5)删除节点
[zk: localhost:2181(CONNECTED) 9] delete /test
[zk: localhost:2181(CONNECTED) 10] ls /
[zookeeper]
- zookeeper服务集群安装+测试+命令
- Zookeeper集群安装及命令
- 分布式协调服务zookeeper-集群安装
- zookeeper集群安装和简单命令学习
- zookeeper集群服务搭建
- 分布式协调服务zookeeper01-zookeeper集群安装部署
- zookeeper集群命令
- ZooKeeper集群的安装、配置、高可用测试 (六)
- kafka安装应用,zookeeper集群集成测试应用
- ZooKeeper 集群的安装、配置、高可用测试
- HBase集群+Zookeeper集群安装
- Zookeeper集群安装小结
- zookeeper集群安装
- Zookeeper集群安装
- Zookeeper集群安装
- zookeeper集群安装配置
- ZooKeeper集群安装配置
- zookeeper集群安装配置
- HTML元素类型详解
- 14. Longest Common Prefix
- 如何开好迭代回顾会议(2)准备、工具
- autoconfig.xml与antx.properties一级application.properties之间的关系(转载)
- poj 3415 Common Substrings
- zookeeper服务集群安装+测试+命令
- 简单仿写网易加载进度条
- 12-13.Hibernate_双向一对多映射
- BZOJ4127 Abs (树链剖分 线段树)
- 算法题——Sort Colors(JAVA)快排
- CentOS hbase put 报错
- 如何开好迭代回顾会议(1)目的、议程
- Excel控件Spire.XLS教程:将数据导出到WPF的Excel中
- fhq_Treap——模板整理