replicaset - Mongodb replica set questions -
i have mongodb replica set configuration of 1 primary machine, 1 secondary machine , 1 arbiter machine. primary , secondary machines have 2 collections (each in own database)
i need delete few gb 1 collection , leave other collection intact. brand new @ ideas/gotchas on this. thinking of following procedure:
- remove secondary replica set.
- in secondary, collection want delete, mongodump of data want keep.
- do mongo restore dump.
- re-add secondary replica set. think have set priorities primary not become secondary?
the secondary sync/catch primary hope happens data deleted in secondary? primary removes itself? (which want)
do need primary?
rolling maintenance:
- to see how time of oplog have, bring down secondary , catchup : db.printreplicationinfo()
- when working primary, secondary , arbiter ... taking out secondary can have risk. primary won't have failover in case happens during maintenance period. primary-secondary-secondary safer.
- after shutdown secondary, restart without --replset option , on different port otherwise rest of replicaset confused.
- restart secondary --replset , old port again add replicaset. don't worry, primary stay primary. voting/election 'only' happens when primary has disappeared ... , not case when adding secondary.
- the secondary catch oplog.
- to work on primary. rs.stepdown() on primary, let secondary take over, , repeat process.
cleanup during rolling maintenance
here not sure , can make guesses because didn't test yet. can during rolling maintenance is:
- update binaries (apt-get update/yum update/...)
- build indexes
- compact , repair
now deleting data? need test on local small replica.
- i'm afraid dump/restore bad idea. i'm not sure.
- execute remove statement... think there way that, , let statement execute on primary don't know how yet.
- most simple: why not execute remove statement on primary , let spread secondary? because want decrease database size? well, after remove can rolling maintenance repair. compact not create space, order data inside pre-allocated files. , repair, careful, needs double space build. 100gb db needs @ least 100gb free space repair.
https://dba.stackexchange.com/questions/28269/disk-space-recovery-on-mongodb-replicaset-secondaries
and have @ https://university.mongodb.com => m202: mongodb advanced deployment , operations ... issue handled in free lessons.
Comments
Post a Comment