• How to Install Apache Solr 4.5 on CentOS 6.4


     

    By Shay Anderson on October 2013

    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 0
    Save 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

  • 相关阅读:
    WeQuant交易策略—NATR
    WeQuant交易策略—网格交易
    免交易手续费的数字货币交易所
    WeQuant交易策略—ATR
    WeQuant交易策略—RSI
    WeQuant交易策略—BOLL
    WeQuant交易策略—KDJ
    WeQuant交易策略—MACD
    WeQuant交易策略—EMA指标
    WeQuant交易策略—简单均线
  • 原文地址:https://www.cnblogs.com/zhangzhen894095789/p/6641766.html
Copyright © 2020-2023  润新知