I’m new to mongo and was doing this training exercise. These are the steps I took.
I get an error when I execute the rs.initiate.
@rem Primary
start "a" mongod --dbpath /users/userxx/mongo/data/db1 --port 30000 --replSet "demo"
@rem Secondary
start "b" mongod --dbpath /users/userxx/mongo/data/db2 --port 40000 --replSet "demo"
@rem Arbiter
start "c" mongod --dbpath /users/userxx/mongo/data/db3 --port 50000 --replSet "demo"
> var demoConfig={ _id: "demo", members: [{_id: 0, host: 'localhost: 30000', priority: 10 }, {_id: 1, host: 'localhost: 40000' }, {_id: 2, host: 'localhost: 50000', arbiterOnly: true }] };
> demoConfig
{
"_id" : "demo",
"members" : [
{
"_id" : 0,
"host" : "localhost: 30000",
"priority" : 10
},
{
"_id" : 1,
"host" : "localhost: 40000"
},
{
"_id" : 2,
"host" : "localhost: 50000",
"arbiterOnly" : true
}
]
}
> rs.initiate(demoConfig)
{
"ok" : 0,
"errmsg" : "member: { _id: 0.0, host: \"localhost: 30000\", priority: 10.0 } :: caused by :: Did not consume whole string.",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}