Facebooktwittergoogle_pluslinkedinmailby feather

AWS has cool documentation but sometimes not guiding you practical solutions. If you have intended you use the following mongodb Cloudformation template:

https://aws.amazon.com/blogs/aws/mongodb-on-the-aws-cloud-new-quick-start-reference-deployment/

You will notice that, mongo is not operable. In order to achieve that you need to ssh and enter to mongo console by typing mongo:

When you check the repliaction set status you will see:

> rs.status ()
{
        "info" : "run rs.initiate(…) if not yet done for the set",
        "ok" : 0,
        "errmsg" : "no replset config has been received",
        "code" : 94

initiate the replica with:

> rs.initiate()
{
        "info2" : "no configuration explicitly specified — making one",
        "me" : "ip-10-0-2-241:27017",
        "ok" : 1
}
 
You can now check the status again:
 
s-1:PRIMARY> rs.status()
{
        "set" : "s-1",
        "date" : ISODate("2016-03-23T16:00:30.805Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "ip-10-0-2-241:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 13924,
                        "optime" : Timestamp(1458748644, 1),
                        "optimeDate" : ISODate("2016-03-23T15:57:24Z"),
                        "electionTime" : Timestamp(1458748644, 2),
                        "electionDate" : ISODate("2016-03-23T15:57:24Z"),
                        "configVersion" : 1,
                        "self" : true
                }
        ],
        "ok" : 1
}