Reputation: 179
I am running Docker Swarm 1.12 on 3 CoreOS machines via Vagrant.
What is the best way to start a Solr cloud on the cluster? Do I need Zookeeper?
I have gotten as far as this:
docker service create --mode=global --name solr -p 8983:8983 solr:5.3.1 bash -c "/opt/solr/bin/solr start -f -c"
But then the Cloud is empty because it does not know about the other 2 machines, how can I use Swarm's power here?
Upvotes: 0
Views: 2399
Reputation: 77991
The container image documentation describes how interconnect Zookeeper as a backing store for a distributed Solr setup:
You can also run a distributed Solr configuration, with Solr nodes in separate containers, sharing a single ZooKeeper server:
Run ZooKeeper, and define a name so we can link to it:
$ docker run --name zookeeper -d -p 2181:2181 -p 2888:2888 -p 3888:3888 jplock/zookeeper
Run two Solr nodes, linked to the zookeeper container:
$ docker run --name solr1 --link zookeeper:ZK -d -p 8983:8983 \ solr \ bash -c '/opt/solr/bin/solr start -f -z $ZK_PORT_2181_TCP_ADDR:$ZK_PORT_2181_TCP_PORT' $ docker run --name solr2 --link zookeeper:ZK -d -p 8984:8983 \ solr \ bash -c '/opt/solr/bin/solr start -f -z $ZK_PORT_2181_TCP_ADDR:$ZK_PORT_2181_TCP_PORT'
Starting with a 3 node swarm:
$ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
2wkpmybf4wni8wia1s46lm2ml * node1 Ready Active Leader
ajrnf5oibgm7b12ayy0hg5i32 node3 Ready Active
bbe8n1hybhruhhrhmswn7fjmd node2 Ready Active
Create a network
$ docker network create --driver overlay my-net
Start a zookeeper service and wait for it to start
$ docker service create --name zookeeper --replicas 1 --network my-net jplock/zookeeper
Start 2 solr instances configured to connect to the DNS address "zookeeper". For more information on swarm mode networking you can read the documentation
$ docker service create --name solr --replicas 2 --network my-net -p 8983:8983 \
solr \
bash -c '/opt/solr/bin/solr start -f -z zookeeper:2181'
The web UI will be available on any node in the cluster
http://192.168.99.100:8983/
http://192.168.99.101:8983/
http://192.168.99.102:8983/
If you check the services you'll notice the containers are spread across all 3 nodes in the cluster. This is the default scheduling behaviour
$ docker service ps zookeeper
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
3fhipbsd4jdazmx8d7zum0ohp zookeeper.1 jplock/zookeeper node1 Running Running 7 minutes ago
$ docker service ps solr
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR
bikggwpyz5q6vdxrpqwevlwsr solr.1 solr node2 Running Running 43 seconds ago
cutbmjsmcxrmi1ld75eox0s9m solr.2 solr node3 Running Running 43 seconds ago
Upvotes: 3