codeofnode
codeofnode

Reputation: 18629

How the lock file is shared among the various mongods

I am trying to setup a shard and replica set.

My assumption procedure be like this :

  1. Start a replica set (let it be only one, just for testing)
  2. mongo then initiate replica
  3. Start a config server (again let it be one, just for testing)
  4. Start a shard server (again let that be just one)
  5. Add the shard and enable sharding via mongo

What i did :

  1. mongod --replSet rs0 --dbpath data/rs0-0 --unixSocketPrefix data/rs0-0
  2. mongo then rs.initiate()
  3. mongod --configsvr --dbpath data/rs0-0 --unixSocketPrefix data/rs0-0

-- now stucked at step 3.

Error i find is 2017-05-22T20:00:13.857+0530 [initandlisten] exception in initAndListen: 10310 Unable to lock file: data/rs0-0/mongod.lock. Is a mongod instance already running?, terminating

What i have tried :

i have tried with different directories for --unixSocketPrefix options, but each time it hits data/rs0-0/mongod.lock the same file. So it did not worked

It seems simple issue but unable to figure out how the lock file is shared among the various mongods (whether it be config server, or replica set, or shard server)

I am on mongodb 2.6.12

Upvotes: 0

Views: 208

Answers (1)

Atish
Atish

Reputation: 4435

You need to start mongod and config server with different dbpath options. You can follow the following steps:

mongod --replSet rs0 --dbpath data/rs0-0 --unixSocketPrefix data/rs0-0

or

mongod --replSet rs0 --dbpath data/rs0-0

mongo then rs.initiate()

mkdir -p /data/configdb (grant required permission recursively)

mongod --configsvr --dbpath /data/configdb --port 27019

Upvotes: 2

Related Questions