Let’s install Solr as a service on Linux. I’m using Ubuntu 11.04
First download the latest version of Solr from (3.3 as of this writing): http://www.apache.org/dyn/closer.cgi/lucene/solr/
Extract the compressed zip or tgz file to where you would like Solr to live.
Currently, I like using runit to run Linux services. http://smarden.org/runit/
Install runit with: sudo apt-get install runit
Create a new service directory.
Create a new shell script called run in the new /etc/sv/solr directory. You will need to have root permission to work in these directories, so use sudo. In this case, I want to run Solr as the user ‘mark’.
Make the run script executable.
Let runit know about the new service.
Now Solr should be up and running. If it dies or you kill it, it will automatically be restarted. If the server is restarted, Solr will be launched on startup.
To stop the service: sudo sv stop solr
To start the service: sudo sv start solr
By default, Solr logs to STD ERROR. You likely want to add a log configuration file to have the most control over how Solr logs – see http://wiki.apache.org/solr/LoggingInDefaultJettySetup. To be lazy though (and perhaps safe), let’s make sure STD OUT and STD ERR are nicely logged for us by runit.
This method just logs STD OUT, so lets first edit our Solr run script to redirect STD ERR to STD OUT
Now create a new directory called log in the /etc/sv/solr service directory. Inside this, create another script called run. This script will start the log service, run it under the user mark, and put the log files in the log directory we just made (we use . for the current working directory).
As we are running as mark, change the owner of the log dir to mark so that the log files can be created: sudo chown mark log
Now make the new run script executable.
The next time runit starts, Solr logs will be logged to the /etc/sv/solr/log/current file and auto rolled for you.
Contact us today to learn how Lucidworks can help your team create powerful search and discovery applications for your customers and employees.