solr4..7部署

1.解压solr-4.7.0.tgz

tar -zxvf solr-4.7.0.tgz

2.将solr-4.4.0\dist\solr-4.4.0.war拷贝到 apache-tomcat-6.0.35\webapps下

mv solr-4.7.0.war /user/local/www/tomcat/solr.war

3.在tomcat的目录conf/Catalina/localhost/solr.xml下创建该文件,内容如下

<?xml version="1.0" encoding="UTF-8"?>

<Context docBase="E:/tomcat/webapps/solr.war" debug="0" crossContext="true" >

   <Environment name="solr/home" type="java.lang.String" value="E:\tomcat\webapps\solr" override="true" />

</Context>

4.启动 tomcat,启动成功后停止 tomcat,并将 solr.war删除

5. 将 solr-server\solr-4.4.0\dist下的 jar拷贝到 webapps\solr\WEB-INF\lib下 
6. 将 solr-server\solr-4.4.0\dist\solrj-lib下的 jar拷贝到 webapps\solr\WEB-INF\lib下 
7. 将 solr-server\solr-4.4.0\example\resources\log4j.properties拷贝到 webapps\solr\WEB-INF\lib下

8.把\example\multicore下面的文件覆盖到solr文件夹下

二.增加dataimport更新

1.在 solr-server\SolrHome\core1\conf增加 dataimport.properties,  内容为:

last_index_time=2013-09-1313\:36\:29  id.last_index_time=2013-09-1313\:36\:29

2.在 solr-server\SolrHome\core1\conf\solrconfig.xml  config节点下,加入以下内容

      <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
      <str name="config">/usr/local/www/tomcat/webapps/solr/core0/conf/data-config.xml</str>      
    </lst>
  </requestHandler>

3.配置data-config.xml 

<dataConfig>

<dataSource  driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/msmall" user="root"  password="nihao123" />

    <document name="products" >

        <entity name="item" query="select id,full_name,image,introduction,market_price from xx_product">

            <field column="id" name="id" />

            <field column="full_name" name="name" />

            <field column="image" name="img" />

            <field column="introduction" name="introduction" />

            <field column="market_price" name="price" />



        </entity>

    </document>

</dataConfig>

网上的配置

<?xmlversion="1.0" encoding="UTF-8" ?>
 <dataConfig>  
<dataSource type="JdbcDataSource"driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/***" user="***" password="***" /> 
 <document name="mytable">  
<entity name="***" transformer="ClobTransformer" query="***" deltaImportQuery="SELECT * FROM *** where id=${dataimporter.delta.id}" deltaQuery="select id from *** where *** >'${dataimporter.last_index_time}' OR *** >'${dataimporter.last_index_time}' OR ***> '${dataimporter.last_index_time}'">  </entity>
 </document> 
</dataConfig>

 

4.

将dist下的apache-solr-dataimportscheduler-1.0.jar拷贝到webapps\solr\WEB-INF\lib

5.在 webapp/solr下添加conf目录,添加 dataimport.properties,主要内容如下:

#索引重建的间隔      (单位为分钟 )
interval=1
#重建索引时的参数 (增量更新      执行 clean和 commit   ) 
params=/dataimport?command\=delta-import&clean\=false&commit\=true
#索引 webapp名称 
webapp=solr 
#索引名称
syncCores=core0
#server名称
server=localhost
#端口
port=8080
# 重做索引时间间隔的计时开始时间,第一次真正执行的时间

# 两种格式: 2012-04-1103:10:00或者   03:10:00,后一种会自动补全日期
reBuildIndexBeginTime=03:10:00

有时间批量增量更新时会出现内存溢出,可以在solrconfig.xml 增加以下

<autoCommit>  
<maxDocs>10000</maxDocs> 
 <maxTime>1000</maxTime>  
</autoCommit>

 完成了

 

 

posted on 2014-03-11 15:28  看我的眼神儿  阅读(85)  评论(0)    收藏  举报