Docker Mongo 设置主从备份
首先设置 Mongodb config 文件.
systemLog: destination: file path: "/my/log/mongodb/mongod.log" logAppend: true replication: oplogSizeMB: 1024 replSetName: configReplSet secondaryIndexPrefetch: all
启动 docker mongo 服务.
docker run --name db -v /my:/my -v /my/db:/data/db -p 27017:27017 -v /etc/localtime:/etc/localtime:ro -d mongo --config /my/config/mongod.conf
进入主服务器 mongo
cfg={"_id":"configReplSet", "members":[ {"_id":0,"host":"ip:27017"} ] }
使用 rs.initiate(cfg)
启动配置
然后 rs.status()
查看配置结果
再添加另外一个服务器进入 rs.add("ip_second:27017")
再添加一个仲裁服务器(arbiter)进入 rs.add("ip_third:27017",true)
结束.
相关推荐
王道革 2020-11-25
bwyyziq 2020-11-22
pigsmall 2020-11-19
changecan 2020-11-19
helloWorldAndYou 2020-11-16
nginxs 2020-11-14
红石丶 2020-11-13
WanKaShing 2020-11-12
yangkang 2020-11-12
滴水穿石点石成金 2020-11-12
张荣珍 2020-11-12
wuxunanjing 2020-11-11
魅惑青花瓷 2020-11-11
lihongtai 2020-11-09
yangkang 2020-11-09
worldsnow 2020-11-06
MichaelJScofield 2020-11-06
TaoTaoFu 2020-11-06