Master Slave Replication in Solr

in utopian-io •  7 years ago 

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

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hi.. I've nominated you for bnw challenge, in my today's blog..

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Isn't there a chance that the Master might become the bottleneck in the system? The problem with master-slave replication for me is that it only scales reads. I always try to go Master-Master for the cost of more messages.

I was thinking of doing the same but I will keep Slave too. I was thinking of creating Master-Master using Sharding and then I will also keep Replication with Slave in-place. I don't want my queries to get slower because of indexing documents.

Yeah, when you do sharding indexing can get ugly, that's why I always did full replication until now, disk space is rarely a bottleneck.
I would only go for sharding if I'd have geographical distribution and it makes sense to store the relevant user data closer to the end user.

That's absolutely true...this is where the SolrCloud has an advantage. It does the Replication and Sharing very nicely, just that you need

Hey @codingdefined I am @utopian-io. I have just upvoted you!

Achievements

  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

Get Noticed!

  • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x