Solr6.5在Centos6上的安装与配置 (一)

这篇文章主要是介绍在Centos6上Solr6.5的安装与配置。

一、安装准备及各软件使用版本说明:

1、JDK8,版本jdk1.8.0_121下载地址:jdk-8u121-linux-x64.tar.gz

2、Apache Tomcat,版本8.5.13 下载地址:apache-tomcat-8.5.13.tar.gz

3、Solr,版本solr-6.5.0,下载地址:solr-6.5.0.tgz

此文使用的是centos6.6的系统。在系统根目录下建立down目录。然后依次下载上面的三个软件。下载完成后如下:

/down
├── apache-tomcat-8.5.12.tar.gz
├── jdk-8u121-linux-x64.tar.gz
└── solr-6.5.0.tgz

二、jdk安装与配置:

1、安装

cd /down
tar -zxvf jdk-8u121-linux-x64.tar.gz //解压缩jdk包解压后jdk的路径应该为/down/jdk1.8.0_121/

2、配置:

修改系统环境变量文件:

vi /etc/profile

向文件里面追加以下内容:

JAVA_HOME=/down/jdk1.8.0_121
JRE_HOME=/down/jdk1.8.0_121/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

使修改生效:

[[email protected] local]# source /etc/profile   //使修改立即生效
[[email protected] local]# echo $PATH   //查看PATH值

查看系统环境状态:

[[email protected] down]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/down/jdk1.8.0_121/bin:/down/jdk1.8.0_121/jre/bin:/root/bin
[root@localhost down]#

查看JAVA版本:

[[email protected] down]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
[root@localhost down]# 

至此jdk安装完毕。

二、Solr安装与配置:

1、解压apache-tomcat-8.5.12.tar.gz和solr-6.5.0.tgz

[[email protected] down]# tar -zxvf apache-tomcat-8.5.12.tar.gz
[[email protected] down]# tar -zxvf solr-6.5.0.tgz 
解压后的目录结构:[[email protected] down]# ls
apache-tomcat-8.5.12         jdk1.8.0_121                solr-6.5.0
apache-tomcat-8.5.12.tar.gz  jdk-8u121-linux-x64.tar.gz  solr-6.5.0.tgz

2、复制Solr文件夹中的一些文件到apache-tomcat下:

1)将 solr 压缩包中 solr\server\solr-webapp\文件夹下有个webapp文件夹,将之复制到tomcat\webapps\目录下,文件夹名改成solr(任意) ;

2)将 solr 压缩包中 solr\server\lib\ext 中的 jar 全部复制到 Tomcat\ webapps\solr\WEB-INF\lib 目录中;

3)将solr压缩包中solr/server/lib/metrics* 开头的jar全部复制到 Tomcat\ webapps\solr\WEB-INF\lib 目录中;

4)将solr压缩包中solr/server/lib/solr-dataimporthandler-* 开头的jar全部复制到 Tomcat\ webapps\solr\WEB-INF\lib 目录中;

5)在Tomcat\ webapps\solr\WEB-INF\下建立classes目录,并将solr/server/resources/log4j.properties文件复制其中;

6)在tomcat目录下建立solrhome目录(也可以放在其它目录中)

