安装环境

Windows 7 64bit

Apache-tomcat-8.0.9-windows-x64

Solr-4.9.0

JDK 1.8.0_05 64bit

安装步骤

Tomcat和JDk的安装在这里就略过。

注意:solr4.9要求jdk1.7+

步骤一:

解压solr-4.9.0到任意文件夹,我解压到D:\Installed Applications\solr-4.9.0\solr-4.9.0目录下。

步骤二:

将solr-4.9.0\dist\ solr-4.9.0.war复制到Tomcat webapp/目录下,最好重命名为solr.war。

步骤三:

启动Tomcat,会报错,这步只是为了将solr-4.9.0.war解压,所以手动解压放在webapp目录下面也是可行的。

步骤四:

方法一:

打开webapps\solr\WEB-INF\web.xml

找到:

  

<!--
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>/put/your/solr/home/here</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
-->

这里是需要配置solr/home,只需要修改<env-entry-value>/put/your/solr/home/here</env-entry-value>

这个目录可以自定义,建议就用步骤一解压的目录,这里需要非常注意:在Solr官网的Tutorial里面有如下一段话:

How Solr Works with Tomcat

The two basic steps for running Solr in any Web application container are as follows:

  1. Make the Solr classes available to the container. In many cases, the Solr Web application archive (WAR) file can be placed into a special directory of the application container. In the case of Tomcat, you need to place the Solr WAR file in Tomcat's webapps directory. If you installed Tomcat with Solr, take a look in tomcat/webapps:you'll see the solr.war file is already there.
  2. Point Solr to the Solr home directory that contains conf/solrconfig.xml and conf/schema.xml. There are a few ways to get this done. One of the best is to define the solr.solr.home Java system property. With Tomcat, the best way to do this is via a shell environment variable, JAVA_OPTS. Tomcat puts the value of this variable on the command line upon startup

从这里可以看 出,<env-entry-value>指向的目录需要包含conf/solrconfig.xml和conf/schema.xml这两个 文件,也就意味着在<env-entry-value>所指向的目录中需要有conf子目录,我就是因为官网的这段解释,搞了半天没有成功, 其实是我理解错了,我认为在solr.solr.home目录下必须要有子目录conf,conf里面包含solrconfig.xml和 schema.xml。但是其实conf目录是放在collection1目录下面的,collection是solr的一个Instance实 例,solr中可以配置多个collection,可以有独立的配置文件。

我这边web.xml的配置为:

  

<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>D:/Installed Applications/solr-4.9.0/solr-4.9.0/example</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>

特别需要注意配置里面使用的是反斜杠"/",而不是windows下默认的"\"。

这里我是直接指向example文件夹。

方法二(个人推荐)

在$TOMCAT_HOME/conf/Catalina/localhost目录下新建solr.xml文件,内容为:

 

<Context path="/solr" docBase="… /tomcat/webapps/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value=" D:/Installed Applications/solr-4.9.0/solr-4.9.0/example " override="true"/>
  这边需要注意,override需要设置为false,否则每次启动tomcat都会重新解压war文件覆盖掉之前的配置,或者手动解压后,把context path直接指向文件夹
</Context>

步骤五:

将solr- 4.9.0\example\solr目录下的collection1目录整体copy到solr-4.9.0\example目录下。读者可以自己自定 义路径,web.xml中定义的<env-entry-value></env-entry-type>,这个指向的目录包含 collection1目录就好了。

步骤六:

将 D:\Installed Applications\solr-4.9.0\solr-4.9.0\example\lib\ext目录下的jar包copy到apache- tomcat-8.0.9\lib目录下,也可以copy到webapps\solr\WEB-INF\lib下,读者可以自行选择(全局和局部的问题而 已)。(如果启动还是报错,可以根据提示在solr-4.9.0\dist中找相应的jar包)。

步骤七:

打开Tomcat conf目录下的server.xml,找到下面一段代码添加URIEncoding="UTF-8",添加中文支持。

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />

步骤八:

启动Tomcat,打开浏览器输入:http://localhost:8080/solr/admin/,看到启动画面就说明安装成功。

总结

由上面的安装步骤可以 看出来,其中步骤四是最核心的一步,这里面需要了解Solr的运行原理:Solr是类似于Http接口的一种服务,它需要在Web容器(这里是 Tomcat)中部署,运行后,应用程序用Http请求的方式和Solr交互,包括添加索引、查询等等。所以我们需要在Web容器中部署Solr,并且在 Tomcat配置中指明Solr配置的目录。

