I have to say that Apache Solr is an amazing product. If you reached this post you probably run or heard about it before, if not head to http://lucene.apache.org/solr/ to read more about it. It's just wonderful to see what the open source community can achieve.
One thing that I missed was a good start and stop script on Ubuntu/Debian. Paul Doerwalds has an superb example which I used as base and then adapted. For security reasons I've created a user called solr that is owner of the whole directory where Solr is installed. In the script it's the solr user that starts the application. You might adjust the memory parameters. This example script is used on a dedicated Solr machine with 16GB memory. Don't forget to do some changes in /etc/sysctl.conf if using more memory. The script looks like this:
#!/bin/bash
# description: Starts and stops Solr production
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
SOLR_DIR=/var/apache-solr-1.3.0/projectname
JAVA_OPTIONS="-Dsolr.solr.home=./solr -Djava.util.logging.config.file=logging.properties -server -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -Xmx13312M -Xms1024M -jar start.jar"
JAVA="/usr/bin/java"
LOG_FILE="/var/log/solr/console.log"
case $1 in
start)
echo "Starting Solr"
cd $SOLR_DIR
su - solr -c "cd $SOLR_DIR && nohup $JAVA $JAVA_OPTIONS 2> $LOG_FILE &"
echo "ok - remember it may take a minute or two before Solr responds on requests"
;;
stop)
echo "Stopping Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS --stop
echo "ok"
;;
restart)
$0 stop
sleep 3
$0 start
;*)
echo "Usage: $0 {start|stop|restart}" >&2exit 1
;;
esac
The start-stop script refers to logging.properties, which has to be placed in the project dir, in this case it would be /var/apache-solr-1.3.0/projectname. Name the file logging.properties and add the following snippet:
# Default global logging level: .level= WARNING # Write to a file: handlers= java.util.logging.FileHandler # Write log messages in XML format: java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter # Log to the current working directory, with log files named solrxxx.log java.util.logging.FileHandler.pattern = /var/log/solr/solr-%u.log
Comments
Post new comment