You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

4 years ago
# storage-mongo-replica
4 years ago
A replica set in MongoDB is a group of mongod processes that maintain the same data set. Replica sets provide redundancy and high availability, and are the basis for all production deployments.
This section introduces replication in MongoDB as well as the components and architecture of replica sets. The section also provides tutorials for common tasks related to replica sets.
##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.
https://docs.mongodb.com/manual/replication/
## Quickstart
4 years ago
4 years ago
<img align="right" width="300" height="300" src="https://git.swarmlab.io:3000/swarmlab/storage-mongo-replica/raw/branch/master/images/replica-set-read-write-operations-primary.bakedsvg.png">
4 years ago
This is a quickstart guide of howto use this *LabInstance storage-mongo-replica*
### HowTo use it
### Default Configuration
- Mongo Port: 27017
- Mongo Root Username: swarmlab
- Mongo Root Password: swarmlab
- Mongo Database: app_swarmlab
- Mongo Database Usename: app_swarmlab
- Mongo Database Password: app_swarmlab
- Mongo ReplicaSet: rs0
4 years ago
<img align="right" width="500" height="300" src="https://git.swarmlab.io:3000/swarmlab/storage-mongo-replica/raw/branch/master/images/replica-set-primary-with-two-secondaries.bakedsvg.png">
4 years ago
### Test it!
4 years ago
4 years ago
>
> MONGO_INITDB_ROOT_USERNAME=swarmlab
> MONGO_INITDB_ROOT_PASSWORD=swarmlab
> MONGO_INITDB_DATABASE=app_swarmlab
> MONGO_INITDB_USERNAME=app_swarmlab
> MONGO_INITDB_PASSWORD=app_swarmlab
> MONGO_REPLICA_SET_NAME=rs0
>
> mongo "mongodb://localhost:30001,localhost:30002,localhost:30003/$MONGO_INITDB_DATABASE" -u $MONGO_INITDB_USERNAME
> mongo "mongodb://localhost:30001,localhost:30002,localhost:30003/app_swarmlab" -u app_swarmlab
>