Skip to content

Instantly share code, notes, and snippets.

@hvwaldow
Last active November 4, 2016 21:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hvwaldow/67fecf80a9790b5c9153 to your computer and use it in GitHub Desktop.
Save hvwaldow/67fecf80a9790b5c9153 to your computer and use it in GitHub Desktop.
How to upgrade to SOLR 5.3.1 on Debian jessie for use with CKAN

Disclaimer

This is without any reasonable idea about SOLR configuration. It just happens to work here. It is also specific to my server, you might severly damage yours if you copy & paste this blindly!

All commands to be executed as root.

Remove Debian packaged solr 3.6.2 and jetty8

apt-get remove --purge solr-common

This also removes the index. I want to re-index anyway.

apt-get remove --purge jetty8    
rm -rf /var/lib/jetty8
apt-get autoremove

The last line removes also java here. I want this because I also update java.

Install java-1.8 and solr 5.3.1

Add this line to /etc/apt/sources.list if not already present:

deb http://ftp.de.debian.org/debian/ jessie-backports main
apt-get update
apt-get install openjdk-8-jre-headless
apt-get install unzip     #This apparently needed for installation

In a temporary directory: (follow instructions on in solr 5.4 docu)

wget http://www.eu.apache.org/dist/lucene/solr/5.3.1/solr-5.3.1.tgz
tar zxvf solr-5.3.1.tgz solr-5.3.1/bin/install_solr_service.sh --strip-components=2
sudo bash ./install_solr_service.sh solr-5.3.1.tgz    #using default installation into /opt

service solr status   #Should show its up and running

Check also http://<hostname>:8983/solr whether you see the admin-interface.

Minimum configuration

Edit /var/solr/solr.in.sh
I just add SOLR_JAVA_MEM="-Xms2g -Xmx2g"for a little more RAM.

CKAN configuration

This was the trickier part because the config file layout is not well documented. Presumably you should figure out what all the files mean and edit them accordingly. The default used here just happens to work here.

mkdir /var/solr/data/ckan1    "ckan1" is an arbitrary name for the (single) solr-"core"
touch /var/solr/data/ckan1/core.properties
cp -a /opt/solr/server/solr/configsets/basic_configs/conf /var/solr/data/ckan1
mv /var/solr/data/ckan1/conf/schema.xml /var/solr/data/ckan1/conf/schema.xml.orig
ln -s /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml /var/solr/data/ckan1/conf/schema.xml
chown -R solr:solr /var/solr

# restart solr
service solr restart

The admin interface http://<hostname>:8983/solr should now indicate that core "ckan1" is available.

CKAN config / re-index

In the init-file, set

solr_url = http://127.0.0.1:8983/solr/ckan1

# Become user `ckan` (might be different for you)
su ckan

# activate virtualenv 
source /usr/lib/ckan/default/bin/activate

cd /usr/lib/ckan/default/src/ckan/ckan
paster search-index rebuild -c /etc/ckan/default/production.ini    #your init-file might be another one.

# As root, restart the httpd
exit
systemctl restart apache2

@yunderboy
Copy link

Cool man, I've been stuck with this problem for 2 days now...
Thanks

@sovello
Copy link

sovello commented Aug 3, 2016

So useful!
Gracias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment