赞
踩
1. 环境安装
主机名称
IP
zookeeper1
192.168.21.66
zookeeper2
192.168.21.57
zookeeper3
192.168.21.17
2.准备zookeeper
2.1 安装jdk8(必须)
1)Centos(普通用户请在命令前加sudo)
yum install java-1.8.0-openjdk* -y
2)Ubuntu(普通用户请在命令前加sudo)
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install oracle-java8-installer
3)检查jdk版本
java -version
2.2 下载zookeeper
1)下载如下的zookeeper的包到zookeeper1上
https://pan.baidu.com/s/1mVCqv-bJW9cAxO44Xosn2A 提取码: tphy
2)在zookeeper1下做如下操作
#将zookeeper解压到/usr/local/zookeeper下面
mv zookeeper-3.4.12.tar /usr/local
tar -zxvf zookeeper-3.4.12.tar
mv zookeeper-3.4.12 zookeeper
#拷贝sample配置
cp /usr/local/zookeeper/conf/zoo_sample.cfg /usr/local/zookeeper/conf/zoo.cfg
#修改/usr/local/zookeeper/conf/zoo.cfg
dataDir=/usr/local/zookeeper/data
#在文件末尾添加,这里的三个ip为内网ip,填写实际就好(ip a查询)
server.1=10.10.10.3:2888:3888
server.2=10.10.10.4:2888:3888
server.3=10.10.10.7:2888:3888
3)初始化集群信息
#1.在zookeeper01下执行
mkdir /usr/local/zookeeper/data echo "1" > /usr/local/zookeeper/data/myid#2.在zookeeper02下执行
mkdir /usr/local/zookeeper/data echo "2" > /usr/local/zookeeper/data/myid#3.在zookeeper03下执行
mkdir /usr/local/zookeeper/data echo "3" > /usr/local/zookeeper/data/myid
3. 运行zk集群&测试
1.分别在zookeeper01,zookeeper02,zookeeper03下执行
/usr/local/zookeeper/bin/zkServer.sh start
2.分别在zookeeper01,zookeeper02,zookeeper03下执行
/usr/local/zookeeper/bin/zkServer.sh status
应该有一台为leader节点,另外两台为follower节点
至此,zookeeper的3节点集群已经搭建完毕。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。