7)复制solr/server/solr/* 所有文件到tomcat/solrhome目录,用到创建solr的core时使用。

操作shell如下:

[[email protected] down]# cd /down
[[email protected] down]# cp -R /down/solr-6.5.0/server/solr-webapp/webapp /down/apache-tomcat-8.5.12/webapps/solr
[[email protected] down]# cp -R /down/solr-6.5.0/server/lib/ext/*  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/
[[email protected] down]# cp -R/down/solr-6.5.0/server/lib/metrics*.*  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/
[[email protected] down]# cp /down/solr-6.5.0/dist/solr-dataimporthandler-*  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/lib/
[[email protected] down]# mkdir /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/classes
[[email protected] down]# cp /down/solr-6.5.0/server/resources/log4j.properties  /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/classes/
[[email protected] down]# mkdir /down/apache-tomcat-8.5.12/solrhome
[[email protected] down]# cp -R /down/solr-6.5.0/server/solr/*  /down/apache-tomcat-8.5.12/solrhome/

3、配置Solr:

编辑web.xml文件:

[[email protected] down]# vi /down/apache-tomcat-8.5.12/webapps/solr/WEB-INF/web.xml 

1)配置solr下core路径,找如下配置内容(初始状态下该内容是被注释掉的):

   <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/down/apache-tomcat-8.5.12/solrhome</env-entry-value> //将路径指向我们创建的solrhome目录。
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

2)配置访问权限:找到如下内容,并注释掉:

<!--
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Disable TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint/>
  </security-constraint>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Enable everything but TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method-omission>TRACE</http-method-omission>
    </web-resource-collection>
  </security-constraint>
-->

整个web.xml的配置文件内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5"
         metadata-complete="true"
>

  <!-- Uncomment if you are trying to use a Resin version before 3.0.19.
    Their XML implementation isn‘t entirely compatible with Xerces.
    Below are the implementations to use with Sun‘s JVM.
  <system-property javax.xml.xpath.XPathFactory=
             "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"/>
  <system-property javax.xml.parsers.DocumentBuilderFactory=
             "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"/>
  <system-property javax.xml.parsers.SAXParserFactory=
             "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"/>
   -->

  <!-- People who want to hardcode their "Solr Home" directly into the
       WAR File can set the JNDI property here...
   -->
    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/down/apache-tomcat-8.5.12/solrhome</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

  <!-- Any path (name) registered in solrconfig.xml will be sent to that filter -->
  <filter>
    <filter-name>SolrRequestFilter</filter-name>
    <filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class>
    <!--
    Exclude patterns is a list of directories that would be short circuited by the
    SolrDispatchFilter. It includes all Admin UI related static content.
    NOTE: It is NOT a pattern but only matches the start of the HTTP ServletPath.
    -->
    <init-param>
      <param-name>excludePatterns</param-name>
      <param-value>/libs/.+,/css/.+,/js/.+,/img/.+,/tpl/.+</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <!--
      NOTE: When using multicore, /admin JSP URLs with a core specified
      such as /solr/coreName/admin/stats.jsp get forwarded by a
      RequestDispatcher to /solr/admin/stats.jsp with the specified core
      put into request scope keyed as "org.apache.solr.SolrCore".

      It is unnecessary, and potentially problematic, to have the SolrDispatchFilter
      configured to also filter on forwards.  Do not configure
      this dispatcher as <dispatcher>FORWARD</dispatcher>.
    -->
    <filter-name>SolrRequestFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <servlet>
    <servlet-name>LoadAdminUI</servlet-name>
    <servlet-class>org.apache.solr.servlet.LoadAdminUiServlet</servlet-class>
  </servlet>

  <!-- Remove in Solr 5.0 -->
  <!-- This sends SC_MOVED_PERMANENTLY (301) for resources that changed in 4.0 -->
  <servlet>
    <servlet-name>RedirectOldAdminUI</servlet-name>
    <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
    <init-param>
      <param-name>destination</param-name>
      <param-value>${context}/#/</param-value>
    </init-param>
  </servlet>

  <servlet>
    <servlet-name>RedirectOldZookeeper</servlet-name>
    <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
    <init-param>
      <param-name>destination</param-name>
      <param-value>${context}/admin/zookeeper</param-value>
    </init-param>
  </servlet>

  <servlet>
    <servlet-name>RedirectLogging</servlet-name>
    <servlet-class>org.apache.solr.servlet.RedirectServlet</servlet-class>
    <init-param>
      <param-name>destination</param-name>
      <param-value>${context}/#/~logging</param-value>
    </init-param>
  </servlet>

  <servlet>
    <servlet-name>SolrRestApi</servlet-name>
    <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
    <init-param>
      <param-name>org.restlet.application</param-name>
      <param-value>org.apache.solr.rest.SolrSchemaRestApi</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>RedirectOldAdminUI</servlet-name>
    <url-pattern>/admin/</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>RedirectOldAdminUI</servlet-name>
    <url-pattern>/admin</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>RedirectOldZookeeper</servlet-name>
    <url-pattern>/zookeeper.jsp</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>RedirectOldZookeeper</servlet-name>
    <url-pattern>/zookeeper</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>RedirectLogging</servlet-name>
    <url-pattern>/logging</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>LoadAdminUI</servlet-name>
    <url-pattern>/old.html</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>LoadAdminUI</servlet-name>
    <url-pattern>/index.html</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>SolrRestApi</servlet-name>
    <url-pattern>/schema/*</url-pattern>
  </servlet-mapping>

  <mime-mapping>
    <extension>.xsl</extension>
    <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
    <mime-type>application/xslt+xml</mime-type>
  </mime-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

  <!-- Get rid of error message -->
  <!--
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Disable TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint/>
  </security-constraint>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Enable everything but TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method-omission>TRACE</http-method-omission>
    </web-resource-collection>
  </security-constraint>
  -->

</web-app>

至此solr的配置工作完成.

三、运行Solr:

启动执行:/down/apache-tomcat-8.5.12/bin/startup.sh

[[email protected] down]# /down/apache-tomcat-8.5.12/bin/startup.sh
Using CATALINA_BASE:   /down/apache-tomcat-8.5.12
Using CATALINA_HOME:   /down/apache-tomcat-8.5.12
Using CATALINA_TMPDIR: /down/apache-tomcat-8.5.12/temp
Using JRE_HOME:        /down/jdk1.8.0_121/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/down/apache-tomcat-8.5.12/bin/tomcat-juli.jar
Tomcat started.
[root@localhost down]# 

在浏览器输入http://localhost:8080/solr即可出现Solr的管理界面

关闭solr只需要关闭tomcat即可:

[[email protected] down]# /down/apache-tomcat-8.5.12/bin/shutdown.sh

至此solr的安装完毕。

下一篇将介绍创建core并加上中文分词的配置。

时间: 2024-12-19 10:54:58

Solr6.5在Centos6上的安装与配置 (一)的相关文章

Tomcat在Linux上的安装与配置

Tomcat在Linux上的安装与配置 1.  jdk下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html tomcat下载地址:http://tomcat.apache.org/download-70.cg 2.jdk安装与配置.(rpm包)    (1)jdk安装    rpm包:    # rpm -ivh jdk-7u79-linux-x64.rpm tar.gz

CentOs6.5中安装和配置vsftp简明教程

这篇文章主要介绍了CentOs6.5中安装和配置vsftp简明教程,需要的朋友可以参考下 一.vsftp安装篇 复制代码代码如下: # 安装vsftpdyum -y install vsftpd# 启动service vsftpd start# 开启启动chkconfig vsftpd on 二.vsftp相关命令之服务篇 复制代码代码如下: # 启动ftp服务service vsftpd start# 查看ftp服务状态service vsftpd status # 重启ftp服务servic

MongoDB 3.2 在CentOS 上的安装和配置

MongoDB 3.2 在CentOS 上的安装和配置 2016-01-06 14:41:41 发布 您的评价:       0.0   收藏     0收藏 一.安装 编辑/etc/yum.repos.d/mongodb-org-3.2.repo [mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpg

Oracle10g/11g 在SUSE/RHEL上的安装与配置

在过去对众多项目的支撑过程中,Oracle作为首选数据库,其安装与配置过程成了重复性最多的工作之一.在此,我进行了总结,并分享出来,希望能对大家有所帮助.随着Oracle版本的提升,从9i ->10g ->11g,其安装与配置过程其实越来越简单,尤其到了11g,会自动检测所缺少的系统软件包,并在系统参数配置方面进行自动调优. 在Linux下Oracle的安装配置过程我认为可分为三大步:第一步 预安装的环境参数配置在Windows下没有这一步,因为已经由安装程序直接完成了,Linux下目前也有相

java环境--JDK和Tomcat在linux上的安装和配置

Tomcat在Linux上的安装与配置 以下使用的Linux版本为: Redhat Enterprise Linux 7.0 x86_64,Tomcat版本为tomcat-7.0.54.1.下载JDK与Tomcat.    jdk下载地址:    http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html    tomcat下载地址:    http://tomcat.apache.org

solr5.5.0在CenOS上的安装与配置

solr5.5.0在CenOS上的安装与配置 1. Solr简介 Solr是一个基于Lucene的Java搜索引擎服务器.Solr 提供了层面搜索.命中醒目显示并且支持多种输出格式(包括 XML/XSLT 和 JSON 格式).它易于安装和配置,而且附带了一个基于 HTTP 的管理界面.Solr已经在众多大型的网站中使用,较为成熟和稳定.Solr 包装并扩展了 Lucene,所以Solr的基本上沿用了Lucene的相关术语.更重要的是,Solr 创建的索引与 Lucene 搜索引擎库完全兼容.通

Win7上Git安装及配置过程

Win7上Git安装及配置过程 文档名称 Win7上Git安装及配置过程 创建时间 2012/8/20 修改时间 2012/8/20 创建人 Baifx 简介(收获) 1.在win7上安装msysgit步骤: 2.在win7上安装TortoiseGit步骤: 3.在VS2010中集成Git方法和步骤. 参考源 Git的配置与使用 http://wenku.baidu.com/view/929d7b4e2e3f5727a5e962a8.html 一.安装说明 1.Git在windows平台上安装说

在CentOS6上编译安装实现LAMP(php-modules)+phpMyAdmin安装过程全记录

php与apache协作有三种模式:CGI.modules.FastCGI. 在CGI模式下,用户请求php文件时,apache会启动响应进程,调用php处理器处理请求,然后将结果返回给客户端.用户响应及处理由前端apache服务器完成: 在modules模式下,php解析器作为apache的一个模块,php处理器与web服务器一起运行处理用户请求.用户响应由apache处理,请求处理由apache与php处理器协同完成: 在fastcgi模式下,apache调用proxcy模块,发挥代理作用,

Ubuntu上snmp安装、配置、启动及远程测试完整过程

0.说明 关于一个完整的教程,还是那句话,国内的要么不完整,要么就太旧了,而且思路也不清晰,所以这里写一篇完整的给大家分享一下. 虽然对于Linux主机的监控可以通过执行特定的命令来完成,但是相比之后,通过snmp的方式来获取Linux主机的信息则会更轻松简单些,只不过在使用前的配置可能需要花多一点时间,不过这绝对值得!而且如果需要开发Linux主机的监控软件,那使用snmp肯定是首选,毕竟它可以获得的信息太多太多! 后面的内容就来分享一下在Ubuntu上安装.配置.启动snmp以及进行远程测试