In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The idea of processing equalizer information in [ToolsForMongo] mongo_detail.py
First, take a look at the db.settings.find ({'_ id':'balancer'}) output in several typical situations:
1. After creating the mongos, when the balancer is never set:
Mongos > var x = db.settings.findOne ({'_ id':'balancer'}) mongos > x = = nulltruemongos > sh.getBalancerState () true
two。 After creating the mongos, the balancer was manually closed for some reason
Mongos > db.settings.findOne ({'_ id':'balancer'}) {"_ id": "balancer", "mode": "off", "stopped": true} mongos > sh.getBalancerState () false
3. The running time period of balancer is set, but the current time is not in it
Mongos > var x = db.settings.findOne ({'_ id':'balancer'}) mongos > x {"_ id": "balancer", "stopped": true, "activeWindow": {"start": "00:00", "stop": "06:00"} mongos > sh.getBalancerState () false
4. The running time period of balancer is set, in which the current time is
Mongos > var x = db.settings.findOne ({'_ id':'balancer'}) mongos > x {"_ id": "balancer", "stopped": false, "activeWindow": {"start": "00:00", "stop": "22:00"} mongos > sh.getBalancerState () true
Take a look at the js code in the official mongo shell.
Mongos > sh.getBalancerStatefunction (configDB) {if (configDB = = undefined) configDB = sh._getConfigDB (); var x = configDB.settings.findOne ({_ id: "balancer"}); if (x = = null) return true; return! x.stopped;}
1. First deal with the case that configDB is not the default config library
2.x = = null indicates that balancer has never been set above and is enabled by default
3. Invert the .stopped item in the return value to get whether it is running
Mongos > sh.isBalancerRunningfunction (configDB) {if (configDB = = undefined) configDB = sh._getConfigDB (); var x = configDB.locks.findOne ({_ id: "balancer"}); if (x = = null) {print ("config.locks collection empty or missing. Be sure you are connected to a mongos"); return false;} return x.state > 0;}
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.