Is there a way to replicate certain part of collection in Mongodb
-
12-12-2020 - |
質問
Is there away to stream certain part of collection in MongoDB
or TokuMX
from master server to another server? I need to duplicate only certain collection
Or if it isn't possible, are there any other alternative for database that doesn't enforce schema?
解決
MongoDB at least to current version 2.6+ for sure does not support that as build-in functionality. I guess because a replica set using selective replication won't be consistent.
There is a feature called filtered replication in Couch but never tried it: http://wiki.apache.org/couchdb/Replication#Filtered_Replication
他のヒント
The filtered replication is not something that is currently implemented in MongoDB out of the box.
That said, the replication in MongoDB is based on a special collection named "oplog", that you can listen to and do the filter yourself, and in this case implement the filter you want to push data into another cluster. (This will be viewed as 2 different clusters, not a single ReplicaSet)
As a starting point I am inviting you to look a the MongoDB Connector, that allow you to capture the changes in the oplog: