Prerequisites

      Installation

      Configuration

      Create a core

      Delete a core

      Firewall the ports

Prerequisites

Install java and some utilities.

apt-get install default-jre-headless unzip lsof curl

Installation

Download the tarball from http://lucene.apache.org/solr/ and unpack it in /opt/, symlinking it to /opt/solr.

lrwxrwxrwx 1 root root   11 Oct  1 08:23 solr -> solr-5.3.1/
drwxr-xr-x 9 root root 4.0K Oct  1 08:23 solr-5.3.1
-rw-r--r-- 1 root root 129M Oct  1 08:23 solr-5.3.1.tgz
-rw-r--r-- 1 root root   57 Oct  1 08:24 solr-5.3.1.tgz.sha1

Then symlink /opt/solr/bin/solr to /usr/local/bin/solr.

Configuration

If you now try to start it as a normal user who wants its own instance, it will die, because it will try to write files (log, pids, indexes) in directories which belong to root.

So create a dedicated directory under $HOME and do:

mkdir -p $HOME/solr/{solr,pids,logs}
cp /opt/solr/server/solr/solr.xml $HOME/solr/solr
export SOLR_LOGS_DIR=$HOME/solr/logs
export SOLR_PID_DIR=$HOME/solr/pids
export SOLR_HOME=$HOME/solr/solr
export SOLR_PORT=9213
solr start
solr status

You can also pack the setting in a file and export SOLR_INCLUDE=/path/to/setting/file instead.

This way you can set the log dir, the pid dir, the data directory and the port.

Create a core

Let's assume you want a core named mysite.

solr create_core -c mysite -d sample_techproducts_configs -p 9213

Then update the schema.xml found in $HOME/solr/solr/mysite/conf/schema.xml with your definitions.

You can also provide to the -d switch a directory with your configuration.

Pass the -p option if you have more solr instance, for some reason create_core seems to ignore the SOLR_PORT environment variable.

The solr_url to pass to modules like WebService::Solr will become: http://localhost:9213/solr/mysite

Delete a core

solr delete -c mysite

Firewall the ports

By default, solr listen to all the interfaces, so be sure to firewall them once finished.