solr7.2.1使用——定时增量更新数据

本文介绍如何通过配置Solr数据导入调度器实现增量数据同步。主要包括下载并配置必要的JAR包、设置dataimport.properties文件参数及web.xml监听器,同时提供Linux与Windows环境下定时任务的设置方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、下载JAR:http : //code.google.com/p/solr-data-import-scheduler/    添加至webapp lib目录下

2、创建dataimport.properties

文件内容:

#################################################
#                                               #
#       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=gx_core,core_magazine

#  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-webapp

#  URL params [mandatory]
#  remainder of URL
params=/select?qt=/dataimport&command=delta-import&clean=false&commit=true
#params=/dataimport?command=delta-import&clean=false&commit=true&optimize=false&wt=json&indent=true&entity=forumTopic&verbose=false&debug=false
#  schedule interval
#  number of minutes between two runs
#  [defaults to 30 if empty]
interval=1

3.配置web.xml监听

<listener>
   <listener-class>org.apache.solr.handler.dataimport.scheduler.ApplicationListener</listener-class>
 </listener>

配置完重启就可以了

 

 

Linux crontab定时任务

以Linux crontab 为例 每隔一分钟,定时Get请求方式访问URL进行增量导入

Linux终端下输入crontab -e进入编辑模式:

*/1 * * * * /usr/bin/curl -G -d "/dataimport?command=delta-import&clean=false&commit=true" http://localhost:8983/solr/core1

然后重启服务

service crond restart         //重启服务 

window 使用cur命令 (cur 需要安装:https://curl.haxx.se/download.html 下载后把crul.exr拷到C盘windows system32下)

命令:(批处理下特殊符号转义加^)

curl http://localhost:8983/solr/core1/dataimport?command=delta-import^&clean=false^&commit=true

 添加到定时任务即可

vbs运行不弹命令窗口

Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c solr.bat",0

评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值