您的位置:首页 > 其它

zookeeper集群的完全分布式安装

2016-04-24 16:46 435 查看

zookeeper集群的完全分布式安装

本文是传智播客八天——第五天学习笔记

使用一台主机和两个虚拟机

下载zookeeper-3.4.5并解压到/home/kun/soft文件夹下

修改配置文件

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好难用啊。。>///<
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: