1. 程式人生 > >Zookeeper叢集搭建— 叢集搭建

Zookeeper叢集搭建— 叢集搭建

軟體環境:

Linux伺服器一臺、三臺、五臺(2*n+1臺);

Java jdk 1.8

zookeeper 3.4.6版;

Zookeeper的啟動停止狀態檢視

[email protected]:/opt/zookeeper/zookeeper-3.4.8/bin# ./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
[email protected]
:/opt/zookeeper/zookeeper-3.4.8/bin# ./zkServer.sh start ZooKeeper JMX enabled by default Using config: /opt/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [email protected]:/opt/zookeeper/zookeeper-3.4.8/bin# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg Mode: follower
[email protected]
:/opt/zookeeper/zookeeper-3.4.8/bin#

Zookeeper的主程序檢視

[email protected]:/opt/zookeeper/zookeeper-3.4.8/bin# jps
4229 Jps
4174 QuorumPeerMain

Zookeeper叢集搭建 搭建成功標誌

   在任一臺機器執行sh zkServer.sh status出現下面兩幅圖中任一輸出結果,說明你的叢集成功搭建。

[email protected]:/opt/zookeeper/zookeeper-3.4.8/bin# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: leader
[email protected]:/opt/zookeeper/zookeeper-3.4.8/bin# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: follower

Zookeeper叢集搭建叢集配置引數講解

重要配置

myid檔案和server.myid

zoo.cfg檔案;

log4j. properties檔案;

zkEnv.shzkServer.sh檔案

# 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=/opt/zookeeper/zkdata
dataLogDir=/opt/zookeeper/zkdatalog
# the port at which the clients will connect
clientPort=12181
# 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=1
server.1=192.168.13.128:12888:13888
server.2=192.168.13.130:12888:13888
server.3=192.168.13.131:12888:13888