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