配置Solr7.3定时增量同步数据(定时与数据库同步数据)
2019-03-19 09:53
274 查看
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_44018093/article/details/88655359
添加updateTime字段与其他需要查询的字段
solr定时与数据库同步数据
-
配置准备:
需要(solr-dataimport-scheduler.jar)适用于7.3的jar包(有需要的可以留下邮箱)
-
dataimport.properties配置文件
-
新建数据库字段updateTime,并设置根据时间戳更新
-
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,我的是goods syncCores=goods # solr server name or IP address # [defaults to localhost if empty] # 本地的话不用改变 server=localhost # solr server port # [defaults to 80 if empty] # 配置solr的tomca端口号,默认8080 port=8080 # application name/context # [defaults to current ServletContextListener's context (app) name] # 默认不改 webapp=solr # URL params [mandatory] # remainder of URL # 默认不用修改,solr同步数据库的链接 params=/dataimport?command=full-import&wt=json # schedule interval # number of minutes between two runs # [defaults to 30 if empty] # 这里是设置定时任务的,单位是分钟,也就是多长时间你检测一次数据同步,根据项目需求修改 # 开始测试的时候为了方便看到效果,时间可以设置短一点 interval=1 # 重做索引的时间间隔,单位分钟,默认7200,即5天; # 为空,为0,或者注释掉:表示永不重做索引 reBuildIndexInterval=7200 # 重做索引的参数 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-dataimport-scheduler.jar 放到…apache-tomcat-8.0.39\webapps\solr\WEB-INF\lib下
修改\apache-tomcat-8.0.39\webapps\solr\WEB-INF\web.xml文件
添加以下代码(粘贴ApplicationListener别有空格)
<listener> <listener-class> org.apache.solr.handler.dataimport.scheduler.ApplicationListener </listener-class> </listener>
在\apache-tomcat-8.0.39\solrhome\下创建conf目录(文件夹)
-
把dataimport.properties配置文件放到创建好的conf目录中
进入\apache-tomcat-8.0.39\solrhome\goods\conf文件(你的core文件的conf)
打开并修改solr-data-config.xml文件,内容如下(需要修改成自己的)
<?xml version="1.0" encoding="UTF-8" ?> <dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/myup" user="yhl" password="123456"/> <document> <entity name="t_goods" pk="go_id" query="SELECT * FROM t_goods" deltaImportQuery="SELECT * FROM t_goods where go_id = '${dih.delta.go_id}'" deltaQuery="SELECT go_id FROM t_goods where updateTime > '${dataimporter.last_index_time}'"> > <field column="go_id" name="go_id"/> <field column="go_name" name="go_name"/> <field column="updateTime" name="updateTime"/> </entity> </document> </dataConfig>
修改完保存退出并打开managed-schema文件
配置完成,启动solr,等待一分钟看效果,如果一分钟后数据同步过来就OK了
相关文章推荐
- solr 配置自动同步数据库数据(全量,增量)
- solr5.5配置定时全量、增量同步索引mysql数据
- (一)solr 7.31版本window系统全程安装搭建,涵盖项目用到的大部分配置,常用查询,solr多条件查询、排序,配置数据库,定时同步,全量与增量更新,使用solrJ在java程序进行增删改查
- 用solr DIH 实现mysql 数据定时,增量同步到solr
- solr连接数据库,实现数据定时同步(个人项目经验)
- solr 从数据库导入数据,全量索引和增量索引(实例&配置&原理)
- 转:solr 从数据库导入数据,全量索引和增量索引(实例&配置&原理)
- solr 7+tomcat 8 + mysql实现solr 7基本使用(安装、集成中文分词器、定时同步数据库数据以及项目集成)
- solr 7+tomcat 8 + mysql实现solr 7基本使用(安装、集成中文分词器、定时同步数据库数据以及项目集成)
- 数据库增量同步(二台SQL Server服务器的数据库之间增量传输数据)(jaime原创)
- solr5.5.5安装配置,数据库数据导入实现检索
- Solr学习 DIH增量、定时导入并检索数据
- Solr全量索引、增量索引和定时增量索引配置
- Solr学习 DIH增量、定时导入并检索数据
- 利用DBLink创建数据库数据定时更新或同步
- solr增量数据配置说明
- solr7.2.1使用——定时增量更新数据
- solr运行配置与数据库数据导入到solr
- Solr:数据导入(包括关系数据库的全导入和增量导入)
- solr运行配置与数据库数据导入到solr