简体   繁体   English

尝试使用PRIMARY的mongo shell中的rs.add()将节点添加到副本集“ rs0”

[英]Trying to add nodes to a replica set “rs0” using rs.add() in the mongo shell of the PRIMARY

The instances are new with no data and were created in AWS Marketplace using a Parse server powered by Bitnami on Ubuntu 14.04. 实例是新的,没有数据,是在Ubuntu Marketplace上使用由Bitnami支持的Parse服务器在AWS Marketplace中创建的。

I tried to add a node using rs.add() but got this error: 我尝试使用rs.add()添加一个节点,但收到此错误:

rs0:PRIMARY> rs.add( "172.31.39.86:27017" )
{
    "ok" : 0,
    "errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: ip-172-31-44-97:27017; the following nodes did not respond affirmatively: 172.31.39.86:27017 failed with Failed attempt to connect to 172.31.39.86:27017; couldn't connect to server 172.31.39.86:27017 (172.31.39.86), connection attempt failed",
    "code" : 74
}

The PrivateIP of the instance I'm trying to add to the ReplicaSet "rs0" is 172.31.39.86 and the PrivateIP of the instance which is currently PRIMARY is 172.31.44.97 . 实例我试图添加到ReplicaSet“RS0”的PrivateIP是172.31.39.86和这是目前PRIMARY实例的PrivateIP是172.31.44.97。

The steps I did are describe as follow: 我所做的步骤描述如下:

  • SSH the instances (into both instances each in a different terminal) SSH实例(进入不同终端的两个实例)

    ssh ubuntu@InstancePublicIP -i KeyFileName ssh ubuntu @ InstancePublicIP -i KeyFileName

  • Shutdown MongoDB (in both instances) 关闭MongoDB(在两种情况下)

    sudo /opt/bitnami/ctlscript.sh stop sudo /opt/bitnami/ctlscript.sh停止

  • Edit the mongodb.conf file by adding replSet = rs0 (in both instances) 通过添加replSet = rs0编辑mongodb.conf文件(在两种情况下)

    sudo nano /home/bitnami/stack/mongodb/mongodb.conf 须藤nano /home/bitnami/stack/mongodb/mongodb.conf

Looking like this: 看起来像这样:

dbpath=/opt/bitnami/mongodb/data/db
logpath=/opt/bitnami/mongodb/log/mongodb.log
logappend=true
bind_ip = 0.0.0.0
port = 27017
auth = true
setParameter = enableLocalhostAuthBypass=0
unixSocketPrefix=/opt/bitnami/mongodb/tmp
fork = true
setParameter = enableLocalhostAuthBypass=0
replSet = rs0
filePermissions = 0766
  • Restart MongoDB (in both instances) 重新启动MongoDB(在两个实例中)

    sudo /opt/bitnami/ctlscript.sh restart sudo /opt/bitnami/ctlscript.sh重新启动

  • Access to MongoDB (in one of the instances "172.31.44.97" ) 访问MongoDB(在其中一个实例“ 172.31.44.97”中

    mongo admin --username root --password fromSystemLog mongo admin --username root --password fromSystemLog

  • Start the Replication Set (in the MongoDB shell of one of the instances "172.31.44.97" ) 启动复制集(在实例“ 172.31.44.97”之一的MongoDB Shell中)

    rs.initiate() rs.initiate()

  • Add a node to the PRIMARY (in the MongoDB shell of one of the instances "172.31.44.97" ) 将节点添加到PRIMARY中(在实例“ 172.31.44.97”之一的MongoDB Shell中)

    rs.add( "172.31.39.86" ) rs.add(“ 172.31.39.86”)

That error message comes when primary node cannot connect that secondary during rs.add -process. 当主节点无法在rs.add -process期间连接辅助节点时,将出现该错误消息。 Reason to that is normally FIREWALL at destination, what prevents traffic to any other port than SSH. 原因通常是目的地处的防火墙,这是阻止流量到SSH以外的任何其他端口的原因。

If you go to command line of your (current PRIMARY) mongodb node and give command mongo --host 172.31.39.86:27017 the other mongo node should answer. 如果转到您的(当前PRIMARY)mongodb节点的命令行并输入命令mongo --host 172.31.39.86:27017则另一个mongo节点应回答。 If not, then connection to that node is not working OR node is not working. 如果不是,则与该节点的连接不起作用或节点不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM