将几个 mongodb 与 monstache 一起使用
Posted
技术标签:
【中文标题】将几个 mongodb 与 monstache 一起使用【英文标题】:Using several mongodbs with monstache 【发布时间】:2021-11-23 23:28:30 【问题描述】:我有一个使用 docker 进行弹性搜索和 mongodb 同步的工作 monstache 部署。配置文件如下图:
mongo-url = "mongodb://project-db:27017"
elasticsearch-urls = ["http://es7:9200"]
direct-read-namespaces = ["project.data"]
change-stream-namespaces = ["project.data"]
[logs]
error = "./logs/error.log"
[[mapping]]
namespace = "project.data"
index = "Project"
[[script]]
namespace = "project.data"
path = "./scripts/collection.js"
routing = true
但是,我需要添加其他几个数据库,比如其中的 10 个。 mongo-url 是一个字符串。有没有办法为索引添加几个 mongodb 源?
【问题讨论】:
【参考方案1】:Monstache 看起来相当轻。我建议在 docker compose 设置中使用多个 docker。像这样:
version: '3.5'
networks:
proxynet:
name: proxynet
driver: bridge
services:
mongodb:
networks:
- mongodbnet
- proxynet
ports:
- 27017:27017
container_name: mongodb
image: mongo:4.2.17
command: --auth --replSet mongoset
volumes:
- /path/to/docker/mongodb/data:/data/db
restart: unless-stopped
elasticsearch:
container_name: elasticsearch
networks:
- proxynet
ports:
- 9200:9200
- 9300:9300
environment:
- "discovery.type=single-node"
- ELASTIC_PASSWORD=random
volumes:
- /path/to/docker/elasticsearch/data:/usr/share/elasticsearch/data
image: elasticsearch:7.5.2
restart: unless-stopped
monstache01:
networks:
- proxynet
image: rwynn/monstache
container_name: monstache
ports:
- 8080:8080
working_dir: /monstache
command: -f ./monstache.toml
volumes:
- /path/to/monstache01:/monstache
depends_on:
- elasticsearch
- mongodb
restart: unless-stopped
monstache02:
networks:
- proxynet
- mongodbnet
image: rwynn/monstache
container_name: monstache
ports:
- 8081:8080
working_dir: /monstache
command: -f ./monstache.toml
volumes:
- /path/to/docker/monstache02:/monstache
depends_on:
- elasticsearch
- mongodb
restart: unless-stopped
【讨论】:
以上是关于将几个 mongodb 与 monstache 一起使用的主要内容,如果未能解决你的问题,请参考以下文章