In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the knowledge points of NoSQL and CAP theory". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn what are the knowledge points of NoSQL and CAP theory.
NoSQL database
The emergence of a new technology is demand-driven, so what demand for databases drives the emergence of NoSQL? Take a look at some of the problems with traditional databases:
The main results are as follows: (1) in the case of large amount of data, the throughput can not meet the requirements, and there is a single point bottleneck.
(2) the requirement of ACID feature of transaction is too high, and many application scenarios do not need this constraint.
(3) with a single point of failure, the machine cannot be used after downtime. Although it can be a master and slave, it still requires human intervention and is not available for a period of time.
(4) all data cannot be stored in a single node.
(5) the data is easy to be lost. If there is only one copy of the data if it is not used as the master and backup, the data will be lost if the disk is broken.
Therefore, the traditional database is generally used in banking systems, medical systems and other scenarios where the operation requirements are relatively high or the amount of data is small. While some applications that need high availability, such as Facebook, Taobao, Amazon and so on, the traditional database can not meet the requirements.
Therefore, people want to abandon the traditional database idea and build a distributed NoSQL database, which has the following goals:
The main results are as follows: (1) each node can provide read and write services, improve the system throughput, add and delete nodes dynamically, and the cluster throughput increases linearly with the increase of nodes.
(2) the transaction is removed and only a relatively simple read-write interface is provided.
(3) to avoid single point of failure, in a cluster composed of multiple nodes, if one node breaks down, other nodes can provide services.
(4) the disks of all nodes can be used to store data and provide distributed storage capacity.
(5) in order to ensure that the data is not lost, the copy mechanism is adopted, and multiple copies of one data are stored in different nodes.
(6) in order to control the storage location of data, the concept of data partition is put forward.
CAP theory
When building a NoSQL database, you often need to strike a balance in many ways. Brewer put forward the CAP theory around 2000, the acronym of Consistency, Availability and Partition Tolerance.
CAP theory: a distributed system can not satisfy consistency, availability and partition fault tolerance at the same time, and can only satisfy two of them at most.
This distributed system generally refers to the asynchronous network, where there is no global clock, and the node can only make decisions based on the received messages and local computing.
Some misunderstandings about CAP also stem from the ambiguity of the specific meaning of these three properties. Let's take a look at what these three properties mean respectively.
Consistency
The consistency of CAP is different from the C of ACID in traditional relational databases. C in ACID is concerned with constraints in the database, not only for single data values, but also for values between multiple data. The consistency of CAP is concerned with whether different copies of a data item have the same value.
In NoSQL database, because there are multiple copies of data, a write operation needs to update all replicas. Due to the delay of communication between nodes, some copies of nodes may be updated, and some of them are still old values, so the values returned by reading different copies will be inconsistent. Therefore, consistency in CAP refers to replica consistency, or mutual Consistency, which is related to a transient state called mutual consistency:
Consistent with each other: if all copies of each data item in the system have the same value, the system is in a consistent state. At some point, there are only two situations in this state: satisfied or dissatisfied.
We can assume that the NoSQL database only provides simple read and write operations on a single data item, such as write (a), read (b), write (b), and so on. In this case, the performance of consistency is related to the order of read and write operations between different nodes. As a result, many levels of consistency specify the order and results of read and write operations.
Consistency in CAP refers to strong consistency: when an update transaction commits, all replicas are in a consistent state.
From an operational point of view: all operations must have a globally unique order so that each operation appears to have been completed in an instant. In this case, the value of the write can be read by a read after a write operation.
All nodes can read the updated results, which looks like a stand-alone database, and the operation is serial, just like the serializable isolation level in ACID isolation.
Usability
Availability in CAP means that each node in the system can process the request (receive the request and return the result).
In general, the availability of traditional database refers to whether the system as a whole can provide services, as long as one node or most nodes can provide response, it can be called available.
Partition tolerance
A partition is a network partition, that is, a cluster is divided into multiple partitions, and nodes within each partition can communicate, but not across partitions, and this partition is assumed to be permanent. Network partitioning cannot be escaped in a distributed system.
The partition tolerance refers to whether the system can provide services normally when the network partition occurs.
Give an example
This picture is a more classic picture in CAP. Since no NoSQL can satisfy three at the same time, you can only choose one of the two.
Because the traditional database has only one node and there is no network partition problem, it can achieve strong consistency and availability under normal circumstances. On the other hand, the active and standby technology of traditional database is to sacrifice availability to ensure consistency.
Since network partitioning is inevitable in the NoSQL database, when network partitioning occurs, the figure on the left below shows that when a write operation is received (this write request will only be sent to one node), we assume that each node needs the approval of the other two nodes to perform the operation and return the result. At this point, you can only choose between consistency and availability.
If consistency is guaranteed, then any node that receives the request cannot receive the approval of all nodes, so this operation will be suspended and eventually return a timeout or execution error.
If availability is guaranteed, one network partition may receive this write request and synchronize the write request within the current partition, which will be inconsistent with the data of another partition. This partition is random, either N3 or N1 and N2 as shown in the figure above.
At this point, I believe you have a deeper understanding of "what are the knowledge points of NoSQL and CAP theory?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.