Install and use Solr 5 in GNU Linux for CKAN - ckan/ckan GitHub Wiki
In this tutorial we are going to install Solr 5 on our server (no compilation required!) and set up a core for CKAN.
Solr 5 comes with a nice script for install the package in the system, it detect the OS and eventually creates the solr user for the daemon.
Go to the Apache Solr website and download Solr5, in this tutorial we are going to use the .zip
format, but it works with .tgz
as well.
Download the package from the web and put it somewhere in your file-system, we are going to use the installer soon
wget https://archive.apache.org/dist/lucene/solr/5.3.1/solr-5.3.1.zip
when the download is finished, unzip the package and go to the bin
directory
unzip solr-5.3.1.zip
cd solr-5.3.1/bin
as root
, we need to create the install directory and execute the file install_solr_service.sh
. This script accepts arguments if we need to install the daemon to listen ad different port or with another user.
Usage: install_solr_service.sh path_to_solr_distribution_archive OPTIONS
The first argument to the script must be a path to a Solr distribution archive, such as solr-5.0.0.tgz
(only .tgz or .zip are supported formats for the archive)
Supported OPTIONS include:
-d Directory for live / writable Solr files, such as logs, pid files, and index data; defaults to /var/solr
-i Directory to extract the Solr installation archive; defaults to /opt/
The specified path must exist prior to using this script.
-p Port Solr should bind to; default is 8983
-s Service name; defaults to solr
-u User to own the Solr files and run the Solr process as; defaults to solr
This script will create the specified user account if it does not exist.
NOTE: Must be run as the root user
If we want to install everything to /opt/solr5
mkdir /opt/solr5
install_solr_service.sh ../../solr-5.3.1.zip -i /opt/solr5
note that we use the .zip
file as argument to the script, change the path if you need.
Now the script installs the binaries under /opt/solr5
, it puts the init script under /etc/init.d/solr
and eventually create the solr
user.
As root, switch to the solr
user and go to the bin
directory
su solr
cd /opt/solr5/solr5/bin
now create the ckan
core
./solr create -c ckan
solr creates all the configuration files and directories. At this point, we can see the core listed in our solr admin http://localhost:8983/solr and we can proceed to edit the configuration files
cd /var/solr/data/ckan/conf
open solrconfig.xml
and uncomment the followin line
<schemaFactory class="ClassicIndexSchemaFactory"/>
and remove
<schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
<str name="managedSchemaResourceName">managed-schema</str>
</schemaFactory>
delete this element too
<initParams path="/update/**">
<lst name="defaults">
<str name="update.chain">add-unknown-fields-to-the-schema</str>
</lst>
</initParams>
and this
<processor class="solr.AddSchemaFieldsUpdateProcessorFactory">
<str name="defaultFieldType">strings</str>
<lst name="typeMapping">
<str name="valueClass">java.lang.Boolean</str>
<str name="fieldType">booleans</str>
</lst>
<lst name="typeMapping">
<str name="valueClass">java.util.Date</str>
<str name="fieldType">tdates</str>
</lst>
<lst name="typeMapping">
<str name="valueClass">java.lang.Long</str>
<str name="valueClass">java.lang.Integer</str>
<str name="fieldType">tlongs</str>
</lst>
<lst name="typeMapping">
<str name="valueClass">java.lang.Number</str>
<str name="fieldType">tdoubles</str>
</lst>
</processor>
remove managed-schema
and copy the schema.xml
from ckan
rm managed-schema
cp /somewhere/over/the/rainbow/ckan/conf/solr/schema.xml .
and restart solr
/etc/init.d/solr restart
For CKAN 2.8+, update the solr_url
solr_url = http://127.0.0.1:8983/solr/ckan/