Back to home

How to manage Solr in userspace


Solr is an open source enterprise search platform built on Apache Lucene. Its major features include full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, and rich document (e.g., Word, PDF) handling.

Step by step guide

In this guide we show you how to install a single Solr Instance in the ~/solr directory of your user. This instance manage multiple cores with different configurations to be used in different applications. .However by adopting this you can install multiple instances of the same or different Solr versions if required.


  • Ubuntu 16.04 (Xenial)
  • OpenJDK installed on your server.

Install Solr from source

Create the ~/solr directory

To keep everything concerning Solr nice and tidy we create a subdirectory which will contain it all.

mkdir ~/solr

Download Solr

We download the desired Version and unpack it.

export SOLR_VERSION=6.5.0
cd solr
curl -OL${SOLR_VERSION}/solr-${SOLR_VERSION}.tgz
tar xzf solr-${SOLR_VERSION}.tgz
rm solr-${SOLR_VERSION}.tgz

Create default Instance

Create a instance named default. The Solr instance does not know anything about this name but this enables us to run multiple version should we desire to do so.
To simplify further upgrade we use a symlink to point to the Solr version we use.

mkdir -p default/{data,logs}
cd default
ln -s ../solr-${SOLR_VERSION} solr
cp -nv solr/server/solr/{solr.xml,zoo.cfg} data/
cp -nv solr/server/resources/ solr/bin/ .

Setup systemd user service

Create the template for the systemd user service solr-instance@ will give you the solr-instance@default.service to manage the created instance.

mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/solr-instance@.service << EOF
Description=Solr Instance %i of %u

ExecStart=/bin/bash solr/bin/solr start -f
ExecStop=/bin/bash solr/bin/solr stop


With the following command you can start and check your instance.

www-data@server$ systemctl --user enable solr-instance@default.service
Created symlink from /home/www-data/.config/systemd/user/ to /home/www-data/.config/systemd/user/solr-instance@.service.
www-data@server$ systemctl --user start solr-instance@default.service
www-data@server$ systemctl --user status solr-instance@default.service
● solr-instance@demo.service - Solr Instance demo of www-data
   Loaded: loaded (/home/www-data/.config/systemd/user/solr-instance@.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-04-06 07:24:01 CEST; 1s ago
 Main PID: 32403 (java)
   CGroup: /user.slice/user-33.slice/user@33.service/solr\x2dinstance.slice/solr-instance@demo.service
           └─32403 java -server -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGC

Feb 30 07:24:01 server systemd[816]: Started Solr Instance demo of www-data.

To ensure it is started on system boot time you need to enable it.

www-data@server$ systemctl --user is-enabled solr-instance@default.service

Set up a new core

You can set-up your cores within the data directory as you prefer. Solr is looking for any file within this directory at startup and load the described core. Typically each core has its own subdirectory directly under the data directory.
To simplify the configuration of multiple cores configsets can be defined and the referenced by the individual cores instead of duplicating the configuration.

Install a new configset

To install a configset copy it to ~/solr/default/data/configsets. Download the appropriate configset from the Solr integration you use or upload a custom on. As an example we copy the Solr example configsets.

cd ~/solr/default/data
mkdir -p configsets
cp -r ../solr/server/solr/configsets/*  configsets/

Examples for configsets from integrations are:

Create a new core

To create a new core we need to create a new file somewhere in the ~/solr/default/data directory. This example creates a core name core1 using the basic_configs configset.

cd ~/solr/default/data
mkdir core1
cat > core1/ << EOF

To help you with the creation of a correctly configured core most integrations will provide you with examples. For the before mentioned integrations this can be found in the git repository too.

Configuration Changes

The Solr start scripts uses different Environment Variables to change its behaviour and configuration. For example the amount of memory available to Solr, or the Port it listens on can be changed this way.

The contains a list of available Variables and examples. This file is loaded by systemd on each run. Change this file appropriately and restart your Solr instance for the changes to become active.

To change the port modify the following part of the file

# Sets the port Solr binds to, default is 8983

to look like the following.

# Sets the port Solr binds to, default is 8983

After the restart Solr is not listening on Port 8983 but on 8984.

Didn't find what you were looking for?

Contact our support:

+41 44 637 40 40 Support Portal