方法 1 手动执行 对应的接口
启动tomcat,访问http://localhost:8080/solr/dataimport?command=full-import 将数据全部导入solr服务器进行索引
访问http://localhost:8080/solr/dataimport?command=status可以查看运行状态
当修改data-config.xml 文件配置时运行http://localhost:8080/solr/dataimport?command=reload-config可以进行重新加载配置文件
如果想终止运行http://localhost:8080/solr/dataimport?command=abort
方法2 添加定时任务 crond
方法 3 使用 solr-dataimportscheduler-1.1.jar
接下来 主要介绍 solr-dataimportscheduler-1.1.jar 的配置
下载 solr-dataimportscheduler-1.1.jar ,在 solr_name 目录下 创建 conf ,讲 solr-dataimportscheduler-1.1.jar 放在 conf下 ,解压
保留 dataimport.properties 其余删除 如没有 ,手动 新建 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 对应的core 名称
syncCores=im_core
# solr server name or IP address
# [defaults to localhost if empty]
server=localhost
# solr server port Tomcat 对应的接口 我本机是 8089
# [defaults to 80 if empty]
port=8089
# application name/context
# [defaults to current ServletContextListener's context (app) name]
webapp=solr
# 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
# schedule interval
# number of minutes between two runs 默认单位 分钟
# [defaults to 30 if empty]
interval=1
# 重做索引的时间间隔,单位分钟,默认7200,即1天;
# 为空,为0,或者注释掉:表示永不重做索引
#reBuildIndexInterval=2
# 重做索引的参数
reBuildIndexParams=/select?qt=/dataimport&command=full-import&clean=true&commit=true
# 重做索引时间间隔的计时开始时间,第一次真正执行的时间=reBuildIndexBeginTime+reBuildIndexInterval*60*1000;
# 两种格式:2012-04-11 03:10:00 或者 03:10:00,后一种会自动补全日期部分为服务启动时的日期
reBuildIndexBeginTime=03:10:00
配置结束
将solr-dataimportscheduler-1.1.jar包复制到 对应 Tomcat\solr\WEB-INF\lib中
在apache-tomcat-7.0.72\webapps\solr\WEB-INF目录下的web.xml文件中添加监听配置
<
listener
>
<
listener-class
>
org.apache.solr.handler.dataimport.scheduler.ApplicationListener
</
listener-class
>
</
listener
>
重启 tomcat 查看结果。。。到此结束