在Linux下的安装方法跟Windows下没有大的区别。

solr 在windows下的安装的更多相关文章

  1. solr在windows下的安装及配置

    solr在windows下的安装及配置 首先,solr是基于Java开发的,所以使用的话需要先进行java环境的配置,在Java环境配置好之后就可以去http://www.apache.org/dyn ...

  2. memcache的windows下的安装和简单使用

    原文:memcache的windows下的安装和简单使用 memcache是为了解决网站访问量大,数据库压力倍增的解决方案之一,由于其简单实用,很多站点现在都在使用memcache,但是memcach ...

  3. Windows下pry安装和配置

    Windows下pry安装和配置 pry是一个增强型的交互式命令行工具,比irb强大. 有自动完成功能,自动缩进,有颜色.有更强大的调试功能. pry 安装很简单. 在终端输入: gem instal ...

  4. Windows下虚拟机安装Mac OS X ----- VM12安装Mac OS X 10.11

    Windows下虚拟机安装Mac OS X -– VM12安装Mac OS X 10.11 随着Iphone在国内大行其道,越来越多的开发者涌入iOS开发大军 中,但都苦于没有苹果机,本文即将介绍WI ...

  5. Windows下memcache安装使用

    Windows下Memcache安装 随着时间的推移,网上现在能找到的在 Windows下安装 Memcache 的文档大多已经过时.雪峰这里再简要介绍一下当下最新版的安装和配置方法. Memcach ...

  6. Windows 下如何安装配置Snort视频教程

    Windows 下如何安装配置Snort视频教程: 第一步: http://www.tudou.com/programs/view/UUbIQCng360/ 第二部: http://www.tudou ...

  7. 在windows下完美安装GitHub

    笔者最近在Windows下安装GitHub,过程中遇到不少问题.现在把安装的详细步骤分享给大家,免得大家走弯路. 笔者安装了GitHub for Windows程序,一切都运行顺利.但事情没有结束,首 ...

  8. windows下Eclipse安装Perl插件教程

    windows下Eclipse安装Perl插件教程 想用eclipse编写perl.网上看了很多资料.但EPIC插件的下载连接都失效了.无奈,只好自己动手写个教程记录一下. 准备工作: 安装好Ecli ...

  9. Ruby入门--Linux/Windows下的安装、代码开发及Rails实战

    Ruby入门--Linux/Windows下的安装.代码开发及Rails实战 http://www.linuxidc.com/Linux/2014-04/100242.htm Ubuntu 13.04 ...

随机推荐

  1. SGU 168.Matrix

    时间限制:0.5s 空间限制:15M 题意: 给出一个N*M的矩阵A,计算矩阵B,满足B[i][j]=min{ A[x][y]:(y>=j) and ( x>=i+j-y )} Solut ...

  2. chromedriver release note

    ----------ChromeDriver v2.25 (2016-10-25)---------- Supports Chrome v53-55 Resolved issue 1547: Chro ...

  3. python json string和dict的转化

    __author__ = 'SRC_TJ_XiaoqingZhang' import json data1 = {'b': 789, 'c': 456, 'a': 123} encode_json = ...

  4. A Statistical View of Deep Learning (III): Memory and Kernels

    A Statistical View of Deep Learning (III): Memory and Kernels Memory, the ways in which we remember ...

  5. A Statistical View of Deep Learning (II): Auto-encoders and Free Energy

    A Statistical View of Deep Learning (II): Auto-encoders and Free Energy With the success of discrimi ...

  6. DOMContentLoaded vs onload

    http://ie.microsoft.com/testdrive/HTML5/DOMContentLoaded/Default.html The DOMContentLoaded event fir ...

  7. About javascript language

    Core http://www.cnblogs.com/leoo2sk/archive/2010/12/19/ecmascript-scope.html function(arguments) fun ...

  8. [转]Windows Azure上安装SharePoint 2013

    基于Windows Azure 安装SharePoint 2013 前段时间写的基于Windows Azure安装SharePoint系列,由于Azure的体验账号过期了,所以不得不暂停.今天有幸参加 ...

  9. 通过 IDE 向 Storm 集群远程提交 topology

    转载: http://weyo.me/pages/techs/storm-topology-remote-submission/ http://www.javaworld.com/article/20 ...

  10. #include< >和#include""的区别

    Answer 1:#include 会将指定文件的内容插入到源程序文件中.当使用的格式时,编译器会从环境变量INCLUDE所指定的路径中寻找file-name 文件,如果没有定义INCLUDE,C 编 ...