mongo-shake使用
-
分类
软件
·
-
发表于 2025-01-08 11:02:55
下载文件
1
| wget "http://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/196977/jp_ja/1608863913991/mongo-shake-v2.4.16.tar.gz" -O mongoshake.tar.gz
|
解压
1
| tar zxvf mongoshake.tar.gz && mkdir mongoshake && mv mongo-shake-v2.4.16 mongoshake && cd mongoshake/mongo-shake-v2.4.16
|
配置
1 2 3 4 5 6 7 8 9 10
| vi collector.conf # 源mongodb地址 mongo_urls = mongodb://mongoshake:mongoshake@172.18.67.252:27117/admin?connect=direct # 目录mongodb地址 tunnel.address = mongodb://user:password@127.0.0.1:27017/dbName?connect=direct # 模式 # 同步模式,all表示全量+增量同步,full表示全量同步,incr表示增量同步。 sync_mode = full # 指定库和集合,不要加引号,多个分号分隔 filter.namespace.white = db1.col1;db2.col2
|
执行
1
| ./collector.linux -conf=collector.conf -verbose
|
mongodb用户权限
源数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| use admin db.createUser({ user: "mongoshake", roles: [ { role: "read", db: "local" }, { role: "readWrite", db: "mongoshake" }, { role: "read", db: "config" }, { role: "readAnyDatabase", db: "admin" } ] })
|
目标数据库
1 2 3 4 5 6 7 8 9 10
| use dbName db.createUser({ user: "dbUser", roles: [ { role: "readWrite", db: "dbName" } ] });
|
完整说明
https://help.aliyun.com/zh/mongodb/user-guide/use-mongoshake-to-implement-one-way-synchronization-between-apsaradb-for-mongodb-replica-set-instances