5

I try to setup a Replica Set on Ubuntu 14.04 x64. First error I run into when trying

$ sudo mongod --port 27017 --replSet rs0:

replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)

I read that > rs.initiate() solves that issue, so I do

$ sudo service mongod start
$ mongo
rs.initiate()

which throws:

{ "ok" : 0, "errmsg" : "server is not running with --replSet" }

So if I can't start mongod with --replSet how can I solve the error within rs.initiate() which I need to solve the first error? It's like a vicious circle!

styvane
  • 59,869
  • 19
  • 150
  • 156
Senju
  • 435
  • 2
  • 5
  • 20

2 Answers2

6

Solved the problem by using a second command shell:

console1:

$ sudo mongod --port 27017 --replSet rs0

console2:

$ mongo
  > rs.initiate()
Senju
  • 435
  • 2
  • 5
  • 20
2

you can set this replSet in /etc/mongodb.conf file,

# Replication
replication:
   replSetName: rs0

#fork
processManagement:
   fork: true

Fork for running in background.

Now start mongod,

mongod --config /etc/mongod.conf

To check the process status,

ps aux | grep mongod

Refer : https://docs.mongodb.org/manual/administration/configuration/

Nir Alfasi
  • 53,191
  • 11
  • 86
  • 129
Lakshmikandan
  • 4,301
  • 3
  • 28
  • 37