前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Solr 如何自动导入来自 MySQL 的数据

Solr 如何自动导入来自 MySQL 的数据

作者头像
村雨遥
发布2022-06-15 09:59:53
2K0
发布2022-06-15 09:59:53
举报
文章被收录于专栏:JavaPark

导入数据时的注意事项

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

自动增量更新

  • solr-dataimport-scheduler.jar 放入 solr-xxx/server/solr-webapp/webapp/WEB-INF/lib 文件夹下;
  • 在 ``solr-xxx/server/solr-webapp/webapp/WEB-INF/web.xml` 中配置监听;
代码语言:javascript
复制
<listener>
	<listener-class>  
		org.apache.solr.handler.dataimport.scheduler.ApplicationListener
	</listener-class>
</listener>
  • solr-xxx/server/solr/ 下新建文件夹 conf注意不是 solr-xxx/server/solr/weibo/ 中的 conf
  • solr-data-importscheduler.jar 中提取出 dataimport.properties 放入上一步创建的 conf 文件夹中,并根据自己的需要进行修改;比如我的配置如下;
代码语言:javascript
复制
# 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

总结

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

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-04-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 导入数据时的注意事项
  • 自动增量更新
  • 总结
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档