mongodb 开启副本集
Last updated on January 17, 2025 am
🧙 Questions
mongo开启副本集
☄️ Ideas
mkdir -p /Users/ispong/isxcode/mongo
openssl rand -base64 756 > /Users/ispong/isxcode/mongo/mongo-keyfile
chmod 400 /Users/ispong/isxcode/mongo/mongo-keyfile
docker run \
--name ispong-mongo \
--privileged=true \
-d \
-p 27017:27017 \
-v /Users/ispong/isxcode/mongo/mongo-keyfile:/data/configdb/mongo-keyfile \
-e MONGO_INITDB_ROOT_USERNAME=root \
-e MONGO_INITDB_ROOT_PASSWORD=root123 \
mongo:latest --replSet rs0 --keyFile /data/configdb/mongo-keyfile
docker exec -it ispong-mongo bash
mongosh "mongodb://root:root123@localhost:27017"
rs.initiate({
_id: "rs0",
members: [
{ _id: 0, host: "localhost:27017" }
]
});
rs.status();
🔗 Links
mongodb 开启副本集
https://ispong.isxcode.com/db/mongodb/mongodb 开启副本集/