In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to restore mongodb data and synchronize it to other systems? As long as we understand the principle of database logging, everything is that simple.
Oplog principle
Oplog.rs table type is Capped Collections
-Table type:
Capped collections inserts very fast, almost as fast as disk writes, and supports efficient query operations in the order in which they are inserted. Capped collections is fixed in size and works much like a ring buffer (circular buffers), overwriting the data that is inserted first when there is not enough space left.
Advantages:
Capped collections is characterized by efficient insertion and retrieval, so it is best not to add additional indexes on Capped collections, otherwise it will affect the insertion speed.
Insert fast: no index
Fast retrieval: natural [insert order] / ∗ by default only supports returning results in natural order (that is, insert order) Cappedcollections can use "role=" presentation "> natural [insert order] / default only supports returning results in natural order (that is, insert order) Cappedcollections can use natural [insert order] / default only supports returning results in natural order (that is, insert order) Cappedcollections can use the natural operator to return results in positive or reverse order
, /
Oplog does not allow additional indexes to be created in order to ensure insert performance.
Capped collections can be used in the following scenarios:
Storing logs: the first-in-first-out feature of Capped collections just meets the storage order of log events.
Cache a small amount of data: because the cache is characterized by more reads and less writes, indexes can be used appropriately to improve read speed.
Restrictions:
If you update the data, you need to create an index on it to prevent collection scan
The size of the document cannot be changed when the data is updated. For example, if the name attribute is' abc', it can only be modified to a string of 3 characters, otherwise the operation will fail.
Data cannot be deleted. If it must be deleted, it can only be deleted by drop collection.
Db ['oplog.rs'] .find ({}) .sort ({$natural:-1})
Oplog is a special Capped collections, which is special in that it is a system-level Collection, which records all the operations of the database and relies on Oplog for data synchronization between clusters. The full name of Oplog is local.oplog.rs and is located under local data.
Summary
The above is the idea of MongoDB data recovery and synchronization solution introduced by the editor to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply you in time. Thank you very much for your support to the website!
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.