发布:2022/6/21 20:33:37作者:管理员 来源:本站 浏览次数:998
使用docker部署solr以及solr使用的zookeeper
SolrCloud(solr 云)是Solr提供的分布式搜索方案,当你需要大规模,容错,分布式索引和检索能力时使用 SolrCloud。当一个系统的索引数据量少的时候是不需要使用SolrCloud的,当索引量很大,搜索请求并发很高,这时需要使用SolrCloud来满足这些需求。
SolrCloud是基于Solr和Zookeeper的分布式搜索方案,它的主要思想是使用Zookeeper作为集群的配置信息中心。
部署solr使用的zookeeper集群
三台机器
192.168.100.44
192.168.100.45
192.168.100.46
192.168.100.44操作
[root@localhost ~]# cd /opt/
[root@localhost opt]# mkdir -p docker-data/solr-zk
[root@localhost opt]# cd docker-data/solr-zk
[root@localhost solr-zk]# mkdir {conf,data,datalog}
[root@localhost solr-zk]# cd conf
[root@localhost conf]# vim zoo.cfg
dataDir=/data
dataLogDir=/datalog
clientPort=2181
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
standaloneEnabled=true
admin.enableServer=false
server.1=0.0.0.0:2888:3888
server.2=192.168.100.45:12888:13888
server.3=192.168.100.46:12888:13888
[root@localhost conf]# cd ..
[root@localhost solr-zk]# vim run.sh
需要在zk的data目录下手动创建myid文件
docker run -d \
-p 12181:2181 \
-p 12888:2888 \
-p 13888:3888 \
--restart=always \
-v /opt/docker-data/solr-zk/data/:/data/ \
-v /opt/docker-data/solr-zk/datalog/:/datalog/ \
-v /opt/docker-data/solr-zk/conf/zoo.cfg:/conf/zoo.cfg \
-v /etc/localtime:/etc/localtime:ro \
--name solr-zk-100.44 \
-h 192.168.100.44 \
zookeeper:3.4.14
[root@localhost solr-zk]# echo 1 > data/myid
192.168.100.45操作
[root@localhost ~]# cd /opt/
[root@localhost opt]# mkdir -p docker-data/solr-zk
[root@localhost opt]# cd docker-data/solr-zk
[root@localhost solr-zk]# mkdir {conf,data,datalog}
[root@localhost solr-zk]# cd conf
[root@localhost conf]# vim zoo.cfg
dataDir=/data
dataLogDir=/datalog
clientPort=2181
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
standaloneEnabled=true
admin.enableServer=false
server.1=192.168.100.44:12888:13888
server.2=0.0.0.0:2888:3888
server.3=192.168.100.46:12888:13888
[root@localhost conf]# cd ..
[root@localhost solr-zk]# vim run.sh
需要在zk的data目录下手动创建myid文件
docker run -d \
-p 12181:2181 \
-p 12888:2888 \
-p 13888:3888 \
--restart=always \
-v /opt/docker-data/solr-zk/data/:/data/ \
-v /opt/docker-data/solr-zk/datalog/:/datalog/ \
-v /opt/docker-data/solr-zk/conf/zoo.cfg:/conf/zoo.cfg \
-v /etc/localtime:/etc/localtime:ro \
--name solr-zk-100.45 \
-h 192.168.100.45 \
zookeeper:3.4.14
[root@localhost solr-zk]# echo 2 > data/myid
192.168.100.46操作
[root@localhost ~]# cd /opt/
[root@localhost opt]# mkdir -p docker-data/solr-zk
[root@localhost opt]# cd docker-data/solr-zk
[root@localhost solr-zk]# mkdir {conf,data,datalog}
[root@localhost solr-zk]# cd conf
[root@localhost conf]# vim zoo.cfg
dataDir=/data
dataLogDir=/datalog
clientPort=2181
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
standaloneEnabled=true
admin.enableServer=false
server.1=192.168.100.44:12888:13888
server.2=192.168.100.45:12888:13888
server.3=0.0.0.0:2888:3888
[root@localhost conf]# cd ..
[root@localhost solr-zk]# vim run.sh
# 需要在zk的data目录下手动创建myid文件
docker run -d \
-p 12181:2181 \
-p 12888:2888 \
-p 13888:3888 \
--restart=always \
-v /opt/docker-data/solr-zk/data/:/data/ \
-v /opt/docker-data/solr-zk/datalog/:/datalog/ \
-v /opt/docker-data/solr-zk/conf/zoo.cfg:/conf/zoo.cfg \
-v /etc/localtime:/etc/localtime:ro \
--name solr-zk-100.46 \
-h 192.168.100.46 \
zookeeper:3.4.14
[root@localhost solr-zk]# echo 3 > data/myid
solr-zk集群部署完毕,接下来部署solr集群
solr-zk集群部署完毕,接下来部署solr集群
192.168.100.44
[root@localhost docker-data]# mkdir solr
[root@localhost docker-data]# cd solr
[root@localhost solr]# docker pull solr #下载最新版本solr镜像
[root@localhost solr]# mkdir {config,dist,log,solrhome}
[root@localhost solr]# cd config
[root@localhost config]# vim solr.in.sh
# Increase Java Heap as needed to support your indexing / query needs
SOLR_HEAP="4g"
ZK_HOST="192.168.100.44:12181,192.168.100.45:12181,192.168.100.46:12181"
SOLR_HOST="192.168.100.44"
SOLR_TIMEZONE="UTC+8"
ENABLE_REMOTE_JMX_OPTS="false"
SOLR_OPTS="$SOLR_OPTS -Xss256k"
SOLR_OPTS="$SOLR_OPTS -Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=60"
SOLR_HOME="/var/solr/data/"
SOLR_LOGS_DIR="/var/solr/logs/"
[root@localhost solr]# vim run.sh
docker run -d \
--restart=always \
-p 8983:8983 \
-l io.rancher.container.network=true \
-v /opt/docker-data/solr/solrhome/:/var/solr/solrhome/ \
-v /opt/docker-data/solr/log/:/var/solr/log/ \
-v /opt/docker-data/solr/dist/:/var/solr/dist/ \
-v /opt/docker-data/solr/config/solr.in.sh:/etc/default/solr.in.sh \
-v /etc/localtime:/etc/localtime:ro \
--name solr-1 \
-h 192.168.100.44 \
solr:latest
192.168.100.45
[root@localhost docker-data]# mkdir solr
[root@localhost docker-data]# cd solr
[root@localhost solr]# docker pull solr #下载最新版本solr镜像
[root@localhost solr]# mkdir {config,dist,log,solrhome}
[root@localhost solr]# cd config
[root@localhost config]# vim solr.in.sh
# Increase Java Heap as needed to support your indexing / query needs
SOLR_HEAP="4g"
ZK_HOST="192.168.100.44:12181,192.168.100.45:12181,192.168.100.46:12181"
SOLR_HOST="192.168.100.45"
SOLR_TIMEZONE="UTC+8"
ENABLE_REMOTE_JMX_OPTS="false"
SOLR_OPTS="$SOLR_OPTS -Xss256k"
SOLR_OPTS="$SOLR_OPTS -Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=60"
SOLR_HOME="/var/solr/data/"
SOLR_LOGS_DIR="/var/solr/logs/"
[root@localhost solr]# vim run.sh
docker run -d \
--restart=always \
-p 8983:8983 \
-l io.rancher.container.network=true \
-v /opt/docker-data/solr/solrhome/:/var/solr/solrhome/ \
-v /opt/docker-data/solr/log/:/var/solr/log/ \
-v /opt/docker-data/solr/dist/:/var/solr/dist/ \
-v /opt/docker-data/solr/config/solr.in.sh:/etc/default/solr.in.sh \
-v /etc/localtime:/etc/localtime:ro \
--name solr-2 \
-h 192.168.100.45 \
solr:latest
192.168.100.46
[root@localhost docker-data]# mkdir solr
[root@localhost docker-data]# cd solr
[root@localhost solr]# docker pull solr #下载最新版本solr镜像
[root@localhost solr]# mkdir {config,dist,log,solrhome}
[root@localhost solr]# cd config
[root@localhost config]# vim solr.in.sh
# Increase Java Heap as needed to support your indexing / query needs
SOLR_HEAP="4g"
ZK_HOST="192.168.100.44:12181,192.168.100.45:12181,192.168.100.46:12181"
SOLR_HOST="192.168.100.46"
SOLR_TIMEZONE="UTC+8"
ENABLE_REMOTE_JMX_OPTS="false"
SOLR_OPTS="$SOLR_OPTS -Xss256k"
SOLR_OPTS="$SOLR_OPTS -Dsun.net.inetaddr.ttl=60 -Dsun.net.inetaddr.negative.ttl=60"
SOLR_HOME="/var/solr/data/"
SOLR_LOGS_DIR="/var/solr/logs/"
[root@localhost solr]# vim run.sh
docker run -d \
--restart=always \
-p 8983:8983 \
-l io.rancher.container.network=true \
-v /opt/docker-data/solr/solrhome/:/var/solr/solrhome/ \
-v /opt/docker-data/solr/log/:/var/solr/log/ \
-v /opt/docker-data/solr/dist/:/var/solr/dist/ \
-v /opt/docker-data/solr/config/solr.in.sh:/etc/default/solr.in.sh \
-v /etc/localtime:/etc/localtime:ro \
--name solr-3 \
-h 192.168.100.46 \
solr:latest
三台操作
启动solr集群
[root@localhost solr]# sh run.sh #运行启动脚本
[root@localhost solr]# docker ps 查看容器是否启动成功
验证
solr集群启动成功浏览器访问ip:8983
集群部署完毕