Solr works best on Linux, so start there.
Docker
Install Docker
https://docs.docker.com/engine/install/ubuntu/
Install Docker Compose
https://docs.docker.com/compose/install/
Solr
Install Solr - single instance
https://hub.docker.com/_/solr/
Run a demo image from DockerHub
sudo -i
docker run -p 8983:8983 -t solr
But research suggests running multiple Solr instances in a Docker container on single Virtual Machine results in faster query response times than single Solr instance on bare metal server.
Install SolrCloud - Variation 1
Create a 3-node Solr Cloud / Zookeeper cluster following this online docker-compose example:
mkdir /opt/mycluster
cd /opt/mycluster
curl --output docker-compose.yml
docker-compose up -d
Install SolrCloud - Variation 2
Create a 3-node Solr Cloud / Zookeeper cluster with volumes for persisting data using the following docker-compose.yml
file
version: '3.7'
services:
solr1:
image: solr:latest
container_name: solr1
ports:
- "8981:8983"
environment:
- ZK_HOST=zoo1:2181,zoo2:2181,zoo3:2181
networks:
- solr
volumes:
- data1:/var/solr
depends_on:
- zoo1
- zoo2
- zoo3
solr2:
image: solr:latest
container_name: solr2
ports:
- "8982:8983"
environment:
- ZK_HOST=zoo1:2181,zoo2:2181,zoo3:2181
networks:
- solr
volumes:
- data2:/var/solr
depends_on:
- zoo1
- zoo2
- zoo3
solr3:
image: solr:latest
container_name: solr3
ports:
- "8983:8983"
environment:
- ZK_HOST=zoo1:2181,zoo2:2181,zoo3:2181
networks:
- solr
volumes:
- data3:/var/solr
depends_on:
- zoo1
- zoo2
- zoo3
zoo1:
image: zookeeper:latest
container_name: zoo1
restart: always
hostname: zoo1
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
networks:
- solr
zoo2:
image: zookeeper:latest
container_name: zoo2
restart: always
hostname: zoo2
ports:
- 2182:2181
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=0.0.0.0:2888:3888;2181 server.3=zoo3:2888:3888;2181
networks:
- solr
zoo3:
image: zookeeper:latest
container_name: zoo3
restart: always
hostname: zoo3
ports:
- 2183:2181
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=0.0.0.0:2888:3888;2181
networks:
- solr
networks:
solr:
volumes:
data1:
data2:
data3:
Add the Solr Getting Started collection, and populate it with data:
sudo docker exec -it --user=solr solr1 bin/solr create_collection -c gettingstarted
sudo docker exec -it --user=solr solr1 bin/post -c gettingstarted example/exampledocs/manufacturers.xml
Add the Data Import Handler collection:
sudo docker exec -it --user=solr solr1 bin/solr create_collection -c dih
References
Docker-Solr FAQ
- https://github.com/docker-solr/docker-solr/blob/master/Docker-FAQ.md#can-i-run-zookeeper-and-solr-clusters-under-docker
Docker-Solr Builds
Docker-Solr Documentation
Solr Data Import Handler