CentOS-7下ZooKeeper的过程(集群)

1.简要介绍

ZooKeeper诞生于Yahoo,后转入Apache孵化,最终孵化成Apache的顶级项目,是Hadoop和Hbase的重要组件。ZooKeeper是一种集中式服务,用于维护配置信息、命名、提供分布式同步和提供组服务。所有这些类型的服务都以分布式应用程序的某种形式使用。由于实现上述需求都需要做很多工作来修复不可避免的错误和竞争条件。因此,这些服务的实现变得非常困难,即使这些服务顺利完成,管理和运维的成本也非常高,所以zookeeper以救世主的身份出现,解决上述技术难题,降低了分布式应用程序的开发难度和工作量,让程序员专注于分布式架构的设计

2.ZooKeeper的安装

1.实验物料

三台CentOS7的虚拟机,JDK1.8,zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
在这里插入图片描述

2.ZooKeeper安装过程

1.首先安装JDK,尽量选用1.8及以上的JDK,关于JDK的安装,这里不再赘述,不会的同学可以看我上一篇文章《CentOS-7下安装JDK1.8的过程》
2.下载Zookeeper的软件安装包,这里我选zookeeper-3.4.14.tar.gz

wget https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz

3.解压缩

tar xf zookeeper-3.4.14.tar.gz

4.移动到opt下

mv zookeeper-3.4.14 /opt/

5.创建配置文件
在conf下,创建zoo.cfg。我直接采用复制里面样例的方式创建:

cp zoo_sample.cfg 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=/var/zookeeper
# 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=192.168.15.20:2888:3888
server.2=192.168.15.21:2888:3888
server.3=192.168.15.22:2888:3888

6.创建myid
在/var/zookeeper目录下,创建myid文件,里面填写数字1

vi /var/zookeeper/myid

7.配置环境变量

vi /etc/profile

配置内容如下:

 export ZOOKEEPER_HOME=/opt/zookeeper-3.4.14
 export PATH=$JAVA_HOME/bin:$JRE_HOME/bin/$JAVA_HOME:$PATH:$ZOOKEEPER_HOME/bin

在这里插入图片描述
8.刷新配置文件

source /etc/profile

9.文件同步
将在192.168.15.20中安装的文件,同步到其他两台机器上:

scp -r  ./opt/zookeeper-3.4.14/ root@192.168.15.21:/opt/zookeeper-3.4.14/
scp -r  ./opt/zookeeper-3.4.14/ root@192.168.15.22:/opt/zookeeper-3.4.14/

然后在192.168.15.21上也创建/var/zookeeper目录和myid文件,里面填写数字2;
然后在192.168.15.22上也创建/var/zookeeper目录和myid文件,里面填写数字3;
10.启动
在三台机器上都执行以下命令:

zkServer.sh start

这样就完成了安装。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值