ZooKeeper Install

Tar -zxvf zookeeper-3.4.10.tar.gz
[ [emailprotected] local]# rm -rf zookeeper-3.4.10.tar.gz
Remotely transfer zookeeper-3.4.10 to others Node
[ [email protected] local]# scp -r /usr/local/zookeeper-3.4.10 [email protected]:/usr/local/
[ [email protected] local]# ls
bin etc games hadoop hive include java lib lib64 libexec python3Dir sbin share src zookeeper-3.4.10
[ [emailprotected] conf]# ls
configuration.xsl log4j.properties zoo_sample.cfg
[ [emailprotected ] conf]# cp zoo_sample.cfg zoo.cfg
[ [email protected] conf]# ls
configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg
Edit the configuration file
[ [email protected] conf]# vim zoo.cfg
#The first port number 2888 is the communication port between Leader and follower; 3888 is the port number used for election
#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
According to the zoo.cfg file dataDir=/tmp /zookeeper Create the corresponding directory and configure the myid file to map the cluster
[ [emailprotected] conf]# cd /tmp
[ [emailprotected] tmp]# ls
hsperfd ata_root systemd-private-d38862e2d5524a42994bdd9ddd858f50-chronyd.service-nIGJPI
[ [emailprotected] tmp]# mkdir zookeeper
[ [emailprotected] tmp]# vim myid
[ [emailprotected] tmp]# more myid
1
[ [emailprotected] tmp]#
Enter the IP information for each machine server.0=172.26.19.40:2888:3888; you should enter 0
[ [emailprotected] bin]# ./zkServer.sh status
[ [emailprotected] bin]# ./zkServer.sh start
[ [emailprotected] bin]# ./zkServer.sh stop
[ [emailprotected] ] bin]# jps
21690 Jps
21550 QuorumPeerMain
[ [emailprotected] bin]# kill -9 18976
View zookeeper log files
[ [emailprotected] bin]# more zookeeper .out

The client has the same version of zookeeper-3.4.10 package file (copied from the remote zookeeper node)
Client login
[[emailprotected] bin] # ./zkCli.sh -server hmaster:2181[zk: hmaster:2181(CONNECTED) 0] helpZooKeeper -server host:port cmd argsstat path [watch]set path data [version]ls path [watch]delquota [-n| -b] pathls2 path [watch]setAcl path aclsetquota -n|-b val pathhistory redo cmdnoprintwatches on|offd elete path [version]sync pathlistquota pathrmr pathget path [watch]create [-s] [-e] path data acladdauth scheme authquit getAcl pathclose connect host:port[zk: hmaster:2181(CONNECTED) 1] ls / consistent, with header , Data tree [zk: hslave1:2181(CONNECTED) 0] ls /[zookeeper][zk: hslave1:2181(CONNECTED) 1] create /app app_contentCreated /app[zk: hslave1:2181(CONNECTED) 2] ls /[ app, zookeeper][zk: hslave1:2181(CONNECTED) 3] get /appapp_contentcZxid = 0x200000002ctime = Mon Dec 10 21:43:19 EST 2018mZxid = 0x200000002mtime = Mon Dec 10 21:43:19 EST 2018pZxid = 0x200000002cversion = 0dataVersion = 0aclVersion = 0ephemeralOwner = 0x0dataLength = 11numChildren = 0[zk: hslave1:2181(CONNECTED) 4] set /app appcontent11cZxid = 0x200000002ctime = Mon Dec 10 21:43:19 EST 2018mZxid = 0x200000003mtime = Mon Dec 10 21:45xid = EST 2018pZtime = Mon Dec 10 21:45:05 0x200000002cversion = 0dataVersion = 1aclVersion = 0ephemeralOwner = 0x0dataLength = 12numChildren = 0[zk: hslave1:2181(CONNECTED) 5] get /appappcontent11cZxid = 0x200000002ctime = Mon Dec 10 21:43:19 EST 2018mZxid = 0x200000003mtime = Mon Dec 10 21:45:05 EST 2018pZxid = 0x200000002cversion = 0dataVersion = 1aclVersion = 0ephemeralOwner = 0x0dataLength = 12numChildren = 0[zk: hslave1:2181(CONNECTED) 6k delete /[appEDz] : hslave1:2181(CONNECTED) 7] ls /[zookeeper]

Leave a Comment

Your email address will not be published.