SOLR and. NET Series courses (vi) SOLR timing incremental indexing and security
The way that SOLR increments the index is an HTTP request, but the request obviously does not meet the requirements, we need an automatic incremental index, SOLR officially provides a timer instance to complete the incremental index,
First download apache-solr-dataimportscheduler-1.0.jar,:http://solr-dataimport-scheduler.googlecode.com/files/ Apache-solr-dataimportscheduler-1.0.jar
Official address can not be accessed, please click on this Http://pan.baidu.com/s/1pJt3KZD
Start configuration below
1. Copy Apache-solr-dataimportscheduler-1.0.jar to C:\Program Files\apache software Foundation\tomcat 7.0\webapps\solr\ Web-inf\lib (C:\Program files\apache software foundation\tomcat 7.0 for TOMCAT installation path)
2. Modify the Web. xml file under C:\Program Files\apache software foundation\tomcat 7.0\webapps\solr\web-inf to increase in front of the servlet node
< Listener > < Listener-class > org.apache.solr.handler.dataimport.scheduler.ApplicationListener </ Listener-class> </listener>
3. Remove the dataimport.properties from the Apache-solr-dataimportscheduler-.jar and put it in C:\Program Files\apache software Foundation\ Tomcat 7.0\solr\conf, no conf create a new
4. Restart Tomcat
Dataimport.properties Configuration Item Description
################################################## # # DataImport S Cheduler Properties # # ############################################# ###### to sync or not to sync# 1-active; Anything else-inactivesyncenabled=1# which cores to schedule# in a multi-core environment can decide which cores y ou want syncronized# leave empty or comment it out if using Single-core deploymentsynccores=game,resource# SOLR server n Ame or IP address# [defaults to localhost if empty]server=localhost# solr server port# [defaults to + if empty]port=80 80# application name/context# [defaults to current Servletcontextlistener ' s context (APP) name]webapp=solr# URL params [mandatory]# remainder of Urlparams=/select?qt=/dataimport&command=delta-import&clean=false&commit=true# Schedule interval# number of minutes between both runs# [defaults to If empty]interval=1# re-indexing interval, in minutes, Default 7200, i.e. 1 days; # is empty, 0, or commented out: A parameter that never re-indexes rebuildindexinterval=2# indexes Rebuildindexparams=/select?qt=/dataimport&command=full-import&clean=true&commit=true# The timing start time of the redo index interval, the first time to actually execute =rebuildindexbegintime+rebuildindexinterval*60*1000;# two formats: 2012-04-11 03:10:00 or 03:10:00, the latter one automatically complements the date part as the date when the service was started rebuildindexbegintime=03:10:00
The above is the original, #后面的是注释, let's translate
################################################## # # DataImport Scheduler Properties # # ############## ################################### #syncEnabled =1# The core of the incremental index to be timed, multi-core comma-separated collection1, collection2synccores= collection1# This, needless to say, the server address server=192.168.0.9port=8080webapp=solr# the command executed by the incremental index params=/dataimport?command= Delta-import &clean =false& Commit =true #多长时间执行一次, default unit minutes interval=30# below, is someone changed the file, the newly added timed rebuild index, The original package is not time-rebuilt index, only the incremental index, the official package is not supported by the following three sentences, do not need to delete rebuildindexinterval=7200rebuildindexparams=/dataimport?command= Full-import &clean =true& Commit =truerebuildindexbegintime=03:10:00
If you search other articles, you will see someone said that the official package has a bug, because the official submitted by post, but I have been tested, the official can use, the above in my project can be normal use.
Refer to the following article if you want to learn more about adding timing from the original package to the index, and the bug in the package http://www.denghuafeng.com/post-242.html
Well, when the above work is done, your SOLR will be able to index incrementally on a regular basis,
Let's take a look at SOLR security issues
Knowing SOLR, as everyone knows, SOLR does all the work through HTTP requests, and that's the problem, if someone knows the address of your SOLR server is very dangerous, and Solr's additions and deletions are all done via HTTP requests, after the address burst, Your data will be vulnerable to attack. My solution here is to set up tomcat access, which can only be accessed by a fixed IP so that no one else will be able to access your SOLR.
Modify C:\Program files\apache software foundation\tomcat 7.0\conf\server.xml, add IP restrictions
Global settings, valid for all apps under Tomcat
Add the following line to the Server.xml and restart the server:
<valve classname= "Org.apache.catalina.valves.RemoteAddrValve" allow= "192.168.1.*" deny= "/> This line on
Cases:
1, only allow 192.168.1.10 access:
<valve classname= "Org.apache.catalina.valves.RemoteAddrValve" allow= "192.168.1.10" deny= "/>
2, only allow 192.168.1.* network segment access: <valve classname= "Org.apache.catalina.valves.RemoteAddrValve" allow= "192.168.1.*" deny= "" />
3, only allow 192.168.1.10, 192.168.1.30 visit <valve classname= "Org.apache.catalina.valves.RemoteAddrValve" allow= "192.168.1.10,192.168.1.30" deny= ""/>
4, limit by hostname:
<valve classname= "Org.apache.catalina.valves.RemoteHostValve" allow= "abc.com" deny= ""/>
SOLR and. NET Series courses (vi) SOLR timing incremental indexing and security