Solr Replication Guide

Opensolr Solr Replication Guide — find answers to your questions

Manual Opensolr Index Replication

Solr replication copies an index from a leader to one or more followers. The followers poll the leader and pull the changed index files after each commit, so they serve the same data, in another region if you want, while you write only to the leader.

The quickest way is built in: Replicate an index sets all of this up for two of your indexes in a few clicks. This page is the same mechanism configured by hand, in solrconfig.xml.
Leader indexyou write herefiles aftereach commitFollower indexpolls and pulls

The follower checks the leader every pollInterval and copies what changed.

01 · On the leader

Open the leader index, click Configuration and add the handler to solrconfig.xml (edit a file):

<requestHandler name="/replication" class="solr.ReplicationHandler">
  <lst name="leader">
    <str name="replicateAfter">startup</str>
    <str name="replicateAfter">commit</str>
    <str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
  </lst>
</requestHandler>

replicateAfter: when the leader offers a new version, after startup and after each commit.

confFiles: configuration files copied along with the data. Leave solrconfig.xml out: the follower needs its own.

02 · On the follower

In the follower index, add:

<requestHandler name="/replication" class="solr.ReplicationHandler">
  <lst name="follower">
    <str name="leaderUrl">https://LEADER_HOST/solr/LEADER_INDEX</str>
    <str name="pollInterval">00:00:20</str>
    <str name="httpBasicAuthUser">LEADER_USERNAME</str>
    <str name="httpBasicAuthPassword">LEADER_PASSWORD</str>
  </lst>
</requestHandler>

leaderUrl: the address of the leader index, https:// + the Host on its Info tab + /solr/ + its name (address and login).

pollInterval: how often the follower checks for changes, as HH:MM:SS.

httpBasicAuthUser and httpBasicAuthPassword: the username and password of the leader index (HTTP Basic Auth).

Solr 9 and newer use leader, follower and leaderUrl, and Solr 10 accepts only those. On older versions write master, slave and masterUrl instead. Opensolr writes the same pairs when it sets up replication for you.

03 · Let the two indexes reach each other

On the leader, allow the follower's server on the /replication handler, in the Security tab under IP Restriction. Find its address with ping FOLLOWER_HOST.

Do the same on the follower for the leader's server.

Keep schema.xml identical on both indexes. A mismatch makes replication fail or the results differ.

04 · Check that it works

Save both files (each save reloads its index), then ask the follower for its replication status:

curl -u "FOLLOWER_USERNAME:FOLLOWER_PASSWORD" "https://FOLLOWER_HOST/solr/FOLLOWER_INDEX/replication?command=details&wt=json"

An error that says the leader is not available has its own page: Leader not available.

Replication

Manual index replication: leader and follower (this page)

Read Full Answer

Solr Replication Repeater - Leader Repeater and Followers

A repeater is an index that follows a leader and is, at the same time, the leader of its own followers. One leader feeds the repeater, and the repeater feeds the rest, so the leader serves one copy instead of many.

Leaderyou write hereRepeaterfollows, then leadsFollowerspull from the repeater

The leader serves one copy, the repeater serves the followers.

01 · When it helps

Many followers would otherwise all poll the same leader.

The followers are in another region: one copy crosses the distance, the rest stay local.

A large index where every extra copy from the leader costs time and bandwidth.

02 · The repeater's solrconfig.xml

One replication handler with both blocks: it follows the leader and offers what it receives.

<requestHandler name="/replication" class="solr.ReplicationHandler">
  <lst name="follower">
    <str name="leaderUrl">https://LEADER_HOST/solr/LEADER_INDEX</str>
    <str name="pollInterval">00:00:30</str>
    <str name="httpBasicAuthUser">LEADER_USERNAME</str>
    <str name="httpBasicAuthPassword">LEADER_PASSWORD</str>
  </lst>
  <lst name="leader">
    <str name="replicateAfter">commit</str>
    <str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
  </lst>
</requestHandler>

03 · The followers

Each follower points leaderUrl at the repeater instead of the leader, with the repeater's username and password. The follower block itself is the one from manual index replication.

04 · Rules that keep the chain healthy

The same schema.xml on the leader, the repeater and every follower.

IP rules at every link: the leader allows the repeater on /replication, the repeater allows its followers (IP Restriction).

A slightly longer pollInterval on the repeater than on its followers.

Every extra hop adds delay before a change reaches the last follower. Keep the chain short.

Solr 9 and newer use leader / follower / leaderUrl; older versions use master / slave / masterUrl.

05 · Example

RoleIndexPulls from
Leadercatalognobody: you write here
Repeatercatalog_eucatalog
Followercatalog_ukcatalog_eu
Followercatalog_decatalog_eu

Replication

Replication repeater: leader, repeater and followers (this page)

Read Full Answer