Can't initiate replica set in Ubuntu

后端 未结 5 1477
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 21:57

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

{
    \"info2\" : \"no configuration explicitly specified -- making one\",
           


        
相关标签:
5条回答
  • 2020-12-30 22:23

    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.

    0 讨论(0)
  • 2020-12-30 22:24

    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.

    0 讨论(0)
  • 2020-12-30 22:26

    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.

    0 讨论(0)
  • 2020-12-30 22:33

    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.
    
    0 讨论(0)
  • 2020-12-30 22:40

    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

    0 讨论(0)
提交回复
热议问题