ZooKeeper Install

Tar -zxvf zookeeper-3.4.10.tar.gz
[root@hmaster local]# rm -rf zookeeper-3.4.10.tar.gz
远程传输zookeeper-3.4.10到其他节点
[root@hmaster local]# scp -r /usr/local/zookeeper-3.4.10 root@hslave1:/usr/local/
[root@hmaster local]# ls
bin etc games hadoop hive include java lib lib64 libexec python3Dir sbin share src zookeeper-3.4.10
[root@hmaster conf]# ls
configuration.xsl log4j.properties zoo_sample.cfg
[root@hmaster conf]# cp zoo_sample.cfg zoo.cfg
[root@hmaster conf]# ls
configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg
编辑配置文件
[root@hmaster conf]# vim zoo.cfg
#第一个端口号2888 是Leader与follower之间通讯的端口;3888是选举使用的端口号
#autopurge.purgeInterval=1
server.0=172.26.19.40:2888:3888
server.1=172.26.19.41:2888:3888
server.2=172.26.19.42:2888:3888
根据zoo.cfg 文件中dataDir=/tmp/zookeeper 创建相应目录,配置myid文件,使得集群映射
[root@hslave1 conf]# cd /tmp
[root@hslave1 tmp]# ls
hsperfdata_root systemd-private-d38862e2d5524a42994bdd9ddd858f50-chronyd.service-nIGJPI
[root@hslave1 tmp]# mkdir zookeeper
[root@hslave1 tmp]# vim myid
[root@hslave1 tmp]# more myid
1
[root@hslave1 tmp]#
每台机器输入对IP的信息server.0=172.26.19.40:2888:3888;应该输入0
[root@hmaster bin]# ./zkServer.sh status
[root@hmaster bin]# ./zkServer.sh start
[root@hmaster bin]# ./zkServer.sh stop
[root@hmaster bin]# jps
21690 Jps
21550 QuorumPeerMain
[root@hmaster bin]# kill -9 18976
查看zookeeper日志文件
[root@hmaster bin]# more zookeeper.out

客户端有相同版本的zookeeper-3.4.10包文件(从远程zookeeper节点拷贝而来)
客户端登录
[root@hslave3 bin]# ./zkCli.sh -server hmaster:2181
[zk: hmaster:2181(CONNECTED) 0] help
ZooKeeper -server host:port cmd args
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
[zk: hmaster:2181(CONNECTED) 1] ls /
一致,有头,数据树
[zk: hslave1:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: hslave1:2181(CONNECTED) 1] create /app app_content
Created /app
[zk: hslave1:2181(CONNECTED) 2] ls /
[app, zookeeper]
[zk: hslave1:2181(CONNECTED) 3] get /app
app_content
cZxid = 0x200000002
ctime = Mon Dec 10 21:43:19 EST 2018
mZxid = 0x200000002
mtime = Mon Dec 10 21:43:19 EST 2018
pZxid = 0x200000002
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 11
numChildren = 0
[zk: hslave1:2181(CONNECTED) 4] set /app appcontent11
cZxid = 0x200000002
ctime = Mon Dec 10 21:43:19 EST 2018
mZxid = 0x200000003
mtime = Mon Dec 10 21:45:05 EST 2018
pZxid = 0x200000002
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0
[zk: hslave1:2181(CONNECTED) 5] get /app
appcontent11
cZxid = 0x200000002
ctime = Mon Dec 10 21:43:19 EST 2018
mZxid = 0x200000003
mtime = Mon Dec 10 21:45:05 EST 2018
pZxid = 0x200000002
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 12
numChildren = 0
[zk: hslave1:2181(CONNECTED) 6] delete /app
[zk: hslave1:2181(CONNECTED) 7] ls /
[zookeeper]

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/196293.html

(0)
上一篇 2021年11月16日
下一篇 2021年11月16日

相关推荐

发表回复

登录后才能评论