docker 安装mongo 集群
MongoDB集群部署(基于docker)_badvalue: security.keyfile is required when author-CSDN博客
Docker 快速搭建 MongoDB 4.x 集群(一主一从)_docker mongo-CSDN博客
docker run -dit --name mongo -p 27017:27017 -v /mydata/mongo/mongo-keyfile:/data/configdb/mongoKeyfile.key -v /mydata/mongo/config/mongod.conf:/etc/mongod.conf -v /mydata/mongo/data:/data/db -v /mydata/mongo/logs:/var/log/mongodb -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=123456 --restart=always mongo --replSet rs0 --keyFile /data/configdb/mongoKeyfile.key
rs.initiate({
_id: "rs0",
members: [
{ _id: 0, host: "192.168.187.128:27017", priority: 3 },
{ _id: 1, host: "192.168.187.129:27017", priority: 2 },
{ _id: 2, host: "192.168.187.130:27017", priority: 1 }
]
});