how to install Apache Solr on a CentOS 7 VPS ?

Apache Solr is an open source enterprise search platform used to easily create search engines which searches websites, files and databases.

 

Please follow the given steps to install Solr :

 

1. Type

yum update

2.  Install the latest version of Java :

yum list available | grep -i jdk

java-1.7.0-openjdk.x86_64

3. Verify that Java is properly installed:

java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel-2.5.1.2.el7_0-x86_64 u65-b17)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

4. The next step is to download and unpack the Solr archive.

cd /opt
wget http://www.bizdirusa.com/mirrors/apache/lucene/solr/4.9.0/solr-4.9.0.tgz
tar -xvf solr-4.9.0.tgz
mv /opt/solr-4.9.0 /opt/solr
mv /opt/solr/example /opt/solr/core

5. Create an init script for the Solr service:

vi /etc/init.d/solr
#!/bin/bash
#
# chkconfig: 2345 20 20
# short-description: Solr
# description: Startup script for Apache Solr Server

SOLR_DIR="/opt/solr/core"
LOG_FILE="/var/log/solr.log"
JAVA="/usr/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar"

start() {
echo -n "Starting Solr... "
cd $SOLR_DIR
$JAVA > $LOG_FILE 2>&1 &
sleep 2
RETVAL=$?

    if [ $RETVAL = 0 ]
    then
        echo "done."
    else
        echo "failed. See error code for more information."
    fi
    return $RETVAL
}

stop() {
echo -n "Stopping Solr... "
pkill -f start.jar > /dev/null
RETVAL=$?

    if [ $RETVAL = 0 ]
    then
        echo "done."
    else
        echo "failed. See error code for more information."
    fi
    return $RETVAL
}

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

6. Set the proper permission for the ‘solr’ script and make Solr automatically start on server boot:

chmod +x /etc/init.d/solr

chkconfig --add solr

7. You can now start Solr using the following command:

/etc/init.d/solr start

 

8.  Once Solr is up and running you should be able to access it through your favorite web browser at
http://server_IP:8983/solr/

 

http://www.stradsolutions.com/linux-vps.php

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*