按时间增量导入_Solr 笔记3 自动导入数据库的数据

ff36cf0b1571f30c368748ad347613d1.png

导入数据时的注意事项

在笔记 2 中,可能在执行导入时会报错,那是因为还需要将 mysql-connector-java-xxx.jar 放入 solr-xxx/server/lib 文件夹下;

自动增量更新

  • solr-dataimport-scheduler.jar 放入 solr-xxx/server/solr-webapp/webapp/WEB-INF/lib 文件夹下;

00e64ad0ffd23e3b0c6b6ac2462eea60.png
  • `solr-xxx/server/solr-webapp/webapp/WEB-INF/web.xml 中配置监听;
    <listener>
    <listener-class>
    org.apache.solr.handler.dataimport.scheduler.ApplicationListener
    </listener-class>
    </listener>

7cca6d40bf92a6bfe41de5a6aaefa886.png
  • solr-xxx/server/solr/ 下新建文件夹 conf注意不是 solr-xxx/server/solr/weibo/ 中的 conf

4151dea1495660f5b4d9578749478e01.png
  • solr-data-importscheduler.jar 中提取出 dataimport.properties 放入上一步创建的 conf 文件夹中,并根据自己的需要进行修改;比如我的配置如下;
 # dataimport.properties example
 #
 # From this example, copy everything bellow "dataimport scheduler properties" to your
 #   dataimport.properties file and then change params to fit your needs
 #
 # IMPORTANT:
 # Regardless of whether you have single or multiple-core Solr,
 #   use dataimport.properties located in your solr.home/conf (NOT solr.home/core/conf)
 # For more info and context see here:
 # http://wiki.apache.org/solr/DataImportHandler#dataimport.properties_example
 ​
 ​
 #Tue Jul 21 12:10:50 CEST 2010
 # metadataObject.last_index_time=2010-09-20 11:12:47
 # last_index_time=2010-09-20 11:12:47
 ​
 ​
 #################################################
 #                                               #
 #       dataimport scheduler properties         #
 #                                               #
 #################################################
 ​
 #  to sync or not to sync
 #  1 - active; anything else - inactive
 syncEnabled=1
 ​
 #  which cores to schedule
 #  in a multi-core environment you can decide which cores you want syncronized
 #  leave empty or comment it out if using single-core deployment
 syncCores=weibo
 ​
 #  solr server name or IP address
 #  [defaults to localhost if empty]
 server=localhost
 ​
 #  solr server port
 #  [defaults to 80 if empty]
 port=8983
 ​
 #  application name/context
 #  [defaults to current ServletContextListener's context (app) name]
 webapp=solr
 ​
 #  URL params [mandatory]
 #  remainder of URL
 params=/dataimport?command=delta-import&clean=false&commit=true
 ​
 #  schedule interval
 #  number of minutes between two runs
 #  [defaults to 30 if empty]
 # 自动增量更新时间间隔,单位为 min,默认为 30 min
 interval=5
 ​
 # 重做索引时间间隔,单位 min,默认 7200,即 5 天
 reBuildIndexInterval = 7200
 ​
 # 重做索引的参数
 reBuildIndexParams=/dataimport?command=full-import&clean=true&commit=true
  
 ​
 # 重做索引时间间隔的开始时间
 reBuildIndexBeginTime=1:30:00

总结

到此,我们就可以实现数据库自动增量导入了;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值