zookeeper配置

部署+启动

#解压 win linux一样,win参数可能不同,win时beta版本tar新增的(为了侵占类unix市场?逃)
tar -zxf apache-zookeeper-3.5.6-bin.tar.gz

# 将conf目录中的zoo_sample.cfg配置文件改为zoo.cfg
mv conf/zoo_sample.cfg conf/zoo.cfg
vim conf/zoo.cfg
# 将dataDir目录改一下, 默认在/tmp/zookeeper, 这是存放数据的目录

# 启动server
./zkServer.sh start 
# 查看server状态
./zkServer.sh status
# stop
./zkServer.sh stop
# or
java -cp zookeeper.jar:lib/*:conf org.apache.zookeeper.server.quorum.QuorumPeerMain zoo.conf 

# client连接server
./zkCli.sh -server 192.168.40.128:2181
# zkCli.sh 参数  <-r 只读模式> <-timeout 2000 超时时间ms> ip:port

配置文件 zoo.cfg

# The number of milliseconds of each tick
# zk客户端与zk服务器心跳间隔 单位:ms
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
# leader和follower之间发送消息的请求和应答的次数,最长不能超过多少个tickTime的时间长度,syncLimit*tickTime毫秒
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
# 存储内存中数据库快照保存的位置,默认情况下日志也保存在这个目录
dataDir=/opt/apache-zookeeper-3.5.6/data
# the port at which the clients will connect
clientPort=2181 #客户端连接zk的端口
clientPortAddress=192.168.40.128
# 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 保留在dataDir的快照数
#autopurge.snapRetainCount=3
# Purge task interval in hours 以小时为单位自动清除
# Set to "0" to disable auto purge feature  设置为0不自动清除 
#autopurge.purgeInterval=1
dynamicConfigFile=/zookeeper/conf/zoo_replicated1.cfg.dynamic
# 多个服务器配置 server.serverNumber=serverIP:server/clientConnect Port:exchangeMessagePort:electLeaderPort
server.1=192.168.40.127:2181:2182:2183
server.2=192.168.40.128:2181:2182:2183
server.3=192.168.40.129:2181:2182:2183
#java系统专属配置
zookeeper.cnxTimeout= 5 # 选举超时时间,默认5秒。使用选举算法3(electionAlg 3)的时候生效
zookeeper.extendedTypesEnabled=true #默认关闭。重要信息:由于内部限制,启用的服务器ID必须小于255
zookeeper.emulate353TTLNodes=true #由于版本问题上述不行的话,需要增加这个属性,服务器id必须小于127
# 非java sys
electionAlg = #只能1/2/3 12马上就要被删,只有3是ok:基于TCP的FastLeaderElection 
1:non-authenticated UDP-based version of fast leader election
2:authenticated UDP-based

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值