0
votes

I am trying to deploy a sharded cluster in MongoDB in mac. I am following this page. For creating a config server for sharded cluster I did the following steps

mkdir -p /data/config/config-a /data/config/config-b /data/config/config-c
mongod --logpath "cfg-a.log" --dbpath /data/config/config-a --port 57040 --fork --configsvr --smallfiles
mongod --logpath "cfg-b.log" --dbpath /data/config/config-b --port 57041 --fork --configsvr --smallfiles
mongod --logpath "cfg-c.log" --dbpath /data/config/config-c --port 57042 --fork --configsvr --smallfiles

and after this I tried initiating the replica set, as follows

$ mongo --port 57040

> config = { _id : "cs", members : [{ _id:0, host:"localhost:57040"}, { _id:1, host: "localhost:57041"}, { _id:2, host:"localhost:57042"}]};
{
    "_id" : "cs",
    "members" : [
        {
            "_id" : 0,
            "host" : "localhost:57040"
        },
        {
            "_id" : 1,
            "host" : "localhost:57041"
        },
        {
            "_id" : 2,
            "host" : "localhost:57042"
        }
    ]
> rs.initiate(config)
{
    "ok" : 0,
    "errmsg" : "This node was not started with the replSet option",
    "code" : 76,
    "codeName" : "NoReplicationEnabled"
}

Why am I getting this error ? I did not get any error while initiating other replica sets but I am getting error in this one. Could someone help me with this.

1

1 Answers

0
votes

The guide you are following is outdated. MongoDB documentation has a tutorial that configures a sharded cluster. It gives both --replSet and --configsvr arguments:

mongod --configsvr --replSet <replica set name> --dbpath <path> --bind_ip localhost,<hostname(s)|ip address(es)>