In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to modify oplogSize in MongoDB. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. Close the node and start it with a single instance. 1.1.The process of shutting down the node SECONDARY > db.shutdownServer () 1.2Log out the startup parameters related to Replica set.
And modify the port number (assuming it was 27001, now it is 37001)
1.3 restart / apps/mongodb/bin/mongod-f / data/johnny/cfg/shard1.cnf2, backup node oplog log
Complete all oplog records of the current node
Mongodump-port 37001-db local-collection 'oplog.rs'
Back up the most recent oplog record in oplog.rs
> use local > db.optmp.drop ()-clear the temporary table Store the most recent record in oplog > db.optmp.save (db.oplog.rs.find ({}, {ts: 1, h: 1}). Sort ({$natural:-1}). Limit (1). Next ()-- store the most recent record in a temporary collection > db.optmp.find ()-- verify that the record has been stored in {"_ id": ObjectId ("5a0d437ed4738d194fa0b94f"), "ts": Timestamp (1510389543). 1), "h": NumberLong ("- 2633465233485407995")} 3, modify oplogSize
Delete the original oplog.rs collection
> use local > db.oplog.rs.drop ()
Create a new oplog.rs collection
> db.runCommand ({create: "oplog.rs", capped: true Size: (2 * 1024 * 1024 * 1024)} {"ok": 1}-if successful, ok4 will be returned and the last record backed up before will be restored > db.oplog.rs.save (db.optmp.findOne ()) > db.oplog.rs.find ()-query to verify whether 5, Rejoin replica set 5.1 close the current single instance process > db.shutdownServer () 5.2 restore profile information
(note the modification of the oplogSizeMB parameter value)
Start the instance process / apps/mongodb/bin/mongod-f / data/johnny/cfg/shard1.cnf6 and check the node status
Log in to mongo shell to check whether the node has successfully joined the replica set schema
> rs.status () check whether oplogSize is valid (red font) SECONDARY > rs.printReplicationInfo () configured oplog size: 2048MBlog length start to end: 0secs (0hrs) oplog first event time: Sat Nov 11 2017 16:39:03 GMT+0800 (CST) oplog last event time: Sat Nov 11 2017 16:39:03 GMT+0800 (CST) now: Thu Nov 16 2017 17:00:32 GMT+0800 (CST) 7, modify the oplogSize parameters of other members of the replica set in turn according to the above steps
Note: when modifying the Primary node, remember to use the following command to downgrade before modifying
Primary > rs.stepDown ()-can produce election method 2 more effectively:
Dynamic modification methods supported after version 3.6
1. Modify the parameter size before: replication: oplogSizeMB: 1024 replSetName: shardrs1
Check the oplog.rs collection size after logging in to mongo shell
> use localswitched to db local > db.oplog.rs.stats (). MaxSizeNumberLong (1073741824)-unit bytes, that is, 2014MB2. Modify > use localswitched to db local > db.adminCommand ({replSetResizeOplog:1, size: 2048}) through the administrative command -2048 units also MB {"ok": 1, "operationTime": Timestamp (1537776585, 1), "$clusterTime": {"clusterTime": Timestamp (1537776585, 1), "signature": {"hash": BinData (0, "AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId": NumberLong (0)}} 3. Verify success > db.oplog.rs.stats () .maxSizeNumberLong ("2147483648")
So far, our oplog size has been dynamically modified, is it very simple, is it very easy?
Think about:
Ask the 1:replSetResizeOplog command whether the replication.oplogSizeMB parameter value has been changed at the same time.
A: I checked the startup configuration file at this time and found that the oplogSizeMB is still 1024
Q2: will the parameter values in the configuration file be changed to modified values after reboot?
A: after restarting the database instance, I found that there was no such thing as the initial value.
Q3: will the newly modified values expire after reboot?
A: I found out again that I didn't. I still used the latest value.
Shardrs1:PRIMARY > db.oplog.rs.stats (). MaxSizeNumberLong ("2147483648") on how to modify oplogSize in MongoDB is shared here, I hope the above content can be helpful to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.