XC Solr

Last updated on
30 April 2025

Running Solr in special way

If you have the great Apache Solr Search module installed, and you would like to use our XC Drupal Toolkit module, you should set up a second Solr instance. This is not a hard task, but we should learn the meaning and usage of three necessary parameters. In this section we are using the Jetty servlet container, which comes with the Solr package. These parameters are relevant in other cases, but the way you should setup could be different.

To run Solr on different port than the standard one (which is 8983) use the jetty.port parameter, for example:

-Djetty.port=8984

If you want Solr to use a different index, than the standard port (which is solr/data) use the solr.data.dir parameter, for example:

-Dsolr.data.dir=./solr/data4xc_records

If you want Solr to use different configurations, than the standard one (which take place in solr/conf directory) use the solr.solr.home parameter, but make sure that you have the configuration directory inside the new Solr home directory. For example:

-Dsolr.solr.home=/users/xc_user/solr

With this parameters you can run multiple Solr instances in parallel. Example:

java start.jar
java -Dsolr.data.dir=./solr/data4xc_records -Djetty.port=8984 -Dsolr.solr.home=/users/xc_user/solr start.jar

With this way you can use the command line to run Solr instances, but there are other more robust ways to accomplish this by modifying Jetty's configuration files. For more information about the topic, please consult the Solr wiki: http://wiki.apache.org/solr/SolrJetty, or in the case you use a different servlet container: http://wiki.apache.org/solr/SolrInstall.

To help ourselves in starting/stopping Solr, we will use scripts to handle this.

solr.sh:

#!/bin/sh
#
# chkconfig: - 80 45
# description: Starts and stops Solr

start() {
        echo -n "Starting Solr... "
        nohup /usr/local/apache-solr-1.4.0/example/solr.start
        echo "OK"
        return 0
}

stop() {
        echo -n "Stopping Solr... "
        /usr/local/apache-solr-1.4.0/example/solr.stop
        echo "OK"
        return 0
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        start
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?

solr.start:

#!/bin/sh
java -DSTOP.PORT=8079 -DSTOP.KEY=ftasolrstop -Xms512M -Xmx1024M -jar start.jar &

solr.stop:

#!/bin/sh
java -DSTOP.PORT=8079 -DSTOP.KEY=ftasolrstop -jar start.jar --stop

The source of the scripts is Peter Manis' blog.

Help improve this page

Page status: Not set

You can: