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

cvxl0en2  于 2023-02-07  发布在  Go
关注(0)|答案(2)|浏览(171)

我已经创建了3个mongodb示例,下面是mongod.conf [Primary 1,Secondary 1,Secondary 2]

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”:“启动”,如果我检查其日志,则表示以下错误:

“消息”:“获取事务表失败”,“属性”:{“错误”:“尚未初始化:尚未配置复制”}}
第2期:

由于问题1,如果我尝试为辅助2使用rs.add(),它不起作用

rs.状态()响应

{
                        "_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"}}
r6vfmomb

r6vfmomb1#

问题得到了修复。主数据库能够连接到辅助主机,但反过来辅助主机不能。所以我调整了安全组并连接。要点是所有的主和辅助主机都应该能够在mongodb端口(27017)相互连接。

yvgpqqbh

yvgpqqbh2#

同样的问题发生在我身上,网络和一切都很好。问题是主服务器的主机条目丢失,仍然是次要的试图连接DNS名称
“ctx”:“复制网络”,“消息”:“正在连接”,“属性”:{“主机和端口”:“MONGODB 01:27717”}}
已立即添加到主机条目中,所有内容均已同步

相关问题