###############################

keyfile是mongodb副本集的实例之间的权限认证,要求如下:

1, keyfile文件的权限必须是600;

2,keyfile文件的内容比如完全相同。

 

如果keyfile文件内容不同,那么该实例添加到副本集的时候,会出现不可达的状态:

 

在主库上执行如下命令来添加一个副本集实例:

rs.add("xxx:27003");

rs.status();

 

 

 "name" : "xxx:27003",
 "health" : 0,
 "state" : 6,
 "stateStr" : "(not reachable/healthy)",
 "uptime" : 0,
 "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-03-29T02:41:09.636Z"),
 "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
 "pingMs" : NumberLong(0),
 "lastHeartbeatMessage" : "",
 "authenticated" : false,
 "syncingTo" : "",
 "syncSourceHost" : "",
 "syncSourceId" : -1,
 "infoMessage" : "",
 "configVersion" : -1

 

 

 

 

 

 

 

 

 

 

 

#########################