Apache Solr is the open source enterprise search platform from the Apache Lucene™ project. Solr is written in Java and runs as a standalone full-text search server within a servlet container such as Jetty. In the next lines we’ll make a master-slave replication so the slave can process all user queries while the master is being updated. You can find more information about Solr Replication here.
Setting up the master
We will start with making a copy of the example Solr setup which is located in the “example/” folder.
By default there’s only one core named “collection1”. Let’s give our master core more propriety name. We’ll name it “project-master” and edit the core’s configuration file which is located in master/solr/solr.xml.
You should update the file so the cores section look like this:
<core name="project-master" instanceDir="project-master" />
</cores>
Let’s rename the default “collection1” core to “project-master”.
We are ready to configure the “project-master” core.
You should find the Solr Replication section and make it look like this:
<lst name="master">
<str name="replicateAfter">startup</str>
<str name="replicateAfter">commit</str>
<str name="confFiles">schema.xml,stopwords.txt,elevate.xml</str>
<str name="commitReserveDuration">00:00:10</str>
</lst>
<str name="maxNumberOfBackups">1</str>
</requestHandler>
The master is now configured.
Setting up the slave
We must repeat almost the same process of setting the master but with slightly changes. Let’s make a copy of the example Solr setup again. This time we’ll use it for our slave server.
We’ll rename the default core like we’ve done it when configuring the master so instead of “collection1” we will name our core “project-slave”.
You should update the file so the cores section look like this:
<core name="project-slave" instanceDir="project-slave" />
</cores>
Let’s rename the default “collection1″ core to “project-slave”.
It’s time to configure the “project-slave” core.
You should find the Solr Replication section and make it look like this:
<lst name="slave">
<str name="masterUrl">http:⁄⁄localhost:8983/solr/project-master/replication</str>
<str name="pollInterval">00:00:20</str>
<str name="compression">internal</str>
<str name="httpConnTimeout">5000</str>
<str name="httpReadTimeout">10000</str>
</lst>
</requestHandler>
The slave is now configured, too.
Starting the replication
Enter the master directory and start the master using the following command:
If everything is OK, you should see the following message: INFO:oejs.AbstractConnector:Started SocketConnector@0.0.0.0:8983
We’ll use different port for the slave so enter its directory and run the following command:
If everything is OK, you should see the following message: INFO:oejs.AbstractConnector:Started SocketConnector@0.0.0.0:8181
You should be able to check the status of the replicaton using the following URLs:
Master: http://localhost:8983/solr/#/project-master/replication
Slave: http://localhost:8181/solr/#/project-slave/replication