Using CentOS 7.

MongoDB version: 3.2.15

Hostname: node1

Make directory:

mkdir /mongo-metadata


# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
  dbPath: /mongo-metadata
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
  port: 27017
  bindIp:  # Listen to local interface only, comment to listen on all interfaces.



  replSetName: rs0


## Enterprise-Only Options



Start the replication member:

mongod --config /etc/mongod.conf

Run mongo:

# try
        "info2" : "no configuration specified. Using a default configuration for the set",
        "me" : "node1:27017",
        "ok" : 0,
        "errmsg" : "No host described in new configuration 1 for replica set rs0 maps to this node",
        "code" : 93

# try
config = {
    _id : "rs0",
     members : [
         {_id : 0, host : "node1:27017"},
         {_id : 1, host : "node2:27017"},
    "ok" : 0,
    "errmsg" : "No host described in new configuration 1 for replica set rs0 maps to this node",
    "code" : 93



So what's the reason? It can't realize the hostname?


Answer is simple! You don't have "node1" defined in your /etc/hosts file. Your machine don't know IP address of "node1" (or "node2").

echo "  node1" >> /etc/hosts

And then other thing, you have defined (in config file) that your mongod is listening only localhost. So it means that your whole replica set must be in that one machine and if it is so, all those three members cannot use same port 27017, every member must have different port.

  • Thank you very much. That step went well. Now there has another issue: dba.stackexchange.com/questions/180194/…. You said I am using only localhost now. I added the private IP to config. Is there something else wrong? Jul 19 '17 at 5:46
  • Just remove that bindIp line from config file(s) (reboot mongod) and you can always use IP addresses when you do rs.initialize(config) (no need for hostnames, although it's easier for human) . Rest of config file looks fine.
    – JJussi
    Jul 19 '17 at 6:15

For my case: replace with localhost. Then it works.

Here is the rsconf:

rsconf = {
  _id: 'rs0',
  members: [
      _id: 0,
      host: 'localhost:27017'
      _id: 1,
      host: 'localhost:27018'
      _id: 2,
      host: 'localhost:27019'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.