The issue was probably with solr, since we had modified solrconfig initially and later even solr.xml (of solr) in the process of trial and error.
So, I did the whole thing again from ground zero. This time I referred another, rather relevant How-To
In sort, the mistake I made was to make changes to solr. Don't do that!
Solr Tomcat Wiki suggests: "Solr4.3 requires completely different deployment. These instructions are not current and are for an indeterminate version of Solr."
With wiki you tend to click on the index and miss fine print! I had referred it, therefore messed with working solr (lucky I had taken a back-up).
From the How-To I referred, I learned following things:
1 Don't make changes to a working solr config (i.e. run solr from jetty to check if it starts up fine)
2 Get tomcat up and running prior to adding solr in to it. (run both independently. Stop both the service if you are satisfied that both are fine)
3 Let's say solr path is /usr/local/solr-4.x, then copy solr-4.x.war from /usr/local/solr-4.x/dist/solr-4.x.x.war to /usr/local/solr-4.x/example/solr/solr.war . That's all you need to do in the solr directory. Rest, you need to take few files from solr directory in to tomcat directory (pt. 6)
4 Modify tomcat's server.xml and make sure you have URIEncoding in it:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
5 Create solr.xml in tomcat's conf : vim /usr/local/tomcat/conf/Catalina/localhost/solr.xml add following lines:
<Context path="/solr" docBase="/usr/local/solr/example/solr/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/usr/local/solr/example/solr" override="true"/>
</Context>
note: solr cores are under the path: /usr/local/solr/example/solr/core{0,1,..n}
6 Copy Solr extensions files and log4j configuration file to tomcat:
cp -v /usr/local/solr/example/lib/ext/* /usr/local/tomcat/lib/
cp -v /usr/local/solr-oncars/example/resources/log4j.properties /usr/local/tomcat/conf/
For the rest, cross-check with the 'How-To'
In the end, grant tomcat ownership to solr and tomcat directories (if tomcat run as user/group 'tomcat'):
chown -R tomcat:tomcat /usr/local/tomcat
chown -R tomcat:tomcat /usr/local/solr
Start up tomcat and access the solr-url, it worked!
Solr can handle multiple requests at a time.
I have tested it by running a long query [qTime=7203, approx. 7sec] and several small-queries-after the long-one [qTime=30], Solr responds for smaller queries first, even if they ran after the long-query.
This point gives much reason in answer: Use single solr instance with multiple core. Just assign High memory to JVM.
Other Points:
1. Each solr instance will require RAM, so running multiple instances will require more resources, which will be expensive. And if you are using facets
, sort fields
then you need to allocate more RAM to each instance.
As you can see in my case I need to start the solr with high memory(8GB). You can see a case for Danish Web Archive, Which uses multiple instances and allocated 9GB RAM to each with cumulative 256GM total RAM.
2. You can run multiple instances of solr on different PORTS by using the command java -Djetty.port=8984 -jar start.jar
. Everything ran ok BUT I got one problem.
While indexing it may give "not enough memory error" and then solr instance will be killed. So you need to start second instance with high memory, which will lead to more RAM requirement.
3. Solr Resource Requirement and Performance Problem can be understand here. According to this 64bit environment and 12GB RAM is recommended for good performance. Solr Optimization are explained here.
Best Answer
At Websolr, we use a combination of a custom
init.d
script plus Monit to start Solr and ensure that it stays running.That said, for a simpler self-hosted setup, I would recommend using Upstart to start and stop Solr, if your system has Upstart available. Upstart scripts have the benefit of being fairly simple, and Upstart does a good job restarting processes in the event they crash. Plus the start and stop commands (
start
andstop
, respectively) are pretty easy to remember for the next time you need to make Solr aware of new configs.Here is a good blog post covering starting Solr with Upstart. I've copied their upstart script below; be sure to update the relevant paths to match your system: