pWoz
pWoz

Reputation: 1679

How replication works

Lets say that I have replication on master Solr server configured like this:

<lst name="master">
    <str name="enable">true</str>
    <str name="replicateAfter">optimize</str>

    <str name="confFiles">solrconfig.xml,schema.xml,stopwords.txt,synonyms.xml</str>
    <str name="commitReserveDuration">00:00:10</str>
</lst>

and slave configured like this:

<lst name="slave">
    <str name="enable">true</str>
    <str name="masterUrl">masterSolr</str>
    <str name="pollInterval">24:00:00</str>
</lst>
  1. How slave knows that optimization was performed on master (master know nothing about slaves)?
  2. Does slave checks it every 24 hours (not more often)?
  3. Will replication be performed if there was no optimization but some several commits (on master)?
  4. How to reach a state where slave will do the replication ONLY after optimization (nothing else) and will do it shortly after this optimization (we don't want to wait several hours)?

Upvotes: 0

Views: 260

Answers (1)

Klaus Petersen
Klaus Petersen

Reputation: 301

the replication is a pull mechanism - so to be able to support your scenario you need to do a bit of configuration.

For you questions:
1. it does not - it pulls in intervals (or forced) from master which tells what version is ready to be replicated
2. yes - 24 hours
3. only if an optimize have been done since the last index fetch
4. some configuration and knowledge from master to slave is needed.
You can use the postOptimize update event on the updatehandler to force a repication on slaves

<listener event="postOptimize" class="solr.RunExecutableListener">
      <str name="exe">wget</str>
      <str name="dir">solr/bin</str>
      <bool name="wait">true</bool>
      <arr name="args"> <str> http://slave_host:port/solr/core?/replication?command=fetchindex</str> </arr>

    </listener>

you can then remove the poll interval from the slave config. you need to add multiple args (in str tags) for each slave

Upvotes: 1

Related Questions