Last active
November 6, 2019 23:10
-
-
Save bootandy/4134840 to your computer and use it in GitHub Desktop.
Mongodb admin notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Start mongodb replica servers: | |
| mongod --replSet abc --dbpath /db/1 --port 27001 --oplogSize 50 --logpath log.1 --logappend --fork --rest | |
| mongod --replSet abc --dbpath /db/2 --port 27002 --oplogSize 50 --logpath log.2 --logappend --fork --rest | |
| mongod --replSet abc --dbpath /db/3 --port 27003 --oplogSize 50 --logpath log.3 --logappend --fork --rest | |
| Basic config for a replica set: | |
| cfg= | |
| { | |
| "_id" : "abc", | |
| "version" : 1, | |
| "members" : [ | |
| { | |
| "_id" : 0, | |
| "host" : "localhost:27001" | |
| }, | |
| { | |
| "_id" : 1, | |
| "host" : "localhost:27002" | |
| }, | |
| { | |
| "_id" : 2, | |
| "host" : "localhost:27003", | |
| } | |
| ] | |
| } | |
| rs.initiate(cfg) | |
| [ rs.reconfig(cfg) ] | |
| options: store arbiterOnly / priority / hidden / slaveDelay / (votes) | |
| priority - how likely it will be master (0=never) | |
| slaveDelay - db which is X seconds delayed (requires big oplog, priority always 0) | |
| Run commands on slave: | |
| rs.slaveOk() | |
| Check on things: | |
| >rs.status() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment