0

I'm running MongoDB 3.2.15 on Ubuntu 16.04 LTS

I can't execute rs.initiate();. It returns the following error

{
  "ok" : 0,
  "errmsg" : "assertion src/mongo/db/repl/replset_commands.cpp:275",
  "code" : 8
}

opened mongo with the following arguments

mongod --config /etc/mongod.conf --replSet rs0

Configuration file :

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
net:
  port: 27017
  bindIp: 0.0.0.0

The log file :

2017-07-26T08:25:38.400+0000 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2017-07-26T08:25:42.186+0000 I COMMAND  [conn1] initiate : no configuration specified. Using a default configuration for the set
2017-07-26T08:25:42.186+0000 I -        [conn1] Assertion failure h != "localhost" src/mongo/db/repl/replset_commands.cpp 275
TuGordoBello
  • 4,350
  • 9
  • 52
  • 78
xar
  • 1,429
  • 2
  • 17
  • 29
  • Looks like the path to your conf file is wrong? – Eric Jul 26 '17 at 14:41
  • @Eric i double checked and the path is correct. There are lines in the log file that shows that I got the right configuration loaded. – xar Jul 26 '17 at 14:44
  • This question really belongs on [dba.stackexchange.com](https://dba.stackexchange.com) which is the site to use for database administration and configuration questions. StackOverflow is for programming topics only, of which this question is not. **Please move your question to the correct site by deleting and reposting.** – Neil Lunn Jul 26 '17 at 23:54

1 Answers1

4

Try this (success for me):

mongo
> config = {_id:"rs0", members:[ {_id:0, host:"127.0.0.1:27017"}]}
{
    "_id" : "rs0",
    "members" : [
        {
            "_id" : 0,
            "host" : "127.0.0.1:27017"
        }
    ]
}
> rs.initiate(config)
{ "ok" : 1 }

Reference: http://blog.csdn.net/Aegeaner/article/details/56277129

vansy
  • 51
  • 3