zookeeper入门(2)-Zookeeper集群安装

1、我的环境及软件版本

3台虚拟机,操作系统为centos6.5。分别为:

hostname        ip                   

hdp01               192.168.72.11

hdp02               192.168.72.12

hdp03               192.168.72.13

jdk版本:jdk-7u45-linux-x64.tar.gz

zookeeper版本:zookeeper-3.4.5

2、安装过程

第一步:安装好jdk,配置好网络环境,保证三台服务器可以相互访问。

安装jdk过程比较简单,下载jdk安装包,解压,配置好环境变量就行。

第二步:上传安装包,解压安装包,解压命令

上传安装包,可以提前安装一下lrzsz,yum -y install lrzsz,上传文件比较简单。如图,上传文件只需使用rz命令。

 

解压安装包使用命令tar –zxvf zookeeper-3.4.5.tar.gz。

 

第三步:重命名,命令:mv zookeeper-3.4.5 zookeeper,也可忽略。

第四步:修改环境变量

执行命令:vi /etc/profile

在profile文件后面追加下面2行:

    export ZOOKEEPER_HOME=/root/apps/zookeeper

    export PATH=$PATH:$ZOOKEEPER_HOME/bin

最后执行source /etc/profile,使环境变量生效。

第五步:修改配置文件

 1、修改配置文件zoo.cfg

       cd zookeeper/conf,进入到zookeeper目录下的配置文件目录conf。

       cp zoo_sample.cfg  zoo.cfg ,拷贝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=/root/apps/zookeeper/zkdata

dataLogDir=/root/apps/zookeeper/zkLogs
# 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

server.1=hdp01:2888:3888
server.2=hdp02:2888:3888
server.3=hdp03:2888:3888

 2、创建myid文件

 Zookeeper目录下创建目录zkdata,在zoo.cfg里面有设置,在zkdata里面创建文件myid,

并写入值为1。命令:

  cd zkdata

  echo 1 > myid

 第六步:分发安装包到其他机器。

  scp -r zookeeper/ root@hdp02:/root/apps/

  scp -r zookeeper/ root@hdp03:/root/apps/

 第七步:修改其他机器的配置文件

 修改hdp02和hdp03上的zookeeper中的myid文件内容问2和3.

  第八步:启动测试

分别执行三台服务器的zookeeper的bin目录下的zkServer.sh  start,

然后执行zkServer.sh status,查看zookeeper状态,显示出mode,即集群部署成功

 

 

 

        

posted @ 2019-02-12 12:57  Miles_mjy  阅读(119)  评论(0编辑  收藏  举报