Master Slave Replication in Solr

We use SOLR a lot for searching. Now to reduce the workload of system we do replication as a Master and Slave where the complete copy of a master is copied over to one or more slave.

The intention of using Master-Slave Configuration is that we want one system to completely do the indexing i.e. if any new documents comes in it will be added by the Master and once done slave will show it to the User by getting the updated list from the master. All queries or the result are handled by the slaves.

To start with the Master-Slave Replication you need atleast 2 system where one acts as a master and one as a slave. You can have more than one slave too, which all the slaves will act as a query processing server.

The configuration of the server is rather simple where you need to add the replication request handler as shown below in solrconfig.js.

<requestHandler name="/replication" class="solr.ReplicationHandler" >
    <lst name="master">
        <str name="enable">true</str>
        <str name="replicateAfter">commit</str>
        <str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
        <str name="commitReserveDuration">00:00:20</str>
        <str name="backupAfter">optimize</str>
     </lst>
     <lst name="slave">
        <str name="enable">false</str>
        <str name="masterUrl">MASTER_URL/replication</str>
        <str name="pollInterval">00:00:60</str>
        <str name="compression">internal</str>
        <str name="httpConnTimeout">5000</str>
        <str name="httpReadTimeout">10000</str> 
     </lst>
  </requestHandler>

If it is a master make <str name="enable"></str> true and when it is slave it should be true. We want the replication should be done after all the files are indexed that's why it is replication after commit. In the confFiles you need to write what all the files which you want to replicate. Here we are keeping schema.xml,stopwords.txt and elevate.xml.

In the slave we have to say which is the Master URL and what is the poll interval of finding the new documents from the master.

That way you can create Master-Slave configuration and thus the load is balanced between two system and not one.



Posted on Utopian.io - Rewarding Open Source Contributors

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Logo
Center