Running Solr as a Service on Linux

Let’s install Solr as a service on Linux. I’m using Ubuntu 11.04 First download the latest version of Solr from…

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

Great.

Logging

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.

 

 

You Might Also Like

From search company to practical AI pioneer: Our vision for 2025 and beyond

CEO Mike Sinoway shares insights on AI's future, introducing Commerce Studio™ and...

Read More

When AI Goes Wrong: Real-World Fails and How to Prevent Them

Don’t let your AI chatbot sell a $50,000 Tahoe for $1! This...

Read More

Lucidworks Core Packages: Industry-Optimized AI Search & Personalization Solutions

Discover our comprehensive Core Packages that combine Analytics Studio, Commerce Studio, and...

Read More

Quick Links