Home  >  Article  >  Backend Development  >  怎么使mysql的数据和Elasticsearch的数据保持实时同步?

怎么使mysql的数据和Elasticsearch的数据保持实时同步?

WBOY
WBOYOriginal
2016-07-06 13:53:571506browse

最近在做一个项目,需要使用Elasticsearch做一个商品搜索,应该怎样做才能使mysql的数据和Elasticsearch的数据保持实时同步,我现在能想到的就是每次涉及到数据库操作的时候都去更新Elasticsearch,但是这样的话对原来的程序需要修改的地方就太多了,因为原来的使用的仅仅是mysql,求一个比较好的解决方案,谢谢!!!

回复内容:

最近在做一个项目,需要使用Elasticsearch做一个商品搜索,应该怎样做才能使mysql的数据和Elasticsearch的数据保持实时同步,我现在能想到的就是每次涉及到数据库操作的时候都去更新Elasticsearch,但是这样的话对原来的程序需要修改的地方就太多了,因为原来的使用的仅仅是mysql,求一个比较好的解决方案,谢谢!!!

每天的变化,有多大的量呢?
假如库存,销量等频繁变化的数据隔离出来了,或者周期性更新,频率控制好了。
我这边是通过触发器来处理的。
http://www.toozy.cn/mysql-trigger-elasticsearch/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn