Solr
Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world's largest internet sites.
Introduction
You can download the solr from here. Setting up solr is easy as they have perfect document to do that. Starting the solr is also easy. Go to the path, start the solr by the command what they have provided for the version you have downloaded. By pressing Ctrl + c or by killing the port you can easily start and restart the solr.
Consider the production environment. You don't have to manually follow this process each and every time. To simplify this tedious process, follow the below steps.
Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script will launch Solr in a mode that will automatically respawn if it | |
# crashes. Output will be sent to /var/log/solr/solr.log. A PID file will be | |
# created in the standard location. | |
start () { | |
daemon --running --verbose --name=solr | |
RETVAL1=$? | |
if [ $RETVAL1 = 0 ] | |
then | |
echo "Solr is already running" | |
else | |
echo -n "Starting solr..." | |
# Start daemon | |
daemon --chdir='/home/chezhian/Chezhian_files/solr/solr-4.7.0/example' --command "java -jar start.jar" --respawn --output=/var/log/solr/solr.log --name=solr --verbose | |
RETVAL=$? | |
if [ $RETVAL = 0 ] | |
then | |
echo "done." | |
else | |
echo "failed. See error code for more information." | |
fi | |
return $RETVAL | |
fi | |
} | |
stop () { | |
# Stop daemon | |
echo -n "Stopping solr..." | |
daemon --stop --name=solr --verbose | |
RETVAL=$? | |
if [ $RETVAL = 0 ] | |
then | |
echo "Done." | |
else | |
echo "Failed. See error code for more information." | |
fi | |
return $RETVAL | |
} | |
restart () { | |
daemon --restart --name=solr --verbose | |
} | |
status () { | |
# Report on the status of the daemon | |
daemon --running --verbose --name=solr | |
return $? | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
status) | |
status | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo $"Usage: solr {start|status|stop|restart}" | |
exit 3 | |
;; | |
esac | |
exit $RETVAL |
- copy the above code and paste in /etc/init.d/solr file
- mention your solr path, and start command in the start daemon place
- following needs to be done in the server ( just copy paste in your terminal )
sudo update-rc.d solr defaults sudo apt-get install chkconfig update-rc.d solr defaults sudo chmod og+x /etc/init.d/solr sudo apt-get install daemon
Then you can start and stop the solr by the following command
/etc/init.d/solr start /etc/init.d/solr stop
Thats it, now you can start and stop solr by the above command.