Setup on any system using Jetty¶
Instead of using Tomcat, you can use Jetty. It comes with Solr so I expect the quality to be at least as good as Solr itself. In over a year of use I have only had to restart the process when I changed my multi-core configuration or when the multiple cores ran out of memory. In the last case I just restarted Jetty, but now with a bit more
Starting a Solr instance¶
When you download and unzip the Solr package, you will find a file called
start.jar inside. You can run this file directly using java:
java -jar start.jar. You either need to be in the directory to run the file or you can pass some extra command line options to java, specifying the path, libs etc.
When you run start.jar it will create a Solr instance on the default port: 8983. That's it. You're up.
Detaching from the jetty process¶
But, you're in a terminal and you're attached to the process. This is nice because you can see all the process output scrolling by. If you want to log out of the session and leave solr running, you can start it
inside a screen session:
cd /var/www/solr/multicore && screen -S java -jar -server -Xmx128M -Dfile.encoding=UTF8 -Djava.headless=True start.jar
Starting Solr when the system starts¶
You can put the following in the rc.local to make it start when the system boots up:
su - your_username -c "cd /var/www/solr/multicore && screen -S java -jar -server -Xmx128M -Dfile.encoding=UTF8 -Djava.headless=True start.jar"
You can do a similar thing for Windows using the task manager. You may have to install cygwin and screen. Hackish, I know. If you don't like it: run Tomcat.
If you are worried about security and run your Solr on another machine
than the one using it, you can close the default port and configure
access to 8983 through another frontend (like Apache) that supports nice
and familiar access control:
<VirtualHost 220.127.116.11:80> ServerName solr.somedomain.com ServerAdmin firstname.lastname@example.org <Directory /> Options -Indexes </Directory> ProxyRequests Off ProxyPreserveHost on ProxyPass / http://127.0.0.1:8983/ ProxyPassReverse / http://127.0.0.1:8983/ <LocationMatch "(/solr/www.someuser.nl/*)"> Order deny,allow Deny from all # www.someuser.nl Allow from 18.104.22.168 </LocationMatch> <LocationMatch "(/solr/www.someuser.nl/admin/ping)"> Order deny,allow Deny from all # www.someuser.nl Allow from 22.214.171.124 </LocationMatch> </VirtualHost>
You can re-attach to the screen any time you like and then detach again.
In my experience, jetty is very robust, the process has only hung up on
me once. The cause was a too low memory setting for the start command.
After fixing that it ran fine again.