IP error caused MongoDB replica set initialization failed

Source: Internet
Author: User
Tags mongodb

Problem Description:

When setting up an environment for a client, initialization failed during initialization of a MongoDB replica set, reported "No host described in new configuration 1 for replica set mongotest maps to thi S node ". Specific error information as follows (to protect customer privacy, IP is processed):

2018-06-20T11:51:45.695+0800 I CONTROL  [initandlisten]> config = { _id:"mongotest", members:[  {_id:0,host:"10.0.0.217:27017"}]  };{        "_id" : "mongotest",        "members" : [                {                        "_id" : 0,                        "host" : "10.0.0.217:27017"                }        ]}> rs.initiate(config);{        "ok" : 0,        "errmsg" : "No host described in new configuration 1 for replica set mongotest maps to this node",        "code" : 93,        

The execution of config = {_id: "Mongotest", members:[{_id:0,host: "10.0.0.217:27017"}]} was successful, but execution Rs.initiate (config); has been reporting this error.

Cause Analysis:

The hint that "No host described in new Config 1 for replica set mongotest maps to this node" is suspected to be inconsistent with the configuration in the command line and the mongo.conf file, but To view the configuration file, it is true that Mongotest is configured:

[[email protected] ~]# cat /etc/mongodb/mongo.confsystemLog:   destination: file   path: "/opt/mongodb/mongod.log"   logAppend: truestorage:   journal:      enabled: true   dbPath: /opt/mongodbsetParameter:   enableLocalhostAuthBypass: truereplication:   replSetName: mongotest     #和执行的命令行是一致的,没有问题processManagement:   fork: true   pidFilePath: "/opt/mongodb/mongod.pid"security:   authorization: enabled   keyFile: "/etc/mongodb/mongodb-keyfile"[[email protected] ~]#

Then think of whether it is the problem of IP.
The machine's hostname and command-line windows are 10.0.0.217, since entering the machine is a bastion machine to go in. But actually the IP of this machine is not this, ifconfig view real IP address is actually 172.0.2.12 Instead of the 10.0.0.217 displayed by hostname. When the command line is configured, the hostname IP is used directly, so this error occurs.

Workaround:

Replace the IP in the command with the correct IP, and then re-execute the command inside the MongoDB command line, OK:

2018-06-20T11:51:45.695+0800 I CONTROL  [initandlisten]> config = { _id:"mongotest", members:[  {_id:0,host:"172.0.2.12:27017"}]  };{        "_id" : "mongotest",        "members" : [                {                        "_id" : 0,                        "host" : "172.0.2.12:27017"                }        ]}> rs.initiate(config);     #这次就不再报错了{ "ok" : 1 }mongotest:OTHER>mongotest:SECONDARY>mongotest:PRIMARY>mongotest:PRIMARY>mongotest:PRIMARY>mongotest:PRIMARY>

A single-point copy set is fine.

IP error caused MongoDB replica set initialization failed

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.