In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how MONGODB creates an index with large memory and chain thinking. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.
Creating an index of MONGODB is a basic operation, but if a collection with 2T needs to add an index, it is also a basic operation. In fact, quantitative change produces qualitative change, and many problems are not so simple.
There may be a voice at this time, is it as troublesome as you said? I use background:true
And this way of processing in the background, there will be no lock on the existing system and tasks can not handle the problem, the disadvantage is that it is slightly more time-consuming than the foreground operation.
When you create an index, you can see the relevant progress through the following statement
Db.currentOp (true) .inprog.forEach (function (op) {if (op.msgforth undefined) print (op.msg)})
On MONGODB 4.2 systems, index build only acquires exclusive locks on indexed collections at the beginning and end of the build process to protect metadata changes. The rest of the build process uses the build behavior of the background index build to maximize read and write access to the collection during the build. 4.2 despite looser locking behavior, index construction can still generate efficient index data structures. The mongodb4.2 system should have abandoned the parameters of background to create a search. According to the idea that the generation is getting stronger and stronger, it is natural that there are some areas where background needs to be improved before the new version will be changed.
In MONGODB 3.4.There is one parameter.
SetParameter:
MaxIndexBuildMemoryUsageMegabytes: 1024
This parameter directly adds index acceleration to the background, if there is enough memory,
Has nothing to do with wiretiger), the speed at which background adds an index is accelerated.
As a replication set, the index is also added as a command push to the slave node, but if
A lot of suggestions for the huge collection are that indexes need to be added in a special way.
This is similar to the process of adding indexes or fields to some large MYSQL tables.
1 separate nodes from the cluster
2 add an index on a separate node
3 add nodes to the cluster here
4 replace the master node with the slave node that adds the index
Over and over again for 5 weeks, until the nodes of the cluster of the index have added the index
Of course, you should pay attention to your time window, and the time for the cluster to leave should not exceed the time window of oplog, otherwise
You'll look good.
So adding an index to a large collection is a process from quantitative change to qualitative change, and you need to consider the problem.
1 the size of your memory, can you hold the index you added
2 whether the business visit degree is high-intensity, if so, then you need to consider the methods mentioned above
The design size of 3 oplog is actually related to some basic operations in the future.
4 try to abandon the old version and upgrade to version 3.6 or above, so that you can quickly adjust
The size of the oplog
So an indexed thing that doesn't seem to be worth mentioning, in fact, if the quantity is large to a certain extent, then
Consider and need to analyze the problem and the order of magnitude is relatively small can not be compared with the same day.
The above is how MONGODB creates indexes with large memory and chain thinking, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.