栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用tomcat 6.0的Apache Solr配置

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用tomcat 6.0的Apache Solr配置

这是有帮助的分步过程。

第1部分:使用TOMCAT设置SOLR

步骤1:下载Solr。这只是一个zip文件。

步骤2:从SOLR_HOME_DIR / dist / apache-solr-1.3.0.war复制到tomcat Webapps目录:$
CATALINA_HOME / webapps / solr.war –注意war文件名更改。那很重要

步骤3:在您选择的位置创建solr主目录。这是该solr安装的配置所在的位置。最简单的方法是将SOLR_HOME_DIR / examples /
solr目录复制到您想要的Solr主容器所在的位置。说它放在C: solr中。

步骤4:希望您已经设置了环境变量,否则请设置JAVA_HOME,JRE_HOME,CATALINA_OPTS,CATALINA_HOME。请注意,CATALINA_HOME是指您的Tomcat目录,而CATALINA_OPTS是指您要提供给Solr的堆内存量。

步骤5:启动tomcat。请注意,仅在允许tomcat解压缩war文件时才需要这样做。如果在$ CATALINA_HOME /
webapps下查看,现在应该有一个solr目录。

步骤6:停止tomcat

步骤7:进入该solr目录并编辑WEB-INF / web.xml。向下滚动,直到看到如下所示的条目:

<!-- People who want to hardpre 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>/Path/To/My/solr/Home/solr/</env-entry-value>     <env-entry-type>java.lang.String</env-entry-type>  </env-entry>-->

设置您的Solr主页(例如:C: solr),然后取消注释环境条目。

第8步:再次启动Tomcat,一切应该进行得很出色。您应该可以通过尝试使用URL http:// localhost:8080 / solr /
admin /来验证solr是否正在运行。

第2部分:使用数据导入处理程序使用MSSQL Server设置SOLR

步骤1:下载Microsoft SQL Server JDBC驱动程序3.0。只需提取内容即可。在solr主目录下创建一个文件夹(示例:C: solr
lib)。从上面下载的存档中复制文件sqljdbc4.jar到其中。

步骤2:因此在Solr主目录下,所需的基本目录是conf和lib。您可能在第1部分的步骤3和lib中获得的第一个conf就是在第2部分的步骤1中创建的目录。

步骤3.进入conf目录。请在编辑器中打开3个文件:data-config.xml,schema.xml和solrconfig.xml。

步骤4.从编辑data-config.xml开始。放置您的SQL查询,数据库名称,服务器名称等。例如:

•   <dataConfig>•   <dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://X.Y.Z.U:1433;databaseName=myDB" user="test" password="tester" /> •   <document>•   <entity name="Text" query="select documentId, Data from Text">•   <field column="documentId" name="documentId" /> •   <field column="Data" name="Data" /> •   </entity>•   </document>•   </dataConfig>

步骤5:告诉Solr我们的data-
config.xml文件。这可以通过向solrconfig.xml文件(即solr配置文件)中添加请求处理程序来完成。将以下请求处理程序添加到solrconfig.xml中:

•   <requestHandler name="/dataimport"   >•   <lst name="defaults">•   <str name="config">C:solrconfdata-config.xml</str> •   </lst>•   </requestHandler>

第6步:配置schema.xml-在此文件中,您可以执行多项操作,例如设置字段的数据类型,设置搜索的唯一/主键等。

步骤7:启动Tomcat

步骤8:现在访问http:// localhost:8080 / solr / admin / dataimport.jsp?handler = /
dataimport并开始完全导入。

一些方便的注意事项:

    •   There are a number of reasons a data import could fail, most likely due to problem with the configuration of data-config.xml. To see for sure what's going on you'll have to look in C:tomcat6logscatalina.*.    •   If you happen to find that your import is failing due to system running out of memory, however, there's an easy, SQL Server specific fix. Add responseBuffering=adaptive and selectMethod=cursor to the url attribute of the dataSource node in data-config.xml. That stops the JDBC driver from trying to load the entire result set into memory before reads can occur.    •   Note that by default the index gets created in C:Tomcat6binsolrdataindex. To change this path just edit solrconfig.xml & change <dataDir>${solr.data.dir:./solr/data}</dataDir>.    •   In new Solr versions, I think 3.0 and above you have to place the 2 data import handler jars in your solr lib directory (i.e. for example apache-solr-dataimporthandler-3.3.0.jar & apache-solr-dataimporthandler-extras-3.3.0.jar). Search for them in your Solr zip you downloaded. In older Solr versions this is not required because they are bundled with solr.war. Since we have placed the data import handlers in the lib directory so we need to specify their paths in solrconfig.xml. Add this line to solrconfig.xml: (Example: <lib dir="C:/solr/lib/" regex="apache-solr-dataimporthandler-d.*.jar" />)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/609671.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号