zk集群部署

Scroll Down

首先必须是3台或者以上的服务器

正常安装解压

修改配置文件


# 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=/root/soft/zk/mydata
dataLogDir=/root/soft/zk/mylog
# the port at which the clients will connect
clientPort=2181
#admin.serverPort=8089
# 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=ip1:2888:3888
server.2=ip2:2888:3888
server.3=ip3:2888:3888

对应的服务器开放端口,安全组中的出入都开放 2181,2888,3888

dataDir=/root/soft/zk/mydata 中新建一个文件myid

myid中的内容对应 zoo.cfg中的server.xxx
ip1 那就是 myid 中内容为1

image.png

上面几步做完就可以了

测试的时候,可以使用 ./zkServer.sh start-foreground
会把日志打印出来

测试无问题,在直接使用 ./zkServer.sh start 启动

image.png