WO2022188184A1 - 数据存储方法及相关设备 - Google Patents

数据存储方法及相关设备 Download PDF

Info

Publication number
WO2022188184A1
WO2022188184A1 PCT/CN2021/080608 CN2021080608W WO2022188184A1 WO 2022188184 A1 WO2022188184 A1 WO 2022188184A1 CN 2021080608 W CN2021080608 W CN 2021080608W WO 2022188184 A1 WO2022188184 A1 WO 2022188184A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
processing unit
server node
migrated
node
Prior art date
Application number
PCT/CN2021/080608
Other languages
English (en)
French (fr)
Inventor
王义元
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2021/080608 priority Critical patent/WO2022188184A1/zh
Priority to CN202180004728.XA priority patent/CN115349116A/zh
Publication of WO2022188184A1 publication Critical patent/WO2022188184A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines

Definitions

  • the present application relates to the field of computer technology, and in particular, to a data storage method and related equipment.
  • the embodiments of the present application disclose a data storage method and related equipment, which can save storage resources while ensuring data reliability.
  • a first aspect of the present application discloses a data storage method, which is applied to a data storage system.
  • the data storage method includes: acquiring cached data and a first data distribution table, wherein the first data distribution table includes a primary location and a replica location of the data ; Write the cached data at the first client node; Determine the first server node according to the master location of the cached data obtained from the first data distribution table; Write the master copy consistent with the cached data at the first server node data; if the processing unit running the first client node is consistent with the processing unit running the first server node, determine the copy position of the cached data according to the first data distribution table, and write the copy data consistent with the primary data to the The server node corresponding to the determined replica location.
  • the data storage system needs to store primary data and replica data corresponding to the cached data.
  • the processing unit where the cached data is located is consistent with the processing unit where the primary data is located, the copy data corresponding to the cached data is written at the server node, thereby saving storage space.
  • the data distribution table includes a first data distribution table
  • the data distribution strategy corresponding to the data distribution table includes: the primary data and the replica data of any piece of data in the data storage system are distributed in different processing units ; and/or the number of primary data and the number of replica data in each processing unit is balanced; and any piece of data exists in a corresponding primary location and replica location.
  • the electronic devices or nodes in the data storage system can generate or update the data distribution table according to the data distribution strategy.
  • the replica data is not written in the data storage system.
  • any processing unit in the data storage system fails or shrinks
  • the processing unit that fails or shrinks is used as the processing unit to be migrated out
  • the processing unit to be migrated out runs to be migrated out
  • the client node and the server node to be migrated stores cache data to be migrated
  • the server node to be migrated stores the master data to be migrated and the replica data to be migrated
  • the data storage method further includes: according to the data to be migrated The client node and server node of the remaining processing units other than the processing unit, update the first data distribution table, and obtain the second data distribution table.
  • the first data distribution table can be updated to obtain the second data distribution table.
  • data storage is performed according to the second data distribution table.
  • the data storage method further includes: determining the master location of the master data to be migrated as the server node to be migrated according to the second data distribution table; This data is written to the server node to be migrated; the second client node that stores the cached data consistent with the primary data to be migrated is determined; if the processing unit running the second client node and the server node to be migrated run The processing unit is consistent, and the second server node is determined according to the copy position of the master data to be migrated obtained from the second data distribution table; the copy data consistent with the master data to be migrated is written in the second server node.
  • the copy position of the master data to be migrated obtained from the second data distribution table can be obtained.
  • the replica data consistent with the master data to be migrated in the server node to be migrated is converted to the master This data is used as the master data to be migrated.
  • the conversion of the replica data to the master data can be realized under the condition that the copy data consistent with the master data to be migrated exists in the to-be-migrated server node.
  • writing the data of the master to be migrated to the server node to be migrated includes: if any client node in the processing unit running the server node to be migrated exists and the master to be migrated exists For the cached data with consistent data, write the cached data consistent with the master data to be migrated to the server node to be migrated as the master data to be migrated.
  • the main data can be written according to the cached data.
  • the data storage method further includes: determining, according to the second data distribution table, a third client node that stores cached data consistent with the replica data to be migrated, The third server node of the master data whose replica data to be migrated is consistent; if the processing unit running the third client node is the same as the processing unit running the third server node, the replica data to be migrated is distributed according to the second data distribution table Write to the server node corresponding to the replica location of the replica data to be migrated.
  • the copy data to be migrated is written into the copy data to be migrated according to the second data distribution table
  • the server node corresponding to the location of the replica to ensure data reliability.
  • the copy data to be migrated is not written to the service corresponding to the copy location of the copy data to be migrated end node.
  • the storage resources required for the copy data to be migrated can be saved while ensuring the reliability of the data.
  • the data storage method further includes: determining a client node with the smallest load from the data storage system, and adjusting the task corresponding to the cached data to be migrated to the data storage system with the smallest load or determine the client node with the smallest remaining storage resources from the data storage system, and adjust the task corresponding to the cached data to be migrated to the client node with the smallest remaining storage resources in the data storage system.
  • the expanded processing unit is used as the expanded processing unit, and the expanded processing unit runs the fourth client node and the fourth server node, and the data storage method It also includes: updating the first data distribution table according to the capacity expansion processing unit to obtain an updated third data distribution table; The data to be written to the main book stored by the four server nodes; the data to be written to the main book is written to the fourth server node, and the data to be written to the main book is deleted from other server nodes in the data storage system; The task corresponding to the buffered data is adjusted to the fourth client node.
  • the data to be written can be written into the fourth server node, and the to-be-written data can be deleted from other server nodes in the data storage system Enter the main data; adjust the tasks corresponding to the data to be written to the cache to the fourth client node to ensure a balanced distribution of services and data.
  • the data storage method further includes: storing cached data consistent with the to-be-written master book data in the data storage system
  • the client node is determined to be the fifth client node, and it is judged whether the processing unit running the fifth client node is consistent with the processing unit running the fourth server node; if the processing unit running the fifth client node is the same as running the fourth service node If the processing units of the end nodes are inconsistent, the fifth server node is determined according to the copy position of the data to be written in the master book obtained from the updated third data distribution table; the deletion from the fifth server node is consistent with the data to be written in the master book copy data.
  • the replica data to be written to the master data is not generated in the data storage system.
  • the data storage method further includes: determining, according to the updated third data distribution table, to-be-written replica data that needs to be stored by the fourth server node;
  • the sixth client node with cached data consistent with the copy data to be written determines the sixth server node that stores the master data consistent with the copy data to be written; if the processing unit running the sixth client node is the same as running The processing units of the sixth server node are consistent, and according to the updated third data distribution table, the copy data to be written is written into the fourth server node.
  • the processing unit running the sixth client node is inconsistent with the processing unit running the sixth server node, there is replica data to be written in the fourth server node, and the fourth server node is loaded from the fourth server node. Delete the data to be written to the replica.
  • the copy data to be written is not written to the fourth server node.
  • the data storage method further includes: storing the master data in the data storage system consistent with the to-be-written cached data
  • the server node of this data is determined to be the seventh server node, and it is determined whether the processing unit running the fourth client node is consistent with the processing unit running the seventh server node; if the processing unit running the fourth client node is the same as the processing unit running the seventh server node
  • the processing units of the seven server nodes are inconsistent, and the copy data to be written to the cache data is not generated in the data storage system.
  • a second aspect of the present application discloses a data storage method, which is applied to a data storage system.
  • the data storage system includes a plurality of processing units, each processing unit runs at least one client node and at least one server node, wherein the first client The end node stores cached data, and the first server node stores master data consistent with the cached data.
  • the data storage method includes: judging whether the processing unit running the first client node is consistent with the processing unit running the first server node; The processing unit running the first client node is the same as the processing unit running the first server node, and there is no copy data consistent with the master data in the data storage system, and it is written in any server node of another processing unit. Copy data consistent with the master data; if the processing unit running the first client node is inconsistent with the processing unit running the first server node, delete the copy data consistent with the master data in the data storage system.
  • the replica data stored in the data storage system can be modified by writing, deleting, etc. Save storage resources for storing replica data.
  • a third aspect of the present application discloses a computer-readable storage medium, where the computer-readable storage medium stores at least one computer instruction, and the at least one computer instruction implements the data storage method when executed on an electronic device.
  • a fourth aspect of the present application discloses a computer device, including a processor and a memory; the memory is used to store instructions; the processor is used to call the instructions in the memory, so that the computer device executes the data storage method.
  • FIG. 1 is a schematic diagram of an application scenario of the data storage method disclosed in the embodiment of the present application.
  • Figure 2 is a schematic diagram of data distribution.
  • FIG. 3 is a flowchart of a writing scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 4 is a first data distribution table.
  • FIG. 5 is a schematic diagram of data distribution in a writing scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 6 is a flowchart of a specific writing scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 7 is a second data distribution table.
  • FIG. 8 is a schematic diagram of data distribution in a scaling scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 9 is a flowchart of a specific scaling scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 10 is a third data distribution table.
  • FIG. 11 is a schematic diagram of data distribution in a capacity expansion scenario of a data storage method disclosed in an embodiment of the present application.
  • FIG. 12 is a flowchart of a specific capacity expansion scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 13 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application.
  • FIG. 1 is a schematic diagram of an application scenario of the data storage method disclosed in the embodiment of the present application.
  • the data storage method of the present application can be applied to a data storage system, and the data storage system can be a software system based on a client-server architecture.
  • the data storage system includes a plurality of processing units, each processing unit running at least one client node and at least one server node.
  • the processing unit is the running entity where the client node and the server node are located.
  • the data storage system includes three processing units, the processing unit 1 runs the client node 1 and the server node 1; the processing unit 2 runs the client node 2 and the server node 2; the processing unit 3 runs the client node 3 and server node 3.
  • the processing unit when the client node and the server node are processes, the processing unit may be a virtual machine or a physical machine.
  • the processing unit can be a rack or a cluster.
  • one processing unit may also run multiple nodes on the client side and/or multiple nodes on the server side.
  • FIG. 2 is a schematic diagram of data distribution. Client nodes and server nodes are distributed on multiple processing units.
  • the client node may store cache data
  • the server node may store master data and replica data corresponding to the cache data
  • the copy data may be the master data or the backup data of the cache data.
  • the cached data of the client node can be on the same processing unit as the primary data or replica data of the server node, or it can be on a different processing unit from the primary data and replica data of the server node.
  • the primary data and replica data of the server node can be on different processing units. When one processing unit fails, data can be recovered from other processing units.
  • data1 represents the cached data stored by the client node
  • data1(m) represents the master data stored by a server node that is consistent with data1
  • data1(s) represents another server node Stored copy data consistent with data1.
  • data2, data3, data4, data5, and data6 are not described again.
  • data1 For any data, such as data1, three copies are stored in the software system based on the client-server architecture, namely data1, data1(m) and data1(s). Three copies of data1 can only ensure that data will not be lost when a single processing unit fails.
  • the data1 stored in client node 1 and the data1(m) stored in server node 1 are on the same processing unit 1, that is, stored on processing unit 1. Two copies of the same data are stored, which does not increase the reliability of the software system, but takes up additional storage resources.
  • the storage resources may include memory, disks, storage media, and the like.
  • FIG. 3 is a flowchart of a writing scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 3 takes the application scenario of FIG. 1 as an example for description.
  • the data storage method is applied to a data storage system.
  • the data storage system includes a plurality of processing units, and each processing unit runs at least one client node and at least one server node. Client nodes and server nodes can be aware of the processing unit they belong to.
  • Data storage methods include:
  • the data distribution strategy corresponding to the data distribution table in the embodiment of the present application includes: the master data and the replica data of any piece of data in the data storage system are distributed in different processing units; and/or the number of master data and The number of replica data is balanced; there is a corresponding primary location and replica location for any piece of data, that is, the primary location and replica location for any piece of data.
  • the business processing of the client node is logically separated from the data storage of the server node, that is, when the server formulates the data distribution strategy, it does not need to perceive the storage location of the cached data (that is, it does not need to perceive the storage location of the cached data). client nodes), therefore, the data distribution strategy needs to include the primary and replica locations of any data.
  • FIG. 4 is a first data distribution table. 4, taking the cache data data1 as an example, the primary location of data1 is server node 1 running on processing unit 1, and the copy location of data1 is server node 2 running on processing unit 2.
  • the primary data and replica data of data1 are distributed in different processing units.
  • the first data distribution table includes the primary location of data1 (running on the server node 1 of processing unit 1) and the replica location (running on the server of processing unit 2). node 2).
  • the number of primary copies per processing unit is equal or similar, and the number of replicas per processing unit is equal or similar.
  • the cached data may be one of data1, data2, data3, data4, data5, and data6.
  • the cached data can be written to different client nodes (ie, the first client node).
  • the first client node in step 302 is the client End node 1; if the cached data is data2, the first client node is client node 2; if the cached data is data3, the first client node is client node 3; if the cached data is data4, the first client node is Client node 1; if the cached data is data5, the first client node is client node 2; if the cached data is data6, the first client node is client node 3.
  • client node 1 and server node 1 run on processing unit 1
  • client node 2 and server node 2 run on processing unit 2
  • client node 3 and server node 3 run on processing unit 3 .
  • the first server node in step 303 can be determined as server node 1 according to the primary location of the cached data in the first data distribution table. If the cached data is data2, the first server node is determined to be the server node 1 according to the primary location of the cached data in the first data distribution table. If the cached data is data3, the first server node is determined as the server node 2 according to the primary location of the cached data in the first data distribution table. data4, data5, and data6 are not repeated here.
  • write the master data of data1 to server node 1 write the master data of data2 to server node 1, and write the master data of data3 to server node 2.
  • data4, data5, and data6 are not repeated here.
  • processing unit running the first client node is the same as the processing unit running the first server node, determine the copy position of the cached data according to the first data distribution table, and write the copy data consistent with the primary data to the corresponding copy data.
  • the server node corresponding to the determined replica location If the processing unit running the first client node is the same as the processing unit running the first server node, determine the copy position of the cached data according to the first data distribution table, and write the copy data consistent with the primary data to the corresponding copy data.
  • the server node corresponding to the determined replica location is the same as the processing unit running the first server node.
  • the processing unit running client node 1 (that is, the first client node of data1) is the same as the processing unit running server node 1 (that is, the first server node of data1).
  • the table determines that the replica location of data1 is server node 2, and writes the replica data data1(s) of data1 to server node 2.
  • the copy data will not be written in the data storage system, because the cached data and the primary data are already Located in different processing units to ensure data security and reliability, no need to write duplicate data and occupy additional storage space.
  • the processing unit running client node 2 (ie, the first client node of data2) is inconsistent with the processing unit running server node 1 (ie, the first server node of data2), and is not in the data storage system.
  • the processing unit running client node 3 (ie, the first client node of data3) is inconsistent with the processing unit running server node 2 (ie, the first server node of data3), and data3 is not written in the data storage system (s).
  • data4, data5, and data6 are not repeated here.
  • FIG. 5 is a schematic diagram of data distribution in a writing scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 5 shows the results of writing to data1, data2, data3, data4, data5, and data6.
  • FIG. 5 saves the storage resources required by data2(s), data3(s), data4(s), and data5(s), but the data reliability did not decrease.
  • the data storage method of the embodiment of the present application saves storage resources under the condition of maintaining data reliability.
  • FIG. 6 is a flowchart of a specific writing scenario of the data storage method disclosed in the embodiment of the present application.
  • client node 1 For data1, client node 1 writes data1 to the cache. Client node 1 synchronizes the write operation of data1 to server node 1, and obtains the master data data1(m) of data1. Since both data1 and data1(m) are in processing unit 1, in order to ensure reliability, it needs to be in server node 2. (It can be determined according to the first data distribution table) to generate replica data. Write replica data data1(s) on server node 2.
  • client node 2 For data2, client node 2 writes data2 to the cache. Client node 2 synchronizes the write operation of data2 to server node 1, and obtains the master data data2(m) of data2. Since data2 and data2(m) are in different processing units, there is no need to write duplicate data.
  • client node 3 For data3, client node 3 writes data3 to the cache. Client node 3 synchronizes the write operation of data3 to server node 2, and obtains the master data data3(m) of data3. Since data3 and data3(m) are in different processing units, there is no need to write copy data. data4, data5, and data6 are not repeated here.
  • the failed or shrinking processing unit is regarded as the processing unit to be migrated out, indicating that the data in the faulty or shrinking processing unit needs to be migrated.
  • the client node running on the processing unit to be migrated out is called the client node to be migrated out
  • the server node running on the processing unit to be migrated out is called the server node to be migrated out.
  • the to-be-migrated client node stores the to-be-migrated cache data
  • the to-be-migrated server node stores the to-be-migrated master data and the to-be-migrated replica data
  • the data storage method further includes:
  • the first data distribution table is updated to obtain the second data distribution table according to the client nodes and server nodes of the remaining processing units other than the processing unit to be migrated out.
  • the data storage system updates the first data distribution table according to the client nodes and server nodes of the remaining processing units other than the processing units to be migrated, and obtains the second data distribution table .
  • the data storage system regenerates the second data distribution table according to the client nodes and server nodes of the processing units other than the processing units to be migrated out.
  • FIG. 7 is a second data distribution table. Taking the cached data data1 as an example, the primary location of data1 is server node 1 running on processing unit 1, and the copy location of data1 is server node 2 running on processing unit 2.
  • the data storage method further includes:
  • the master location of the master data to be migrated is the server node to be migrated; the master data to be migrated is written to the server node to be migrated; it is determined that the stored data is consistent with the master data to be migrated
  • the second client node of the cached data if the processing unit running the second client node is consistent with the processing unit running the server node to be migrated, according to the copy position of the master data to be migrated obtained from the second data distribution table , determine the second server node; write the replica data consistent with the master data to be migrated on the second server node.
  • processing unit to be migrated is processing unit 3, and processing unit 3 (processing unit to be migrated) runs client node 3 (client node to be migrated out). ) and server node 3 (server node to be migrated out), client node 3 (client node to be migrated out) stores data3 and data6 (cache data to be migrated), server node 3 (server node to be migrated out) Stored data5(m) and data6(m).
  • writing the master data to be migrated to the to-be-migrated server node includes: if there is duplicate data consistent with the to-be-migrated master data in the to-be-migrated server node, writing the to-be-migrated server node with the same copy data as the to-be-migrated master data.
  • the replica data that is consistent with the master data to be migrated is converted into the master data as the master data to be migrated.
  • the server node 1 For data6(m), it is determined according to the second data distribution table that the main location of the corresponding master data data6(m) is the server node 1 (to be migrated into the server node); as shown in Figure 5, because the server node Copy data data6(s) consistent with data6(m) already exists in 1; convert data6(s) to data6(m); when processing unit 3 fails, adjust the cached data data6 to be migrated to client node 1, According to the copy data data6(s) of the server node 1, the copy data data6(s) can be written to the client node 1, that is, the data6 is moved to the client node 1; The processing unit of the server node 1 is the same, and the copy position of data6(m) obtained from the second data distribution table is the server node 2 (the second server node); in the server node 2, write the same as data6(m) Consistent replica data data6(s).
  • writing the to-be-migrated master data to the to-be-migrated server node includes: if any client node in the processing unit running the to-be-migrated server node has cached data consistent with the to-be-migrated master data , and write the cached data consistent with the master data to be migrated to the to-be-migrated server node as the master data to be migrated.
  • the client node 2 determines that data3(m) is stored in the server node 2 according to the second data distribution table; restores data3 from the server node 2 to the client node 2, that is, according to the master data data3(m), in the client End node 2 writes data3; if the processing unit running client node 2 is consistent with the processing unit running server node 2, the copy position of data3(m) obtained from the second data distribution table is server node 1 (No. Two server nodes); write the copy data data3(s) consistent with data3(m) on the server node 1.
  • the data storage method further includes:
  • the second data distribution table determine the third client node that stores the cached data consistent with the copy data to be migrated, and determine the third server node that stores the master data consistent with the copy data to be migrated;
  • the processing unit of the end node is the same as the processing unit running the third server node, and according to the second data distribution table, the replica data to be migrated is written to the server node corresponding to the replica position of the replica data to be migrated.
  • the copy data to be migrated is not written to the copy location corresponding to the copy data to be migrated. server node.
  • the data storage method further includes:
  • FIG. 8 is a schematic diagram of data distribution in a scaling scenario of the data storage method disclosed in the embodiment of the present application.
  • FIG. 8 shows the result of downsizing the processing unit 3 .
  • the processing unit 3 in the shaded part indicates that a failure or shrinkage has occurred.
  • the data storage system of FIG. 8 lacks the processing unit 3 .
  • the data storage system migrates or backs up the data in the original processing unit 3 to the processing unit 1 and the processing unit 2 .
  • FIG. 9 is a flowchart of a specific scaling scenario of the data storage method disclosed in the embodiment of the present application.
  • data5(m) and data6(m) of the server node 3 are lost, and data3 and data6 of the client node 3 are lost.
  • the services corresponding to data3 and data6 of client node 3 are adjusted to client node 2 and client node 1 for processing respectively.
  • the client node 3 and the server node 3 in the shaded part indicate that there is a failure or a capacity reduction.
  • data5(m) it is determined according to the second data distribution table that data5(m) should be stored in server node 2. Since client node 2 stores cached data data5, data5 can be restored from client node 2 to The server node 2, that is, the server node 2 writes the master data data5(m) consistent with the cache data data5. Since client node 2 and server node 2 are in the same processing unit, in order to ensure reliability, it is necessary to generate duplicate data. After the server node 2 writes the master data data5(m), according to the second data distribution table, the server node 1 writes the replica data data5(s).
  • the master data data6(m) For data6(m), according to the adjusted data distribution strategy (the second data distribution table), the master data data6(m) should be stored in the server node 1, because the server node 1 already exists with the master data data6( m) Consistent copy data data6(s), the original copy data data6(s) of the server node 1 can be changed to the main data data6(m), that is, there is no need to repeatedly write the same data.
  • Client node 1 finds that the main data data6(m) is in server node 1, and can directly restore cached data data6 from server node 1, that is, client node 1 writes data6 into the cache.
  • Client node 1 initiates data location verification of data6 to server node 1.
  • the server node 1 Since data6 and data6(m) are in the same processing unit 1, in order to ensure reliability, duplicate data needs to be generated.
  • the server node 1 generates the corresponding replica data data6(s) on the server node 2 according to the data distribution strategy (second data distribution table).
  • the client node 2 finds the corresponding master data data3(m) in the server node 2, and then restores the data from the server node 2.
  • Client node 2 writes data3 to the cache.
  • Client node 2 initiates data location verification of data3 to server node 2. Since data3 and data3(m) are in the same processing unit, in order to ensure reliability, duplicate data needs to be generated.
  • the server node 2 generates corresponding replica data data3(s) on the server node 1 according to the data distribution policy (second data distribution table).
  • the expanded processing unit is used as the capacity expansion processing unit, and the capacity expansion processing unit runs the fourth client node and the fourth server node, and the data storage method further includes:
  • the first data distribution table is updated to obtain an updated third data distribution table; according to the updated third data distribution table, it is determined that the cached data to be written to be stored by the fourth client node and the fourth server node to be stored are determined.
  • the corresponding task is adjusted to the fourth client node.
  • the data storage system updates the first data distribution table according to the expansion processing unit and the client node and server node of the original processing unit to obtain an updated third data distribution table. surface. Or, based on the data distribution strategy, the data storage system regenerates the third data distribution table according to the expansion processing unit and the client node and server node of the original processing unit.
  • FIG. 10 is a third data distribution table. Taking the cached data data1 as an example, the primary location of data1 is server node 1 running on processing unit 1, and the copy location of data1 is server node 2 running on processing unit 2.
  • the added capacity expansion processing unit is the processing unit 4, and the processing unit 4 runs the client node 4 (the fourth client node) and the server node 4 (the fourth service end node).
  • the client node 4 stores the to-be-written cache data data6, and the server node 4 stores the to-be-written master data data4(m).
  • the data storage method further includes: storing cached data consistent with the data to be written in the main book in the data storage system
  • the client node is determined to be the fifth client node, and it is judged whether the processing unit running the fifth client node is consistent with the processing unit running the fourth server node; if the processing unit running the fifth client node is the same as running the fourth service node If the processing units of the end nodes are inconsistent, the fifth server node is determined according to the copy position of the data to be written in the master book obtained from the updated third data distribution table; the deletion from the fifth server node is consistent with the data to be written in the master book copy data.
  • the replica data to be written to the master data is not generated in the data storage system.
  • the fourth server node is the server node 4 and runs on the processing unit 4 .
  • the above-mentioned fifth client node is the client node 1 and runs on the processing unit 1 .
  • the processing unit 4 is not identical to the processing unit 1, therefore, no replica data data4(s) is generated in the data storage system.
  • the data storage method further includes: determining, according to the updated third data distribution table, to-be-written copy data that needs to be stored by the fourth server node;
  • the sixth client node with cached data consistent with the copy data to be written determines the sixth server node that stores the master data consistent with the copy data to be written; if the processing unit running the sixth client node is the same as running The processing units of the sixth server node are consistent, and according to the updated third data distribution table, the copy data to be written is written into the fourth server node.
  • the processing unit running the sixth client node is inconsistent with the processing unit running the sixth server node, and there is copy data to be written in the fourth server node, delete the copy to be written from the fourth server node. data.
  • the copy data to be written is not written to the fourth server node.
  • the updated third data distribution table determines the data6(s) that needs to be stored by the server node 4 (the fourth server node); according to the updated third data distribution table
  • the table determines that the client node 4 (sixth client node) with data6 is stored, and it is determined that the server node 3 (sixth server node) with data6(m) is stored;
  • the processing units running server node 3 are inconsistent and do not write data6(s) to server node 4.
  • the data storage method further includes: storing in the data storage system a host that is consistent with the to-be-written cache data
  • the server node of this data is determined to be the seventh server node, and it is determined whether the processing unit running the fourth client node is consistent with the processing unit running the seventh server node; if the processing unit running the fourth client node is the same as the processing unit running the seventh server node
  • the processing units of the seven server nodes are inconsistent, and the copy data to be written to the cache data is not generated in the data storage system.
  • the seventh part of the data storage system that stores the copy data data6(m) The server node is server node 3, the processing unit running client node 4 is inconsistent with the processing unit running server node 3, and the copy data data6(s) to be written is not generated in the data storage system.
  • FIG. 11 is a schematic diagram of data distribution in a capacity expansion scenario of a data storage method disclosed in an embodiment of the present application.
  • FIG. 11 shows the result of expanding the capacity of the processing unit 3 .
  • the capacity of the processing unit 4 has been expanded.
  • the data storage system of FIG. 11 adds the processing unit 3 .
  • the data storage system transfers data in processing units other than the processing unit 4 to the processing unit 4 .
  • FIG. 12 is a flowchart of a specific capacity expansion scenario of the data storage method disclosed in the embodiment of the present application.
  • data4(m) is migrated from the server node 2 to the server node 4 according to the adjusted data distribution strategy (updated third data distribution table). .
  • server node 2 deletes data4(m).
  • Client node 1 initiates data location verification of data4 to server node 4. Since data4 and data4(m) are in different processing units, there is no need to generate duplicate data.
  • the server node 4 For the cached data data6, according to the adjusted data distribution strategy (updated third data distribution table), the server node 4 generates replica data data6(s). The server node 1 deletes the original copy data data6(s). After the processing unit 4 is expanded, the service corresponding to the cached data data6 of the client node 3 is adjusted to the client node 4 for processing. The client node 4 finds that the master data6(m) is in the server node 3 (using the adjusted data distribution strategy), and then restores the data from the server node 3 to the client node 4, that is, according to the master of the server node 3 The data data6(m) is written to the corresponding cache data to the client node 4. Client node 4 writes data6 to the cache. The client node 4 initiates the data location check of data6 to the server node 3. Since data6 and data6(m) are in different processing units, there is no need to generate duplicate data. Server node 4 deletes data6(s).
  • the data storage method is applied to a data storage system, the data storage system includes a plurality of processing units, each processing unit runs at least one client node and at least one server node, wherein the first client node stores cache data, and the first server node Nodes store primary data consistent with cached data.
  • Data storage methods include:
  • the replica data stored in the data storage system can be modified by writing, deleting, etc., through this embodiment.
  • a server node on the processing unit where the client node is located may be used as a local data access node, that is, a new client node.
  • each processing unit deploys a server node, and each processing unit deploys a fixed number of client nodes.
  • the data of the client node is evenly backed up on each server node, and each server node stores 1/N of the master data. Only the master data of the server node in the same processing unit as the client node needs the copy data.
  • the data storage system of the embodiment of the present application needs to store 1+(1/N) pieces of data. Normally, the data storage system needs to store 2 copies of data. Therefore, the data storage system in this embodiment of the present application saves 1-1/N copies of data, and the saving ratio is (N-1)/2N. The larger N is, the more storage resources are saved, and the saving ratio is closer to 50%.
  • FIG. 13 is a schematic structural diagram of an electronic device (eg, the site in FIG. 1 ) disclosed in an embodiment of the present application.
  • the electronic device 130 may include: a radio frequency (RF) circuit 1301, a memory 1302, an input unit 1303, a display unit 1304, a sensor 1305, an audio circuit 1306, a Wi-Fi module 1307, a processor 1308 and Power 1309 and other components.
  • RF radio frequency
  • FIG. 13 does not constitute a limitation on the electronic device, and may include more or less components than the one shown, or combine some components, or arrange different components.
  • the RF circuit 1301 can be used to send and receive information or to receive and transmit signals during a call. In particular, after receiving the downlink information of the base station, it is transferred to the processor 1308 for processing; in addition, it sends the uplink data to the base station.
  • the RF circuit 1301 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like.
  • LNA Low Noise Amplifier
  • the memory 1302 can be used to store software programs and modules, and the processor 1308 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 1302 .
  • the memory 1302 may mainly include a stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; Data (such as audio data, etc.) created by the use of electronic equipment, etc.
  • memory 1302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the input unit 1303 may be used to receive input numerical or character information, and generate key signal input related to user setting and function control of the electronic device.
  • the input unit 1303 may include a touch panel 13031 and other input devices 13032 .
  • the touch panel 13031 also known as a touch screen, collects the user's touch operations on or near it (such as the user using a finger, a stylus, or any suitable object or accessory on or near the touch panel 13031) operation), and drive the corresponding connection device according to the preset program.
  • the touch panel 13031 may include two parts, a touch detection device and a touch controller.
  • the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the touch controller.
  • the touch panel 13031 can be realized by various types of resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 1303 may also include other input devices 13032 .
  • other input devices 13032 may include, but are not limited to, one or more of physical keyboards, function keys (such as volume control keys, switch keys, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 1304 may be used to display information input by the user or information provided to the user and various menus of the electronic device.
  • the display unit 1304 may include a display panel 13041, and optionally, the display panel 13041 may be configured in the form of a liquid crystal display (Liquid Crystal Display, LCD), an organic light-emitting diode (Organic Light-Emitting Diode, OLED), or the like.
  • the touch panel 13031 can cover the display panel 13041. When the touch panel 13031 detects a touch operation on or near it, it transmits it to the processor 1308 to determine the type of the touch event, and then the processor 1308 determines the type of the touch event according to the touch event. Type provides corresponding visual output on display panel 13041.
  • the touch panel 13031 and the display panel 13041 are used as two independent components to realize the input and output functions of the electronic device, but in some embodiments, the touch panel 13031 and the display panel 13041 can be integrated And realize the input and output functions of electronic equipment.
  • the electronic device may also include at least one sensor 1305, such as light sensors, motion sensors, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 13041 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 13041 and the display panel 13041 when the electronic device is moved to the ear. / or backlight.
  • the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary, and can be used for applications that recognize the posture of electronic devices (such as horizontal and vertical screen switching, related games, magnetometer attitude calibration), vibration recognition related functions (such as pedometer, tapping), etc.; in addition, electronic devices can also be equipped with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. This will not be repeated here.
  • the audio circuit 1306, the speaker 13061, and the microphone 13062 can provide an audio interface between the user and the electronic device.
  • the audio circuit 1306 can transmit the received audio data converted electrical signal to the speaker 13061, and the speaker 13061 converts it into a sound signal for output; on the other hand, the microphone 13062 converts the collected sound signal into an electrical signal, which is converted by the audio circuit 1306. After receiving, it is converted into audio data, and then processed by the audio data output processor 1308, and then sent to another electronic device through the RF circuit 1301, or the audio data is output to the memory 1302 for further processing.
  • Wi-Fi is a short-distance wireless transmission technology
  • the electronic device 130 can help users to send and receive emails, browse web pages, access streaming media, etc. through the Wi-Fi module 1307, which provides users with wireless broadband Internet access.
  • FIG. 13 shows the Wi-Fi module 1307, it can be understood that it is not a necessary component of the electronic device, and can be completely omitted as required and within the scope of not changing the essence of the invention.
  • the processor 1308 is the control center of the electronic device, using various interfaces and lines to connect various parts of the entire electronic device, by running or executing the software programs and/or modules stored in the memory 1302, and calling the data stored in the memory 1302. , perform various functions of electronic equipment and process data, so as to monitor electronic equipment as a whole.
  • the processor 1308 may include one or more processing units; preferably, the processor 1308 may integrate an application processor and a modem, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem mainly processes Wireless communication. It can be understood that, the above-mentioned modulation and demodulation processor may not be integrated into the processor 1308.
  • the electronic device also includes a power supply 1309 (such as a battery) that supplies power to various components.
  • a power supply 1309 (such as a battery) that supplies power to various components.
  • the power supply can be logically connected to the processor 1308 through a power management system, so as to manage charging, discharging, and power consumption management functions through the power management system. .
  • the electronic device may further include a camera, a Bluetooth module, and the like, which will not be repeated here.
  • the electronic device described in FIG. 13 may be used to implement some or all of the processes in the method embodiments introduced in this application, and reference may be made to the relevant descriptions in the foregoing embodiments, which will not be repeated here.
  • This embodiment also provides a computer storage medium, where computer instructions are stored in the computer storage medium, and when the computer instructions are executed on the electronic device, the electronic device executes the above-mentioned related method steps to realize the memory recycling method in the above-mentioned embodiment.
  • This embodiment also provides a computer program product, which, when the computer program product runs on the electronic device, causes the electronic device to execute the above-mentioned relevant steps, so as to realize the memory recycling method in the above-mentioned embodiment.
  • the embodiments of the present application also provide an apparatus, which may specifically be a chip, a component or a module, and the apparatus may include a connected processor and a memory; wherein, the memory is used for storing computer execution instructions, and when the apparatus is running, The processor can execute the computer-executed instructions stored in the memory, so that the chip executes the memory recycling method in each of the foregoing method embodiments.
  • the electronic device, computer storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above. Therefore, for the beneficial effects that can be achieved, reference can be made to the corresponding provided above. The beneficial effects in the method will not be repeated here.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be combined. Or it may be integrated into another device, or some features may be omitted, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and components shown as units may be one physical unit or multiple physical units, that is, may be located in one place, or may be distributed to multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as an independent product, may be stored in a readable storage medium.
  • a readable storage medium including several instructions to make a device (may be a single chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program codes .

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据存储方法及相关设备,所述方法应用于数据存储***,数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点,所述方法包括:获取缓存数据和第一数据分布表,其中,第一数据分布表包括数据的主本位置和副本位置(301);在第一客户端节点写入缓存数据(302);根据从第一数据分布表获取的缓存数据的主本位置,确定第一服务端节点(303);在第一服务端节点写入与缓存数据一致的主本数据(304);若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元一致,根据第一数据分布表确定缓存数据的副本位置,将与主本数据一致的副本数据写入至与确定的副本位置对应的服务端节点(305)。该方法可以节约存储资源。

Description

数据存储方法及相关设备 技术领域
本申请涉及计算机技术领域,尤其涉及一种数据存储方法及相关设备。
背景技术
在客户端-服务端架构的软件***中,为了确保数据可靠性,需要分别在服务端多个节点存储数据。在服务端多个节点存储的数据份数越多,数据可靠性越高,同时,占用存储资源也越多。
在确保数据可靠性的同时,如何节约存储资源成为需要解决的问题。
发明内容
本申请实施例公开了一种数据存储方法及相关设备,可以在确保数据可靠性的同时,节约存储资源。
本申请第一方面公开了一种数据存储方法,应用于数据存储***,数据存储方法包括:获取缓存数据和第一数据分布表,其中,第一数据分布表包括数据的主本位置和副本位置;在第一客户端节点写入缓存数据;根据从第一数据分布表获取的缓存数据的主本位置,确定第一服务端节点;在第一服务端节点写入与缓存数据一致的主本数据;若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元一致,根据第一数据分布表确定缓存数据的副本位置,将与主本数据一致的副本数据写入至与确定的副本位置对应的服务端节点。
通常,对于客户端节点的缓存数据,数据存储***中需要存储与缓存数据对应的主本数据和副本数据。本申请提供的实施例中,当缓存数据所在的处理单元与主本数据所在的处理单元一致时,才在服务端节点写入与缓存数据对应的副本数据,从而节约了存储空间。
在一些可选的实施方式中,数据分布表包括第一数据分布表,数据分布表对应的数据分布策略包括:数据存储***中任意一份数据的主本数据和副本数据分布在不同的处理单元;和/或各个处理单元的主本数据数量和副本数据数量均衡;和任意一份数据存在对应的主本位置和副本位置。
通过采用该技术方案,数据存储***中的电子设备或节点可以根据数据分布策略生成或更新数据分布表。
在一些可选的实施方式中,若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元不一致,不在数据存储***中写入副本数据。
通过采用该技术方案,在运行第一客户端节点的处理单元与运行第一服务端节点的处理单元不一致的情况下,不在数据存储***中写入副本数据。在一个处理单元发生故障时,数据存储***中仍存储了与故障处理单元中丢失数据对应的备份数据,从而可以 在可靠性不降低的同时,节省存储副本数据的存储资源。
在一些可选的实施方式中,若数据存储***中的任一处理单元发生故障或缩容,将发生故障或缩容的处理单元作为待迁出处理单元,待迁出处理单元运行待迁出客户端节点和待迁出服务端节点,待迁出客户端节点存储待迁移缓存数据,待迁出服务端节点存储待迁移主本数据与待迁移副本数据,数据存储方法还包括:根据待迁出处理单元以外的其余处理单元的客户端节点和服务端节点,更新第一数据分布表,得到第二数据分布表。
通过采用该技术方案,可以对第一数据分布表进行更新,得到第二数据分布表。以在处理单元发生缩容的情况下,根据第二数据分布表进行数据存储。
在一些可选的实施方式中,对于待迁移主本数据,数据存储方法还包括:根据第二数据分布表确定待迁移主本数据的主本位置为待迁入服务端节点;将待迁移主本数据写入至待迁入服务端节点;确定存储了与待迁移主本数据一致的缓存数据的第二客户端节点;若运行第二客户端节点的处理单元与运行待迁入服务端节点的处理单元一致,根据从第二数据分布表获取的待迁移主本数据的副本位置,确定第二服务端节点;在第二服务端节点写入与待迁移主本数据一致的副本数据。
通过采用该技术方案,可以在运行第二客户端节点的处理单元与运行待迁入服务端节点的处理单元一致的情况下,根据从第二数据分布表获取的待迁移主本数据的副本位置,确定第二服务端节点;在第二服务端节点写入与待迁移主本数据一致的副本数据。以确保数据可靠性。
在一些可选的实施方式中,若待迁入服务端节点中存在与待迁移主本数据一致的副本数据,将待迁入服务端节点中与待迁移主本数据一致的副本数据转换为主本数据,作为待迁移主本数据。
通过采用该技术方案,可以在待迁入服务端节点中存在与待迁移主本数据一致的副本数据的情况下,实现副本数据向主本数据的转换。
在一些可选的实施方式中,将待迁移主本数据写入至待迁入服务端节点包括:若运行待迁入服务端节点的处理单元中的任一客户端节点存在与待迁移主本数据一致的缓存数据,将与待迁移主本数据一致的缓存数据写入至待迁入服务端节点,作为待迁移主本数据。
通过采用该技术方案,可实现根据缓存数据写入主本数据。
在一些可选的实施方式中,对于待迁移副本数据,数据存储方法还包括:根据第二数据分布表确定存储了与待迁移副本数据一致的缓存数据的第三客户端节点,确定存储了与待迁移副本数据一致的主本数据的第三服务端节点;若运行第三客户端节点的处理单元与运行第三服务端节点的处理单元一致,根据第二数据分布表,将待迁移副本数据写入与待迁移副本数据的副本位置对应的服务端节点。
通过采用该技术方案,在运行第三客户端节点的处理单元与运行第三服务端节点的处理单元一致的情况下,根据第二数据分布表,将待迁移副本数据写入与待迁移副本数据的副本位置对应的服务端节点,确保数据可靠性。
在一些可选的实施方式中,若运行第三客户端节点的处理单元与运行第三服务端节点的处理单元不一致,不将待迁移副本数据写入与待迁移副本数据的副本位置对应的服务端节点。
通过采用该技术方案,可以在确保数据可靠性的同时,节省待迁移副本数据所需的存储资源。
在一些可选的实施方式中,对于待迁移缓存数据,数据存储方法还包括:从数据存储***中确定负载最小的客户端节点,将待迁移缓存数据对应的任务调整至数据存储***中负载最小的客户端节点;或从数据存储***中确定剩余存储资源最小的客户端节点,将待迁移缓存数据对应的任务调整至数据存储***中剩余存储资源最小的客户端节点。
通过采用该技术方案,可以实现任务在客户端节点间的调整。
在一些可选的实施方式中,若数据存储***中的处理单元发生扩容,将发生扩容的处理单元作为扩容处理单元,扩容处理单元运行第四客户端节点和第四服务端节点,数据存储方法还包括:根据扩容处理单元,更新第一数据分布表,得到更新的第三数据分布表;根据更新的第三数据分布表,确定需第四客户端节点存储的待写入缓存数据、需第四服务端节点存储的待写入主本数据;将待写入主本数据写入第四服务端节点,从数据存储***中的其他服务端节点中删除待写入主本数据;将待写入缓存数据对应的任务调整至第四客户端节点。
通过采用该技术方案,可以在数据存储***中的处理单元发生扩容的情况下,将待写入主本数据写入第四服务端节点,从数据存储***中的其他服务端节点中删除待写入主本数据;将待写入缓存数据对应的任务调整至第四客户端节点,保证业务和数据的分配均衡。
在一些可选的实施方式中,在将待写入主本数据写入第四服务端节点之后,数据存储方法还包括:将数据存储***中存储了与待写入主本数据一致的缓存数据的客户端节点确定为第五客户端节点,判断运行第五客户端节点的处理单元与运行第四服务端节点的处理单元是否一致;若运行第五客户端节点的处理单元与运行第四服务端节点的处理单元不一致,根据从更新的第三数据分布表获取的待写入主本数据的副本位置,确定第五服务端节点;从第五服务端节点删除与待写入主本数据一致的副本数据。
通过采用该技术方案,可以在运行第五客户端节点的处理单元与运行第四服务端节点的处理单元不一致,根据从更新的第三数据分布表获取的待写入主本数据的副本位置,确定第五服务端节点;从第五服务端节点删除与待写入主本数据一致的副本数据,以节约存储副本数据所需的存储资源。
在一些可选的实施方式中,若运行第五客户端节点的处理单元与运行第四服务端节点的处理单元不一致,不在数据存储***中生成待写入主本数据的副本数据。
通过采用该技术方案,可以节约存储副本数据所需的存储资源。
在一些可选的实施方式中,数据存储方法还包括:根据更新的第三数据分布表,确定需第四服务端节点存储的待写入副本数据;根据更新的第三数据分布表确定存储了与待写入副本数据一致的缓存数据的第六客户端节点,确定存储了与待写入副本数据一致的主本数据的第六服务端节点;若运行第六客户端节点的处理单元与运行第六服务端节点的处理单元一致,根据更新的第三数据分布表,将待写入副本数据写入第四服务端节点。
通过采用该技术方案,可以确保数据的可靠性。
在一些可选的实施方式中,若运行第六客户端节点的处理单元与运行第六服务端节点的处理单元不一致,第四服务端节点中存在待写入副本数据,从第四服务端节点删除待写入副本数据。
通过采用该技术方案,可以节约存储副本数据所需的存储资源。
在一些可选的实施方式中,若运行第六客户端节点的处理单元与运行第六服务端节点的 处理单元不一致,不写入待写入副本数据至第四服务端节点。
通过采用该技术方案,可以节约存储副本数据所需的存储资源。
在一些可选的实施方式中,在将待写入缓存数据对应的任务调整至第四客户端节点之后,数据存储方法还包括:将数据存储***中存储了与待写入缓存数据一致的主本数据的服务端节点确定为第七服务端节点,判断运行第四客户端节点的处理单元与运行第七服务端节点的处理单元是否一致;若运行第四客户端节点的处理单元与运行第七服务端节点的处理单元不一致,不在数据存储***中生成待写入缓存数据的副本数据。
通过采用该技术方案,可以节约存储副本数据所需的存储资源。
本申请第二方面公开了一种数据存储方法,应用于数据存储***,数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点,其中,第一客户端节点存储缓存数据,第一服务端节点存储与缓存数据一致的主本数据,数据存储方法包括:判断运行第一客户端节点的处理单元与运行第一服务端节点的处理单元是否一致;若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元一致,且数据存储***中不存在与主本数据一致的副本数据,在另一个处理单元的任一服务端节点写入与主本数据一致的副本数据;若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元不一致,删除数据存储***中的与主本数据一致的副本数据。
通过采用该技术方案,对于副本数据不满足上述数据分布策略的数据存储***,可以通过本实施例对数据存储***存储的副本数据进行写入、删除等修改,以在确保数据可靠性的同时,节省存储副本数据的存储资源。
本申请第三方面公开了一种计算机可读存储介质,所述计算机可读存储介质存储有至少一个计算机指令,所述至少一个计算机指令在电子设备上运行时实现所述的数据存储方法。
本申请第四方面公开了一种计算机设备,包括处理器和存储器;所述存储器,用于存储指令;所述处理器,用于调用所述存储器中的指令,使得所述计算机设备执行所述的数据存储方法。
第三方面至第四方面所带来的技术效果可参见上述方法部分各涉及的方法相关的描述,此处不再赘述。
附图说明
图1是本申请实施例公开的数据存储方法的应用场景示意图。
图2是数据分布示意图。
图3是本申请实施例公开的数据存储方法的写入场景的流程图。
图4是第一数据分布表。
图5是本申请实施例公开的数据存储方法的写入场景的数据分布示意图。
图6是本申请实施例公开的数据存储方法的具体写入场景的流程图。
图7是第二数据分布表。
图8是本申请实施例公开的数据存储方法的缩容场景的数据分布示意图。
图9是本申请实施例公开的数据存储方法的具体缩容场景的流程图。
图10是第三数据分布表。
图11是本申请实施例公开的数据存储方法的扩容场景的数据分布示意图。
图12是本申请实施例公开的数据存储方法的具体扩容场景的流程图。
图13是本申请实施例公开的电子设备的结构示意图。
具体实施方式
为了便于理解,示例性的给出了部分与本申请实施例相关概念的说明以供参考。
需要说明的是,本申请中“至少一个”是指一个或者多个,“多个”是指两个或多于两个。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。本申请的说明书和权利要求书及附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不是用于描述特定的顺序或先后次序。
为了更好地理解本申请实施例公开的数据存储方法及相关设备,下面首先对本申请数据存储方法的应用场景进行描述。
图1是本申请实施例公开的数据存储方法的应用场景示意图。本申请数据存储方法可以应用于数据存储***,数据存储***可以是基于客户端-服务端架构的软件***。数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点。处理单元是客户端节点和服务端节点所在的运行实体。如图1所示,数据存储***包括三个处理单元,处理单元1运行客户端节点1和服务端节点1;处理单元2运行客户端节点2和服务端节点2;处理单元3运行客户端节点3和服务端节点3。
在本申请的一个实施例中,客户端节点和服务端节点是进程时,处理单元可以是虚拟机或物理机。客户端节点和服务端节点是虚拟机或物理机时,处理单元可以是机架或集群。
在其他的实施例中,一个处理单元也可运行客户端多个节点和/或服务端多个节点。
图2是数据分布示意图。客户端节点与服务端节点分布在多个处理单元上。
在本申请的一个实施例中,客户端节点可存储缓存数据,服务端节点可存储与缓存数据相应的主本数据和副本数据,副本数据可以是主本数据或缓存数据的备份数据。客户端节点的缓存数据,可以与服务端节点的主本数据或副本数据在相同的处理单元上,也可以与服务端节点的主本数据和副本数据在不相同的处理单元上。服务端节点的主本数据与副本数据可以在不同的处理单元上。当一个处理单元发生故障时,可以从其他处理单元恢复数据。
参见图2所示,以data1为例,data1表示客户端节点存储的缓存数据,data1(m)表示一个服务端节点存储的与data1一致的主本数据,data1(s)表示另一个服务端节点存储的与data1一致的副本数据。如图2所示,data2、data3、data4、data5、data6不再赘述。
对于任意一数据,如data1,在基于客户端-服务端架构的软件***中存储了3份,分别为data1、data1(m)和data1(s)。3份data1只能确保单个处理单元发生故障时数据不会丢失,存储于客户端节点1的data1与存储于服务端节点1的data1(m)同在处 理单元1上,即处理单元1上存储了两份相同的数据,没有增加软件***的可靠性,但占用了额外的存储资源。其中,存储资源可以包括内存、磁盘、存储介质等。
应当理解,在数据可靠性不降低的情况下,如何减少数据副本数量,以节省存储资源,是目前需要解决的问题。
图3是本申请实施例公开的数据存储方法的写入场景的流程图。图3以图1的应用场景为例进行说明。数据存储方法应用于数据存储***中,数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点。客户端节点和服务端节点可以感知所属的处理单元。数据存储方法具体包括:
301,获取缓存数据和第一数据分布表,其中,第一数据分布表包括数据的主本位置和副本位置。
本申请实施例中的数据分布表对应的数据分布策略包括:数据存储***中任意一份数据的主本数据和副本数据分布在不同的处理单元;和/或各个处理单元的主本数据数量和副本数据数量均衡;和任意一份数据存在对应的主本位置和副本位置,即包括任意一份数据的主本位置和副本位置。
在数据分布策略中,客户端节点的业务处理与服务端节点的数据存储进行逻辑分离,即在服务端制定数据分布策略时,不需要感知缓存数据的存储位置(即不需要感知存储缓存数据的客户端节点),因此,数据分布策略中需要包括任意数据的主本位置和副本位置。
图4是第一数据分布表。结合图4所示,以缓存数据data1为例,data1的主本位置为运行于处理单元1的服务端节点1,data1的副本位置为运行于处理单元2的服务端节点2。data1的主本数据与副本数据分布在不同的处理单元,第一数据分布表包括data1的主本位置(运行于处理单元1的服务端节点1)和副本位置(运行于处理单元2的服务端节点2)。每个处理单元的主本数量相等或相近,每个处理单元的副本数量相等或相近。
302,在第一客户端节点写入缓存数据。
结合图4所示,缓存数据可以是data1、data2、data3、data4、data5、data6中的一个。缓存数据可以写入至不同的客户端节点(即第一客户端节点)中,例如,以图5所示的范例来看,若缓存数据是data1,步骤302中的第一客户端节点是客户端节点1;若缓存数据是data2,第一客户端节点是客户端节点2;若缓存数据是data3,第一客户端节点是客户端节点3;若缓存数据是data4,第一客户端节点是客户端节点1;若缓存数据是data5,第一客户端节点是客户端节点2;若缓存数据是data6,第一客户端节点是客户端节点3。
如图1所示,客户端节点1和服务端节点1运行于处理单元1,客户端节点2和服务端节点2运行于处理单元2,客户端节点3和服务端节点3运行于处理单元3。
303,根据从第一数据分布表获取的缓存数据的主本位置,确定第一服务端节点。
如图4所示的第一数据分布表,若缓存数据为data1,根据第一数据分布表中缓存数据的主本位置可以确定步骤303中的第一服务端节点为服务端节点1。若缓存数据为data2,根据第一数据分布表中缓存数据的主本位置确定第一服务端节点为服务端节点1。若缓存数据为data3,根据第一数据分布表中缓存数据的主本位置确定第一服务端节点为服务端节点2。data4、data5、data6不再赘述。
304,在第一服务端节点写入与缓存数据一致的主本数据。
如上例,将data1的主本数据写入服务端节点1,将data2的主本数据写入服务端节点1,将data3的主本数据写入服务端节点2。data4、data5、data6不再赘述。
305,若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元一致,根据第一数据分布表确定缓存数据的副本位置,将与主本数据一致的副本数据写入至与确定的副本位置对应的服务端节点。
如上例,对于data1,运行客户端节点1(即data1的第一客户端节点)的处理单元与运行服务端节点1(即data1的第一服务端节点)的处理单元一致,根据第一数据分布表确定data1的副本位置为服务端节点2,将data1的副本数据data1(s)写入至服务端节点2。
在本申请的一个实施例中,若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元不一致,不在数据存储***中再写入副本数据,因缓存数据与主本数据已经位于不同的处理单元,可确保数据安全与可靠性,无需再写入副本数据而占用额外的存储空间。
如上例,对于data2,运行客户端节点2(即data2的第一客户端节点)的处理单元与运行服务端节点1(即data2的第一服务端节点)的处理单元不一致,不在数据存储***中写入data2的副本数据data2(s)。对于data3,运行客户端节点3(即data3的第一客户端节点)的处理单元与运行服务端节点2(即data3的第一服务端节点)的处理单元不一致,不在数据存储***中写入data3(s)。data4、data5、data6不再赘述。
图5是本申请实施例公开的数据存储方法的写入场景的数据分布示意图。图5表示对data1、data2、data3、data4、data5、data6的写入结果。与图2对比,在采用本申请实施例提供的数据存储方法,图5节约了data2(s)、data3(s)、data4(s)、data5(s)所需的存储资源,但是数据可靠性并没有降低。当任意一个处理单元发生故障后,可以从另外的处理单元恢复数据,所以本申请实施例的数据存储方法在保持数据可靠性的条件下,节约了存储资源。
图6是本申请实施例公开的数据存储方法的具体写入场景的流程图。
对于data1,客户端节点1将data1写入缓存。客户端节点1同步data1的写操作到服务端节点1,得到data1的主本数据data1(m),由于data1与data1(m)都在处理单元1,为了保证可靠性,需要在服务端节点2(可以根据第一数据分布表确定)生成副本数据。在服务端节点2写入副本数据data1(s)。
对于data2,客户端节点2将data2写入缓存。客户端节点2同步data2的写操作到服务端节点1,得到data2的主本数据data2(m)。由于data2与data2(m)在不同的处理单元,不需要写副本数据。
对于data3,客户端节点3将data3写入缓存。客户端节点3同步data3的写操作到服务端节点2,得到data3的主本数据data3(m),由于data3与data3(m)在不同的处理单元,不需要写副本数据。data4、data5、data6不再赘述。
以下对本申请实施例公开的数据存储方法的缩容场景进行说明。
若数据存储***中的任一处理单元发生故障或缩容,将发生故障或缩容的处理单元 作为待迁出处理单元,表明需将发生故障或缩容的处理单元中的数据进行迁移处理。在待迁出处理单元上运行的客户端节点称为待迁出客户端节点,在待迁出处理单元上运行的服务端节点称为待迁出服务端节点。待迁出客户端节点存储待迁移缓存数据,待迁出服务端节点存储待迁移主本数据与待迁移副本数据,数据存储方法还包括:
根据待迁出处理单元以外的其余处理单元的客户端节点和服务端节点,更新第一数据分布表得到第二数据分布表。
具体地,基于上述数据分布策略,数据存储***根据待迁出处理单元以外的其余处理单元的客户端节点和服务端节点,在第一数据分布表的基础上进行更新,得到第二数据分布表。或者,基于数据分布策略,数据存储***根据待迁出处理单元以外的其余处理单元的客户端节点和服务端节点,重新生成第二数据分布表。
图7是第二数据分布表。以缓存数据data1为例,data1的主本位置为运行于处理单元1的服务端节点1,data1的副本位置为运行于处理单元2的服务端节点2。
在本申请的一个实施例中,对于待迁移主本数据,数据存储方法还包括:
根据第二数据分布表确定待迁移主本数据的主本位置为待迁入服务端节点;将待迁移主本数据写入至待迁入服务端节点;确定存储了与待迁移主本数据一致的缓存数据的第二客户端节点;若运行第二客户端节点的处理单元与运行待迁入服务端节点的处理单元一致,根据从第二数据分布表获取的待迁移主本数据的副本位置,确定第二服务端节点;在第二服务端节点写入与待迁移主本数据一致的副本数据。
如图5的数据分布示意图(在图5的基础上),已知待迁出处理单元为处理单元3,处理单元3(待迁出处理单元)运行客户端节点3(待迁出客户端节点)和服务端节点3(待迁出服务端节点),客户端节点3(待迁出客户端节点)存储data3和data6(待迁移缓存数据),服务端节点3(待迁出服务端节点)存储的data5(m)和data6(m)。
对于data5(m),根据第二数据分布表确定对应的主本数据data5(m)的主本位置为服务端节点2(待迁入服务端节点);将data5(m)写入至服务端节点2;确定存储了与data5(m)一致的缓存数据data5的客户端节点2(第二客户端节点);若运行客户端节点2的处理单元与运行服务端节点2的处理单元一致,根据从第二数据分布表获取的data5(m)的副本位置为服务端节点1(第二服务端节点);在服务端节点1写入与data5(m)一致的副本数据data5(s)。
可选地,将待迁移主本数据写入至待迁入服务端节点包括:若待迁入服务端节点中存在与待迁移主本数据一致的副本数据,将待迁入服务端节点中与待迁移主本数据一致的副本数据转换为主本数据,作为待迁移主本数据。
对于data6(m),根据第二数据分布表确定对应的主本数据data6(m)的主本位置为服务端节点1(待迁入服务端节点);如图5所示,由于服务端节点1中已经存在与data6(m)一致的副本数据data6(s);将data6(s)转换为data6(m);处理单元3发生故障时,将待迁移缓存数据data6调整至客户端节点1,可以根据服务端节点1的副本数据data6(s),将副本数据data6(s)写入至客户端节点1,即将data6迁入至客户端节点1;若运行客户端节点1的处理单元与运行服务端节点1的处理单元一致,根据从第二数据分布表获取的data6(m)的副本位置为服务端节点2(第二服务端节点);在服务端节点2写入与data6(m)一致的副本数据data6(s)。
可选地,将待迁移主本数据写入至待迁入服务端节点包括:若运行待迁入服务端节点的处理单元中的任一客户端节点存在与待迁移主本数据一致的缓存数据,将与待迁移主本数据一致的缓存数据写入至待迁入服务端节点,作为待迁移主本数据。
对于data3,客户端节点2根据第二数据分布表确定data3(m)存储于服务端节点2;从服务端节点2恢复data3至客户端节点2,即根据主本数据data3(m),在客户端节点2写入data3;若运行客户端节点2的处理单元与运行服务端节点2的处理单元一致,根据从第二数据分布表获取的data3(m)的副本位置为服务端节点1(第二服务端节点);在服务端节点1写入与data3(m)一致的副本数据data3(s)。
在本申请的一个实施例中,对于待迁移副本数据,数据存储方法还包括:
根据第二数据分布表确定存储了与待迁移副本数据一致的缓存数据的第三客户端节点,确定存储了与待迁移副本数据一致的主本数据的第三服务端节点;若运行第三客户端节点的处理单元与运行第三服务端节点的处理单元一致,根据第二数据分布表,将待迁移副本数据写入与待迁移副本数据的副本位置对应的服务端节点。
在本申请的另一个实施例中,若运行第三客户端节点的处理单元与运行第三服务端节点的处理单元不一致,不将待迁移副本数据写入与待迁移副本数据的副本位置对应的服务端节点。
在本申请的一个实施例中,对于待迁移缓存数据,数据存储方法还包括:
从数据存储***中确定负载最小的客户端节点,将待迁移缓存数据对应的任务调整至数据存储***中负载最小的客户端节点;或从数据存储***中确定剩余存储资源最小的客户端节点,将待迁移缓存数据对应的任务调整至数据存储***中剩余存储资源最小的客户端节点。
图8是本申请实施例公开的数据存储方法的缩容场景的数据分布示意图。图8表示对处理单元3进行缩容的结果。其中,阴影部分的处理单元3表示出现了故障或缩容,与图5对比,图8的数据存储***缺少处理单元3。数据存储***将原处理单元3中的数据迁移或备份至处理单元1和处理单元2。
图9是本申请实施例公开的数据存储方法的具体缩容场景的流程图。
处理单元3发生故障后,服务端节点3的data5(m)和data6(m)丢失,客户端节点3的data3和data6丢失。客户端节点3的data3和data6对应的业务分别调整到客户端节点2和客户端节点1处理。其中,阴影部分的客户端节点3和服务端节点3表示出现了故障或缩容。
对于data5(m),根据第二数据分布表确定,data5(m)应该存储在服务端节点2,由于客户端节点2存储了缓存数据data5,可根据缓存数据data5从客户端节点2恢复data5至服务端节点2,即在服务端节点2写入与缓存数据data5一致的主本数据data5(m)。由于客户端节点2和服务端节点2在相同的处理单元,为了保证可靠性,需要生成副本数据。在服务端节点2写入主本数据data5(m)后,根据第二数据分布表,在服务端节点1写入副本数据data5(s)。
对于data6(m),按照调整后的数据分布策略(第二数据分布表),主本数据data6(m)应该存储在服务端节点1,由于服务端节点1中已经存在与主本数据data6(m)一致的副本数据data6(s),可将服务端节点1原有的副本数据data6(s)更改为主本数据 data6(m),即无需重复写入相同的数据。客户端节点1(根据调整后的数据分布策略)发现主本数据data6(m)在服务端节点1,可直接从服务端节点1恢复缓存数据data6,即客户端节点1将data6写入缓存。客户端节点1向服务端节点1发起data6的数据位置核查。由于data6与data6(m)在相同的处理单元1,为了保证可靠性,需要生成副本数据。服务端节点1根据数据分布策略(第二数据分布表),在服务端节点2生成相应的副本数据data6(s)。
对于缓存数据data3,客户端节点2(根据调整后的数据分布策略)发现相应的主本数据data3(m)在服务端节点2,然后从服务端节点2恢复数据。客户端节点2将data3写入缓存。客户端节点2向服务端节点2发起data3的数据位置核查。由于data3与data3(m)在相同的处理单元,为了保证可靠性,需要生成副本数据。服务端节点2根据数据分布策略(第二数据分布表),在服务端节点1生成相应的副本数据data3(s)。
以下对本申请实施例公开的数据存储方法的扩容场景进行说明。
若数据存储***中的处理单元发生扩容,将发生扩容的处理单元作为扩容处理单元,扩容处理单元运行第四客户端节点和第四服务端节点,数据存储方法还包括:
根据扩容处理单元,更新第一数据分布表得到更新的第三数据分布表;根据更新的第三数据分布表,确定需第四客户端节点存储的待写入缓存数据、需第四服务端节点存储的待写入主本数据;将待写入主本数据写入第四服务端节点,从数据存储***中的其他服务端节点中删除待写入主本数据;及将待写入缓存数据对应的任务调整至第四客户端节点。
具体地,基于上述数据分布策略,数据存储***根据扩容处理单元以及原有的处理单元的客户端节点和服务端节点,在第一数据分布表的基础上进行更新,得到更新的第三数据分布表。或者,基于数据分布策略,数据存储***根据扩容处理单元以及原有的处理单元的客户端节点和服务端节点,重新生成第三数据分布表。
图10是第三数据分布表。以缓存数据data1为例,data1的主本位置为运行于处理单元1的服务端节点1,data1的副本位置为运行于处理单元2的服务端节点2。
如图5的数据分布示意图(在图5的基础上),增加的扩容处理单元为处理单元4,处理单元4运行客户端节点4(第四客户端节点)和服务端节点4(第四服务端节点)。结合图10以及图11所示,由第三数据分布表可知,客户端节点4存储待写入缓存数据data6,服务端节点4存储待写入主本数据data4(m)。将data4(m)迁移到服务端节点4,从服务端节点2中删除data4(m);及将data6迁移至客户端节点4,或者将data6对应的任务调整至客户端节点4运行。
在本申请的一个实施例中,在将待写入主本数据写入第四服务端节点之后,数据存储方法还包括:将数据存储***中存储了与待写入主本数据一致的缓存数据的客户端节点确定为第五客户端节点,判断运行第五客户端节点的处理单元与运行第四服务端节点的处理单元是否一致;若运行第五客户端节点的处理单元与运行第四服务端节点的处理单元不一致,根据从更新的第三数据分布表获取的待写入主本数据的副本位置,确定第五服务端节点;从第五服务端节点删除与待写入主本数据一致的副本数据。
可选地,若运行第五客户端节点的处理单元与运行第四服务端节点的处理单元不一 致,不在数据存储***中生成待写入主本数据的副本数据。
如上例的主本数据data4(m),第四服务端节点为服务端节点4,运行于处理单元4。结合图5可知,上述的第五客户端节点为客户端节点1,运行于处理单元1。处理单元4与处理单元1不一致,因此,不在数据存储***中生成副本数据data4(s)。
在本申请的一个实施例中,数据存储方法还包括:根据更新的第三数据分布表,确定需第四服务端节点存储的待写入副本数据;根据更新的第三数据分布表确定存储了与待写入副本数据一致的缓存数据的第六客户端节点,确定存储了与待写入副本数据一致的主本数据的第六服务端节点;若运行第六客户端节点的处理单元与运行第六服务端节点的处理单元一致,根据更新的第三数据分布表,将待写入副本数据写入第四服务端节点。
可选地,若运行第六客户端节点的处理单元与运行第六服务端节点的处理单元不一致,第四服务端节点中存在待写入副本数据,从第四服务端节点删除待写入副本数据。
在本申请的另一个实施例中,若运行第六客户端节点的处理单元与运行第六服务端节点的处理单元不一致,不写入待写入副本数据至第四服务端节点。
如上例,对于待写入副本数据data6(s),根据更新的第三数据分布表,确定需服务端节点4(第四服务端节点)存储的data6(s);根据更新的第三数据分布表确定存储了与data6的客户端节点4(第六客户端节点),确定存储了与data6(m)的服务端节点3(第六服务端节点);若运行客户端节点4的处理单元与运行服务端节点3的处理单元不一致,不写入data6(s)至服务端节点4。
在本申请的一个实施例中,在将待写入缓存数据对应的任务调整至第四客户端节点之后,数据存储方法还包括:将数据存储***中存储了与待写入缓存数据一致的主本数据的服务端节点确定为第七服务端节点,判断运行第四客户端节点的处理单元与运行第七服务端节点的处理单元是否一致;若运行第四客户端节点的处理单元与运行第七服务端节点的处理单元不一致,不在数据存储***中生成待写入缓存数据的副本数据。
如上例,在将data6对应的任务调整至客户端节点4(第四客户端节点)之后(将缓存数据data6写入客户端节点4),数据存储***中存储副本数据data6(m)的第七服务端节点为服务端节点3,运行客户端节点4的处理单元与运行服务端节点3的处理单元不一致,不在数据存储***中生成待写入副本数据data6(s)。
图11是本申请实施例公开的数据存储方法的扩容场景的数据分布示意图。图11表示对处理单元3进行扩容的结果。其中,处理单元4出现扩容,与图5对比,图11的数据存储***增加处理单元3。数据存储***将除处理单元4外的处理单元中的数据转移至处理单元4。
图12是本申请实施例公开的数据存储方法的具体扩容场景的流程图。
对于主本数据data4(m),数据存储***扩容处理单元4后,按照调整后的数据分布策略(更新的第三数据分布表),data4(m)从服务端节点2迁移到服务端节点4。data4(m)迁移完成后,服务端节点2删除data4(m)。客户端节点1向服务端节点4发起data4的数据位置核查。由于data4与data4(m)在不同的处理单元,不需要生成副本数据。
对于缓存数据data6,按照调整后的数据分布策略(更新的第三数据分布表),在服 务端节点4生成副本数据data6(s)。服务端节点1删除原副本数据data6(s)。扩容处理单元4后,客户端节点3的缓存数据data6对应的业务被调整到客户端节点4处理。客户端节点4发现主本数据data6(m)在服务端节点3(使用调整后的数据分布策略),然后从服务端节点3恢复数据至客户端节点4,即根据服务端节点3的主本数据data6(m)写入相应的缓存数据至客户端节点4。客户端节点4将data6写入缓存。客户端节点4向服务端节点3发起data6的数据位置核查。由于data6与data6(m)在不同的处理单元,不需要生成副本数据。服务端节点4删除data6(s)。
以下对本申请实施例公开的数据存储方法的修改场景进行说明。
数据存储方法应用于数据存储***,数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点,其中,第一客户端节点存储缓存数据,第一服务端节点存储与缓存数据一致的主本数据。数据存储方法具体包括:
判断运行第一客户端节点的处理单元与运行第一服务端节点的处理单元是否一致;若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元一致,且数据存储***中不存在与主本数据一致的副本数据,在另一个处理单元的任一服务端节点写入与主本数据一致的副本数据;若运行第一客户端节点的处理单元与运行第一服务端节点的处理单元不一致,删除数据存储***中的与主本数据一致的副本数据。
对于副本数据不满足上述数据分布策略的数据存储***,可以通过本实施例对数据存储***存储的副本数据进行写入、删除等修改。
在本申请的一个实施例中,若客户端节点不能缓存数据,可以将客户端节点所在处理单元上的一个服务端节点作为本地数据访问节点,即新的客户端节点。
以下对本申请实施例公开的数据存储方法节省的存储资源进行说明。
若数据存储***包括N个处理单元,每个处理单元部署一个服务端节点,每个处理单元部署固定数量的客户端节点。客户端节点的数据均匀的备份在各个服务端节点上,每个服务端节点存储1/N的主本数据,与客户端节点在相同处理单元的服务端节点的主本数据才需要副本数据,本申请实施例的数据存储***需要存储1+(1/N)份数据。通常情况下,数据存储***需要存储2份数据,因此,本申请实施例的数据存储***节省1-1/N份数据,节省比例为(N-1)/2N。N越大,节省的存储资源越多,节省比例更接近50%。
图13是本申请实施例公开的一种电子设备(例如图1中的站点)的结构示意图。如图13所示,电子设备130可以包括:射频(Radio Frequency,RF)电路1301、存储器1302、输入单元1303、显示单元1304、传感器1305、音频电路1306、Wi-Fi模块1307、处理器1308以及电源1309等部件。本领域技术人员可以理解,图13中示出的结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
RF电路1301可用于收发信息或在通话过程中,对信号进行接收和发送,特别地,接收基站的下行信息后,转给处理器1308进行处理;另外,将涉及上行的数据发送给基站。通常,RF电路1301包括,但不限于:天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。
存储器1302可用于存储软件程序以及模块,处理器1308通过运行存储在存储器1302 中的软件程序以及模块,从而执行电子设备的各种功能应用以及数据处理。存储器1302可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作***、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据电子设备的使用所创建的数据(比如音频数据等)等。此外,存储器1302可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元1303可用于接收输入的数字或字符信息,以及产生与电子设备的用户设置以及功能控制有关的键信号输入。具体地,输入单元1303可包括触控面板13031以及其他输入设备13032。触控面板13031,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触控笔等任何适合的物体或附件在触控面板13031上或在触控面板13031附近的操作),并根据预先设定的程序驱动相应的连接装置。可选地,触控面板13031可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器1308,并接收处理器1308发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板13031。除了触控面板13031,输入单元1303还可以包括其他输入设备13032。具体地,其他输入设备13032可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元1304可用于显示由用户输入的信息或提供给用户的信息以及电子设备的各种菜单。显示单元1304可包括显示面板13041,可选地,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板13041。进一步地,触控面板13031可覆盖显示面板13041,当触控面板13031检测到在其上或附近的触摸操作后,传送给处理器1308以确定触摸事件的类型,随后处理器1308根据触摸事件的类型在显示面板13041上提供相应的视觉输出。虽然在图13中,触控面板13031与显示面板13041是作为两个独立的部件来实现电子设备的输入和输出功能,但是在某些实施例中,可以将触控面板13031与显示面板13041集成而实现电子设备的输入和输出功能。
电子设备还可包括至少一种传感器1305,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板13041的亮度,接近传感器可在电子设备移动到耳边时,关闭显示面板13041和/或背光。作为运动传感器的一种,加速计传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别电子设备姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;此外,电子设备还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。
音频电路1306、扬声器13061,传声器13062可提供用户与电子设备之间的音频接口。音频电路1306可将接收到的音频数据转换后的电信号,传输到扬声器13061,由扬声器13061转换为声音信号输出;另一方面,传声器13062将收集的声音信号转换为电信号,由音频电路1306接收后转换为音频数据,再将音频数据输出处理器1308处理后, 经RF电路1301发送给另一电子设备,或者将音频数据输出至存储器1302以便进一步处理。
Wi-Fi属于短距离无线传输技术,电子设备130通过Wi-Fi模块1307可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图13示出了Wi-Fi模块1307,但是可以理解的是,其并不属于电子设备的必需构成,完全可以根据需要、在不改变发明本质的范围内进行省略。
处理器1308是电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器1302内的软件程序和/或模块,以及调用存储在存储器1302内的数据,执行电子设备的各种功能和处理数据,从而对电子设备进行整体监控。可选地,处理器1308可包括一个或多个处理单元;优选的,处理器1308可集成应用处理器和调制解调器,其中,应用处理器主要处理操作***、用户界面和应用程序等,调制解调器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器1308中。
电子设备还包括给各个部件供电的电源1309(比如电池),可选地,电源可以通过电源管理***与处理器1308逻辑相连,从而通过电源管理***实现管理充电、放电、以及功耗管理等功能。
尽管未示出,电子设备还可以包括摄像头、蓝牙模块等,在此不再赘述。
图13中描述的电子设备可以用于实施本申请介绍的方法实施例中的部分或全部流程,可参见前述实施例中的相关阐述,这里不再赘述。
本实施例还提供一种计算机存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得电子设备执行上述相关方法步骤实现上述实施例中的内存回收方法。
本实施例还提供了一种计算机程序产品,当该计算机程序产品在电子设备上运行时,使得电子设备执行上述相关步骤,以实现上述实施例中的内存回收方法。
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中的内存回收方法。
其中,本实施例提供的电子设备、计算机存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,该模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点, 所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
该作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (20)

  1. 一种数据存储方法,应用于数据存储***,其特征在于,所述数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点,所述数据存储方法包括:
    获取缓存数据和第一数据分布表,其中,所述第一数据分布表包括数据的主本位置和副本位置;
    在第一客户端节点写入所述缓存数据;
    根据从所述第一数据分布表获取的所述缓存数据的主本位置,确定第一服务端节点;
    在所述第一服务端节点写入与所述缓存数据一致的主本数据;
    若运行所述第一客户端节点的处理单元与运行所述第一服务端节点的处理单元一致,根据所述第一数据分布表确定所述缓存数据的副本位置,将与所述主本数据一致的副本数据写入至与确定的副本位置对应的服务端节点。
  2. 如权利要求1所述的数据存储方法,其特征在于,数据分布表包括所述第一数据分布表,所述数据分布表对应的数据分布策略包括:
    所述数据存储***中任意一份数据的主本数据和副本数据分布在不同的处理单元;和/或
    各个处理单元的主本数据数量和副本数据数量均衡;和
    任意一份数据存在对应的主本位置和副本位置。
  3. 如权利要求1所述的数据存储方法,其特征在于,若运行所述第一客户端节点的处理单元与运行所述第一服务端节点的处理单元不一致,不在所述数据存储***中写入所述副本数据。
  4. 如权利要求1所述的数据存储方法,其特征在于,若所述数据存储***中的任一处理单元发生故障或缩容,将发生故障或缩容的处理单元作为待迁出处理单元,所述待迁出处理单元运行待迁出客户端节点和待迁出服务端节点,所述待迁出客户端节点存储待迁移缓存数据,所述待迁出服务端节点存储待迁移主本数据与待迁移副本数据,所述数据存储方法还包括:
    根据所述待迁出处理单元以外的其余处理单元的客户端节点和服务端节点,更新所述第一数据分布表,得到第二数据分布表。
  5. 如权利要求4所述的数据存储方法,其特征在于,对于所述待迁移主本数据,所述数据存储方法还包括:
    根据所述第二数据分布表确定所述待迁移主本数据的主本位置为待迁入服务端节点;
    将所述待迁移主本数据写入至所述待迁入服务端节点;
    确定存储了与所述待迁移主本数据一致的缓存数据的第二客户端节点;
    若运行所述第二客户端节点的处理单元与运行所述待迁入服务端节点的处理单元一致,根据从所述第二数据分布表获取的所述待迁移主本数据的副本位置,确定第二服务端节点;
    在所述第二服务端节点写入与所述待迁移主本数据一致的副本数据。
  6. 如权利要求5所述的数据存储方法,其特征在于,若所述待迁入服务端节点中存在与所述待迁移主本数据一致的副本数据,将所述待迁入服务端节点中与所述待迁移主本数据一致的副本数据转换为主本数据,作为待迁移主本数据。
  7. 如权利要求5所述的数据存储方法,其特征在于,所述将所述待迁移主本数据写入至所述待迁入服务端节点包括:
    若运行所述待迁入服务端节点的处理单元中的任一客户端节点存在与所述待迁移主本数据一致的缓存数据,将与所述待迁移主本数据一致的缓存数据写入至所述待迁入服务端节点,作为待迁移主本数据。
  8. 如权利要求5所述的数据存储方法,其特征在于,对于所述待迁移副本数据,所述数据存储方法还包括:
    根据所述第二数据分布表确定存储了与所述待迁移副本数据一致的缓存数据的第三客户端节点,确定存储了与所述待迁移副本数据一致的主本数据的第三服务端节点;
    若运行所述第三客户端节点的处理单元与运行所述第三服务端节点的处理单元一致,根据所述第二数据分布表,将所述待迁移副本数据写入与所述待迁移副本数据的副本位置对应的服务端节点。
  9. 如权利要求8所述的数据存储方法,其特征在于,若运行所述第三客户端节点的处理单元与运行所述第三服务端节点的处理单元不一致,不将所述待迁移副本数据写入与所述待迁移副本数据的副本位置对应的服务端节点。
  10. 如权利要求5所述的数据存储方法,其特征在于,对于所述待迁移缓存数据,所述数据存储方法还包括:
    从所述数据存储***中确定负载最小的客户端节点,将所述待迁移缓存数据对应的任务调整至所述数据存储***中负载最小的客户端节点;
    或从所述数据存储***中确定剩余存储资源最小的客户端节点,将所述待迁移缓存数据对应的任务调整至所述数据存储***中剩余存储资源最小的客户端节点。
  11. 如权利要求1所述的数据存储方法,其特征在于,若所述数据存储***中的处理单元发生扩容,将发生扩容的处理单元作为扩容处理单元,所述扩容处理单元运行第四客户端节点和第四服务端节点,所述数据存储方法还包括:
    根据所述扩容处理单元,更新所述第一数据分布表,得到更新的第三数据分布表;
    根据所述更新的第三数据分布表,确定需所述第四客户端节点存储的待写入缓存数据、需所述第四服务端节点存储的待写入主本数据;
    将所述待写入主本数据写入所述第四服务端节点,从所述数据存储***中的其他服务端节点中删除所述待写入主本数据;
    将所述待写入缓存数据对应的任务调整至所述第四客户端节点。
  12. 如权利要求11所述的数据存储方法,其特征在于,在所述将所述待写入主本数据写入所述第四服务端节点之后,所述数据存储方法还包括:
    将所述数据存储***中存储了与所述待写入主本数据一致的缓存数据的客户端节点确定为第五客户端节点,判断运行所述第五客户端节点的处理单元与运行所述第四服务端节点的处理单元是否一致;
    若运行所述第五客户端节点的处理单元与运行所述第四服务端节点的处理单元不一致, 根据从所述更新的第三数据分布表获取的所述待写入主本数据的副本位置,确定第五服务端节点;
    从所述第五服务端节点删除与所述待写入主本数据一致的副本数据。
  13. 如权利要求12所述的数据存储方法,其特征在于,若运行所述第五客户端节点的处理单元与运行所述第四服务端节点的处理单元不一致,不在所述数据存储***中生成所述待写入主本数据的副本数据。
  14. 如权利要求11所述的数据存储方法,其特征在于,所述数据存储方法还包括:
    根据所述更新的第三数据分布表,确定需所述第四服务端节点存储的待写入副本数据;
    根据所述更新的第三数据分布表确定存储了与所述待写入副本数据一致的缓存数据的第六客户端节点,确定存储了与所述待写入副本数据一致的主本数据的第六服务端节点;
    若运行所述第六客户端节点的处理单元与运行所述第六服务端节点的处理单元一致,根据所述更新的第三数据分布表,将所述待写入副本数据写入所述第四服务端节点。
  15. 如权利要求14所述的数据存储方法,其特征在于,若运行所述第六客户端节点的处理单元与运行所述第六服务端节点的处理单元不一致,所述第四服务端节点中存在所述待写入副本数据,从所述第四服务端节点删除所述待写入副本数据。
  16. 如权利要求14所述的数据存储方法,其特征在于,若运行所述第六客户端节点的处理单元与运行所述第六服务端节点的处理单元不一致,不写入所述待写入副本数据至所述第四服务端节点。
  17. 如权利要求11所述的数据存储方法,其特征在于,在所述将所述待写入缓存数据对应的任务调整至所述第四客户端节点之后,所述数据存储方法还包括:
    将所述数据存储***中存储了与所述待写入缓存数据一致的主本数据的服务端节点确定为第七服务端节点,判断运行所述第四客户端节点的处理单元与运行所述第七服务端节点的处理单元是否一致;
    若运行所述第四客户端节点的处理单元与运行所述第七服务端节点的处理单元不一致,不在所述数据存储***中生成所述待写入缓存数据的副本数据。
  18. 一种数据存储方法,应用于数据存储***,其特征在于,所述数据存储***包括多个处理单元,每个处理单元运行至少一个客户端节点和至少一个服务端节点,其中,第一客户端节点存储缓存数据,第一服务端节点存储与所述缓存数据一致的主本数据,所述数据存储方法包括:
    判断运行所述第一客户端节点的处理单元与运行所述第一服务端节点的处理单元是否一致;
    若运行所述第一客户端节点的处理单元与运行所述第一服务端节点的处理单元一致,且所述数据存储***中不存在与所述主本数据一致的副本数据,在另一个处理单元的任一服务端节点写入与所述主本数据一致的副本数据;
    若运行所述第一客户端节点的处理单元与运行所述第一服务端节点的处理单元不一致,删除所述数据存储***中的与所述主本数据一致的副本数据。
  19. 一种计算机可读存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1至18中任一项所述的数据存储方法。
  20. 一种电子设备,其特征在于,所述电子设备包括处理器和存储器,所述处理器用 于调用所述存储器中的指令,使得所述电子设备执行如权利要求1至18中任一项所述的数据存储方法。
PCT/CN2021/080608 2021-03-12 2021-03-12 数据存储方法及相关设备 WO2022188184A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2021/080608 WO2022188184A1 (zh) 2021-03-12 2021-03-12 数据存储方法及相关设备
CN202180004728.XA CN115349116A (zh) 2021-03-12 2021-03-12 数据存储方法及相关设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/080608 WO2022188184A1 (zh) 2021-03-12 2021-03-12 数据存储方法及相关设备

Publications (1)

Publication Number Publication Date
WO2022188184A1 true WO2022188184A1 (zh) 2022-09-15

Family

ID=83226230

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/080608 WO2022188184A1 (zh) 2021-03-12 2021-03-12 数据存储方法及相关设备

Country Status (2)

Country Link
CN (1) CN115349116A (zh)
WO (1) WO2022188184A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101808127A (zh) * 2010-03-15 2010-08-18 成都市华为赛门铁克科技有限公司 数据备份方法、***和服务器
CN103513938A (zh) * 2013-09-16 2014-01-15 华为技术有限公司 一种独立磁盘冗余阵列raid***扩容方法及装置
CN107657027A (zh) * 2017-09-27 2018-02-02 北京小米移动软件有限公司 数据存储方法及装置
CN108023967A (zh) * 2017-12-20 2018-05-11 联想(北京)有限公司 一种数据平衡方法、装置及分布式存储***中的管理设备
CN112000426A (zh) * 2020-07-24 2020-11-27 新华三大数据技术有限公司 一种数据处理方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101808127A (zh) * 2010-03-15 2010-08-18 成都市华为赛门铁克科技有限公司 数据备份方法、***和服务器
CN103513938A (zh) * 2013-09-16 2014-01-15 华为技术有限公司 一种独立磁盘冗余阵列raid***扩容方法及装置
CN107657027A (zh) * 2017-09-27 2018-02-02 北京小米移动软件有限公司 数据存储方法及装置
CN108023967A (zh) * 2017-12-20 2018-05-11 联想(北京)有限公司 一种数据平衡方法、装置及分布式存储***中的管理设备
CN112000426A (zh) * 2020-07-24 2020-11-27 新华三大数据技术有限公司 一种数据处理方法及装置

Also Published As

Publication number Publication date
CN115349116A (zh) 2022-11-15

Similar Documents

Publication Publication Date Title
CN112035410B (zh) 日志存储方法、装置、节点设备及存储介质
US11388220B2 (en) Image distribution method and apparatus, and image obtaining method and apparatus
EP3531290B1 (en) Data backup method, apparatus, electronic device, storage medium, and system
CN107357704B (zh) 一种应用程序检测方法、终端及计算机可读存储介质
US20140115021A1 (en) Method and Terminal for Accessing a File of a Terminal
CN109101363B (zh) 基于Android***的异常恢复方法、装置、智能设备及存储介质
CN109885573B (zh) 一种数据存储***的维护方法、装置和移动终端
CN112035298A (zh) 一种数据备份方法、装置、电子设备及存储介质
US10922193B2 (en) Data backup method, storage medium, and terminal
WO2021098360A1 (zh) 应用程序控制方法、电子设备及服务器
EP3843356A1 (en) Management method for model files and terminal device
WO2022042233A1 (zh) 应用界面迁移***、方法及相关设备
WO2024113568A1 (zh) 固态硬盘的数据迁移方法、装置、电子设备及存储介质
WO2022188184A1 (zh) 数据存储方法及相关设备
CN115657943A (zh) 存储***精简卷的数据处理方法、装置、设备及存储介质
CN105653394A (zh) 数据备份的方法和装置
CN111858147A (zh) 容灾处理方法、装置、移动终端及存储介质
CN115509770A (zh) 微服务调用方法、装置、电子设备及可读存储介质
CN115756879A (zh) 一种内存共享方法和相关装置
CN115048463B (zh) 数据迁移方法、***及存储介质
CN110659329A (zh) 一种数据处理方法、装置及电子设备
CN113032361B (zh) 一种数据库配置的变更方法、装置、电子设备及存储介质
US20230394008A1 (en) Distributed file access method and related device
CN115883352B (zh) 服务节点创建方法、相关设备及存储介质
CN115658639A (zh) 数据处理方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21929657

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21929657

Country of ref document: EP

Kind code of ref document: A1