zookeeper集群
Posted xgmxm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zookeeper集群相关的知识,希望对你有一定的参考价值。
安装jdk8
cd /opt/tools
tar -xf jdk-8u112-linux-x64.tar.gz
mv jdk1.8.0_112 /opt/
vim /etc/profile.d/env.sh
######
export JAVA_HOME=/opt/jdk1.8.0_112
export JAVA_BIN=/opt/jdk1.8.0_112/bin
export JRE_HOME=/opt/jdk1.8.0_112/jre
export PATH=$PATH:/opt/jdk1.8.0_112/bin:/opt/jdk1.8.0_112/jre/bin
export CLASSPATH=/opt/jdk1.8.0_112/jre/lib:/opt/jdk1.8.0_112/lib:/opt/jdk1.8.0_112/jre/lib/charsets.jar
######
source /etc/profile
[[email protected] tools]# java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
节点1
mkdir /opt/zkcluster cd /opt/tools tar -xf zookeeper-3.4.10.tar.gz mv zookeeper-3.4.10 /opt/zkcluster/3001 cd /opt/zkcluster/3001 mkdir data logs cd conf vim zoo.cfg ##### tickTime=2000 initLimit=10 syncLimit=5 dataDir=/opt/zkcluster/3001/data dataLogDir=/opt/zkcluster/3001/logs clientPort=3001 server.1=192.168.159.30:2887:3887 server.2=192.168.159.30:2888:3888 server.3=192.168.159.30:2889:3889 #主要修改ip,端口 ##### echo 1 > /opt/zkcluster/3001/data/myid 启动 /opt/zkcluster/3001/bin/zkServer.sh start
节点2
cd /opt/cluster cp -av 3001 3002 sed -i ‘s/3001/3002/g‘ /opt/zkcluster/3002/conf/zoo.cfg echo 2 > /opt/zkcluster/3002/data/myid
启动
/opt/zkcluster/3002/bin/zkServer.sh start
节点3
cd /opt/cluster cp -av 3001 3003 sed -i ‘s/3001/3003/g‘ /opt/zkcluster/3003/conf/zoo.cfg echo 3 > /opt/zkcluster/3003/data/myid 启动 /opt/zkcluster/3002/bin/zkServer.sh start
验证集群
[[email protected] conf]# /opt/zkcluster/3001/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zkcluster/3001/bin/../conf/zoo.cfg Mode: leader [[email protected] conf]# /opt/zkcluster/3002/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zkcluster/3002/bin/../conf/zoo.cfg Mode: follower [[email protected] conf]# /opt/zkcluster/3003/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zkcluster/3003/bin/../conf/zoo.cfg Mode: follower
以上是关于zookeeper集群的主要内容,如果未能解决你的问题,请参考以下文章
ZooKeeper伪分布集群安装及使用 RMI+ZooKeeper实现远程调用框架
使用java代码对zookeeper集群中的solrCloud数据进行CURD