- 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
- 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.
Great post! This is exactly what I am looking for.
ReplyDeleteI got it set up and running. However the zookeeper admin page is saying that shard1 has master1, slave1-master1 and slave2-master2, and shard2 has master2, slave1-master2 and slave2-master2. Shouldn't the slaves be the other way round?
Also, neither of my dashboard is working (http://localhost:7574/solr/ and http://localhost:8983/solr/ ). Content is not loading. No error in the logs though. They both worked when I tried the singlecore SolrCloud following this page: http://wiki.apache.org/solr/SolrCloud#Getting_Started
Allow me to explain:
ReplyDelete1) shard1 is half of the entire dataset and all the indexing is done for it on master1.
1a) The replicated instances which are used for searching are called slave1-master1 and slave2-master1.
1b) The postfix called "-master1" is present in each of their names to indicate that they are replicated slaves of master1.
1c) If that is the case then doesn't it make sense that they actually manage shard1 part of the dataset? Any clearer?
If not, let me go on to what I think may be confusing you. You may be confused by the fact that the slaves of master1 are actually sitting on the Solr instance that is managing master2 and visa-versa. The reason behind this is that someone very smart in the Solr mailing-list alerted me to the fact that if one of the two instances of Solr goes DOWN then at least I have 2 slaves of a shard to read from (they can't be updated though) and one master of the other half of the shard to read & write to :)
Litte typo remark: instancedir needs to be "instanceDir". It's case-sensitive.
ReplyDeleteHi,
ReplyDeletei configure as explain in a single server but i get follow problems
--------------------------------------
SEVERE: Error while trying to recover.
org.apache.solr.client.solrj.SolrServerException: Server at http://fc:8983/solr was not found (404).
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:372)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:182)
at org.apache.solr.cloud.RecoveryStrategy.sendPrepRecoveryCmd(RecoveryStrategy.java:192)
at org.apache.solr.cloud.RecoveryStrategy.doRecovery(RecoveryStrategy.java:303)
at org.apache.solr.cloud.RecoveryStrategy.run(RecoveryStrategy.java:213)
Jun 15, 2012 5:33:21 PM org.apache.solr.cloud.RecoveryStrategy doRecovery
SEVERE: Recovery failed - trying again...
--------------------------------------
Any idea?
another little remark:
ReplyDeletei add -Dcollection.configName=scaleDeep in java start
otherwise i get the follow SEVERE pb
SEVERE: Specified config does not exist in ZooKeeper:scaleDeep
Jun 15, 2012 5:43:07 PM org.apache.solr.common.SolrException log
SEVERE: null:org.apache.solr.common.cloud.ZooKeeperException: Specified config does not exist in ZooKeeper:scaleDeep
This comment has been removed by a blog administrator.
ReplyDelete