Can't initiate replica set in Ubuntu

走远了吗. 提交于 2019-11-30 13:40:04

问题


Whenever I type: rs.initiate(), I get the following error message:

{
    "info2" : "no configuration explicitly specified -- making one",
    "me" : "VMHOSTNAME:27017",
    "ok" : 0,
    "errmsg" : "No host described in new configuration 1 for replica set rs0 maps to this node",
    "code" : 93
}

I'm running under google-cloud-engine with latest MongoDB.

Any suggestions on how to solve this?


回答1:


You could try passing a parameter to the .initiate() command.

Like so:

rs.initiate({_id:"yourReplSetName", members: [{"_id":1, "host":"yourHost:yourPort"}]})

This did the trick for me.




回答2:


Your VMHOSTNAME must be an alias for 127.0.0.1 in your /etc/hosts file to make it work.

See here https://jira.mongodb.org/browse/SERVER-16157




回答3:


The problem might be in your mongo config. Look for the following line and comment it out:

#bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.



回答4:


Yeah, exactly, or you can change your hostname to something that is already in your /etc/hosts pointing to 127.0.0.1 such as localhost.

With a mac you can do this by typing sudo scutil –-set HostName localhost.




回答5:


If you find the VMHOSTNAME in the /etc/hostnames file and the referenced mongo instance is running then its possibly a port number error. In my case it was. Shards tipically started at port 27018.



来源:https://stackoverflow.com/questions/28843496/cant-initiate-replica-set-in-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!