How To Install Solr 4.10.4 On CentOS 6.5

by admin on March 16, 2015

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.

In this tutorial I will explain How to install Solr 4.10.4 on CentOS 6.5. The first of all, Login as root user.

Installing JAVA

To start things off first check if you have Java installed:

# which java

If you do not have Java installed check for latest version:

# yum list available | grep openjdk


java-1.6.0-openjdk.x86_64                  1:     updates
java-1.6.0-openjdk-demo.x86_64             1:     updates
java-1.6.0-openjdk-devel.x86_64            1:     updates
java-1.6.0-openjdk-javadoc.x86_64          1:     updates
java-1.6.0-openjdk-src.x86_64              1:     updates
java-1.7.0-openjdk-demo.x86_64             1:      updates
java-1.7.0-openjdk-devel.x86_64            1:      updates
java-1.7.0-openjdk-javadoc.noarch          1:      updates
java-1.7.0-openjdk-src.x86_64              1:      updates
java-1.8.0-openjdk.x86_64                  1:        updates
java-1.8.0-openjdk-demo.x86_64             1:        updates
java-1.8.0-openjdk-devel.x86_64            1:        updates
java-1.8.0-openjdk-headless.x86_64         1:        updates
java-1.8.0-openjdk-javadoc.noarch          1:        updates
java-1.8.0-openjdk-src.x86_64              1:        updates

Type the following command to install java

# yum install java-1.8.0-openjdk.x86_64

Finally, check Java version:

# java -version
java version "1.8.0_75"
OpenJDK Runtime Environment (rhel- u75-b13)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
[root@host-129-19 ~]# 

Installing Solr

Install the latest version Solr release by downloading from

# cd /opt/
# wget

Extracting solr package:

# tar zxvf solr-4.10.4.tgz
# mv solr-4.10.4 solr

Renaming “example” directory to project name, example “core”:

# cd solr
# mv example core

Running Solr

You should now be able to test running the Solr server with following command

# cd /opt/solr/core
# java -jar start.jar

If everything works correctly you should be able to view the Solr server admin by going to:
http://[server hostname or IP]:8983/solr/
If this does not work try viewing the log /opt/solr/solr/logs/solr.log

Auto Start Apache Solr

First, create script for handling the Solr server service

# vi /etc/init.d/solr

And add the following script

# chkconfig: 2345 95 20 
# description: Solr Server 
# Solr Server service start, stop, restart 
# @author Shay Anderson 10.13 

JAVA="/usr/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=a09df7a0d -jar start.jar" 

case $1 in 
            echo "Starting Solr..." 
            cd $SOLR_DIR 
            $JAVA 2> $LOG_FILE & 
            sleep 3 
            echo "Stopping Solr..." 
            pkill -f start.jar > /dev/null 
            if [ $RETVAL -eq 0 ]; then 
                  echo "Stopped" 
                  echo "Failed to stop" 
            $0 stop 
            sleep 2 
            $0 start 
            echo "Usage: $0 [start|stop|restart]" 
            exit 1 

exit 0

To run Apache Solr by default when the system boots, type the following command

# chmod +x /etc/init.d/solr
# chkconfig --level 345 solr on

Related Posts:

Leave a Comment

Previous post:

Next post: