On Ubuntu Server 8.04 LTS. Using 'java -jar start.jar'.
What about when you reboot your Apache Solr server? Are you going to type in that java -jar start.jar after each reboot? There's an easier way. We are now going to create a startup script to automatically start Apache Solr when you reboot your Ubuntu Server 8.04.x LTS.
This how-to handbook is
- For beginners.
- Using 'java -jar start.jar' method.
STEPS
Type in the following command in TERMINAL to install nano text editor.
sudo apt-get install nano
Type in the following command in TERMINAL to add a new script.
sudo nano /etc/init.d/solr
TERMINAL will display a new page title “GNU nano 2.0.x”.
Paste the below script in this TERMINAL window.
#!/bin/sh -e
# Starts, stops, and restarts solr
SOLR_DIR="/apache-solr-1.4.0/example"
JAVA_OPTIONS="-Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar"
LOG_FILE="/var/log/solr.log"
JAVA="/usr/bin/java"
case $1 in
start)
echo "Starting Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS 2> $LOG_FILE &
;;
stop)
echo "Stopping Solr"
cd $SOLR_DIR
$JAVA $JAVA_OPTIONS --stop
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
-
Note: In above script you might have to replace
/apache-solr-1.4.0/examplewith appropriate directory name.
Press CTRL-X keys.
Type in Y
When ask File Name to Write press ENTER key.
You're now back to TERMINAL command line.
Type in the following command in TERMINAL to create all the links to the script.
sudo update-rc.d solr defaults
Type in the following command in TERMINAL to make the script executable.
sudo chmod a+rx /etc/init.d/solr
To test. Reboot your Ubuntu Server.
Wait until Ubuntu Server reboot is completed.
Wait 2 minutes for Apache Solr to startup.
Using your internet browser go to your website and try a Solr search.
That's it. You have successfully created a startup script to automatically start Apache Solr when you reboot your Ubuntu Server. Enjoy.
Sources:
- http://rc98.net/solrinit
- http://19thstreetdesign.com/blog/2009.02.04/installing-apache-solr-drupal-6
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion