Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorgermduarte/mongo-replication
https://github.com/jorgermduarte/mongo-replication
cluster data mongo mongodb mongoose replica replica-set replication
Last synced: about 22 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/jorgermduarte/mongo-replication
- Owner: jorgermduarte
- License: mit
- Created: 2023-08-07T16:53:34.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-03T05:15:26.000Z (about 1 year ago)
- Last Synced: 2024-05-28T21:19:57.188Z (6 months ago)
- Topics: cluster, data, mongo, mongodb, mongoose, replica, replica-set, replication
- Language: JavaScript
- Homepage:
- Size: 80.1 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mongo-replication
This example creates a mongo replication with 3 nodes (1 primary and 2 secondary).
![Replication Nodes](images/nodes.png)
## Replication in mongodb
- A replica set is a group of mongod instances that maintain the same data set. A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes.
- The primary node receives all write operations. A replica set can have only one primary capable of confirming writes with { w: "majority" } write concern; although in some circumstances, another mongod instance may transiently believe itself to also be primary. [1] The primary records all changes to its data sets in its operation log, i.e. oplog. For more information on primary node operation, see Replica Set Primary.
- The secondaries replicate the primary’s oplog and apply the operations to their data sets such that the secondaries’ data sets reflect the primary’s data set. If the primary is unavailable, the replica set will elect a secondary to be primary. For more information on secondary members, see Replica Set Secondary Members.
> for more information read : https://www.mongodb.com/docs/v3.0/core/replication-introduction/
## Executing
> docker compose up mongo-setup --build -d
## Testing the connection ( connecting thru an application on containers)
> docker compose up mongo-connection-test --build
you should notice in the output: **"Connected to mongo1 successfully"**
![Connection Test](images/connection_test.png)
## Running the backup service
> docker compose up backup-service --build -d
A new backup with a random uuid will be created on the app/temp_backup directory
![Backup example](images/backup_example.png)