SolrCloud(一)搭建Zookeeper

时间:2022-11-10 23:38:47

搭建Zookeeper

一 准备三台服务器(本人Centos7虚拟机)

AMouse: 192.168.3.201

BCattle: 192.168.3.202

Ctiger: 192.168.3.203

二 下载Zookeeper

版本: zookeeper-3.4.6

地址: http://mirror.bit.edu.cn/apache/zookeeper/

地址: https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/

 三 上传文件到/usr/local/ 目录下,解压至当前目录,并将zookeeper-3.4.6修改为为 zookeeper

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

mv zookeeper-3.4.6 zookeeper

SolrCloud(一)搭建Zookeeper 

四 在zookeeper目录下建立data和 logs目录

mkdir /usr/local/zookeeper/data
mkdir /usr/local/zookeeper/logs

  

五 将zookeeper目录下/usr/local/zookeeper/conf/zoo_simple.cfg文件修改为 zoo.cfg

cd /usr/local/zookeeper/conf

mv zoo_sample.cfg zoo.cfg

六  修改zoo.cfg 文件

vi 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=/usr/local/zookeeper/data
# 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 dataLogDir=/usr/local/zookeeper/logs server.1=192.168.3.201:2888:3888 server.2=192.168.3.202:2888:3888 server.3=192.168.3.203:2888:3888

七 拷贝zookeeper目录到另外两台服务器

scp -r /usr/local/zookeeper root@192.168.3.202:/usr/local/

scp -r /usr/local/zookeeper root@192.168.3.203:/usr/local/

八 在三台服务器上分别创建myid文件

server.1 的myid内容为1

192.168.3.201

echo "1">> /usr/local/zookeeper/data/myid

server.2的myid内容为2

192.168.3.202

echo "2">> /usr/local/zookeeper/data/myid

server.3的myid为 3

192.168.3.203

echo "3">> /usr/local/zookeeper/data/myid

九 在三台服务器上分别启动ZooKeeper服务

cd /usr/local/zookeeper/

bin/zkServer.sh  start

十 ZooKeeper集群的状态

bin/zkServer.sh  status

SolrCloud(一)搭建Zookeeper