By Shay Anderson on October 2013
Knowledge Base  /  Linux  /  How to Install Apache Solr 4.5 on CentOS 6.4

In this tutorial I explain how to install Apache Solr 4.5 on CentOS 6.4. In all the examples below I am using the root user, if you are not you will need to prepend some of the examples with sudo.

Install Java

To start things off first check if you have Java installed:# which javaIf you do not have Java installed check for latest version:# yum list available | grep javaAnd install Java, in my case it was:# yum install java-1.7.0-openjdk.x86_64Install Java - MySQL DB connector:# yum install mysql-connector-java
Finally, check Java version:# java -version 
java version "1.7.0_25" 
OpenJDK Runtime Environment (rhel-2.3.10.4.el6_4-x86_64) 
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Install Solr

Install the latest Solr release by downloading from http://www.apache.org/dyn/closer.cgi/lucene/solr/. For example, I downloaded using:# wget http://apache.mirrors.tds.net/lucene/solr/4.5.0/solr-4.5.0.tgz /optExtract download:# tar -xvf /opt/solr-4.5.0.tgzMove main directory for install:# mv -v /opt/solr-4.5.0 /opt/solrAnd move example directory to project name or simply core:# mv -v /opt/solr/example /opt/solr/core
Create a symlink to the mysql-connector-java we installed earlier:# ln -s /usr/share/java/mysql-connector-java.jar /opt/solr/dist/mysql-connector-java.jarThen edit the /opt/solr/core/solr/collection1/conf/solrconfig.xml file and add these lines by the <lib dir="..."> lines for using MySQL database connection and Data Import Handler (DIH):<!-- data import handler --> 
<lib dir="../../../contrib/dataimporthandler/lib/" regex=".*\.jar" /> 
<lib dir="../../../dist/" regex="solr-dataimporthandler-\d.*\.jar" /> 
<lib dir="../../../dist/" regex="mysql-connector-java.*\.jar" />

Firewall Exception

If you use iptables add a rule to allow access to Solr's admin section and query Solr data (replace 0.0.0.0 with the correct IP address):# iptables -A INPUT -s 0.0.0.0 -p tcp -m tcp --dport 8983 -j ACCEPT 
# service iptables save
Or, if you want to allow port 8983 for all requests use:# iptables -A INPUT -p tcp -m tcp --dport 8983 -j ACCEPT 
# service iptables save
Also, if you're using a MySQL database connection for data importer you'll want to open a firewall exception for the localhost MySQL port:# iptables -A INPUT -s 127.0.0.1 -p tcp -m tcp --dport 3306 -j ACCEPT 
# service iptables save 
# iptables -L 
... 
ACCEPT tcp -- localhost anywhere tcp dpt:mysql 
...

Running Solr

You should now be able to test running the Solr server:# java -jar /opt/solr/core/start.jarIf 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

You can view if Solr is running with command:# lsof -i :8983

Auto Start Apache Solr

Now we may want to configure Apache Solr to auto start on server boot. First, create script for handling the Solr server service:# nano /etc/init.d/solrAnd add the following script (or one like it):#!/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 0Save the file and make it executable:# chmod +x /etc/init.d/solrNow register Solr to run when server boots:# chkconfig --add solr 
# chkconfig --list | grep solr

