Skip to content

Commit

Permalink
Added manual mongo statefulset config docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaknadig committed Mar 21, 2020
1 parent 49b8eab commit 058ab8f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions doc/mongo-statefulset-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# MongoDB Replicaset Configuration

Assuming that the MongoDB replicas are named `mongo-#.mongo`, where `#` is a number, and the name `mongo` after the dot (`.`) is the name of the headless service, we can initialize as:

## Initialization
Choose and initialize the primary.
```javascript
rs.initiate( {
_id: "rs0",
members:[ { _id: 0, host: "mongo-0.mongo:27017" } ]
});
```
Next, add the secondary members.
```javascript
rs.add("mongo-1.mongo:27017");
rs.add("mongo-2.mongo:27017");
```



## Reconfiguration
To check the status, use `rs.status()`
To reconfigure after initialization, use:
```javascript
rsconf = rs.conf()
rsconf.members = [{_id: 0, host: "mongo-0.mongo:27017"}]
rs.reconfig(rsconf, {force: true})
```

0 comments on commit 058ab8f

Please sign in to comment.