前几天学习了eureka的使用,但是eureka已经停止更新了,所以我们用zookeeper来代替eureka做服务注册中心。
首先在Ubuntu下安装zookeeper。下载zookeeper的压缩包并上传到服务器上。使用tar -zxvf 命令解压到/usr/local/zookeeper文件夹下面。
在根目录下创建data以及logs文件夹。进入conf文件夹下面执行cp zoo_sample.cfg zoo_cfg
编辑zoo_cfg文件如下(单机模式):
# The number of milliseconds of each tick
# 心跳间隔,毫秒
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# 配置zookeeper接受客户端初始化连接时最长能忍受多少个时间心跳间隔。
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度。
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
# 数据存放的位置
dataDir=/usr/local/zookeeper/zookeeper-3.4.10/data
#日志存放的位置
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.10/logs
# 服务器客户端的接口
clientPort=2181
# 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
进入bin目录执行
./zkService.sh start 启动
./zkService.sh stop 停止
./zkService.sh stop 查看状态
./zkcli.sh 连接客户端
1664

被折叠的 条评论
为什么被折叠?



