The SOLR replication mode is an implementation method used to synchronize master-slave servers in a distributed environment. Because the deployment cost of the rsync-based SOLR is too high, replaced by solr1.4, it is replaced by an HTTP-based index file transfer mechanism. This method is easy to deploy and requires only one file.
The procedure is as follows:
The steps are divided into the master server and slave server. Multiple slave servers are allowed, that is, the configuration of the slave server is the same.
Master Server:
In solrconfig. XML, find the following line:
<Requesthandler name = "/replication" class = "SOLR. replicationhandler">
- <Lst name = "master">
- <STR name = "replicateafter"> commit </STR>
- <STR name = "conffiles"> schema.xml,stopwords.txt, elevate. xml </STR>
- <STR name = "commitreserveduration"> 00:05:00 </STR>
- <STR name = "httpbasicauthuser"> 123 </STR>
- <STR name = "httpbasicauthpassword"> 123 </STR>
- </Lst>
- </Requesthandler>
Note:
- Replicateafter: SOLR will perform a copy after the following operations occur: 'commit ', 'startup' 'optimize'. Here we choose commit, that is, after SOLR receives a commit request every time, the replication policy is executed.
- Conffiles: the configuration file to be distributed. SOLR also synchronizes the field configuration files schema.xmland stopwords.txt on the master server, and the solid partition file: elevate. XML to the slave server.
- Commitreserveduration: the cycle time for retaining the incremental index after each commit. Set this parameter to 5 minutes.
Slave Server
<Requesthandler name = "/replication" class = "SOLR. replicationhandler">
- <Lst name = "slave">
- <STR name = "masterurl"> http: // localhost: Port/SOLR/corename/replication </STR>
- <STR name = "pollinterval"> 00:05:00 </STR>
- <STR name = "compression"> internal </STR>
- <STR name = "httpconntimeout"> 5000 </STR>
- <STR name = "httpreadtimeout"> 10000 </STR>
- <STR name = "httpbasicauthuser"> 123 </STR>
- <STR name = "httpbasicauthpassword"> 123 </STR>
- </Lst>
- </Requesthandler>
Note:
- Masterurl: synchronization URL of the master server
- Pollinterval: The slave server synchronization interval, that is, the interval at which the master server Synchronizes time.
- Httpconntimeout: sets the connection timeout (unit: milliseconds)
- Httpreadtimeout: If the synchronization index file is too large, increase this value as appropriate. (Unit: milliseconds)
- Httpbasicauthuser: the authentication username, which must be consistent with the master server
- Httpbasicauthpassword: The verification password, which must be consistent with the master server
- Compression: external or internal uses SOLR's own compression algorithm or application container's
Difference: the internal algorithm will greatly increase the synchronization cost. original statement: use this only if your bandwidth is low. This can actually slowdown replication in a LAN.
Therefore, we recommend that you use the external method: external.
At the same time, you need to configure the external application container: Take Tomcat as an example:
- <Connector compression = "on"
- Compressablemimetype = "text/html, text/XML, text/plain"
- Compressionminsize = "2048" type = "parmname" text = "parmname"/>