我使用此命令创建了一个带有replica set的MongoDB docker容器:
Exception in thread "main" java.io.IOException: No FileSystem for scheme: https
容器开始运行。
然后我使用以下命令尝试initiate副本集:
docker run -d --name mongo -v /data/db:/data/db mongo --replSet name
但它会显示错误消息“已初始化”。
使用rs.status()命令
检查副本集的运行状况时rs.initiate()
{
"info2" : "no configuration specified. Using a default configuration for the set",
"me" : "fa07bcdd8591:27017",
"info" : "try querying local.system.replset to see current configuration",
"ok" : 0,
"errmsg" : "already initialized",
"code" : 23
}
它表示副本集配置无效。
答案 0 :(得分:0)
看起来你没有指定任何副本集配置。
rs.initiate(
{
_id: "myReplSet",
version: 1,
members: [
{ _id: 0, host : "mongodb0.example.net:27017" },
{ _id: 1, host : "mongodb1.example.net:27017" },
{ _id: 2, host : "mongodb2.example.net:27017" }
]
}
)