Solr服务安装(Windows)

Solr是一个独立的企业级搜索应用服务器,它对外提供类似于Web-service的API接口。用户可以通过http请求,向搜索引擎服务器提交一定格式的XML文件,生成索引;也可以通过Http Get操作提出查找请求,并得到XML格式的返回结果。

资源准备

jdk1.7.0_60-x64、apache-tomcat-7.0.55、solr-4.10.2。相关资源下载地址:http://pan.baidu.com/s/1bnCVGTp

提示:Solr是运行在某servlet容器(Tomcat、Jboss、Jetty等)中的web服务,而此版本官方教程——solr-4.10.2/docs/tutorial.html中的实例是基于Jetty容器描述的,此文主要是想将教程中的example实例运行在Tomcat容器里。根文件目录如下:

部署Solr服务

将solr-4.10.2/dlist/solr-4.10.2.war解压到apache-tomcat-7.0.55/webapps下,并将solr-4.10.2文件夹重命名为solr。

指定solr.home

将solr-4.10.2/example/solr/*放到solr/home文件夹下。solr/home文件目录如下:

指定solr.home的方式有多种:通过JAVA_OPTS设置Tomcat的运行环境变量。

  • JAVA_OPTS(start-solr-4.10.2.bat批处理文件)
    <span style="font-size:18px;">set CURRENT_DIR=%CD%
    set JAVA_HOME=%CURRENT_DIR%\jdk1.7.0_60-x64
    CD %CURRENT_DIR%\apache-tomcat-7.0.55\bin
    set JAVA_OPTS=-Dsolr.solr.home=%CURRENT_DIR%\solr\home -Dsolr.log=%CURRENT_DIR%\solr\home\logs
    call startup.bat start</span>

运行Solr服务及问题解决

依据实际出现顺序

  • 问题01:日志异常

    异常现象

    <span style="font-size:18px;">
    java.lang.NoClassDefFoundError: Failed to initialize Apache Solr: Could not find necessary SLF4j logging jars. If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
    	at org.apache.solr.servlet.CheckLoggingConfiguration.check(CheckLoggingConfiguration.java:28)
    	at org.apache.solr.servlet.BaseSolrFilter.<clinit>(BaseSolrFilter.java:31)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    	at java.lang.Class.newInstance(Class.java:374)
    </clinit></span>

    异常分析

    缺少日志相关JAR包。Solr从V4.3开始将日志相关JAR包与WAR包分离。可以访问提示链接:http://wiki.apache.org/solr/SolrLogging,获得更多信息。

    解决方案

    将solr-4.10.2/example/lib/ext下的*.jar以及solr-4.10.2/example/resources/log4j.properties文件复制到apache-tomcat-7.0.55/lib下。

  • 问题02:JAR包未找到警告

    异常现象

    <span style="font-size:18px;">
    WARN  - 2015-05-22 12:58:58.509; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../contrib/extraction/lib (resolved as: D:\Applications\solr\home\collection1\..\..\..\contrib\extraction\lib).
    WARN  - 2015-05-22 12:58:58.510; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: D:\Applications\solr\home\collection1\..\..\..\dist).
    WARN  - 2015-05-22 12:58:58.510; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../contrib/clustering/lib/ (resolved as: D:\Applications\solr\home\collection1\..\..\..\contrib\clustering\lib).
    WARN  - 2015-05-22 12:58:58.511; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: D:\Applications\solr\home\collection1\..\..\..\dist).
    WARN  - 2015-05-22 12:58:58.511; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../contrib/langid/lib/ (resolved as: D:\Applications\solr\home\collection1\..\..\..\contrib\langid\lib).
    WARN  - 2015-05-22 12:58:58.512; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: D:\Applications\solr\home\collection1\..\..\..\dist).
    WARN  - 2015-05-22 12:58:58.513; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../contrib/velocity/lib (resolved as: D:\Applications\solr\home\collection1\..\..\..\contrib\velocity\lib).
    WARN  - 2015-05-22 12:58:58.514; org.apache.solr.core.SolrResourceLoader; Can't find (or read) directory to add to classloader: ../../../dist/ (resolved as: D:\Applications\solr\home\collection1\..\..\..\dist).
    
    </span>

    异常分析

    在solr/home/collection1/conf/solrconfig.xml配置中要求引入一下JAR包:

    解决方案

    将solr-4.10.2/contrib文件夹和solr-4.10.2/dist文件夹复制到solr文件夹下。将solrconfig.xml文件中的../../../替换为../../。

运行成功

访问路径一下路径:http://localhost:8080/solr,看是否成功?!

Best Wishes For You!

时间: 2024-08-02 14:01:35

Solr服务安装(Windows)的相关文章

如何使用远程安装服务在远程计算机上安装Windows 2003 Server 2

概要 本文分步介绍了如何使用"远程安装服务"(RIS) 在远程计算机上安装 Windows Server 2003. 您可以通过将 RIS 网络共享文件夹用作 Windows Server 2003 文件的源,使用 RIS 来远程设置基于 Microsoft Windows Server 2003 的新计算机.您可以在具有远程启动功能的客户端计算机上安装操作系统.客户端计算机会被连接到网络,然后使用具有"预启动执行环境"(PXE) 功能的网络适配器或远程启动盘启动它

“无法通过windows installer服务安装此安装程序包”错误如何解决

  今天小编安装一个文件时,出现了一个"无法通过windows installer服务安装此安装程序包.您必须安装带有更新版本windows Installer服务的Windows Service Pack"的错误 我去,好坑啊,好像貌似是从来不更新补丁的,但以前也没遇过到啊.intaller版本太低了,下一个新一点的windows installer程序装上就可以了.

解决xp下无法通过windows installer服务安装此安装程序包。您必须安装带有更新版本Wi

  今天装 tortoisegit 的时候发现安装包不能使用.报错无法通过windows installer服务安装此安装程序包.您必须安装带有更新版本Windows Installer服务的Windows Service Pack解决方案: http://www.microsoft.com/zh-cn/download/confirmation.aspx?id=8483 下载新的更新补丁然后重启之后再次安装tortoisegit 就ok了.   之后就可以进入github的世界.  

c# windows 服务安装的“提交“阶段出现异常,求大神们帮下忙

问题描述 c# windows 服务安装的"提交"阶段出现异常,求大神们帮下忙 正在开始安装的"安装"阶段. 查看日志文件的内容以获得 D:DocumentsVisual Studio 2013ProjectsTimerTimerob jDebugTimer.exe 程序集的进度. 该文件位于 D:DocumentsVisual Studio 2013ProjectsTimerTimerobjDebugTimer. installLog. 正在安装程序集"

service-程序发布——把mfc程序(带有dll)做成安装包, 安装过程中自动安装windows服务

问题描述 程序发布--把mfc程序(带有dll)做成安装包, 安装过程中自动安装windows服务 如题 怎么实现??? 有高手留一下联系方式么~~跪求 如题 怎么实现??? 有高手留一下联系方式么~~跪求如题 怎么实现??? 解决方案 //打开服务控制管理器 SC_HANDLE hSCM = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); if (hSCM == NULL) { return FALSE; } // Get the exe

Centos7下安装Solr服务和Solr基本用法

Requirements root@pts/6 $ java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode) refer to solr system requirements Installation solr 这篇主要是以单实例Sol

安装window服务失败-安装windows services服务失败

问题描述 安装windows services服务失败 解决方案 提示你了,看日志.贴具体错误出来才知道.

.Net实现Windows服务安装完成后自动启动的两种方法

考虑到部署方便,我们一般都会将C#写的Windows服务制作成安装包.在服务安装完成以后,第一次还需要手动启动服务,这样非常不方便. 方法一:在安装完成事件里面调用命令行的方式启动服务 此操作之前要先设置下两个控件 设置serviceProcessInstaller1控件的Account属性为"LocalSystem"设置serviceInstaller1控件的StartType属性为"Automatic"   在服务器上添加安装程序,在private void P

使用WINAPI安装Windows服务[转]

using system; using system.runtime.interopservices; namespace myserviceinstaller { class serviceinstaller { #region private variables private string _servicepath; private string _servicename; private string _servicedisplayname; #endregion private var