How to Install Apache Solr 5.1 on CentOS 6

Thursday, March 29, 2018

How to Install Apache Solr 5.1 on CentOS 6 :-

following are the steps for how to install Apache Solr 5.1 on a CentOS 6 server . 

Step 1. Install Solr :-
download and install solr first.
# cd /opt/solr 
# wget http://mirror.symnds.com/software/Apache/lucene/solr/5.1.0/solr-5.1.0.tgz -O solr-5.1.0.tgz

Uncompress the file:
# tar -xzvf ./solr-5.1.0.tgz
Now the directory /opt/solr/solr-5.1.0 will contain all the Solr files. 

Step 2. Install Java :-
First, check if Java is already installed:
# which java
  If not installed, install the latest version :

# yum list available java* 
# yum install java-1.8.0-openjdk.x86_64

Verify install:
# which java 
[...] 
# java -version 
openjdk version "1.8.0_45" 
OpenJDK Runtime Environment (build 1.8.0_45-b13) 
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

Step 3. Start Solr :-
Next start Solr and test instance:
# cd /opt/solr/solr-5.1.0 
# bin/solr start -noprompt

Verify Solr is running:
# ps aux | grep solr 
[...] 
# lsof -i :8983 
[...]

Step 4. Install NMAP :-
The Solr service can also be verified from a remote machine. First, install nmap if not already installed on remote machine:
# yum install nmap
Then test the Solr service from the remote machine:
# nmap -p 8983 [remote IP address] 

Starting Nmap 5.51 ( http://nmap.org ) at * EDT 
Nmap scan report for 
Host is up (0.054s latency). 
PORT STATE SERVICE 
8983/tcp open unknown 

Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds

If the remote machine is unable to connect try setting up firewall rules, or disable firewall for testing:
# service iptables stop
Stopping Solr can be accomplished using:
# cd /opt/solr/solr-5.1.0 
# bin/solr stop


Step 5. Auto Start Solr :-
Finally, Solr can be setup as a service that starts when the server boots. Create the script file 

/etc/init.d/solr and add:

#!/bin/sh 
# chkconfig: 2345 95 20 
# description: Solr Server 
# Solr Server service start, stop, restart 
# @author Shay Anderson 04.15 

SOLR_DIR="/opt/solr/solr-5.1.0" 

case $1 in 
      start) 
            echo "Starting Solr..." 
            $SOLR_DIR/bin/solr start -noprompt 
            sleep 1 
            lsof -i :8983 
            ;; 
      stop) 
            echo "Stopping Solr..." 
            $SOLR_DIR/bin/solr stop 
            ;; 
      restart) 
            $0 stop 
            sleep 2 
            $0 start 
            ;; 
      status) 
            $SOLR_DIR/bin/solr status 
            ;; 
      *) 
            echo "Usage: $0 [start|stop|restart]" 
            exit 1 
            ;; 
esac 

exit 0

Save the file and set permissions:
# chmod +x /etc/init.d/solr

Now the Solr service can be started/stopped using:
# service solr start 
[...] 
# service solr stop 
[...]

Enable auto start service on server boot:
# cd /etc/init.d 
# chkconfig --add solr 
# chkconfig | grep solr
Now the Solr service will start on server boot. 

Create New Core
A new core can be created using:
# cd /opt/solr/solr-5.1.0 
# bin/solr create -c mycore
This will create the core and core directory /opt/solr/solr-5.1.0/server/solr/mycore

0 comments:

About This Blog

Lorem Ipsum

  © Copyright 2009 Linux-HelpLine.Blogspot.com

Back to TOP