首页 > 数据库 >monstache 实时同步mongodb 数据到 elasticsearch

monstache 实时同步mongodb 数据到 elasticsearch

时间:2022-09-24 11:24:27浏览次数:58  
标签:xxxx mongodb xxx xx monstache elasticsearch

最近在做数据统计功能,需要将mongodb数据实时同步到 elasticsearch 中。目前找到的方案有两种

1、通过flink mongodb cdc 

flink mongodb cdc 的优点是比较灵活,可以将mongodb中的数据同步到任意支持的目标库中,不限于elasticsearch ,但是目前在使用的过程共发现同步时会自动加一个Changelog Normalize 算子,背压比较严重。网上找了很多资料,暂时无法解决。

2、monstache 优点的话就是同步速度很快暂时没有发现性能问题,缺点也比较明显就是只能同步mongodb 数据到elasticsearch 中。

 

docker 中部署monstache(需要注意monstache版本要与elasticsearch 版本匹配)

docker run --privileged --name monstache -v /home/docker/monstache/config/monstache.config.toml:/app/monstache.config.toml -d -t  rwynn/monstache '-f' '/app/monstache.config.toml'

monstache.config.toml 内容如下

 1 # ip地址注意要修改
 2 mongo-url = "mongodb://xx.x.xxx.xxx:27017,xx.x.xxx.xxx:27018,xx.x.xxx.xxx:27019"
 3 # ip地址注意要修改
 4 elasticsearch-urls = ["http://xx.x.xxx.xxx:9200"]
 5 # mydb指的是需要同步的数据库
 6 direct-read-namespaces = ["xx.xxxx","xx.xxxx","xx.xxxx"]
 7 change-stream-namespaces = ["xx.xxxx","xx.xxxx","xx.xxxx"]
 8 #elasticsearch-user = "elastic"
 9 #elasticsearch-password = "pwd"
10 #elasticsearch-max-conns = 4
11 dropped-collections = true
12 dropped-databases = true
13 resume = true
14 resume-strategy = 0
15 verbose = true
16 cluster-name = 'docker-cluster'
17 
18 [[mapping]]
19 namespace = "xx.xxxx"
20 index = "xxxx"
21 type= "type-xxx"
22 
23 [[mapping]]
24 namespace = "xx.xxxx"
25 index = "xxxx"
26 type= "type-xxx"
27 
28 [[mapping]]
29 namespace = "xx.xxxx"
30 index = "xxxx"
31 type= "type-xxx"

 

标签:xxxx,mongodb,xxx,xx,monstache,elasticsearch
From: https://www.cnblogs.com/luozhiji/p/16725168.html

相关文章

  • elasticsearch遇到的一个小bug
     报错如图,idea里面只显示一些较为粗略的异常 经查询排错,原来是这里的score写成content了,Text类型不能排序  ......
  • MongoDB数据库备份(mongodump)以及恢复(mongorestore)工具实践
    摘要mongodump备份工具mongodump能够在Mongodb运行时进行备份,它的工作原理是对运行的Mongodb做查询,然后将所有查到的文档写入磁盘。mongodump的参数与mongoexport的参......
  • MongoDB用户权限管理
    管理用户创建及使用利用createUser函数创建用户:db.createUser({ user:"username", pwd:"password", roles:[ { role:"authorityName", db:"admin" } ......
  • flask MongoDB 很好例子
    逻辑图代码#fromcollectionsimportnamedtuplefromflaskimportFlask,make_response,jsonify,requestfromflask_mongoengineimportMongoEngine#fromapi_co......
  • Golang 使用 MongoDB 报错
    在使用MongoDB时,URI格式一般为:连接URImongodb://用户名:密码@127.0.0.1:27017//等同于mongodb://用户名:密码@127.0.0.1:27017/admin如果不指定数据库名,默认使......
  • ElasticSearch 快照 备份、恢复数据
    ElasticSearch设置备份文件地址 在elasticsearch.yml新增path.repo:["/home/es/snapshot"]注册快照存储库PUT_snapshot/ecopherebbs{"type":"fs",......
  • elasticsearch的.security-7索引崩溃恢复笔记
    装了es三方插件重启后出现以下问题failedtoauthenticateuser[elastic]failedtoretrievepasswordhashforreserveduser[elastic]org.elasticsearch.action.......
  • mongodb学习经验
    1、ObjectId与String相互转换ObjectId类型—→String类型这个非常简单,直接强制类型转换就可以了_id=str(ObjectId('类型'))String类型—→ObjectId类型fromb......
  • Windows - 部署 Elasticsearch
    Windows-部署Elasticsearch                                      引用:https://blog......
  • elasticsearch生成证书的两种方式
    1.elasticsearch-certgen方式注意:这种方式如果以后新增节点导致证书得重新生成并放到es所有节点2.elasticsearch-certutil方式##(1)创建证书$pwd/alidata1/admin......