solr与mysql数据同步的方案
1、使用activeMQ http://blog.csdn.net/zhou2s_101216/article/details/77855413
2、通过配置实现定时同步 http://blog.csdn.net/millery22/article/details/51445964
3、使用Linux的crontab http://blog.csdn.net/zfszhangyuan/article/details/53020897
http://blog.csdn.net/weixin_37178674/article/details/78844959
5、solr的增量全量同步 https://www.jianshu.com/p/c0b06643a467
6、solr自定义分词器
http://blog.csdn.net/qq_33157666/article/details/76350750
http://blog.csdn.net/WeiJonathan/article/details/18354723
7、数据库内容导入solr索引库中:Dataimport插件
https://www.cnblogs.com/anny0404/p/5234367.html

框图画的粗糙!勿喷啊!勿喷啊!
配置数据库与solrconfig.xml
Dataimport插件
可以批量把数据库中的数据导入到索引库中。
1.添加jar包
需要的jar包,再solr,目录的dist下,找到solr-dataimporthandler-4.7.0.jar,solr-dataimporthandler-extras-4.7.0.jar,移动到collection1下,lib包,如果没有lib包,自己创建一个即可。
除了这两个包,还需要数据库驱动包,mysql-connector-java-5.1.7-bin.jar,找不到可点击进行下载。同样放到lib包下。
2.修改solrconfig.xml,添加一个requestHandler。
找到collection1/conf目录的solrconfig.xml文件。
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
3.创建一个data-config.xml。目录和solrconfig.xml在同一个目录下collection1\conf

<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig> <dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://192.168.2.10:3306/lucene"
user="root"
password="root"/>
<document>
<entity name="product" query="SELECT pid,name,catalog_name,price,description,picture FROM products ">
<field column="pid" name="id"/>
<field column="name" name="product_name"/>
<field column="catalog_name" name="product_catalog_name"/>
<field column="price" name="product_price"/>
<field column="description" name="product_description"/>
<field column="picture" name="product_picture"/>
</entity>
</document> </dataConfig>

数据库url,配置成你自己的数据库地址和数据库名称即可。数据库备份SQL。下载 project.sql
4.配置好后,重启tomcat。访问页面。

Dataimport就配置成功了。下面可以导入数据库数据了。
Command : full-import--全导入 data-import---导入没导入的。
Entity:选择配置文件中定义的product实体进行导入。
点击Execute 即可。执行过程中,可能你会觉得很长时间怎么还没完成。点击 Refresh Status 刷新即可。
导入完毕后进行Query 查询。