How to Install Apache Solr 4.5 on CentOS 6.4的更多相关文章

  1. How to Install Apache Tomcat 8.5 on CentOS 7.3

    How to Install Apache Tomcat 8.5 on CentOS 7.3 From: https://www.howtoforge.com/tutorial/how-to-inst ...

  2. Install Apache, PHP And MySQL On CentOS 7 (LAMP)

    This tutorial shows how you can install an Apache2 webserver on a CentOS 7.0 server with PHP5 suppor ...

  3. Apache solr 6.6.0安装

    Apache solr 6.6.0安装 最近使用了Apache solr搜索引擎框架,solr是基于lucene的一个搜索服务器,lucene也是Apache的一个开源项目:对于学习搜索引擎来说,这个 ...

  4. MAGENTO - APACHE SOLR INTEGRATION - PART II (SETUP)

    MAGENTO - APACHE SOLR INTEGRATION - PART II (SETUP) Tue, 03/01/2011 - 18:30 Tweet Development E-Comm ...

  5. 05 Apache Solr: 管理员界面(Admin UI)

         为了方便管理员和工程师调整Solr的配置和访问在线文档和其他的帮助,Solr提供了一个Web界面去查看Solr的配置详情,运行查询语句和分析文档字段.这个界面在第三篇里面提到过就是管理员界面 ...

  6. 03 Apache Solr: 安装和运行

         前面介绍了Solr在项目中的使用和构建高度可用.高度可扩展的Solr服务器的一些想法.但是光说不练假把式,现在开始,把Solr运行起来继续深入了解吧! 安装 安装JAVA Apache So ...

  7. 02 Apache Solr: 概览 Solr在信息系统架构中的位置

    概述:      Apache Solr是一个用JAVA语言构建在Apache Lucene项目上的开源的企业级搜索平台.主要特性包含:全文搜索.命中高亮.片段式搜索.实时索引.动态集群.数据库集成. ...

  8. 01 Apache Solr:提升检索体验 为什么是Solr

    背景:      最近开发一个大型的仓储管理平台项目,项目的前身是无数个版本的历史悠久的基于CS模式的Windows桌面程序.然后对于每一个客户,我们可能需要为之定制比较个性化的特殊功能.于是,有一个 ...

  9. Apache Solr查询语法(转)

    查询参数 常用: q - 查询字符串,必须的. fl - 指定返回那些字段内容,用逗号或空格分隔多个. start - 返回第一条记录在完整找到结果中的偏移位置,0开始,一般分页用. rows - 指 ...

随机推荐

  1. VS 关于无法打开项目文件,此安装不支持该项目类型的问题

    用VS打开后有时会出现类似: 无法打开项目文件,此安装不支持该项目类型 的错误,这个错误一般都是由于用低版本VS打开高版本项目文件造成的 其中包括: 1.用VS2003 打开包括VS2005以上版本项 ...

  2. R 数据类型

    c()功能函数,产数据用 向量:一维数组,要求存放的数据类型一致 矩阵:二维数组,要求存放的数据类型一致,用通过matrix函数创建 数组:维度超过二维时建议用数组,用可araay函数创建 数据框:相 ...

  3. 荧光分子的dynamic quenching 和 通常说的quenching的区别?

    quenching有两种,学术上分为dynamic quenching 和static quenching,我们通常说的quenching就是 static quenching. static que ...

  4. c/c++转义字符大全【转自互联网】

    将转义字符收集如下:转义字符 意义 ASCII码值(十进制) \a 响铃(BEL) 007 \b 退格(BS) 008 \f 换页(FF) 012 \n 换行(LF) 010 \r 回车(CR) 01 ...

  5. Cygwin install apt-cyg

    1. UPDATE CYGWIN First of all you will need to ensure that Cygwin has the necessary binaries require ...

  6. SQL中的union,except,intersect用法

    限制:所有查询中的列数和列的数序必须相同 union all:完全整合两个结果集查出所有数据 union:查出两个表的数据并且去除重复的数据 except:去重之后只会保留第一个表中的数据,查询a表在 ...

  7. 线程池和Thread

    1.线程池 创建线程需要时间.如果有不同的短任务要完成,就可以事先创建许多线程,在应完成这些任务时发出请求.这个线程数最好在需要更多线程时增加,在需要释放资源时减少.不需要自己创建这样一个列表.该列表 ...

  8. 【C#】VS2017 winform 打包

    首先要在想要打包的项目下创建一个新的项目, 创建好setup项目,之后点击属性,去修改打包软件的名字,ProductName....可以选填 到此已经创建好了setup工程了,那么下面开始将要打包的d ...

  9. Delphi Runtime Library在哪里?

    Delphi Runtime Library是Delphi的运行时库,里面包含了大部分Delphi库的代码,这些库代码在哪里呢?其实正常安装完Dephi之后,在它的安装目录下面!下面我以我的Delph ...

  10. 用python实现杨辉三角

    def yanghui(lines): currentlst,lastlst,n=[],[],1 if lines<1: return while n<=lines: lastlst=cu ...