Zookeeper 配置文件 zoo.cfg介绍

2019-05-27  本文已影响0人  逆水寻洲

Zookeeper配置文件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.
dataDir=/Users/dengzhili/zookeeper-3.3.6/data
# the port at which the clients will connect
clientPort=2181
#the location of the log file
dataLogDir=/Users/dengzhili/zookeeper-3.3.6/logs

server.1=127.0.0.1:2888:3888 
server.2=127.0.0.1:2988:3988  
server.3=127.0.0.1:2088:3088 

基本配置

下面是在最低配置要求中必须配置的参数:

# the port at which the clients will connect
clientPort=2181

# The number of milliseconds of each tick
tickTime=2000

# the directory where the snapshot is stored.
dataDir=/Users/dengzhili/zookeeper-3.3.6/data

应该谨慎的选择日志存放的位置,使用专用的日志存储设备能够大大提高系统的性能,如果将日志存储在比较繁忙的存储设备上,那么将会很大程度上影像系统性能。

高级配置

下面是高级配置参数中可选配置参数,用户可以使用下面的参数来更好的规定Zookeeper的行为:

# the directory where the snapshot is stored
dataDir=/usr/local/zk/data

# set maxClientCnxns
maxClientCnxns=1

启动Zookeeper之后,首先用一个客户端连接到Zookeeper服务器上。之后如果有第二个客户端尝试对Zookeeper进行连接,或者有某些隐式的对客户端的连接操作,将会触发Zookeeper的上述配置。

集群配置

# 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

A:其中 A 是一个数字,表示这个是服务器的编号;
B:是这个服务器的 ip 地址;
C:Zookeeper服务器之间的通信端口;
D:Leader选举的端口;

server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2988:3988
server.3=127.0.0.1:2088:3088

上一篇 下一篇

猜你喜欢

热点阅读