"response": {
"numFound": 12,
"start": 0,
"docs": [
{
"product_catalog_name": "惠民特色",
"product_price": 23.6,
"product_name": "八珍豆腐饼",
"id": "1",
"product_picture": "1.jpg",
"_version_": 1527658021822398500
},
{
"product_catalog_name": "惠民特色",
"product_price": 28,
"product_name": "什锦福包",
"id": "2",
"product_picture": "2.jpg",
"_version_": 1527658022878314500
},
{
"product_catalog_name": "惠民特色",
"product_price": 18,
"product_name": "笋尖",
"id": "3",
"product_picture": "3.jpg",
"_version_": 1527658022881460200
},
{
"product_catalog_name": "惠民特色",

完毕!
solr与mysql数据同步的方案的更多相关文章
- Mysql数据同步Elasticsearch方案总结
Mysql数据同步Elasticsearch方案总结 https://my.oschina.net/u/4000872/blog/2252620
- Mysql主从同步配置方案(Centos7)
最近在做项目高可用时,需要使用数据同步.由于只有双节点,且采用主主同步可能存在循环同步的风险,故综合考虑采用Mysql主从同步(Master-Slave同步). 可能没有接触过Mysql数据同步时,可 ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第一篇:Debezium实现Mysql到Elasticsearch高效实时同步
文章转载自: https://mp.weixin.qq.com/s?__biz=MzI2NDY1MTA3OQ==&mid=2247484358&idx=1&sn=3a78347 ...
- 使用Solr索引MySQL数据
环境搭建 1.到apache下载solr,地址:http://mirrors.hust.edu.cn/apache/lucene/solr/ 2.解压到某个目录 3.cd into D:\Solr\s ...
- mysql数据同步
随着各行业信息化水平的不断提升,各种各样的信息管理系统都被广泛使用,各系统间数据完全独立,形成了大量的信息孤岛.出于管理及决策方面的需求,实现各平台的数据同步是一个很迫切的需求,TreeSoft数据库 ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第五篇:logstash-input-jdbc实现mysql 与elasticsearch实时同步深入详解
文章转载自: https://blog.csdn.net/laoyang360/article/details/51747266 引言: elasticsearch 的出现使得我们的存储.检索数据更快 ...
- 几篇关于MySQL数据同步到Elasticsearch的文章---第三篇:logstash_output_kafka:Mysql同步Kafka深入详解
文章转载自: https://mp.weixin.qq.com/s?__biz=MzI2NDY1MTA3OQ==&mid=2247484411&idx=1&sn=1f5a371 ...
- ElasticSearch5+logstash的logstash-input-jdbc实现mysql数据同步
在实现的路上遇到了各种坑,再次验证官方文档只能产考不能全信! ElasticSearch安装就不说了上一篇有说! 安装logstash 官方:https://www.elastic.co/guide/ ...
- Elasticsearch和mysql数据同步(logstash)
1.版本介绍 Elasticsearch: https://www.elastic.co/products/elasticsearch 版本:2.4.0 Logstash: https://www ...
随机推荐
- 浅谈Objeact.clone克隆(纯个人理解,如有错误请指正)
现在先来看一下jdk给出的Object.clone源码和注释 /** * Creates and returns a copy of this object. The precise meaning ...
- GIT命令基本使用
记录摘选自廖雪峰的官方网站归纳总结 1.centos下安装git [root@cdw-lj ~]# yum install git 2.配置用户名以及邮箱 [root@cdw-lj opt]# git ...
- QTableWidget 详细使用
QTableWidget 详细使用
- Codeforces 955C Sad powers (数论)
题目链接:Sad powers 题意:给出n个l和r,求出每个给出的[l,r]之间的可以使是另外一个数的k次方的数.(k>=2) 题解:题目给出的数据范围最大是1E18所以如果要直接把所有的从1 ...
- C标准库string.h中几个常用函数的使用详解
strlen 计算字符串长度 size_t strlen(const char *str) 计算字符串 str 的长度,直到空结束字符,但不包括空结束字符. 函数实现: int Strlen(cons ...
- C# ConcurrentBag的实现原理
目录 一.前言 二.ConcurrentBag类 三. ConcurrentBag线程安全实现原理 1. ConcurrentBag的私有字段 2. 用于数据存储的TrehadLocalList类 3 ...
- BaseProxy:异步http/https中间人
BaseProxy 异步http/https代理,可拦截并修改报文,可以作为中间人工具.仅支持py3.5+.项目地址:BaseProxy. 意义 BaseProxy项目的本意是为了使HTTP/HTTP ...
- JNI探秘-----FileInputStream的read方法详解
作者:zuoxiaolong8810(左潇龙),转载请注明出处,特别说明:本博文来自博主原博客,为保证新博客中博文的完整性,特复制到此留存,如需转载请注明新博客地址即可. 上一章我们已经分析过File ...
- numpy 初识(一)
基本操作: 读取文件(与pandas读取csv相似): import numpy numpy.genfromtxt("word.txt", delimiter=',', dtype ...
- 《Pro SQL Server Internals, 2nd edition》的CHAPTER 3 Statistics中的Introduction to SQL Server Statistics、Statistics and Execution Plans、Statistics Maintenance(译)
<Pro SQL Server Internals> 作者: Dmitri Korotkevitch 出版社: Apress出版年: 2016-12-29页数: 804定价: USD 59 ...