基于apache lucene的solr站内搜索引擎搭配手记之2



   基于apache lucene的solr站内搜索引擎搭配手记之2
   [ 预备警员.10078 @ 2009-03-23 17:16:37 ]


2.2.2
为solr找个home目录,如果将solr作为web一个子目录,我自己觉得不妥,于是就创建了一个solr的home目录:

shell>mkdir -p /opt/bin/solr
shell>mkdir -p /opt/webroot/solr

通过对get started的阅读,我发现solr不单单是做一个页面供查询就可以了, 后续的会有搜索数据的存储维护和管理,所以在这里,单独成项就是为了相对独立于WEB Server一些, 如果不做这个,在下面的配置中,将solr.home的默认将是 webserver_home/webapp/solr .

第二个目录是,solr以后扩展用的,也是为了通过 http://www.example.com/solr/能够访问到而做的。

有了这个目录之后,参考(http://wiki.apache.org/solr/SolrInstall):

Setup
?Stop your servlet container

?From the solr distribution, copy the solr war to the webapps directory of your servlet container as solr.war

?From the solr distribution, copy the example solr home example/solr as a template for your solr home.

?Start the servlet container, passing the location of your solr home. This may be done in a number of ways:

?Set the java system property solr.solr.home to your solr home.

?Configure the servlet container such that a JNDI lookup of "java:comp/env/solr/home" by the solr webapp will point to the solr home.

?The default solr home is "solr" under the JVM's current working directory ($CWD/solr), so start the servlet container in the directory containing ./solr

?Go to the solr admin page to verify that the installation is working. It will be at  http://localhost:8080/solr/admin

?The servlet container may have started on a port other than 8080... check the servlet containers documentation if you don't know what this is.

?If there is already a servlet container running at that port, yours may fail to start. Shut down the other one or change the port that yours is running at.

For information on working with more then one index, or more then one instance of Solr, please see MultipleIndexes.


我的webapp的目录是 /opt/bin/resin-2.1/webapps
我的做法是:

shell>cp /opt/src/apache-solr-1.3.0/example/webapps/solr.war /opt/bin/resin-2.1/webapps/

有了这步之后,resin一般会自动重启(如果没自动restart,手工restart一下),resin会展开 solr.war, 并在启动时加载,这些都是自动的,顺便了解了一下 war -- In computing, a WAR file (which stands for "web application archive" [1]) is a JAR file used to distribute a collection of JavaServer Pages, servlets, Java classes, XML files, tag libraries and static Web pages (HTML and related files) that together constitute a Web application. (http://en.wikipedia.org/wiki/WAR_file)

等resin重启后,会在resin的 webapps子目录的上一级,也就是与webapps 同级的目录,生成一个叫做 solr的子目录,oka,此时,将resin下的整个 solr子目录mv到 之前专门为 solr做的目录下 /opt/bin/solr

shell> mv /opt/bin/resin/solr/* /opt/webroot/solr
shell> mv /opt/bin/resin/webapps/solr.war /opt/webroot/solr/
shell> cp -rf /opt/src/apache-solr-1.3.0/example/solr/* /opt/bin/solr

后一步骤是将solr.war也从resin/webapps 移出,免得再自动展开。经过这个操作,solr就没了,resin不知道去哪里加载它。 此时开始做第三步:

2.2.3
修改solr, web appserver的配置文件,让它能找到 solr并随resin一起动。

2.2.3.1
需要在 /opt/bin/resin-2.1/conf/resin.conf 中增加:

        <web-app id="/solr" character-encoding="utf-8" >
                /opt/webroot/solr
                <directory-servlet>none</directory-servlet>
                <classpath id='solr/WEB-INF/lib' source='solr/WEB-INF/classes' compile='true'/>
                <env-entry>
                        <env-entry-name>solr/home</env-entry-name>
                        <env-entry-type>java.lang.String</env-entry-type>
                        <env-entry-value>/opt/bin/solr</env-entry-value>
                </env-entry>
                <security-constraint>
                  <web-resource-collection>
                        <url-pattern>/update/*</url-pattern>
                  </web-resource-collection>
                <!-- ....
posted @ 2009-10-10 18:56  searchDM  阅读(533)  评论(0编辑  收藏  举报