Zookeeper3.4.6部署伪分布集群(Apache)

1、下载Zookeeper

    http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.4.6/

2、创建/usr/app/zookeeper目录,并切换到该目录,如下所示

    clip_image001

3、使用rz命令上传zookeeper-3.4.6.tar.gz

    clip_image002

4、解压(tar zxvf zookeeper-3.4.6.tar.gz),如下所示

    clip_image003

    clip_image004

5、删除zookeeper-3.4.6.tar.gz,如下所示

    clip_image005

6、重名zookeeper-3.4.6为zookeeper1,如下所示

    clip_image006

7、在zookeeper1目录下,创建data、datalog两目录,如下

    clip_image007

8、在data目录下创建myid文件,输入数字1,然后保存退出,该数字用来标识当前主机
    clip_image008

    clip_image009

9、在conf目录下,将zoo_sample.cfg重名为zoo.cfg,并编辑zoo.cfg文件,如下所示

    clip_image010

  zoo.cfg文件内容如下

复制代码
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
# zookeeper集群中的包含多台server, 其中一台为leader, 集群中其余的为follower,initLimit配置初始化连接时,
# follower和leader之间的最长心跳时间. 此时该参数设置为10, 说明时间限制为10倍tickTime, 即10*2000=20000ms=20s
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
# 该参数配置leader和follower之间发送消息, 请求和应答的最大时间长度. 此时该参数设置为5, 说明时间限制为5倍tickTime, 即10000ms
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/app/zookeeper/zookeeper1/data
dataLogDir=/usr/app/zookeeper/zookeeper1/datalog
# the port at which the clients will connect
# 在伪分布式下,各个server的clientPort不能相同 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 # server.X=A:B:C # 其中X是一个数字, 表示这是第几号server # A是该server所在的IP地址 # B配置该server和集群中的leader交换消息所使用的端口 # C配置选举leader时所使用的端口 # 说明:在伪分布式下, 各个server的B, C参数必须不同 server.1=ljc:2888:3888 server.2=ljc:2889:3889 server.3=ljc:2890:3890
复制代码

10、切换到/usr/app/zookeeper/,将zookeeper1拷贝两份zookeeper2、zookeeper3,如下所示

    clip_image011

    clip_image012

11、修改zookeeper2中两个文件(data/myid、conf/zoo.cfg),将myid文件的内容修改为2,修改zoo.cfg文件中的属性(dataDir=/usr/app/zookeeper/zookeeper2/data、dataLogDir=/usr/app/zookeeper/zookeeper2/datalog、clientPort=2182)

12、修改zookeeper3中两个文件(data/myid、conf/zoo.cfg),将myid文件的内容修改为3,修改zoo.cfg文件中的属性(dataDir=/usr/app/zookeeper/zookeeper3/data、dataLogDir=/usr/app/zookeeper/zookeeper3/datalog、clientPort=2183)

13、启动zookeeper

    clip_image013

  如果出现以下结果,说明启动成功

    clip_image014

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值