我正在部署mongodb分片,已经在两台机器上部署了副本集:
rs.status()
"members" : [
{
"_id" : 0,
"name" : "mongo-shard-1:[port]",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 693,
"optime" : {
"ts" : Timestamp(1536595866, 1),
"t" : NumberLong(13)
},
},
{
"_id" : 1,
"name" : "rs-mongo-shard-1:[port]",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 665,
"optime" : {
"ts" : Timestamp(1536595866, 1),
"t" : NumberLong(13)
},
"optimeDurable" : {
"ts" : Timestamp(1536595866, 1),
"t" : NumberLong(13)
},
}
],
"ok" : 1,
"operationTime" : Timestamp(1536595866, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1536595866, 1),
"signature" : {
"hash" : BinData(0,"QwasVYlskhD/0CkuF+4usWfwMHI="),
"keyId" : NumberLong("6599506821294063618")
}
}
mongo.conf
security: authorization: enabled keyFile: /[path]/mongo-keyfile replication: replSetName: "rs0"
和configsvr在三台机器上,还有mongos在机器上。 我尝试将副本添加到mongos中,但出现错误:
“确定”:0,
“ errmsg”:“找不到与设置rs0匹配的读取首选项{模式:\” primary \“}的主机”, “代码”:133, “ codeName”:“ FailedToSatisfyReadPreference”,