zookeeper集群部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zookeeper集群部署相关的知识,希望对你有一定的参考价值。
一、至少3台主机
二、jdk环境
三、安装
官网下载zk安装(本文档安装版本3.4.6)
# 测试地址
zk1 192.168.233.133
zk2 192.168.233.134
zk3 192.168.233.135
需要安装jdk(这一步安装省略)
以下操作都需要在三台主机进行
# 添加JDK环境变量
JAVA_HOME=/usr/local/jdk
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
[[email protected] ~]# java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
# 添加ZK环境变量
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.6
export PATH=$PATH:$ZOOKEEPER_HOME/bin:$ZOOKEEPER_HOME/conf
# 手动创建文件夹机文件
/usr/loacl/zookeeper-3.4.6/下
mkdir data
mkdir log
# 在data下创建文件myid
echo ‘0‘ >/usr/local/zookeeper-3.4.6/data/myid #三台主机依次添加0,1,2
# 拷贝配置文件
/usr/local/zookeeper-3.4.6/conf/
cp zoo_sample.cfg zoo.cfg
# 修改配置文件
#以下配置需要在分别三台zk上配置
[[email protected] conf]# cat zoo.cfg
ckTime=2000
dataDir=/usr/local/zookeeper-3.4.6/data
dataLogDir=/usr/local/zookeeper-3.4.6/logs
clientPort=2181
initLimit=5
syncLimit=2
server.0=192.168.233.133:2880:3880
server.1=192.168.233.134:2881:3881
server.2=192.168.233.135:2882:3882
# 启动zk集群
#依次分别启动三台zk
[[email protected] bin]# pwd
/usr/local/zookeeper-3.4.6/bin
[[email protected] bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[[email protected] bin]# pwd
/usr/local/zookeeper-3.4.6/bin
[[email protected] bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[[email protected] bin]# pwd
/usr/local/zookeeper-3.4.6/bin
[[email protected] bin]# sh zkServer.sh start
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
#启动完成检查进程,并检查zk状态角色
[[email protected] bin]# sh zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower
[[email protected] bin]# sh zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: leader
[[email protected] bin]# sh zkServer.sh status
JMX enabled by default
Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg
Mode: follower
zk集群部署完成
以上是关于zookeeper集群部署的主要内容,如果未能解决你的问题,请参考以下文章