-
Notifications
You must be signed in to change notification settings - Fork 1
How To Install Apache Solr on Red Hat
The following instructions show how to install and configure the Apache Solr search platform for CKAN on Red Hat Linux. The standard documentation for setting up Solr when installing CKAN on Ubuntu 10.4 uses the Java JDK and jetty to power Solr. The instructions below use the Java JDK with Tomcat instead.
CKAN uses customized schema files that take into account its specific search needs. Different versions of the schema file for Solr are found in the ckan/ckan/config/solr
directory of the ckan codebase. Solr can also be set up with multiple Solr cores to support multiple configurations and indexes on the same instance. This is specially useful when you want other applications than CKAN or different CKAN versions to use the same Solr instance. The instructions here set up two Solr cores to support both schema-1.3.xml for CKAN and schema-1.4.xml (the current latest version). As new CKAN schemas are introduced in the future (e.g., schema-1.5), you will want to modify these instructions accordingly.
yum remove java yum install java-1.6.0-openjdk yum install java-1.6.0-openjdk-devel
sudo yum install -y tomcat6
Install Solr 1.4.1 and create a directory at /data/solr
which will contain the configuration and data for your Solr cores. Tomcat needs to be the owner of /data/solr
and its contents.
cd /usr/src/ curl http://mirror.lividpenguin.com/pub/apache/lucene/solr/1.4.1/apache-solr-1.4.1.tgz | tar xfz - mkdir -p /data/solr cp -R apache-solr-1.4.1/example/solr/* /data/solr cp apache-solr-1.4.1/dist/apache-solr-1.4.1.war /data/solr/solr.war chown -R tomcat /data/solr/
Create a solr.xml file for Catalina localhost.
vi /etc/tomcat6/Catalina/localhost/solr.xml
The contents of the solr.xml file should be:
<Context docBase="/data/solr/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/data/solr" override="true" /> </context>
mkdir -p /usr/share/tomcat6/common/endorsed cd /usr/share/tomcat6/common/endorsed/ ln -s /usr/share/java/xalan-j2.jar xalan-j2.jar
/etc/init.d/tomcat6 start
mkdir -p /data/solr/cores cp /usr/src/apache-solr-1.4.1/example/multicore/solr.xml /data/solr/ mkdir -p /data/solr/cores/core0/conf mkdir -p /data/solr/cores/core1/conf
This default setup will use the following locations in your file system:
- /data/solr: Solr home, with a symlink pointing to the configuration dir in /etc.
- /data/solr/conf: Solr configuration files. The more important ones are schema.xml and solrconfig.xml.
- /data/solr/cores: Solr Multiple core for schema-1.3.xml and schema-1.4.xml
- /data/solr/cores/core0 : for Latest Ckan instance using schema-1.4.xml
- /data/solr/cores/core1 : for Ckan instance using schema-1.3.xml
Each core needs to be configured with its own data directory. This is really important to prevent conflicts between cores. The following commands create the data directories for core0 and core1:
mkdir -p /var/lib/solr/data/core0 chown tomcat /var/lib/solr/data/core0 chgrp tomcat /var/lib/solr/data/core0 mkdir -p /var/lib/solr/data/core1 chown tomcat /var/lib/solr/data/core1 chgrp tomcat /var/lib/solr/data/core1
Populate the core directories by copying /data/solr/conf
into each subdirectory of /data/solr/cores
, and then add a data
directory.
for i in `ls /data/solr/cores`; do cp /data/solr/conf /data/solr/cores/$i/ -r; done for i in `ls /data/solr/cores`; do mkdir /data/solr/cores/$i/data; done
Copy CKAN schemas to replace the schema.xml
files for each core. The lines below set up versions 1.3 and 1.4. To set up other schema versions, you would modify the instructions below accordingly:
cp ~/pyenv/src/ckan/ckan/config/solr/schema-1.3.xml /data/solr/cores/core1/conf/schema.xml cp ~/pyenv/src/ckan/ckan/config/solr/schema-1.4.xml /data/solr/cores/core0/conf/schema.xml
Change ownership and group of the schema.xml files:
chown tomcat /data/solr/cores/core1/conf/schema.xml chgrp tomcat /data/solr/cores/core1/conf/schema.xml chown tomcat /data/solr/cores/core0/conf/schema.xml chgrp tomcat /data/solr/cores/core0/conf/schema.xml
Restart Tomcat:
/etc/init.d/tomcat6 restart
vi /data/solr/solr.xml
<cores adminPath="/admin/cores"> <core name="ckan-schema-1.4" instanceDir="cores/core0"> <property name="dataDir" value="/data/solr/cores/core0" /> </core> <core name="ckan-schema-1.3" instanceDir="cores/core1"> <property name="dataDir" value="/data/solr/cores/core1" /> </core> </cores>
Take note of the value, and make sure that the directory is the right path. In the XML above, the "dataDir" property specifies that the data directory for CKAN schema 1.4 is in the directory at path /data/solr/cores/core0
, and the directory for schema 1.3 is in the directory at path /data/solr/cores/core1
.
Now configure the core to use the data directory you have created. Edit files /data/solr/cores/core0/conf/solrconfig.xml
and /data/solr/cores/core1/conf/solrconfig.xml
to change the <datadir></datadir> element to this variable:
<dataDir>${dataDir}</datadir>Set Perms
chown -R tomcat /data/solr/Restart TomCat
/etc/init.d/tomcat6 restart
vi ~/pyenv/src/ckan/development.iniUncomment solr_url and set it to the correct URL to enable Solr support, e.g.,
solr_url = http://ec2-23-20-243-151.compute-1.amazonaws.com:8080/solr/ckan-schema-1.4
If you have disabled Solr by setting ckan.simple_search = 1, you should comment out that line:
# ckan.simple_search = 1
If you are adding Solr to an already-existing CKAN installation, you should now activate the python environment and restart the web server. Otherwise, if you are installing Solr as part of the setup of a new CKAN installation, proceed by creating a CKAN config file and complete the rest of the installation process.
cd ~ . pyenv/bin/activate cd ../../src/ckan paster serve development.ini
- Setting up Solr instructions in the CKAN documentation