zookeeper集群安装

一、准备阶段

安装包:jdk-8u171-linux-x64.tar.gz 、zookeeper-3.4.12.tar.gz

三台linux centos7 机器

IP:192.168.154.122

IP:192.168.154.123

IP:192.168.154.124

二、安装jdk(每台机器都需要安装jdk)

1.解压tar.gz包

tar -zxvf jdk-8u171-linux-x64.tar.gz

2.创建jdk存放路劲

mkdir /usr/local/java/

mv jdk1.8.0_171 /usr/local/java/

3、配置环境变量

在/etc/profile文件末尾中添加以下环境变量:(我上面的JDK目录是jdk1.8.0_171,所以下面JAVA_HOME中也是这个)

export JAVA_HOME=/usr/local/java/jdk1.8.0_171

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$PATH

 

4.使配置生效

source /etc/profile

 

5.查看jdk是否安装成功

java -version

三、安装zookeeper

1)解压

tar -zxvf zookeeper-3.4.12.tar.gz -C /usr/local

2)配置

cd /usr/local/zookeeper-3.4.12/conf

cp zoo_sample.cfg zoo.cfg

vim zoo.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=/tmp/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.154.122:2888:3888

server.2=192.168.154.123:2888:3888

server.3=192.168.154.124:2888:3888

 

三台机器的zoo.cfg文件相同

192.168.154.122 机器dataDir目录下创建myid 文件 内容为 1

192.168.154.123 机器dataDir目录下创建myid 文件 内容为 2

192.168.154.124 机器dataDir目录下创建myid 文件 内容为 3

分别启动三台zookeeper即可完成集群创建

sh /usr/local/zookeeper-3.4.12/bin/zkServer.sh start 启动命令

sh /usr/local/zookeeper-3.4.12/bin/zkServer.sh status 查询zookeeper状态

sh /usr/local/zookeeper-3.4.12/bin/zkServer.sh stop 停止zookeeper

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值