Tar -zxvf zookeeper-3.4.10.tar.gz
[root@hmaster local]# rm -rf zookeeper-3.4.10.tar.gz
遠(yuǎn)程傳輸zookeeper-3.4.10到其他節(jié)點(diǎn)
[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
#第一個(gè)端口號(hào)2888 是Leader與follower之間通訊的端口;3888是選舉使用的端口號(hào)
#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
根據(jù)zoo.cfg 文件中dataDir=/tmp/zookeeper 創(chuàng)建相應(yīng)目錄,配置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]#
每臺(tái)機(jī)器輸入對(duì)IP的信息server.0=172.26.19.40:2888:3888;應(yīng)該輸入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包文件(從遠(yuǎn)程zookeeper節(jié)點(diǎn)拷貝而來)
客戶端登錄
[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 /
一致,有頭,數(shù)據(jù)樹
[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]
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。