In the last Apache Solr related articles we have discussed “How to setup Apache Solr?“, “How to configure Apache Solr to index data from database?” , etc.. In this article we will see “how to setup Apache Solr replication?“. Before getting into the configuration details, we will discuss a use case to use replication. In most of the online sites, the data will get update so frequently. To make this data available to search, the Apache Solr server requires to do delta indexing so frequently. So, the Solr server used for indexing will be always busy with the indexing. If we use the same indexing server for searching, then the search functionality has performance hit. To isolate the search with the indexing and to achieve the better search performance, we need to go with replication. To setup indexing replication we require at least two Solr instances. The below diagram will depict the replication setup.
From the above diagram, the master Solr instance will do indexing. The Salve Solr instances will serve the content to the web. The index from master to slave instances will get replicate based on the replication interval. Now we will see the configuration details.
To make Apache Solr instance as “Master”, we need to do the below configuration in solrconfig.xml.
<requestHandler name="/replication" class="solr.ReplicationHandler" > <lst name="master"> <str name="replicateAfter">commit</str> <str name="replicateAfter">startup</str> </lst> </requestHandler>
You can find more details of master configuration here.
To make Apache Solr instance as “Slave”, we need to do the below configuration in solrconfig.xml.
<requestHandler name="/replication" class="solr.ReplicationHandler" > <lst name="slave"> <str name="masterUrl">http://localhost:8180/solr/samplecatalog</str> <str name="pollInterval">12:00:00</str> </lst> </requestHandler>
You can find more details of slave configuration here.
Now, we will see the admin consoles of master and slave instances.
From the “Master” Solr instance admin console, we can disable the replication to all the “Slave” Solr instances by clicking on “Disable Replication” button.
Now, we will see the salve solr instance admin console.
From the “Slave” Solr instance admin console, we will come to know the replication polling time, the master instance, the master and slave index statuses and the last iteration replication failures and success details. If we want to disable the polling from the slave, we can use “Disable Polling” button. If we want to replicate the index from master on demand basis, we can use “Replicate Now” button.
If you want more details about Solr replication, you can find here.