您当前的位置: 首页 >  ubuntu

衣舞晨风

暂无认证

  • 3浏览

    0关注

    1156博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Ubuntu 安装 ZooKeeper

衣舞晨风 发布时间:2017-03-07 20:35:24 ,浏览量:3

一、安装

1、安装JDK 我安装的是Oracle的Jdk 1.8 2、下载zookeeper 下载地址:http://zookeeper.apache.org/releases.html 也可以使用wget 下载 我下载的是3.4.9 3、解压 tar -xf zookeeper-3.4.9.tar.gz 将解压后的zookeeper-3.4.9文件放在系统的/home/jiankunking/中。 小注: 我Ubuntu用户名是jiankunking 4、将zookeeper-3.4.9/conf目录下的zoo_sample.cfg文件拷贝一份,命名为为“zoo.cfg”

cp zoo_sample.cfg zoo.cfg

5、修改zoo.cfg配置文件 修改zoo.cfg内容为:

keeper:2888:3888
f 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=/home/jiankunking/zookeeper-3.4.9/zookeeperdir/zookeeper-data
dataLogDir=/home/jiankunking/zookeeper-3.4.9/zookeeperdir/logs

# the port at which the clients will connect
clientPort=2181
#
# 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

# 2888,3888 are election port
server.1=zookeeper:2888:3888

其中,2888端口号是zookeeper服务之间通信的端口,而3888是zookeeper与其他应用程序通信的端口。而zookeeper是在hosts中已映射了本机的ip。

initLimit:这个配置项是用来配置 Zookeeper 接受客户端(这里所说的客户端不是用户连接 Zookeeper服务器的客户端,而是 Zookeeper 服务器集群中连接到 Leader 的 Follower 服务器)初始化连接时最长能忍受多少个心跳时间间隔数。当已经超过 10 个心跳的时间(也就是 tickTime)长度后 Zookeeper 服务器还没有收到客户端的返回信息,那么表明这个客户端连接失败。总的时间长度就是 5*2000=10 秒。 syncLimit:这个配置项标识 Leader 与 Follower 之间发送消息,请求和应答时间长度,最长不能超过多少个 tickTime 的时间长度,总的时间长度就是 2*2000=4 秒。

server.A=B:C:D:其中 A 是一个数字,表示这个是第几号服务器;B 是这个服务器的 ip 地址;C 表示的是这个服务器与集群中的 Leader 服务器交换信息的端口;D 表示的是万一集群中的 Leader 服务器挂了,需要一个端口来重新进行选举,选出一个新的 Leader,而这个端口就是用来执行选举时服务器相互通信的端口。如果是伪集群的配置方式,由于 B 都是一样,所以不同的 Zookeeper 实例通信端口号不能一样,所以要给它们分配不同的端口号。

6、在/etc/profile文件中设置PATH

export ZOOKEEPER_HOME=/home/jiankunking/zookeeper-3.4.9
PATH=$ZOOKEEPER_HOME/bin:$PATH
export PATH

7、安装完毕

二、启动并测试

1、在所有服务器中执行: 切换到/zookeeper-3.4.9/bin/目录下执行

./zkServer.sh start

2、输入jps命令查看进程

jps

这里写图片描述 3、查看状态:zookeeper-3.4.9/bin/zkServer.sh status 这里写图片描述 4、停止zookeeper进程:zookeeper-3.4.9/bin/zkServer.sh stop 这里写图片描述

本文参考: http://blog.csdn.net/gaokao2011/article/details/17020209

作者:jiankunking 出处:http://blog.csdn.net/jiankunking

关注
打赏
1647422595
查看更多评论
立即登录/注册

微信扫码登录

0.0536s