软件环境:
Linux服务器一台、三台、五台(2*n+1台);
Java jdk 1.8;
zookeeper 3.4.6版;
Zookeeper的启动停止状态查看
root@ubuntu-128:/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
root@ubuntu-128:/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
root@ubuntu-128:/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
root@ubuntu-128:/opt/zookeeper/zookeeper-3.4.8/bin#
Zookeeper的主进程查看
root@ubuntu-128:/opt/zookeeper/zookeeper-3.4.8/bin# jps
4229 Jps
4174 QuorumPeerMain
Zookeeper集群搭建 — 搭建成功标志
在任一台机器运行sh zkServer.sh status出现下面两幅图中任一输出结果,说明你的集群成功搭建。
root@ubutu-130:/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
root@ubutu-131:/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.sh和zkServer.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