1. 程式人生 > >JEESZ-Zookeeper叢集安裝

JEESZ-Zookeeper叢集安裝

1. 在根目錄建立zookeeper資料夾(service1、service2、service3都建立)

[[email protected] /]# mkdir zookeeper

通過Xshell上傳檔案到service1伺服器:上傳zookeeper-3.4.6.tar.gz到/software資料夾

2.遠端copy將service1下的/software/zookeeper-3.4.6.tar.gz到service2、service3

[[email protected] software]# scp -r /software/zookeeper-3.4.6.tar.gz

[email protected]:/software/

[[email protected] software]# scp -r /software/zookeeper-3.4.6.tar.gz [email protected]:/software/

3.copy /software/zookeeper-3.4.6.tar.gz到/zookeeper/目錄(service1、service2、service3都執行)

[[email protected] software]# cp /software/zookeeper-3.4.6.tar.gz /zookeeper/

4.安裝解壓zookeeper-3.4.6.tar.gz(service1、service2、service3都執行)

[[email protected] /]# cd /zookeeper/

[[email protected] zookeeper]# tar -zxvf zookeeper-3.4.6.tar.gz

5.在/zookeeper建立兩個目錄:zkdata、zkdatalog(service1、service2、service3都建立)

[[email protected] zookeeper]# mkdir zkdata

[[email protected] zookeeper]# mkdir zkdatalog

6.進入/zookeeper/zookeeper-3.4.6/conf/目錄

[[email protected] zookeeper]# cd /zookeeper/zookeeper-3.4.6/conf/

[[email protected] conf]# ls

configuration.xsl  log4j.properties  zoo.cfg  zoo_sample.cfg

7. 修改zoo.cfg檔案

# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting an acknowledgement

syncLimit=5

# the directory where the snapshot is stored.

# do not use /tmp for storage, /tmp here is just

# example sakes.

dataDir=/zookeeper/zkdata

dataLogDir=/zookeeper/zkdatalog

# the port at which the clients will connect

clientPort=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.

#

#

#

# 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=1

server.1=192.168.2.211:12888:13888

server.2=192.168.2.212:12888:13888

server.3=192.168.2.213:12888:13888

8. 同步修改service2、service3的zoo.cfg配置

9. myid檔案寫入(進入/zookeeper/zkdata目錄下)

[[email protected] /]# cd /zookeeper/zkdata

[[email protected] /]# echo 1 > myid

10. myid檔案寫入service2、service3

echo 2 > myid

echo 3 > myid

11.檢視zk命令:

[[email protected] ~]# cd /zookeeper/zookeeper-3.4.6/bin/

[[email protected] bin]# ls

README.txt  zkCleanup.sh  zkCli.cmd  zkCli.sh  zkEnv.cmd  zkEnv.sh  zkServer.cmd  zkServer.sh  zookeeper.out

12.執行zkServer.sh檢視詳細命令:

[[email protected] bin]# ./zkServer.sh

JMX enabled by default

Using config: /zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

Usage: ./zkServer.sh {start|start-foreground|stop|restart|status|upgrade|print-cmd}

13. 在service1、service2、service3分別啟動zk服務

[[email protected] bin]# ./zkServer.sh start

14. jps檢視zk程序

[[email protected] bin]# jps

31483 QuorumPeerMain

31664 Jps

15. 分別在service1、service2、service3檢視zk狀態(可以看到leader和follower節點)

[[email protected] bin]# ./zkServer.sh status

JMX enabled by default

Using config: /zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: follower

[[email protected] bin]# ./zkServer.sh status

JMX enabled by default

Using config: /zookeeper/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: leader

16. 看到leader和follower節點已經安裝成功