在Tomcat 6.0 Apache Solr实现配置 [英] Apache solr configuration with tomcat 6.0

查看:185
本文介绍了在Tomcat 6.0 Apache Solr实现配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能帮我使用Tomcat配置Apache Solr和如何使用Solr的索引MS SQL数据库。
什么是配置Tomcat给Tomcat运行Apache Solr实现的步骤。

Can you help me configuring Apache Solr using Tomcat and how to index in MS SQL database using Solr. What are the steps to configure Tomcat to run Apache Solr in Tomcat.

推荐答案

下面是一步一步的过程,这将有助于。

Here is the step by step procedure that would help.

第1部分:建立与SOLR TOMCAT

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

Step 1: Download Solr. It's just a zip file.

步骤2:复制从SOLR_HOME_DIR /距离/ Apache的Solr的-1.3.0.war到Tomcat webapps目录下:$ CATALINA_HOME / webapps /下solr.war - 注意war文件名称更改。这是非常重要的。

Step 2: Copy from your SOLR_HOME_DIR/dist/apache-solr-1.3.0.war to your tomcat webapps directory: $CATALINA_HOME/webapps/solr.war – Note the war file name change. That’s important.

第3步:在您选择的位置创建Solr的主目录。这是对于Solr的配置安装所在。要做到这一点最简单的方法是复制SOLR_HOME_DIR /例子/ Solr的目录无论它是您希望Solr的主容器中。说,在C座它:\\ Solr的

Step 3: Create your solr home directory at a location of your choosing. This is where the configuration for that solr install resides. The easiest way to do this is to copy the SOLR_HOME_DIR/examples/solr directory to wherever it is you want your solr home container to be. Say place it in C:\solr.

第4步:希望你有你的设置环境变量,如果没有的话,请设置JAVA_HOME,JRE_HOME,CATALINA_OPTS,CATALINA_HOME。需要注意的是CATALINA_HOME指的是Tomcat的目录和放大器; CATALINA_OPTS指的是你想给你的Solr的堆内存量。

Step 4: Hope you have set your environment variables, if not then please set JAVA_HOME, JRE_HOME, CATALINA_OPTS, CATALINA_HOME. Note that CATALINA_HOME refers to your Tomcat directory & CATALINA_OPTS refers to the amount of heap memory you want to give to your Solr.

第五步:启动tomcat。注意:这仅仅是必要的,让Tomcat来解开你的战争文件。如果你看一下在$ CATALINA_HOME / webapps中现在应该是一个Solr的目录。​​

Step 5: Start tomcat. Note this is only necessary to allow tomcat to unpack your war file. If you look under $CATALINA_HOME/webapps there should now be a solr directory.

第六步:停止Tomcat

Step 6: Stop tomcat

第7步:进入该目录的Solr和编辑WEB-INF / web.xml文件。向下滚动,直到你看到像这样的条目:

Step 7: Go into that solr directory and edit WEB-INF/web.xml. Scroll down until you see an entry that looks like this:

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

设置Solr的主(例如:C:\\ Solr的),并取消对ENV条目

Set your Solr home (for example: C:\solr) and uncomment the env entry.

第8步:再次启动Tomcat和东西要漂漂去。您应该能够核实试图链接的HTTP Solr的运行://本地主机:8080 / Solr的/管理/

Step 8: Start Tomcat again, and things should be going splendidly. You should be able to verify that solr is running by trying the url http://localhost:8080/solr/admin/.

第2部分:建立与SOLR MSSQL Server中使用数据导入HANDLER

第1步:下载的Microsoft SQL Server JDBC驱动程序3.0。只需提取的内容。您Solr的主目录下创建一个文件夹(例如:C:\\ Solr的\\ LIB)。文件sqljdbc4.jar复制出上面下载到它的归档。

Step 1: Download Microsoft SQL Server JDBC Driver 3.0. Just extract the contents. Create a folder under your solr home directory (Example: C:\solr\lib). Copy the file sqljdbc4.jar out of the archive downloaded above into it.

第2步:所以在你家的Solr所需的基本目录是形态和lib。你可能已经有部分1和第3步得到的第一个,即CONF; LIB是你在第2部分第1步创建的目录。

Step 2: So under your Solr home the basic directories needed are conf and lib. The first one i.e. conf you might have got with Step 3 of part 1 & lib is the directory you have created in Step 1 of part 2.

步骤3.转到conf目录。请在你的编辑器中打开3个文件:数据-config.xml中,schema.xml中和放大器; solrconfig.xml中。

Step 3. Go to conf directory. Please open 3 files in your editor: data-config.xml, schema.xml & solrconfig.xml.

步骤4.开始编辑数据-config.xml中。请将您的SQL查询,数据库名称,服务器名称等等。举一个例子:

Step 4. Start by editing data-config.xml. Place your SQL query, DB Name, Server name etc. For an example:

•   <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>

第五步:告诉Solr的关于我们的数据-config.xml文件。这将通过增加一个请求处理程序solrconfig.xml中的文件是Solr的配置文件来完成。
添加以下requesthandler到solrconfig.xml中:

Step 5: Tell Solr about our data-config.xml file. This would be done by adding a request handler to the solrconfig.xml file which is solr configuration file. Add the following requesthandler to solrconfig.xml:

•   <requestHandler name="/dataimport"   class="org.apache.solr.handler.dataimport.DataImportHandler">
•   <lst name="defaults">
•   <str name="config">C:\solr\conf\data-config.xml</str> 
•   </lst>
•   </requestHandler>

第六步:配置schema.xml中 - 在这个文件中,你可以做几样东西设置您的字段的数据类型,设置搜索等唯一/主键

Step 6: Configure schema.xml - In this file you can do several stuff like setting up datatypes of your fields, setting unique/primary key of your search etc.

第7步:启动Tomcat

Step 7: Start Tomcat

第8步:现在访问<一个href=\"http://localhost:8080/solr/admin/dataimport.jsp?handler=/dataimport\">http://localhost:8080/solr/admin/dataimport.jsp?handler=/dataimport &安培;启动全面导入。

Step 8: Now visit http://localhost:8080/solr/admin/dataimport.jsp?handler=/dataimport & start your full import.

一些常见的注意事项:

    •   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:\tomcat6\logs\catalina.*.

    •   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:\Tomcat6\bin\solr\data\index. 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" />)

这篇关于在Tomcat 6.0 Apache Solr实现配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