- If you've already done some work with Solr Cloud then you may want to start fresh by cleaning up any previous ZooKeeper configuration data in order to run this example exercise smoothly.
cd /trunk/solr/example/solr rm -rf zoo_data
- We will create the following setup:
- there will be 2 Solr instances, each with 3 cores
- 1 of the 3 cores will be a master and the other 2 will be slaves
- the slaves of one instance will be configured to use the master of the other one
- The infrastructure will look like:
- Solr-Instance-A
- master1 (indexes changes for shard1)
- slave1-master2 (replicates changes from shard2)
- slave2-master2 (replicates changes from shard2)
- Solr-Instance-B
- master2 (indexes changes for shard2)
- slave1-master1 (replicates changes from shard1)
- slave2-master1 (replicates changes from shard1)
- Solr-Instance-A
- We can reuse the multicore directory of the out-of-the-box example. It already has the core0 and core1 directories, lets create an additional core:
cd /trunk/solr/example/multicore cp -r core0 core2
- If we were NOT using Solr Cloud which has us upload an universal configuration at startup, then we would perform the following sub-steps:
Replace any mention of core0 with core2
sed -ibak 's/core0/core2/g' core2/conf/solrconfig.xml sed -ibak 's/core0/core2/g' core2/conf/schema.xml sed -ibak 's/zero/two/g' core2/conf/schema.xml
- Edit solr.xml as follows:
- Copy over the example's zoo.cfg from the single-solr setup over to the multicore setup:
cd /trunk/solr/example cp ./solr/zoo.cfg ./multicore/
- Copy example to example2 in order to create another Solr instance
cd /trunk/solr cp -r example example2
- Edit solr.xml for example2 as follows:
cd trunk/solr/example2/multicore vi solr.xml
- So where is the configuration that we will we be uploading to ZooKeeper? And what should we edit? Well, the most well formed configuration is sitting in the out-of-the-box single core example so let us simply upload it from there to ZooKeeper! And have it configured such that it can be applied conditionally to all our cores based on the java params that we specify at startup!
- Let us begin by editing the solrconfig.xml file of the single solr core example as follows:
cd /trunk/solr/example/solr/conf vi solrconfig.xml
${enable.master:false} commit startup schema.xml,stopwords.txt ${enable.slave:false} http://${masterHost:localhost}:${masterPort:8983}/solr/${masterCoreName:master1}/replication 00:00:60 - We cannot pass the true/false values via -Denable.master or -Denable.slave at startup because it will end up applying globally to all the cores (1 master & 2 slaves) and there isn't a way to start only one core at a time from the command line. So we must leverage each individual multicore's solr.xml to provide core specific values as follows:
cd /trunk/solr/example/multicore vi solr.xml
cd /trunk/solr/example2/multicore vi solr.xml - Now let us start the 1st instance of the multicore Solr with the appropriate java params and let ZooKeeper know exactly where to get its universal-config (bootstrap_confdir) from:
cd /trunk/solr/example #java -Dbootstrap_confdir=./solr/conf \ # -Dsolr.solr.home=multicore \ # -DmasterHost=localhost -DmasterPort=7574 -DmasterCoreName=master2 \ # -DzkRun \ # -jar start.jar java -Dbootstrap_confdir=./solr/conf -Dsolr.solr.home=multicore -DmasterHost=localhost -DmasterPort=7574 -DmasterCoreName=master2 -DzkRun -jar start.jar
- Start the 2nd instance of the multicore Solr with the appropriate java params:
cd /trunk/solr/example2 #java -Djetty.port=7574 \ # -DhostPort=7574 \ # -Dsolr.solr.home=multicore \ # -DmasterHost=localhost -DmasterPort=8983 -DmasterCoreName=master1 \ # -DzkHost=localhost:9983 \ # -jar start.jar java -Djetty.port=7574 -DhostPort=7574 -Dsolr.solr.home=multicore -DmasterHost=localhost -DmasterPort=8983 -DmasterCoreName=master1 -DzkHost=localhost:9983 -jar start.jar
- Let us begin by editing the solrconfig.xml file of the single solr core example as follows:
- Now, you can check the ZooKeeper status here:
http://localhost:8983/solr/master1/admin/zookeeper.jsp
And that's all there is to it, feel free to leave any feedback as comments below.