So, I am following a MongoDB tutorial on Pluralsight and I've been able to create a, b and c database on the same machine. After a successful creation of all three, I run mongo on port 30000 which is the port for my primary database.
>mongo --port 30000
It displayed connecting to the port and then I typed
db.getMongo()
It made a connection to the address
And I typed in a javascript object as done by the guy on Pluralsight which goes
>var democonfig={ _id: "demo", members: [{ _id: 0, host: 'localhost: 30000', priority: 10}, { _id: 1, host: 'localhost: 40000'}, { _id: 2, host: 'localhost: 50000', arbiterOnly: true}] };
After I pressed enter, I tried to run rs.initiate with the file democonfig
rs.initiate(democonfig)
This is the error I get:
{ "ok" : 0, "errmsg" : "Bad digit \" \" while parsing 30000", "code" : 93 }
This is how my replicaSet bat file looks like.
cd \Pluralsight\
md \Pluralsight\db1
md \Pluralsight\db2
md \Pluralsight\db3
@REM Primary
start "a" c:\MongoDB\bin\mongod.exe --dbpath ./db1 --port 30000 --replSet "demo"
@REM Secondary
start "b" c:\MongoDB\bin\mongod.exe --dbpath ./db2 --port 40000 --replSet "demo"
@REM Arbiter
start "c" c:\MongoDB\bin\mongod.exe --dbpath ./db3 --port 50000 --replSet "demo"
I ran into the same issue on Pluralsight's: "Introduction to MongoDb" tutorial. Below is what I used in the "configuring a replica set" section:
{
"_id": "demo",
"members": [
{
"_id": 0,
"host": "localhost:30000",
"priority": 10
},
{
"_id": 1,
"host": "localhost:40000"
},
{
"_id": 2,
"host": "localhost:50000",
"arbiterOnly": true
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With