zookeeper集群的完全分布式安装

zookeeper集群的完全分布式安装

本文是传智播客八天——第五天学习笔记
使用一台主机和两个虚拟机

  1. 下载zookeeper-3.4.5并解压到/home/kun/soft文件夹下
  2. 修改配置文件
    2.1将/home/kun/soft/zookeeper-3.4.5/conf/zoo_sample.cfg重命名为zoo.cfg
    2.2编辑zoo.cfg
# The number of milliseconds of each tick
#心跳机制的毫秒数
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
#第一个和最后一个启动所允许的最大心跳差为10个心跳
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
#发送请求与相应请求之间所允许的最大的心跳差为5个心跳
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
#数据所存放的位置,一般不要使用默认的
dataDir=/home/kun/soft/zookeeper-3.4.5/data
# 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
#zookeeper集群
server.1=hadoop-master:2888:3888
server.2=hadoop-slave1:2888:3888
server.3=hadoop-slave2:2888:3888

2.3 再上面定义的路径下创建一个data文件夹
2.4在data文件夹中新建一个myid文件,向文件中写入1
2.5 在配置文件中配置ZOOKEEPER_HOME

sudo gedit /etc/profile
export ZOOKEEPER_HOME=/home/kun/soft/zookeeper-3.4.5
export PATH=$PATH:$ZOOKEEPER_HOME/bin

3.将配置好的zookeeper文件拷贝到其他节点中

scp -r /home/kun/soft/zookeeper-3.4.5/ hadoop-slave1:/home/kun/soft/zookeeper-3.4.5
scp -r /home/kun/soft/zookeeper-3.4.5/ hadoop-slave2:/home/kun/soft/zookeeper-3.4.5

并根据zoo.cfg中的配置将hadoop-slave1中的myid修改为2,将hadoop-slave2中的myid修改为3.
4.在三个系统中分别启动zookeeper

./zkServer.sh start

启动完成后查看zookeeper的状态

./zkServer.sh status

如果一个leader两个follower则说明启动成功






最后,markdown好难用啊。。>///<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值