0

I'am trying to create replcaSet in MongoDB and I'am facing a problem.

This is what I did step by step:

1- I entered this command to create these repertories:

mkdir \data\rs1 \data\rs2 \data\rs3 

2- I entered this:

start mongod --replSet amir --logpath \data\rs1\1.log --dbpath \data\rs1 --port 27017 --smallfiles --oplogSize 64

As a second cmd:

start mongod --replSet amir --logpath \data\rs1\2.log --dbpath \data\rs2 --port 27018 --smallfiles --oplogSize 64

Then as a third cmd:

start mongod --replSet amir --logpath \data\rs1\3.log --dbpath \data\rs3 --port 27019 --smallfiles --oplogSize 64

After that I entered this in the first cmd:

config={_id:"amir", members:[ {_id:0,host:"localhost:27017"},  {_id:1,host:"localhost:27018"}, 
{_id:2,host:"localhost:27019"}] };

And finnally I entered:

 rs.initiate (config); 

It showed me this :

  { "ok" : 0, "errmsg" : "Missing expected field \"version\"", "code" : 93 }

Do you have any ideas on this problem?

enter image description here

1

I had similar issue, and the reason was connected than mongo was using my pc name instead of localhost..

start mongoD and search for this string:

2016-03-07T16:01:05.777+0000 I CONTROL [initandlisten] MongoDB starting : pid=26176 port=27017 dbpath=G:\data\db\ 64-bit host=MyLaptop

So I had to switch from localhost to mylaptop in config

please valid form of config

var config={_id:"amir", 
                "version" : 1,
                members:[ {_id:0,host:"localhost:27017"},  
                {_id:1,host:"localhost:27018"}, 
                {_id:2,host:"localhost:27019"}] };
  • +1 I can attest that MongoDB (on linux at least) is picky about FQDNs. – Ali Razeghi Mar 7 '16 at 19:26
  • @AliRazeghi It is not picky. Names just must be resolvable. You can even use /etc/hosts and pick funky names. And they don't need to be FQDNs. – Markus W Mahlberg Mar 8 '16 at 13:21
  • @MarkusWMahlberg man I've had bad experiences in earlier versions and in Hadoop both. I'll test out the post 2.4 versions though, maybe by 3.2 my experiences would be nullified. – Ali Razeghi Mar 8 '16 at 19:52
0

This rs.initiate() command failed because you missed out the version field from the supplied config.

Your error message made that reasonably clear:

{ "ok" : 0, "errmsg" : "Missing expected field \"version\"", "code" : 93 }

The version field is mandatory in the replica set configuration; you can see it is included in the examples in the doc page on the rs.initiate command, the doc page on the configuration document, and the doc page giving a basic tutorial on deploying a replica set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.