Apache solr 配置与 tomcat 6.0 [英] Apache solr configuration with tomcat 6.0

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

问题描述

你能帮助我使用 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 部分:使用 TOMCAT 设置 SOLR

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

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

第 2 步:从您的 SOLR_HOME_DIR/dist/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/examples/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 解压您的 war 文件所必需的.如果您在 $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,事情应该会很顺利.您应该能够通过尝试 url http://localhost:8080/solr/admin/ 来验证 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 部分:使用数据导入处理程序通过 MSSQL SERVER 设置 SOLR

步骤 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 主目录下,所需的基本目录是 conf 和 lib.第一个,即您可能在第 1 部分的第 3 步中获得的 conflib 是您在第 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 个文件:data-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 步.首先编辑 data-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>

第 5 步:将我们的 data-config.xml 文件告诉 Solr.这可以通过将请求处理程序添加到 solrconfig.xml 文件来完成,该文件是 solr 配置文件.将以下请求处理程序添加到 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>

第 6 步:配置 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.

第七步:启动Tomcat

Step 7: Start Tomcat

第 8 步:现在访问 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" />)

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

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