Elasticsearch 与 Mongodb 数据同步问题
1、mongo-connector工具
首先安装python环境
wget http://www.python.org/ftp/python/3.0.1/Python-3.0.1.tgz
tar -zxvf Python-3.0.1.tgz
cd Python-3.0.1
./configure
make all
make install
看来新装的版本生效了,做个软连接应该就OK。
ln -s /usr/local/bin/python3.0 /usr/bin/python
python -V
安装pip
$ wget https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ pip -V #查看pip版本
安装mongo-connector
如果是 Elasticsearch 5.x
pip install 'mongo-connector[elastic5]'
[Reference] https://github.com/mongodb-labs/mongo-connector
执行命令:
mongo-connector -m 192.9.8.204:27017 -t 192.9.8.223:9200 -d elastic2_doc_manager -n wymlib.ym_literature
-m :mongodb地址,-t:目的地址,-d : Used to specify the path to each doc manager file that will be used. -n:指定数据库
2、elasticsearch-river-mongodb
该工具只支持 elasticsearch 1.7.3 及以下版本
bin/plugin --install com.github.richardwilly98.elasticsearch/elasticsearch-river-mongodb/2.0.9
mongodb-river同步信息属性配置完整版:
$ curl -XPUT "localhost:9200/_river/${es.river.name}/_meta" -d '
{
"type": "mongodb",
"mongodb": {
"servers":
[
{ "host": ${mongo.instance1.host}, "port": ${mongo.instance1.port} },
{ "host": ${mongo.instance2.host}, "port": ${mongo.instance2.port} }
],
"options": {
"secondary_read_preference" : true,
"drop_collection": ${mongo.drop.collection},
"exclude_fields": ${mongo.exclude.fields},
"include_fields": ${mongo.include.fields},
"include_collection": ${mongo.include.collection},
"import_all_collections": ${mongo.import.all.collections},
"initial_timestamp": {
"script_type": ${mongo.initial.timestamp.script.type},
"script": ${mongo.initial.timestamp.script}
},
"skip_initial_import" : ${mongo.skip.initial.import},
"store_statistics" : ${mongo.store.statistics},
},
"credentials":
[
{ "db": "local", "user": ${mongo.local.user}, "password": ${mongo.local.password} },
{ "db": "admin", "user": ${mongo.db.user}, "password": ${mongo.db.password} }
],
"db": ${mongo.db.name},
"collection": ${mongo.collection.name},
"gridfs": ${mongo.is.gridfs.collection},
"filter": ${mongo.filter}
},
"index": {
"name": ${es.index.name},
"throttle_size": ${es.throttle.size},
"bulk_size": ${es.bulk.size},
"type": ${es.type.name}
"bulk": {
"actions": ${es.bulk.actions},
"size": ${es.bulk.size},
"concurrent_requests": ${es.bulk.concurrent.requests},
"flush_interval": ${es.bulk.flush.interval}
}
}
}'
[Reference] https://github.com/richardwilly98/elasticsearch-river-mongodb
Elasticsearch 与 Mongodb 数据同步问题的更多相关文章
- MongoDB副本集配置系列十一:MongoDB 数据同步原理和自动故障转移的原理
1:数据同步的原理: 当Primary节点完成数据操作后,Secondary会做出一系列的动作保证数据的同步: 1:检查自己local库的oplog.rs集合找出最近的时间戳. 2:检查Primary ...
- 用elasticsearch索引mongodb数据
参照网页:单机搭建elasticsearch和mongodb的river 三个步骤: 一,搭建单机replicSet二,安装mongodb-river插件三,创建meta,验证使用 第一步,搭建单机m ...
- Elasticsearch和mysql数据同步(logstash)
1.版本介绍 Elasticsearch: https://www.elastic.co/products/elasticsearch 版本:2.4.0 Logstash: https://www ...
- Elasticsearch和mysql数据同步(elasticsearch-jdbc)
1.介绍 对mysql.oracle等数据库数据进行同步到ES有三种做法:一个是通过elasticsearch提供的API进行增删改查,一个就是通过中间件进行数据全量.增量的数据同步,另一个是通过收集 ...
- kettle之mongodb数据同步
需求: 1.源数据库新增一条记录,目标库同时新增一条记录: 2.源数据库修改一条记录,目标库同时修改该条记录: 示例用到三个Kettle组件 下面详细说下每个组件的配置 Source: 本示例连接的是 ...
- 基于netcore实现mongodb和ElasticSearch之间的数据实时同步的工具(Mongo2Es)
基于netcore实现mongodb和ElasticSearch之间的数据实时同步的工具 支持一对一,一对多,多对一和多对多的数据传输方式. 一对一 - 一个mongodb的collection对应一 ...
- Linux安装ElasticSearch与MongoDB分布式集群环境下数据同步
ElasticSearch有一个叫做river的插件式模块,可以将外部数据源中的数据导入elasticsearch并在上面建立索引.River在集群上是单例模式的,它被自动分配到一个节点上,当这个节点 ...
- MongoDB 数据自动同步到 ElasticSearch
我们产品中需要全文检索的功能,后端数据存储主要使用了 MySQL + MongoDB,而其中需要检索的内容是在 MongoDB 中的. MongoDB 本身是自带文本索引功能的,但是,不支持中文.术业 ...
- logstash-out-mongodb实现elasticsearch到Mongodb的数据同步
本文主要实现将Elasticsearch中的索引数据Index同步到Mongodb中的集合collection中. 0.前提 1)已经安装好源数据库:elasticsearch V2.X; 2)已经安 ...
随机推荐
- Cannot retrieve the latest commit at this time.
此时无法检索最新提交. GitHub页面上提示: Cannot retrieve the latest commit at this time. 还没更新的意思,等他更新就好了. 更新后:
- selenium+phantomjs渲染网页
from selenium import webdriverfrom selenium.webdriver.common.desired_capabilities import DesiredCapa ...
- [MySQL] 01- Basic sql
准备 一.配置 1. 登录:mysql -u root -p 2. phpMyAdmin创建数据库,并导入.sql文件. 3. 支持中文:set names utf8; 二.面试题 参考:面试宝典- ...
- 8 -- 深入使用Spring -- 1...1Bean后处理器
8.1.1 Bean后处理器(BeanPostProcessor) Bean后处理器主要负责对容器中其他Bean执行后处理,例如为容器中的目标Bean生成代理等. Bean后处理器会在Bean实例创建 ...
- ubuntu 13.04 nginx.conf 配置详解
1.nginx.conf 文件,路径为:/etc/nginx/agin.conf #使用的用户和组 user www-data; #指定工作衍生进程数(一般等于CPU总核数或总核数的两倍) worke ...
- moment.js用法总结
moment(),获取当前时间 moment(string)把字符串变成moment时间格式 moment().format("YYYY-MM-DD HH:mm:ss"):规定时间 ...
- 使用pull方式解析xml文件示例:
网上的示例太多,基本类似,个人在此做个简单的总结: 1.首先在工程的asserts目录下建一个book.xml文件: <?xml version="1.0" encoding ...
- CopyTransform
// TransformCopier.cs v 1.1 // homepage: http://wiki.unity3d.com/index.php/CopyTransform using Unity ...
- flask获取传入参数的两种方式
#coding=utf-8 from flask import Flask from flask import request app = Flask(__name__) @app.route(&qu ...
- [转]logging使用
来源:https://www.cnblogs.com/nancyzhu/p/8551506.html日志 日志是跟踪软件运行时所发生的事件的一种方法.软件开发者在代码中调用日志函数,表明发生了特定的事 ...