栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Zookeeper-3.4.13集群配置

Zookeeper-3.4.13集群配置

一、下载Zookeeper-3.4.13

官网下载地址

二、解压Zookeeper-3.4.13到/usr/local/,并该名为zookeeper

三、配置Zookeeper 1.复制模版文件zoo_sample.cfg为zoo.cfg
cp /usr/local/zookeeper/conf/zoo_sample.cfg  /usr/local/zookeeper/conf/zoo.cfg

2.修改配置文件zoo.cfg
# The number of 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=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/datalog
# the port at which the clients will connect
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.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888

四、创建所需目录和新建的myid文件

创建/usr/local/zookeeper/data与/usr/local/zookeeper/datalog目录

sudo mkdir /usr/local/zookeeper/data
sudo mkdir /usr/local/zookeeper/datalog
sudo vim /usr/local/zookeeper/data/myid

将myid内容设置为1
设置为1是由于配置文件zoo.cfg中“server.id=host:port:port”,配置项master机器对应的“id”为"1"

五、同步zookeeper文件到salve1、slave2
su root
scp -r /usr/local/zookeeper root@slave1:/usr/local/zookeeper
scp -r /usr/local/zookeeper root@slave2:/usr/local/zookeeper

六、设置$ZOOKEEPER_HOME的目录属主

为了在普通用户下使用Zookeeper集群,依次将master、slave1、slave2三台机器上的zookeeper目录设置为linux普通用户

chown -R 用户名 /usr/local/zookeeper
七、修改slave1、slave2的myid内容

在slave1、slave2中执行

sudo vim /usr/local/zookeeper/data/myid


八、在用户主目录中添加环境变量

export ZOOKEEPER_HOME=/usr/local/zookeeper
export PATH=$ZOOKEEPER_HOME/bin:$PATH

source ~/.bashrc

配置好后执行zkServer.sh start

zkServer.sh start

九、验证zookeeper集群
zkServer.sh status
jps

leader角色随缘分配 这次slave1为leader, master与slave2为follower


master、slave1、slave2 三机器jps出现上图QuorumPeerMain 说明zookeeper集群配置成功

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/761611.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号