In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following brings you a detailed introduction of Mongodb load balancing and backup scheme, hoping to bring some help to you in practical application. Load balancing involves more things, not much theory, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.
Mongodb load balancing and backup Scheme
First, the routing load is uniform. one
Second, backup strategy. three
1. Incremental backup (add delayed backup node). three
two。 Use delayed backup nodes to restore data. four
3. Full backup (add delayed backup node). five
Third, other problems. five
1. The routing load balancer uses appServer for load balancing, because the mongos of Mongodb does not support load balancer. MongoDB is all long links. When the lvs session time is up, when you re-select rs, you may break the previous link, and a 104th error will occur.
Second, backup strategy
1. Incremental backup (add delayed backup node) 1) transfer data from the machine using another secondary
2) add fastsync=true configuration to the configuration file on the new machine (when you need to boot a node from existing data, you must add fastsync=true, otherwise startup will report an error. If you are synchronizing all data directly from the main database, you do not need to add this parameter)
3) after startup, add a node to the primary node, such as: rs.add ("10.168.0.102 secondary 17017"). When we see that it becomes secondary, everything will be fine and we can provide online services normally.
4) View the current node information through the rs.conf () command (admin library password permission is required)
5) rs.remove ("10.168.0.102pur17017") delete node
6) add arbiter node: rs.addArb ("10.73.24.171pur19003")
7) add a delayed backup machine:
Rs.add ({_ id:5,host: "10.168.0.102 priority:0,slaveDelay:300 17017")
Rs.add ({_ id:5,host: "10.168.0.102 priority:0,slaveDelay:300 17018")
Rs.add ({_ id:5,host: "10.168.0.102 priority:0,slaveDelay:300 17019")
Note: slaveDelay unit second.
8) when this error occurs: replSet error RS102 too stale to catch up, we can db.printReplicationInfo () to check the oplog information of the master and slave libraries.
two。 Using delayed backup node to recover data 1) first, the data of delayed backup node is backed up to the master machine of each node. Such as:
#. / mongodump-h 192.168.136.14 data/mongoback/ 17017-d UserInfoDB-o / data/mongoback/
#. / mongodump-h 192.168.136.15 data/mongoback/ 17018-d UserInfoDB-o / data/mongoback/
#. / mongodump-h 192.168.136.16 data/mongoback/ 17019-d UserInfoDB-o / data/mongoback/
2) Import the backed-up data into the master of each node. Such as:
It is recommended to fix it first and compress the space.
Db.repairDatabase (); repair data (and compress (delete data) space)
. / mongorestore-h 127.0.0.1 data/mongoback 17017-- directoryperdb / data/mongoback-- drop-- indexesLast
. / mongorestore-h 127.0.0.1 data/mongoback 17018-- directoryperdb / data/mongoback-- drop-- indexesLast
. / mongorestore-h 127.0.0.1 data/mongoback 17019-- directoryperdb / data/mongoback-- drop-- indexesLast
3. Full backup 1) write a script to back up data in the early morning on a regular basis, such as:
. / mongodump-h 10.168.0.187 data/mongoback/ 10000-d UserInfoDB-o / data/mongoback/
2) restore data
3) it is recommended to repair and compress the space first.
4) db.repairDatabase (); repair data (and compress (delete data) space)
. / mongorestore-h 10.168.0.187 data/mongoback 10000-- directoryperdb / data/mongoback-- drop-- indexesLast
Third, other questions 1. If the startup is unsuccessful, try to fix it. Such as:
. / mongod-- port 27017-- repair-- dbpath / data/database/shard1/
two。 If the master node is kill, then give up the position of the master through rs.stepDown (100).
After reading the above detailed introduction of Mongodb load balancing and backup solution, if there is anything else you need to know, you can find what you are interested in in the industry information or find our professional and technical engineer to answer, the technical engineer has more than ten years of experience in the industry.
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.