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
Outputs
java-1.6.0-openjdk.x86_64 1:1.6.0.34-1.13.6.1.el6_6 updates java-1.6.0-openjdk-demo.x86_64 1:1.6.0.34-1.13.6.1.el6_6 updates java-1.6.0-openjdk-devel.x86_64 1:1.6.0.34-1.13.6.1.el6_6 updates java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.34-1.13.6.1.el6_6 updates java-1.6.0-openjdk-src.x86_64 1:1.6.0.34-1.13.6.1.el6_6 updates java-1.7.0-openjdk-demo.x86_64 1:1.7.0.75-2.5.4.0.el6_6 updates java-1.7.0-openjdk-devel.x86_64 1:1.7.0.75-2.5.4.0.el6_6 updates java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.75-2.5.4.0.el6_6 updates java-1.7.0-openjdk-src.x86_64 1:1.7.0.75-2.5.4.0.el6_6 updates java-1.8.0-openjdk.x86_64 1:1.8.0.31-1.b13.el6_6 updates java-1.8.0-openjdk-demo.x86_64 1:1.8.0.31-1.b13.el6_6 updates java-1.8.0-openjdk-devel.x86_64 1:1.8.0.31-1.b13.el6_6 updates java-1.8.0-openjdk-headless.x86_64 1:1.8.0.31-1.b13.el6_6 updates java-1.8.0-openjdk-javadoc.noarch 1:1.8.0.31-1.b13.el6_6 updates java-1.8.0-openjdk-src.x86_64 1:1.8.0.31-1.b13.el6_6 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-2.5.4.0.el6_6-x86_64 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 http://www.us.apache.org/dist/lucene/solr/
# cd /opt/ # wget http://www.us.apache.org/dist/lucene/solr/4.10.4/solr-4.10.4.tgz
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
#!/bin/sh # chkconfig: 2345 95 20 # description: Solr Server # Solr Server service start, stop, restart # @author Shay Anderson 10.13 SOLR_DIR="/opt/solr/core" JAVA="/usr/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=a09df7a0d -jar start.jar" LOG_FILE="/opt/solr/core/logs/solr-server.log" case $1 in start) echo "Starting Solr..." cd $SOLR_DIR $JAVA 2> $LOG_FILE & sleep 3 ;; stop) echo "Stopping Solr..." pkill -f start.jar > /dev/null RETVAL=$? if [ $RETVAL -eq 0 ]; then echo "Stopped" else echo "Failed to stop" fi ;; restart) $0 stop sleep 2 $0 start ;; *) echo "Usage: $0 [start|stop|restart]" exit 1 ;; esac 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:
- How To Restore Default Permissions Of All Files Under / (ROOT)
- How To Start / Shutdown / Reboot Guest Operating Systems With virsh Command On KVM
- How To Install TCP Discard Service
- How To Install PHP on Centos
- Linux Runlevels
- chkconfig Command