Question:
I have a standalone MongoDB instance in my AWS EC2 instance. I’m planning to shift it to Mongo Atlas. The prerequisite is to convert the MongoDB instance into a replica set.
Below is the code for my mongo.conf
file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# mongodb.conf # Where to store the data. dbpath=/opt/bitnami/mongodb/data/db #where to log logpath=/opt/bitnami/mongodb/log/mongodb.log logappend=true bind_ip = 127.0.0.1 port = 27017 # Enable journaling, http://www.mongodb.org/display/DOCS/Journaling journal=true # Enable smaller default file size for MongoDB # Also reduces size of journal files from 1G to 128M #smallfiles=true # Enables periodic logging of CPU utilization and I/O wait #cpu = true # Turn on/off security. Off is currently the default #noauth = true auth = true # Verbose logging output. #verbose = true # Inspect all client data for validity on receipt (useful for # developing drivers) #objcheck = true # Enable db quota management #quota = true # Set oplogging level where n is # 0=off (default) # 1=W # 2=R # 3=both # 7=W+some reads #oplog = 0 # Diagnostic/debugging option #nocursors = true # Ignore query hints #nohints = true setParameter = enableLocalhostAuthBypass=0 unixSocketPrefix=/opt/bitnami/mongodb/tmp fork = true setParameter = enableLocalhostAuthBypass=0 # Replication Options replication: replSetName: res0 # in replicated mongo databases, specify here whether this is a slave or master #slave = true #source = master.example.com # Slave only: specify a single database to replicate #only = master.example.com # or #master = true #source = slave.example.com |
I’m using the below command to create the replica set:
1 2 |
sudo mongod --port 27017 --dbpath /opt/bitnami/mongodb --replSet res0 --bind_ip localhost |
I’m getting the below error:
1 2 |
NoMatchingDocument: Did not find replica set configuration document in local.system.replset |
What else should I change in my mongo.conf
file?
Answer:
I had same issue but I resolved following below steps :
I am on Windows server . Mongo DB shell version 3.0.4 . Error in below screen shot same as you mentioned
So I connect to Mongo shell switch to local .
Use following command. Please note SIR is my replica set name
1 2 3 4 5 6 7 |
cfg = { _id:"SIR" , members: [{ _id:0,host:"localhost:27017"}] }; rs.initiate(cfg) |
Result