[Mongodb][OpsManager]Mongodb 辅助实例未添加到副本集

[Mongodb][OpsManager]Mongodb secondary instances are not adding to replica set

我创建了 3 个 mongodb 实例 mongod.conf [Primary1,Secondary1,Secondary2]

net:
  port: 27017
  bindIp: 0.0.0.0

replication:
  replSetName: Replica1

我已经使用“sudo service mongod start”启动了 3 实例 如果我使用 mongo –host "ip" –port 27017 将主服务器连接到其他 2 个服务器..它的工作和连接。

问题 1:

在我执行 rs.initiate() 和 rs.conf() 之后 中学 1 包含在成员中,但是当我使用 rs.status() 但显示 stateStr" : "STARTUP" 如果我检查它的日志意味着低于错误:

"msg":"获取事务失败 table","attr":{"error":"NotYetInitialized: 复制尚未配置"}}

问题 2:

由于问题 1,如果我尝试 rs.add() 用于中学 2,它不起作用

rs.status() 响应

{
                        "_id" : 0,
                        "name" : "primary:27017",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY", 
                         .......
}

{
                        "_id" : 1,
                        "name" : "secondary1:27017",
                        "health" : 1,
                        "state" : 0,
                        "stateStr" : "STARTUP",
                        "uptime" : 1579,
                        "optime" : {
                                "ts" : Timestamp(0, 0),
                                "t" : NumberLong(-1)
                        },
                        "optimeDurable" : {
                                "ts" : Timestamp(0, 0),
                                "t" : NumberLong(-1)
                        },
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2021-01-08T04:47:35.455Z"),
                        "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
                        "pingMs" : NumberLong(0),
                        "lastHeartbeatMessage" : "",
                        "syncSourceHost" : "",
                        "syncSourceId" : -1,
                        "infoMessage" : "",
                        "configVersion" : -2,
                        "configTerm" : -1
                }

辅助 1 的日志输出 mongodb.log

{"t":{"$date":"2021-01-08T04:39:16.634+00:00"},"s":"I",  "c":"CONNPOOL", "id":22576,   "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"primary:27017"}}
{"t":{"$date":"2021-01-08T04:39:18.004+00:00"},"s":"I",  "c":"CONTROL",  "id":20714,   "ctx":"LogicalSessionCacheRefresh","msg":"Failed to refresh session cache, will try again at the next refresh interval","attr":{"error":"NotYetInitialized: Replication has not yet been configured"}}
{"t":{"$date":"2021-01-08T04:39:18.004+00:00"},"s":"I",  "c":"CONTROL",  "id":20712,   "ctx":"LogicalSessionCacheReap","msg":"Sessions collection is not set up; waiting until next sessions reap interval","attr":{"error":"NamespaceNotFound: config.system.sessions does not exist"}}
{"t":{"$date":"2021-01-08T04:39:36.634+00:00"},"s":"I",  "c":"CONNPOOL", "id":22576,   "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"primary:27017"}}

问题已解决。主数据库能够连接到辅助主机,但在 return 中辅助主机不能。所以我调整了安全组并连接。要点是所有主要和次要主机都应该能够在 mongodb 端口 (27017)

中相互连接