前言
MongoDB 使用 keyFile
进行 节点间身份验证,我们需要先创建一个 keyFile
并确保所有副本集的节点使用相同的 keyFile
。
openssl rand -base64 756 > mongo-keyfile
chmod 400 mongo-keyfile
docker-compose部署分片集群
无密码方式
# docker-compose-mongodb.yml
services:
# Config Server Replica Set
configsvr1:
image: mongo:latest
restart: always
entrypoint:
[
"mongod",
"--port",
"27017",
"--configsvr",
"--replSet",
"cfgset",
"--dbpath",
"/data/configdb",
"--bind_ip_all"
]
volumes:
- /data/mon