WO2015109483A1 - Data storage method and device - Google Patents

Data storage method and device Download PDF

Info

Publication number
WO2015109483A1
WO2015109483A1 PCT/CN2014/071224 CN2014071224W WO2015109483A1 WO 2015109483 A1 WO2015109483 A1 WO 2015109483A1 CN 2014071224 W CN2014071224 W CN 2014071224W WO 2015109483 A1 WO2015109483 A1 WO 2015109483A1
Authority
WO
WIPO (PCT)
Prior art keywords
server
data
storage space
remaining
servers
Prior art date
Application number
PCT/CN2014/071224
Other languages
French (fr)
Chinese (zh)
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/CN2014/071224 priority Critical patent/WO2015109483A1/en
Priority to CN201480000338.5A priority patent/CN104205780B/en
Publication of WO2015109483A1 publication Critical patent/WO2015109483A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0611Improving I/O performance in relation to response time
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems

Definitions

  • the present invention relates to the field of storage technologies, and in particular, to a method and apparatus for storing data. Background technique
  • a distributed storage system consists of multiple servers. Each server can have one or more virtual machines installed. Each server corresponds to RAID (Redundant Arrays of Independent Disks).
  • RAID Redundant Arrays of Independent Disks
  • the physical storage space is generally allocated for the data generated by the application/virtual machine installed on the server according to the principle of "load balancing", that is, the server is installed according to the principle of "balanced used storage space of each server in HDFS".
  • the data generated by the application/virtual machine allocates physical storage space; wherein, the physical storage space is the storage space of the disk array corresponding to a certain server and/or the storage space of the server itself.
  • the distributed storage system is HDFS ( Hadoop Distributed File System (Distributed File System) is an example:
  • HDFS Hadoop Distributed File System
  • the server first blocks the data. Ground, at most 1 block occupies less than 64M of storage space, the remaining blocks
  • the storage space is equal to 64M; secondly, according to the principle of "balanced used storage space of each server in HDFS", each block is mapped to the storage space of one or more servers in HDFS.
  • the storage space generated by the application/virtual machine is equal to or less than 64M
  • the data is mapped to the HDFS server with the smallest storage space according to the principle of "balanced used storage space of each server in HDFS".
  • Embodiments of the present invention provide a method and apparatus for storing data, which are used to reduce delay in reading data, thereby improving system performance.
  • the embodiment of the present invention adopts the following technical solutions:
  • a method for storing data is provided, which is applied to a distributed storage system, where the distributed storage system includes a first server and other servers, The method includes: determining first data generated by the first server; determining a size relationship between a remaining storage space of the first server and a storage space occupied by the first data;
  • the first server includes a virtual machine
  • the first data is data generated by the virtual machine
  • the other server includes a second server
  • the method also includes:
  • the first indication message is used to indicate that the second server stores the first data in a remaining storage space of the second server; in addition to the first data corresponding to the virtual machine The virtual machine and the other data are migrated to the second server when the storage space occupied by the other data is less than or equal to the remaining storage space of the second server.
  • the other server includes a second server, where the method further includes: if the remaining storage space of the first server is smaller than the storage occupied by the first data a first indication message that includes the first data is sent to the second server, where the first indication message is used to indicate that the second server stores the first data in the second server Remaining storage space; updating remaining storage space of the first server; sending to the second server when the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data a second indication message, the second indication message is used to instruct the second server to migrate the first data to the first server, and receive the first data sent by the second server; The first data is stored in the remaining storage space after the first server is updated.
  • the other server further includes a third server, where The method also includes:
  • a second aspect provides a method for storing data, which is applied to a distributed storage system, where the distributed storage system includes a first server and other servers, and the method includes: determining first data generated by the first server; The storage space occupied by the first data is greater than the maximum value of the minimum storage unit of the distributed storage system; determining the size relationship between the remaining storage space of the first server and the storage space occupied by the first data;
  • a third aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes other servers, where the server includes: a determining module, configured to determine first data generated by the server; a storage module, configured to determine, in the determining module, that a remaining storage space of the server is greater than or equal to the first The first data is stored in the remaining storage space of the server when the storage space occupied by the data is, and the used storage space of the server is greater than the minimum used storage space of the other server.
  • the server includes a virtual machine
  • the first data is data generated by the virtual machine
  • the other server includes a second server
  • the server further The sending module is configured to: when the determining module determines that the remaining storage space of the server is smaller than the storage space occupied by the first data, send a first indication that includes the first data to the second server a message, the first indication message is used to indicate the
  • the second server stores the first data in a remaining storage space of the second server, and a migration module, configured to occupy a storage space of data other than the first data corresponding to the virtual machine When less than or equal to the remaining storage space of the second server, the virtual machine and the other data are migrated to the second server.
  • the other server includes a second server
  • the server further includes: a sending module, configured to determine, in the determining module, that the remaining storage space of the server is smaller than Sending a first indication message including the first data to the second server when the storage space occupied by the first data is used; the first indication message is used to indicate that the second server is to use the first data Storing in a remaining storage space of the second server; an update module, configured to update a remaining storage space of the server; the sending module is further configured to: when the server updates, the remaining storage space is greater than or equal to the Sending a second indication message to the second server when the storage space is occupied by the first data; the second indication message is used to instruct the second server to migrate the first data to the server; And receiving the first data sent by the second server; the storage module is further configured to: store the first data in The remaining storage space of said server update.
  • the other server further includes a third
  • the sending module is further configured to: send, to the third server, a third indication message that includes a copy of the first data, where the third indication message is used to indicate the third service
  • the server stores a copy of the first data in a remaining storage space of the third server.
  • a fourth aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes other servers, where the server includes: a processor, configured to determine first data generated by the server; Determining the size relationship between the remaining storage space of the server and the storage space occupied by the first data;
  • a memory configured to determine, by the processor, that a remaining storage space of the server is greater than or equal to a storage space occupied by the first data, and a used storage space of the server is greater than a minimum used storage of the other server In the space, the first data is stored in the remaining storage space of the server under the control of the processor.
  • the server includes a virtual machine
  • the first data is data generated by the virtual machine
  • the other server includes a second server
  • the server further The method includes: a transmitter, configured to send, when the processor determines that a remaining storage space of the server is less than a storage space occupied by the first data, send a first indication that includes the first data to the second server
  • the first indication message is used to indicate that the second server stores the first data in a remaining storage space of the second server
  • the processor is further configured to: correspond to the virtual machine The virtual machine and the other data are migrated to the second server when the storage space occupied by the data other than the first data is less than or equal to the remaining storage space of the second server.
  • the other server includes a second server
  • the processor is further configured to: update a remaining storage space of the server
  • the transmitter is further configured to: when the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, send a second indication message to the second server;
  • the message is used to indicate that the second server migrates the first data to the server;
  • the server further includes: a receiver, configured to receive the first data sent by the second server; And storing, in the control of the processor, the first data in a remaining storage space after the server is updated.
  • the other server further includes a third The server is further configured to: send, to the third server, a third indication message that includes a copy of the first data, where the third indication message is used to indicate that the third server is to be the first A copy of the data is stored in the remaining storage space of the third server.
  • a fifth aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes another server, where the server includes: a determining module, configured to determine first data generated by the server; The storage space occupied by the data is larger than the maximum storage unit of the distributed storage system; the determining module is configured to determine a size relationship between the remaining storage space of the server and the storage space occupied by the first data; a storage module, configured to determine, in the determining module, that a remaining storage space of the server is greater than or equal to a storage space occupied by the first data, and that the used storage space of the server is less than or equal to a minimum of the other servers Used storage space And storing the first data in a remaining storage space of the server.
  • a sixth aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes other servers, where the server includes: a processor, configured to determine first data generated by the server; a relationship between a remaining storage space of the server and a storage space occupied by the first data; a storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system; When the processor determines that the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, and the used storage space of the server is less than or equal to the minimum used storage space of the other server; And storing the first data in a remaining storage space of the server under the control of the processor.
  • the foregoing technical solution is applied to a distributed storage system.
  • a server determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, the data is preferentially stored in the remaining storage space of the server.
  • the server can directly read the data from the local without having to read the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving system performance.
  • the problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art.
  • FIG. 1 is a flowchart of a method for storing data according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of a method for storing data according to Embodiment 2 of the present invention
  • FIG. 4 is a flowchart of a method for storing data according to Embodiment 2 of the present invention
  • FIG. 1 is a flowchart of a method for storing data according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of a method for storing data according to Embodiment 2 of the present invention
  • FIG. 4 is a flowchart of a method for storing data according to Embodiment 2 of the present invention
  • FIG. 1 is a flowchart of a method for storing data according to Embodiment 1 of the present invention
  • FIG. 2 is a flowchart of a method for storing data according to Embodiment 2 of the present invention
  • FIG. 4 is a flowchart of a method for
  • FIG. 5 is a schematic structural diagram of a server according to Embodiment 3 of the present invention
  • FIG. 7 is a schematic structural diagram of a server according to Embodiment 4 of the present invention
  • FIG. 8 is a schematic structural diagram of another server according to Embodiment 4 of the present invention
  • FIG. 9 is a schematic structural diagram of a server according to Embodiment 5 of the present invention
  • FIG. 10 is a schematic structural diagram of a server according to Embodiment 6 of the present invention.
  • a method for storing data provided in this embodiment is applied to a distributed storage system, where the distributed storage system includes a first server and other services.
  • the method includes:
  • the "first server” may be any server in the distributed storage system; the “other server” refers to all servers except the first server in the distributed storage system.
  • First Data can be any data generated by the first server.
  • the execution subject of this embodiment may be "first server”.
  • a server in a distributed storage system can install one or more virtual machines or not. When a virtual machine is installed on a server, the server shares the disk array corresponding to the server with the virtual machine installed on it.
  • the first data generated by the server may be: an application-generated data installed on the server (physical machine); or a virtual machine installed on the server Machine generated data.
  • the server when the data is data generated by an application installed on the server, the server records the correspondence between the data and the server; when the data is data generated by a virtual machine installed on the server, The server records the correspondence between the data and the virtual machine. Specifically, the corresponding relationship can be recorded by generating a data routing table. In general, each data store in a distributed storage system can share the data routing table. In this paper, when the server where the application/virtual machine that generates a data is located and the server corresponding to the storage space where the data is stored is the same server, it is considered that the localization of the data is realized.
  • the “remaining storage space of the server” refers to the available storage space in the storage space corresponding to the server and/or the storage space of the server itself.
  • the remaining storage space may have a size of 0 or may include one or more storage units.
  • the remaining storage space of each server may be deleted due to deletion of stored data.
  • the data is updated by changing the size of the disk array corresponding to the server.
  • the server may include, but is not limited to, obtaining the remaining storage space in the following manners: periodically acquiring the remaining storage space, periodically obtaining the remaining storage space, acquiring the remaining storage space when generating a data, and the like. This embodiment does not limit the size of the "storage space occupied by the first data".
  • the method may further include: acquiring a storage space occupied by the first data, and remaining storage space of the first server.
  • the step 103 may specifically include: the first server determines that the remaining storage space is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is greater than that of the other server.
  • the storage space is the smallest, the first data is allocated a storage address, and the first data is stored in a storage unit corresponding to the storage address; the storage address is a remaining storage space of the first server. The storage address corresponding to one or more of the storage units.
  • the "minimum used storage space of other servers" is explained by a specific example: Assume that other servers are composed of server 1, server 2, and server 3, and the used storage spaces of the three servers are respectively: A, B, C, and A > B > C; then, the minimum used storage space of other servers is C.
  • step 103 will be described below from the perspective of the relationship between the storage space occupied by the first data and the maximum value of the minimum storage unit of the distributed storage system.
  • step 103 may include the following scenario 1 and scenario 2: scenario 1: the storage space occupied by the first data is larger than the maximum storage unit of the distributed storage system, and the used storage space of the first server is larger than other servers. The smallest used storage space.
  • Scenario 2 The storage space occupied by the first data is less than or equal to the maximum storage unit of the distributed storage system, and the used storage space of the first server is larger than the minimum used storage space of other servers.
  • the first server needs to block the first data, and stores each block in multiple servers of the distributed storage system according to the principle of “load balancing”. In the remaining storage space.
  • scenario 2 in the prior art solution, the first server needs to store the first data in the largest remaining storage space in the other servers. It should be noted that, in actual implementation, the following scenario A and scenario B may occur: scenario A: The storage space occupied by the first data is greater than the maximum storage unit of the distributed storage system, and the first server is used.
  • the storage space is less than or equal to the minimum used storage space of other servers.
  • Scenario B The storage space occupied by the first data is less than or equal to the maximum storage unit of the distributed storage system, and the used storage space of the first server is less than or equal to the minimum used storage space of other servers.
  • the implementation method for the scenario A is provided herein, which is correspondingly described in the following embodiment 2.
  • the implementation method is the same as that of the prior art solution.
  • the first server stores the first data in its remaining storage space.
  • the method for storing data provided by the embodiment of the present invention does not need to limit the size of the storage space occupied by the first data, and does not need to be limited.
  • Used storage space of a server The size relationship with the used storage space of other servers. Specific implementations include, but are not limited to, the methods shown in Embodiments 1 and 2 below.
  • the first server includes a virtual machine
  • the first data is data generated by the virtual machine
  • the other server includes a second server.
  • the method further includes the following steps.
  • a 1 -A2 Step A 1 : sending a first indication message including the first data to the second server, if the remaining storage space of the first server is smaller than the storage space occupied by the first data The first indication message is used to instruct the second server to store the first data in a remaining storage space of the second server.
  • Step A2 when the storage space occupied by the data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage space of the second server, the virtual machine and the other data are used. Migrate to the second server.
  • the second server may be any other than the first data in the distributed storage system except that the remaining storage space is greater than or equal to the first data other than the virtual machine.
  • the storage space "conditions for any server.
  • Step A 1 may include: A ll) if the first server determines that the remaining storage space is smaller than the storage space occupied by the first data, determining, in addition to the first data, corresponding to the virtual machine The size of the storage space occupied by the other data; A 12) the server having the remaining storage space greater than or equal to the storage space as the second server; A 13) transmitting the first data including the first data to the second server Indicate the message.
  • step A2 may be performed immediately after step A1; or may be performed when the virtual machine needs to read the first data.
  • the former can be described as: localizing the first data when the first data is written to the second server
  • the latter can be described as: localization of the first data is implemented when the virtual machine needs to read the first data.
  • the virtual machine after the first server migrates the virtual machine to the second server, the virtual machine becomes a virtual machine installed on the second server, and the virtual machine does not exist on the first server. machine. After the "first server will migrate with the other data to the second server", the other data is stored in the storage space of the second server. Additionally, this alternative embodiment may be referred to as localizing the first data by way of virtual machine migration.
  • the other server includes a second server; the method further includes the following steps B 1 -B4 : Step B 1 : if the remaining storage space of the first server is smaller than the first a storage space occupied by the data, sending a first indication message including the first data to the second server; the first indication message is used to indicate that the second server stores the first data in The remaining storage space of the second server.
  • Step B2 Update the remaining storage space of the first server.
  • Step B3 Send a second indication message to the second server when the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, where the second indication message is used. Instructing the second server to migrate the first data to the first server.
  • Step B4 receiving the first data sent by the second server; storing the first data in a remaining storage space after the first server is updated.
  • the second server may delete the first data stored locally or may not delete the first data.
  • the embodiment may be referred to as localizing the first data by means of the first data migration; in the implementation manner of the latter, The copy of the first data stored in the cloth storage system is changed from n copies to n+ 1 copies, wherein the method of storing the copy of the first data can be seen in the related embodiments below.
  • the optional embodiment is hereinafter referred to as realizing localization of the first data by means of the first data migration.
  • the first server includes a virtual machine
  • the first data is data generated by the virtual machine
  • the other server further includes a third server
  • the method further includes the following Step C: Step C: The first server sends a third indication message that includes a copy of the first data to the third server, where the third indication message is used to indicate that the third server is to be the third A copy of the data is stored in the remaining storage space of the third server.
  • the "third server” may be used to store a copy of the first data, and the distributed storage system may include one or more third servers.
  • each server in the distributed storage system can know the remaining storage space of all servers in the distributed storage system.
  • the first server may select one or more servers in the distributed storage system as the third server according to the principle of "load balancing".
  • This embodiment can achieve the beneficial effect of enhancing the performance of the distributed storage system by storing a copy of the first data.
  • the distributed storage system can be operated normally by calling a copy of the first data, thereby enhancing the stability of the system.
  • the method for storing data provided by the embodiment of the present invention is applied to a distributed storage system including a first server and other servers, where the first server determines that the remaining storage space is greater than or equal to the storage space occupied by the data generated by the first server.
  • the used storage space of the first server is larger than the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server.
  • Embodiment 2 The method for storing data provided in this embodiment is applied to a distributed storage system, where the distributed storage system includes a first server and other servers.
  • This embodiment describes a method for storing data in scenario A in the first embodiment. As shown in Figure 2, it includes:
  • the method may further include: steps A 1 -A2 in the first embodiment, or steps B 1 -B4 in the first embodiment; and Step C in the first embodiment above.
  • the method for storing data provided by the embodiment of the present invention is applied to a distributed storage system including a first server and other servers, where the first server determines that the remaining storage space is greater than or equal to the storage space occupied by the data generated by the first server. If the used storage space of the first server is less than or equal to the minimum used storage space of the other server, the data is preferentially stored in the remaining storage space of the server; wherein the data occupies a larger storage space than the distributed storage system. The maximum value of the smallest memory unit.
  • Embodiment 1 the virtual machine is not included in the first server.
  • “Local” in this embodiment refers to a server where an application for generating data is located.
  • a method for storing data according to this embodiment includes:
  • An application installed on the first server (physical machine) generates a data.
  • the "application” herein may be any one of the prior art applications, such as word processing applications, audio processing applications, video picture processing applications, computer control applications, computer aided design applications, scientific simulation applications, and the like. Assuming that the step 301 is performed four times, an application installed on the first server (physical machine) generates a total of four data, which are D l, D2, D3, and D4.
  • the first server acquires a remaining storage space of the first server and a storage space occupied by the data.
  • the step 302 may be implemented as follows: the distributed storage program on the first server acquires the remaining storage space of the first server and the storage space occupied by the data.
  • step 302 is performed four times, and the remaining storage spaces of the obtained first server are: XI, X2, X3, X4; the space occupied by the data D1, D2, D3, D4
  • the sizes are: Ml, M2, M3, M4.
  • the first server determines whether the remaining storage space is greater than or equal to the storage space occupied by the data. If yes, go to step 304; if no, go to step 305.
  • the step 303 may be implemented as: determining, by the distributed storage program on the first server, whether the remaining storage space of the first server is greater than or equal to the storage space occupied by the data.
  • the first server stores the data in the remaining storage space of the first server.
  • the distributed storage program on the first server allocates a storage address to the data, and stores the data in a storage module corresponding to the storage address; the storage address is one or more of the remaining storage spaces of the first server.
  • D1, D2, and D3 are respectively stored in the (remaining) storage space of the first server.
  • the storage addresses allocated by the first server for D1, D2, and D3 are: Sl/Dl/offsetl, Sl/D2/offset2, and Sl/D2/offset3.
  • SI represents the first server
  • Sl/Dl/offsetl indicates that: the storage address of the data D1 is located at the offset1 of the storage space of the first server S1, and the other storage addresses are not interpreted.
  • the first server sends a first indication message that includes the data to the second server.
  • the first indication message is used to instruct the second server to store the data in the remaining storage space of the second server.
  • step 306 is performed.
  • the second server stores the data in the remaining storage space of the second server according to the first indication message. Specifically, the distributed storage program on the second server allocates a storage address to the data, and stores the data in a storage module corresponding to the storage address; the storage address is one or more of the remaining storage spaces of the second server. The storage address corresponding to the storage module.
  • D4 is stored in the (remaining) storage space of the second server.
  • the storage address assigned by the second server to D4 is: S2/D4/offset4.
  • S2 represents the second server
  • S2/D4/offset4 indicates that the storage address of the data D4 is located at the offset4 of the storage space of the second server S2.
  • D4 SI X4 S2/D4/offset4 As shown in Table 2, the server that obtains data D4 and the server that stores data D4 are the same server.
  • the first server updates the remaining storage space of the first server, and periodically detects the remaining storage space after the first server is updated.
  • the step 307 may be implemented as: the distributed storage program on the first server updates the remaining storage space of the first server, and periodically detects the remaining storage space after the first server is updated.
  • step 306 after performing step 301-306 for the fourth time, when step 307 is performed, the obtained remaining storage space of the first server is represented as X4'. 4 Set X4' > M4.
  • the first server determines whether the updated remaining storage space is greater than or equal to the storage space occupied by the data.
  • step 308 can be implemented as follows: The distributed storage program on the first server determines whether the remaining storage space after the first server is updated is greater than or equal to the storage space occupied by the data.
  • step 308 is specifically as follows: The first server determines whether X4' is greater than or equal to M4.
  • the first server sends a second indication message to the second server, where the second indication message is used to instruct the second server to send the data to the first server.
  • the second server sends the data to the first server according to the second indication message.
  • the first server stores the data in the remaining storage space after the first server is updated. After step 311 is performed, it ends. Specifically, the step 311 may be implemented as: the distributed storage program on the first server stores the data in the remaining storage space after the first server is updated. Exemplarily, according to the example in step 307, after performing step 311, the data routing table recorded in the distributed storage system is shown in Table 3: Table 3
  • the server that acquires the data D4 and the server that stores the data D4 are the same server.
  • SI/D4/offset4 indicates that the storage address of the data D4 is located at the offset 4 of the first server S1.
  • the method may further include the following steps A and B: Step A: The first server sends a third indication message including a copy of the data to the third server, where the third indication message is used to indicate The third server stores a copy of the data in the remaining storage space of the third server.
  • the pair of D 1 , D 2 , D 3 , D 4 This is expressed as: Dl', D2', D3', D4'.
  • Step B The third server stores the copy of the data in the remaining storage space of the third server according to the third indication message.
  • step B may be implemented as: the distributed storage program on the third server stores the copy of the data in the remaining storage space of the third server according to the third indication message.
  • the storage addresses allocated by the third server for D1, D2, D3, and D4 are: S3/D1' /offset 1, S3/D2' /offset2, S3/D3' /offset3, S3/D4' /offset4 , where S3 represents the third server, S3/D 1 ' /offsetl representation.
  • S3 represents the third server, S3/D 1 ' /offsetl representation.
  • a copy of the data D1 D1' storage address is located at the offset1 of the storage space of the third server S3, and the other storage addresses are no longer - explained.
  • step A and step B are used to enhance the stability of the system, specifically, if the data stored in the storage space of the second server is lost or When damaged, the first server may send an indication message to the third server to send a copy of the data to the first server; causing the third server to send a copy of the data to the first server according to the indication message; the first server A copy of the data is stored in the remaining storage space after the first server is updated.
  • the method for storing data provided by the embodiment of the present invention, when the first server determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by an application installed by the first server, the data is preferentially stored in the remaining storage of the server. In the space; when the first server determines that the remaining storage space is less than the storage space occupied by the data, storing the data in the remaining storage space of the second server, and determining that the remaining storage space after the first server is updated is greater than or When it is equal to the storage space occupied by the data, the data is stored in the remaining storage space after the first server is updated.
  • Embodiment 2 In this embodiment, a virtual machine is included on the first server. "Local” in this embodiment refers to a server where the virtual machine that generates data is located. As shown in FIG. 4, a method for storing data according to this embodiment includes:
  • the virtual machine installed on the first server generates a data.
  • VM1, VM2, VM3, VM4 four virtual machines (VM1, VM2, VM3, VM4) are installed on the first server, and the step 401 is executed.
  • VM1, VM2, VM3, and VM4 respectively acquire data D1, D2, and D3.
  • the first server acquires a remaining storage space of the first server and a storage space occupied by the data.
  • the first server determines whether the remaining storage space is greater than or equal to the storage space occupied by the data. If yes, go to step 404; if no, go to step 405.
  • the first server stores the data in the remaining storage space of the first server.
  • step 404 After performing step 404, it ends. It should be noted that the examples in step 402 to step 404 may refer to steps 302-304 in the foregoing embodiment 1, and details are not described herein again.
  • the first server determines the size of the storage space occupied by the data other than the first data corresponding to the virtual machine in step 401, and marks it as W.
  • the first server determines, as a second server, a server in the distributed storage system that has a remaining storage space greater than or equal to W.
  • the first server sends a first indication message that includes the data to the second server.
  • the first indication message is used to instruct the second server to store the data in the remaining storage space of the second server.
  • the second server stores the data in the remaining storage space of the second server according to the first indication message.
  • the server S 1 where the virtual machine VM4 of D4 is located is not the same server as the server S2 where D4 is stored.
  • step 409 The first server migrates the virtual machine and other data generated by the virtual machine to the second server. After step 409 is performed, it ends. Exemplarily, all the data recorded in the data routing table and corresponding to the virtual machine are: D l, D2, D3, D4, then step 409 is specifically: the first server uses the virtual machine and D l, D2, D3 migrated to the second server. Exemplarily, according to the example in step 408, after step 409, the distribution The data routing table recorded in the storage system is shown in Table 3': Table y
  • the server S2 where the virtual machine VM4 that acquires D4 is located is the same server as the server S2 that stores D4.
  • the method may further include step A and step B in the above embodiment 1.
  • Table 4 and Table 5 above can be expressed as Table 4' and Table 5', respectively: Table 4'
  • the first server determines that the remaining storage space is greater than or equal to a data generated by a virtual machine thereon.
  • the data is preferentially stored in the remaining storage space of the server; when the first server determines that the remaining storage space is smaller than the storage space occupied by the data, the data is stored in the storage of the second server. In space, and migrate the virtual machine to the second server.
  • Embodiment 3 As shown in FIG. 5, a server 1 provided in this embodiment is applied to a distributed storage system, where the distributed storage system further includes other servers, and the server 1 is configured to execute the method shown in FIG. A method of storing data, the server 1 comprising:
  • the determining module 5 1 is configured to determine the first data generated by the server 1 ; the determining module 52 is configured to determine a size relationship between a remaining storage space of the server 1 and a storage space occupied by the first data;
  • the storage module 53 is configured to determine, in the determining module 52, that the remaining storage space of the server 1 is greater than or equal to the storage space occupied by the first data, and the used storage space of the server 1 is larger than the other server.
  • the first data is stored in the remaining storage space of the server 1 when the minimum used storage space is used.
  • the server 1 includes a virtual machine, where the first data is data generated by the virtual machine; and the other server includes a second server; as shown in FIG.
  • the server 1 further includes:
  • the sending module 54 is configured to: when the determining module 52 determines that the remaining storage space of the server 1 is smaller than the storage space occupied by the first data, send the first data including the first data to the second server
  • the first indication message is used to instruct the second server to store the first data in a remaining storage space of the second server;
  • the migration module 55 is configured to: when the storage space occupied by the data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage space of the second server, the virtual machine and the The other data is migrated to the second server.
  • the other server includes a second server.
  • the server 1 further includes:
  • the sending module 54 is configured to: when the determining module 52 determines that the remaining storage space of the server 1 is smaller than the storage space occupied by the first data, send the first data including the first data to the second server
  • the first indication message is used to instruct the second server to store the first data in a remaining storage space of the second server;
  • An update module 56 configured to update remaining storage space of the server 1;
  • the sending module 54 is further configured to: when the remaining storage space of the server 1 is greater than or equal to the storage space occupied by the first data, send a second indication message to the second server;
  • the second indication message is used to instruct the second server to migrate the first data to the server 1;
  • the receiving module 57 is configured to receive the first data sent by the second server.
  • the storage module 53 is further configured to store the first data in the remaining storage space of the server 1 after the update.
  • the other server further includes a third server
  • the sending module 54 is further configured to: send, to the third server, the first a third indication message of the copy of the data, the third indication message is used to instruct the third server to store a copy of the first data in a remaining storage space of the third server.
  • the server 1 in this embodiment may be the "first server” described in the first embodiment
  • the “second server” in this embodiment may be the “second server” described in the first embodiment. ".
  • the server 1 provided by the embodiment of the present invention is applied to a distributed storage system that further includes other servers, and the server 1 determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, and the server 1 is used.
  • the server 1 can directly read the data from the local without having to read the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance.
  • the problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art.
  • Embodiment 4 is directed to Embodiment 3, in hardware implementation, where the sending module may be a transmitter, the receiving module may be a receiver, and the transmitter and the receiver may be integrated to form a transceiver; the storage module may be a memory, The determining module, the judging module, the migration module, and the like may be embedded in or independent of the processor of the server 1 in hardware, or may be stored in the memory of the server 1 in software, so that the processor calls to execute the corresponding modules. Operation, the processor can be a central processing unit (CPU), a microprocessor, a microcontroller, or the like. As shown in FIG.
  • CPU central processing unit
  • a server 1 is provided for a distributed storage system, where the distributed storage system further includes other servers, and the server 1 is configured to execute the storage data shown in FIG. 1 .
  • the server 1 includes: a bus system 71, a memory 72, and a processor 73.
  • the memory 72 and the processor 73 are coupled together by a bus system 71.
  • the bus system 71 may include a power bus, a control bus, a status signal bus, and the like in addition to the data bus. However, for the sake of clarity, various buses are labeled as the bus system 71 in the figure.
  • the server 1 includes a virtual machine, the first data is data generated by the virtual machine, and the other server includes a second server. As shown in FIG.
  • the server 1 further includes: sending The controller 74 is configured to: when the processor 73 determines that the remaining storage space of the server 1 is smaller than the storage space occupied by the first data, send a first indication that includes the first data to the second server The first indication message is used to indicate that the second server stores the first data in a remaining storage space of the second server; the processor 73 is further configured to: correspond to the virtual machine The virtual machine and the other data are migrated to the second server when the storage space occupied by the data other than the first data is less than or equal to the remaining storage space of the second server.
  • the other server includes a second server; the processor 73 is further configured to: update a remaining storage space of the server 1; the transmitter 74 is further configured to: when the server 1 is updated, Sending a second indication message to the second server when the storage space is greater than or equal to the storage space occupied by the first data; the second indication message is used to instruct the second server to migrate the first data
  • the server 1 further includes: a receiver 75, configured to receive the first data sent by the second server; the memory 72 is further configured to: The first data is stored in the remaining storage space of the server 1 after the control of the processor 73.
  • the other server further includes a third server, where the transmitter 74 is further configured to: send, to the third server, a third indication message that includes a copy of the first data, where the third indication message is And configured to instruct the third server to store a copy of the first data in a remaining storage space of the third server.
  • the server 1 in this embodiment may be the "first server” described in the first embodiment
  • the “second server” in this embodiment may be the “second server” described in the first embodiment. ".
  • the server 1 provided by the embodiment of the present invention is applied to a distributed storage system that further includes other servers, and the server 1 determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, and the server 1 is used.
  • the server 1 determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, and the server 1 is used.
  • the storage space is larger than the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server.
  • the server 1 can directly read the data from the local without having to read the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance.
  • Embodiment 5 due to other in the network The problem of extended time and poor system performance caused by reading data on the server. Embodiment 5
  • a server 2 provided in this embodiment is applied to a distributed storage system, where the distributed storage system further includes other servers, and the server 2 is configured to execute the stored data shown in FIG.
  • the server 2 includes: a determining module 91, configured to determine first data generated by the server 2; a storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system;
  • the determining module 92 is configured to determine a size relationship between the remaining storage space of the server 2 and the storage space occupied by the first data.
  • the storage module 93 is configured to determine, in the determining module 92, the remaining storage of the server 2 The space is greater than or equal to the storage space occupied by the first data, and the used storage space of the server 2 is less than or equal to the minimum used storage space of the other server, and the first data is stored in the In the remaining storage space of server 2.
  • the server 2 in this embodiment may specifically be the "first server" described in the first embodiment.
  • the server 2 provided by the embodiment of the present invention is applied to a distributed storage system that further includes other servers.
  • the server 2 determines that the remaining storage space is greater than or equal to the storage space occupied by the data generated by the server 2, and the server 2 is used.
  • the storage space is less than or equal to the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server; wherein the storage space occupied by the data is greater than the maximum storage unit of the distributed storage system. .
  • the server 2 can directly read the data from the local without reading the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance.
  • the storage module may be a memory, and the determining module and the determining module may be embedded in the hardware of the server 2 in hardware or may be stored in software.
  • the processor may be a central processing unit (CPU), a microprocessor, a single chip microcomputer or the like.
  • a server 2 is provided for a distributed storage system, where the distributed storage system further includes other servers, and the server 2 is configured to execute the storage data shown in FIG.
  • the server 1 includes: a bus system 10A, a memory 10B, and a processor 10C.
  • the memory 10B and the processor 10C are coupled together by the bus system 10A.
  • the bus system 10A may include a power bus, a control bus, a status signal bus, and the like in addition to the data bus.
  • the various buses are labeled as bus system i 0 A in the figure.
  • a memory 10B for storing a set of codes; a code stored in the memory 10B for controlling the processor 10C to determine the first data generated by the server 2; and determining the remaining storage space of the server 2 and the first data a size relationship of the storage space; the storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system; and the memory 10B is further configured to determine the server 2 at the processor 10C
  • the remaining storage space is greater than or equal to the storage space occupied by the first data, and the used storage space of the server 2 is less than or equal to the minimum used storage space of the other server, in the processor 10C Controlling the first data in storage The remaining storage space of the server 2.
  • the server 2 in this embodiment may be the "first server” described in the first embodiment, and the server 2 provided in the embodiment of the present invention is applied to a distributed storage system that further includes other servers.
  • the server 2 determines that the remaining storage space is greater than or equal to the storage space occupied by one of the data generated by the server 2, and when the used storage space of the server 2 is less than or equal to the minimum used storage space of the other server, the data is preferentially stored in the server.
  • the remaining storage space; wherein, the data occupies a storage space larger than the maximum storage unit of the distributed storage system. In this way, the server 2 can directly read the data from the local without reading the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the modules is only a logical function division.
  • there may be another division manner for example, multiple modules or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or module, and may be in an electrical, mechanical or other form.
  • the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules.
  • each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may be physically included separately, or two or more modules may be integrated into one module.
  • the above integrated modules can be implemented in the form of hardware or in the form of hardware plus software function modules.
  • the above-described integrated modules implemented in the form of software function modules can be stored in a computer readable storage medium.
  • the software function modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform portions of the steps of the various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a disk or an optical disk, and the like, which can store program codes. .

Abstract

The present invention relates to the technical field of storage. Disclosed in an embodiment of the present invention are a data storage method and device for reducing the time delay of reading data, thus improving system performance. The method is applied to a distributed storage system comprising a first server and other servers. The method comprises: determining the first data generated by the first server; determining the relationship between the size of the remaining storage space of the first server and the size of the storage space used by the first data; if the remaining storage space of the first server is larger than or equal to the storage space used by the first data, and the used storage space of the first server is larger than the minimum used storage space of the other servers, then storing the first data in the remaining storage space of the first server.

Description

一种存储数据的方法和装置  Method and device for storing data
技术领域 本发明涉及存储技术领域, 尤其涉及一种存储数据的方法和装 置。 背景技术  TECHNICAL FIELD The present invention relates to the field of storage technologies, and in particular, to a method and apparatus for storing data. Background technique
分布式存储系统以可靠性高、 可用性强、 易于扩展等特点成为 研究的热点。 分布式存储系统由多个服务器构成, 每个服务器上可 以安装一个或者多个虚拟机, 每个服务器对应 RAID ( Redundant Arrays of Independent Disks , 磁盘阵歹 上的一部分存储空间。 目前, 在分布式存储系统中, 一般按照 "负载均衡" 的原则为 服务器上安装的应用 /虚拟机生成的数据分配物理存储空间, 即, 按 照 " HDFS 中的各服务器的已使用存储空间均衡" 的原则为服务器上 安装的应用 /虚拟机生成的数据分配物理存储空间; 其中, 物理存储 空间为某一服务器对应的磁盘阵列的存储空间和 /或该服务器本身 的存储空间。具体的,以分布式存储系统为 HDFS( Hadoop Distributed File System , 分布式文件系统) 为例进行说明: 在 HDFS 中, 最小存储单元为块 ( block ) , 每个块的最大值为 于 64M时, 该服务器首先对该数据进行分块, 一般地, 至多有 1个 块所占的存储空间小于 64M , 其余块所占的存储空间均等于 64M; 其次按照 " HDFS 中的各服务器的已使用存储空间均衡" 的原则, 将 各块映射到 HDFS 中的一个或者多个服务器的存储空间上。 当服务 器上安装的应用 /虚拟机生成的数据所占的存储空间等于或者小于 64M 时, 按照 " HDFS 中的各服务器的已使用存储空间均衡" 的原 则, 将该数据映射到 HDFS 中、 已使用存储空间最小的服务器的存 储空间上。 由于上述方案中按照 "负载均衡" 的原则为服务器上安装的应 用 /虚拟机生成的数据分配物理位置, 因此, 该数据中的部分 /全部数 据可能存储在分布式存储系统中的其他服务器的存储空间上。 这样, 该服务器往往需要从其他服务器的存储空间上读取该数据, 从而造 成读取数据时延大的问题, 进而导致系统性能较差。 发明内容 Distributed storage systems have become the focus of research with high reliability, high availability, and easy expansion. A distributed storage system consists of multiple servers. Each server can have one or more virtual machines installed. Each server corresponds to RAID (Redundant Arrays of Independent Disks). At present, in distributed storage. In the system, the physical storage space is generally allocated for the data generated by the application/virtual machine installed on the server according to the principle of "load balancing", that is, the server is installed according to the principle of "balanced used storage space of each server in HDFS". The data generated by the application/virtual machine allocates physical storage space; wherein, the physical storage space is the storage space of the disk array corresponding to a certain server and/or the storage space of the server itself. Specifically, the distributed storage system is HDFS ( Hadoop Distributed File System (Distributed File System) is an example: In HDFS, the smallest storage unit is a block. When the maximum value of each block is 64M, the server first blocks the data. Ground, at most 1 block occupies less than 64M of storage space, the remaining blocks The storage space is equal to 64M; secondly, according to the principle of "balanced used storage space of each server in HDFS", each block is mapped to the storage space of one or more servers in HDFS. When installed on the server When the storage space generated by the application/virtual machine is equal to or less than 64M, the data is mapped to the HDFS server with the smallest storage space according to the principle of "balanced used storage space of each server in HDFS". Deposit Storage space. Since the above schemes allocate physical locations for data generated by applications/virtual machines installed on the server according to the principle of "load balancing", some/all of the data in the data may be stored in other servers in the distributed storage system. Space. In this way, the server often needs to read the data from the storage space of other servers, thereby causing a problem of large delay in reading data, which in turn leads to poor system performance. Summary of the invention
本发明实施例提供一种存储数据的方法和装置, 用以减少读取 数据时的时延, 从而提高系统性能。 为达到上述目 的, 本发明的实施例采用如下技术方案: 第一方面, 提供一种存储数据的方法, 应用于分布式存储系统, 所述分布式存储系统包括第一服务器和其他服务器, 所述方法包括: 确定所述第一服务器生成的第一数据; 判断所述第一服务器的剩余存储空间与所述第一数据所占的存 储空间的大小关系;  Embodiments of the present invention provide a method and apparatus for storing data, which are used to reduce delay in reading data, thereby improving system performance. To achieve the above objective, the embodiment of the present invention adopts the following technical solutions: In a first aspect, a method for storing data is provided, which is applied to a distributed storage system, where the distributed storage system includes a first server and other servers, The method includes: determining first data generated by the first server; determining a size relationship between a remaining storage space of the first server and a storage space occupied by the first data;
如果所述第一服务器的剩余存储空间大于或者等于所述第一数 据所占的存储空间, 且所述第一服务器的已使用存储空间大于所述 其他服务器的最小已使用存储空间时, 将所述第一数据存储在所述 第一服务器的剩余存储空间中。 结合第一方面, 在第一种可能的实现方式中, 所述第一服务器 包含一虚拟机, 所述第一数据是所述虚拟机生成的数据; 所述其他 服务器包括第二服务器; 所述方法还包括:  If the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is greater than the minimum used storage space of the other server, The first data is stored in the remaining storage space of the first server. With reference to the first aspect, in a first possible implementation, the first server includes a virtual machine, the first data is data generated by the virtual machine, and the other server includes a second server; The method also includes:
如果所述第一服务器的剩余存储空间小于所述第一数据所占的 存储空间, 则向所述第二服务器发送包含所述第一数据的第一指示 消息; 所述第一指示消息用于指示所述第二服务器将所述第一数据 存储在所述第二服务器的剩余存储空间中; 在所述虚拟机对应的除所述第一数据之外的其他数据所占的存 储空间小于或者等于所述第二服务器的剩余存储空间时, 将所述虚 拟机和所述其他数据迁移到所述第二服务器上。 结合第一方面, 在第二种可能的实现方式中, 所述其他服务器 包括第二服务器; 所述方法还包括: 如果所述第一服务器的剩余存储空间小于所述第一数据所占的 存储空间, 则向所述第二服务器发送包含所述第一数据的第一指示 消息; 所述第一指示消息用于指示所述第二服务器将所述第一数据 存储在所述第二服务器的剩余存储空间中; 更新所述第一服务器的剩余存储空间; 当所述第一服务器更新后的剩余存储空间大于或者等于所述第 一数据所占的存储空间时, 向所述第二服务器发送第二指示消息; 所述第二指示消息用于指示所述第二服务器将所述第一数据迁移到 所述第一服务器; 接收所述第二服务器发送的所述第一数据; 将所述第一数据存储在所述第一服务器更新后的剩余存储空间 中。 Sending a first indication including the first data to the second server if a remaining storage space of the first server is smaller than a storage space occupied by the first data The first indication message is used to indicate that the second server stores the first data in a remaining storage space of the second server; in addition to the first data corresponding to the virtual machine The virtual machine and the other data are migrated to the second server when the storage space occupied by the other data is less than or equal to the remaining storage space of the second server. With reference to the first aspect, in a second possible implementation manner, the other server includes a second server, where the method further includes: if the remaining storage space of the first server is smaller than the storage occupied by the first data a first indication message that includes the first data is sent to the second server, where the first indication message is used to indicate that the second server stores the first data in the second server Remaining storage space; updating remaining storage space of the first server; sending to the second server when the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data a second indication message, the second indication message is used to instruct the second server to migrate the first data to the first server, and receive the first data sent by the second server; The first data is stored in the remaining storage space after the first server is updated.
结合第一方面、 第一方面的第一种可能的实现方式或者第二种 可能的实现方式任一种, 在第三种可能的实现方式中, 所述其他服 务器还包括第三服务器, 所述方法还包括:  With reference to the first aspect, the first possible implementation manner of the first aspect, or the second possible implementation manner, in a third possible implementation manner, the other server further includes a third server, where The method also includes:
向所述第三服务器发送包含所述第一数据的副本的第三指示消 息, 所述第三指示消息用于指示所述第三服务器将所述第一数据的 副本存储在所述第三服务器的剩余存储空间中。 第二方面, 提供一种存储数据的方法, 应用于分布式存储系统, 所述分布式存储系统包括第一服务器和其他服务器, 所述方法包括: 确定所述第一服务器生成的第一数据; 所述第一数据所占的存 储空间大于所述分布式存储系统的最小存储单元的最大值; 判断所述第一服务器的剩余存储空间与所述第一数据所占的存 储空间的大小关系; Sending, to the third server, a third indication message that includes a copy of the first data, where the third indication message is used to instruct the third server to store a copy of the first data in the third server The remaining storage space. A second aspect provides a method for storing data, which is applied to a distributed storage system, where the distributed storage system includes a first server and other servers, and the method includes: determining first data generated by the first server; The storage space occupied by the first data is greater than the maximum value of the minimum storage unit of the distributed storage system; determining the size relationship between the remaining storage space of the first server and the storage space occupied by the first data;
如果所述第一服务器的剩余存储空间大于或者等于所述第一数 据所占的存储空间, 且所述第一服务器的已使用存储空间小于或者 等于所述其他服务器的最小已使用存储空间时, 将所述第一数据存 储在所述第一服务器的剩余存储空间中。 第三方面, 提供一种服务器, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 确定模块, 用于确定所述服务器生成的第一数据; 判断模块, 用于判断所述服务器的剩余存储空间与所述第一数 据所占的存储空间的大小关系; 存储模块, 用于在所述判断模块确定所述服务器的剩余存储空 间大于或者等于所述第一数据所占的存储空间, 且所述服务器的已 使用存储空间大于所述其他服务器的最小已使用存储空间时, 将所 述第一数据存储在所述服务器的剩余存储空间中。  If the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is less than or equal to the minimum used storage space of the other server, The first data is stored in a remaining storage space of the first server. A third aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes other servers, where the server includes: a determining module, configured to determine first data generated by the server; a storage module, configured to determine, in the determining module, that a remaining storage space of the server is greater than or equal to the first The first data is stored in the remaining storage space of the server when the storage space occupied by the data is, and the used storage space of the server is greater than the minimum used storage space of the other server.
结合第三方面, 在第一种可能的实现方式中, 所述服务器包含 一虚拟机, 所述第一数据是所述虚拟机生成的数据; 所述其他服务 器包括第二服务器, 所述服务器还包括: 发送模块, 用于在所述判断模块确定所述服务器的剩余存储空 间小于所述第一数据所占的存储空间时, 向所述第二服务器发送包 含所述第一数据的第一指示消息; 所述第一指示消息用于指示所述 第二服务器将所述第一数据存储在所述第二服务器的剩余存储空间 中; 迁移模块, 用于在所述虚拟机对应的除所述第一数据之外的其 他数据所占的存储空间小于或者等于所述第二服务器的剩余存储空 间时, 将所述虚拟机和所述其他数据迁移到所述第二服务器上。 结合第三方面, 在第二种可能的实现方式中, 所述其他服务器 包括第二服务器, 所述服务器还包括: 发送模块, 用于在所述判断模块确定所述服务器的剩余存储空 间小于所述第一数据所占的存储空间时, 向所述第二服务器发送包 含所述第一数据的第一指示消息; 所述第一指示消息用于指示所述 第二服务器将所述第一数据存储在所述第二服务器的剩余存储空间 中; 更新模块, 用于更新所述服务器的剩余存储空间; 所述发送模块还用于, 当所述服务器更新后的剩余存储空间大 于或者等于所述第一数据所占的存储空间时, 向所述第二服务器发 送第二指示消息; 所述第二指示消息用于指示所述第二服务器将所 述第一数据迁移到所述服务器; 接收模块, 用于接收所述第二服务器发送的所述第一数据; 所述存储模块还用于, 将所述第一数据存储在所述服务器更新 后的剩余存储空间中。 结合第三方面、 第三方面的第一种可能的实现方式或者第三方 面的第二种可能的实现方式任一种, 在第三种可能的实现方式中, 所述其他服务器还包括第三服务器; 所述发送模块还用于, 向所述第三服务器发送包含所述第一数 据的副本的第三指示消息, 所述第三指示消息用于指示所述第三服 务器将所述第一数据的副本存储在所述第三服务器的剩余存储空间 中。 With reference to the third aspect, in a first possible implementation, the server includes a virtual machine, the first data is data generated by the virtual machine, and the other server includes a second server, where the server further The sending module is configured to: when the determining module determines that the remaining storage space of the server is smaller than the storage space occupied by the first data, send a first indication that includes the first data to the second server a message, the first indication message is used to indicate the The second server stores the first data in a remaining storage space of the second server, and a migration module, configured to occupy a storage space of data other than the first data corresponding to the virtual machine When less than or equal to the remaining storage space of the second server, the virtual machine and the other data are migrated to the second server. With reference to the third aspect, in a second possible implementation, the other server includes a second server, the server further includes: a sending module, configured to determine, in the determining module, that the remaining storage space of the server is smaller than Sending a first indication message including the first data to the second server when the storage space occupied by the first data is used; the first indication message is used to indicate that the second server is to use the first data Storing in a remaining storage space of the second server; an update module, configured to update a remaining storage space of the server; the sending module is further configured to: when the server updates, the remaining storage space is greater than or equal to the Sending a second indication message to the second server when the storage space is occupied by the first data; the second indication message is used to instruct the second server to migrate the first data to the server; And receiving the first data sent by the second server; the storage module is further configured to: store the first data in The remaining storage space of said server update. With reference to the third aspect, the first possible implementation manner of the third aspect, or the second possible implementation manner of the third aspect, in a third possible implementation manner, the other server further includes a third The sending module is further configured to: send, to the third server, a third indication message that includes a copy of the first data, where the third indication message is used to indicate the third service The server stores a copy of the first data in a remaining storage space of the third server.
第四方面, 提供一种服务器, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 处理器, 用于确定所述服务器生成的第一数据; 以及判断所述 服务器的剩余存储空间与所述第一数据所占的存储空间的大小关 系;  A fourth aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes other servers, where the server includes: a processor, configured to determine first data generated by the server; Determining the size relationship between the remaining storage space of the server and the storage space occupied by the first data;
存储器, 用于在所述处理器确定所述服务器的剩余存储空间大 于或者等于所述第一数据所占的存储空间, 且所述服务器的已使用 存储空间大于所述其他服务器的最小已使用存储空间时, 在所述处 理器的控制下将所述第一数据存储在所述服务器的剩余存储空间 中。  a memory, configured to determine, by the processor, that a remaining storage space of the server is greater than or equal to a storage space occupied by the first data, and a used storage space of the server is greater than a minimum used storage of the other server In the space, the first data is stored in the remaining storage space of the server under the control of the processor.
结合第四方面, 在第一种可能的实现方式中, 所述服务器包含 一虚拟机, 所述第一数据是所述虚拟机生成的数据; 所述其他服务 器包括第二服务器, 所述服务器还包括: 发送器, 用于在所述处理器确定所述服务器的剩余存储空间小 于所述第一数据所占的存储空间时, 向所述第二服务器发送包含所 述第一数据的第一指示消息; 所述第一指示消息用于指示所述第二 服务器将所述第一数据存储在所述第二服务器的剩余存储空间中; 所述处理器还用于, 在所述虚拟机对应的除所述第一数据之外 的其他数据所占的存储空间小于或者等于所述第二服务器的剩余存 储空间时, 将所述虚拟机和所述其他数据迁移到所述第二服务器上。 结合第四方面, 在第二种可能的实现方式中, 所述其他服务器 包括第二服务器; 所述处理器还用于, 更新所述服务器的剩余存储空间; 所述发送器还用于, 当所述服务器更新后的剩余存储空间大于 或者等于所述第一数据所占的存储空间时, 向所述第二服务器发送 第二指示消息; 所述第二指示消息用于指示所述第二服务器将所述 第一数据迁移到所述服务器; 所述服务器还包括: 接收器, 用于接收所述第二服务器发送的 所述第一数据; 所述存储器还用于, 在所述处理器的控制下将所述第一数据存 储在所述服务器更新后的剩余存储空间中。 结合第四方面、 第四方面的第一种可能的实现方式或者第四方 面的第二种可能的实现方式任一种, 在第三种可能的实现方式中, 所述其他服务器还包括第三服务器; 所述发送器还用于, 向所述第三服务器发送包含所述第一数据 的副本的第三指示消息, 所述第三指示消息用于指示所述第三服务 器将所述第一数据的副本存储在所述第三服务器的剩余存储空间 中。 第五方面, 提供一种服务器, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 确定模块, 用于确定所述服务器生成的第一数据; 所述第一数 据所占的存储空间大于所述分布式存储系统的最小存储单元的最大 值; 判断模块, 用于判断所述服务器的剩余存储空间与所述第一数 据所占的存储空间的大小关系; 存储模块, 用于在所述判断模块确定所述服务器的剩余存储空 间大于或者等于所述第一数据所占的存储空间, 且所述服务器的已 使用存储空间小于或者等于所述其他服务器的最小已使用存储空间 时, 将所述第一数据存储在所述服务器的剩余存储空间中。 第六方面, 提供一种服务器, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 处理器, 用于确定所述服务器生成的第一数据; 以及判断所述 服务器的剩余存储空间与所述第一数据所占的存储空间的大小关 系; 所述第一数据所占的存储空间大于所述分布式存储系统的最小 存储单元的最大值; 存储器, 用于在所述处理器确定所述服务器的剩余存储空间大 于或者等于所述第一数据所占的存储空间, 且所述服务器的已使用 存储空间小于或者等于所述其他服务器的最小已使用存储空间时, 在所述处理器的控制下将所述第一数据存储在所述服务器的剩余存 储空间中。 上述技术方案, 应用于分布式存储系统, 在一服务器确定其剩 余存储空间大于或者等于其生成的一数据所占的存储空间时, 优先 将该数据存储在该服务器的剩余存储空间中。 这样, 该服务器可以 直接从本地读取该数据, 而不需要从网络中的其他服务器上读取该 数据, 从而达到缩短时延、 提高系统性能的有益效果。 解决了现有 技术中, 因通过在网络中的其他服务器上读取数据导致的时延长、 系统性能较差的问题。 附图说明 为了更清楚地说明本发明实施例或现有技术中的技术方案, 下 面将对实施例或现有技术描述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是本发明的一些实施例, 对于 本领域普通技术人员来讲, 在不付出创造性劳动性的前提下, 还可 以根据这些附图获得其他的附图。 图 1 为本发明实施例一提供的一种存储数据的方法的流程图; 图 2为本发明实施例二提供的一种存储数据的方法的流程图; 图 3为本发明实施例 1提供的一种存储数据的方法的流程图; 图 4为本发明实施例 2提供的一种存储数据的方法的流程图; 图 5为本发明实施例三提供的一种服务器的结构示意图; 图 6为本发明实施例三提供的另一种服务器的结构示意图; 图 7为本发明实施例四提供的一种服务器的结构示意图; 图 8为本发明实施例四提供的另一种服务器的结构示意图; 图 9为本发明实施例五提供的一种服务器的结构示意图; 图 10为本发明实施例六提供的- -种服务器的结构示意图。 具体实施方式 下面将结合本发明实施例中的附图, 对本发明实施例中的技术 方案进行清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明 一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本 领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他 实施例, 都属于本发明保护的范围。 本文中术语 "系统" 和 "网络" 在本文中常被可互换使用。 本 文中术语 "和 /或", 仅仅是一种描述关联对象的关联关系, 表示可 以存在三种关系, 例如, A和 /或 B , 可以表示: 单独存在 A , 同时 存在 A和 B , 单独存在 B这三种情况。 本文中字符 " /" , 一般表示 前后关联对象是一种 "或" 的关系。 实施例一 With reference to the fourth aspect, in a first possible implementation, the server includes a virtual machine, the first data is data generated by the virtual machine, and the other server includes a second server, where the server further The method includes: a transmitter, configured to send, when the processor determines that a remaining storage space of the server is less than a storage space occupied by the first data, send a first indication that includes the first data to the second server The first indication message is used to indicate that the second server stores the first data in a remaining storage space of the second server; the processor is further configured to: correspond to the virtual machine The virtual machine and the other data are migrated to the second server when the storage space occupied by the data other than the first data is less than or equal to the remaining storage space of the second server. With reference to the fourth aspect, in a second possible implementation, the other server includes a second server, and the processor is further configured to: update a remaining storage space of the server; The transmitter is further configured to: when the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, send a second indication message to the second server; The message is used to indicate that the second server migrates the first data to the server; the server further includes: a receiver, configured to receive the first data sent by the second server; And storing, in the control of the processor, the first data in a remaining storage space after the server is updated. With reference to the fourth aspect, the first possible implementation manner of the fourth aspect, or the second possible implementation manner of the fourth aspect, in a third possible implementation manner, the other server further includes a third The server is further configured to: send, to the third server, a third indication message that includes a copy of the first data, where the third indication message is used to indicate that the third server is to be the first A copy of the data is stored in the remaining storage space of the third server. A fifth aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes another server, where the server includes: a determining module, configured to determine first data generated by the server; The storage space occupied by the data is larger than the maximum storage unit of the distributed storage system; the determining module is configured to determine a size relationship between the remaining storage space of the server and the storage space occupied by the first data; a storage module, configured to determine, in the determining module, that a remaining storage space of the server is greater than or equal to a storage space occupied by the first data, and that the used storage space of the server is less than or equal to a minimum of the other servers Used storage space And storing the first data in a remaining storage space of the server. A sixth aspect provides a server, which is applied to a distributed storage system, where the distributed storage system further includes other servers, where the server includes: a processor, configured to determine first data generated by the server; a relationship between a remaining storage space of the server and a storage space occupied by the first data; a storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system; When the processor determines that the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, and the used storage space of the server is less than or equal to the minimum used storage space of the other server; And storing the first data in a remaining storage space of the server under the control of the processor. The foregoing technical solution is applied to a distributed storage system. When a server determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, the data is preferentially stored in the remaining storage space of the server. In this way, the server can directly read the data from the local without having to read the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving system performance. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings to be used in the embodiments or the description of the prior art will be briefly described below, and obviously, in the following description The drawings are only some of the embodiments of the present invention, and other drawings may be obtained from those skilled in the art without departing from the drawings. 1 is a flowchart of a method for storing data according to Embodiment 1 of the present invention; FIG. 2 is a flowchart of a method for storing data according to Embodiment 2 of the present invention; FIG. 4 is a flowchart of a method for storing data according to Embodiment 2 of the present invention; FIG. 5 is a schematic structural diagram of a server according to Embodiment 3 of the present invention; FIG. 7 is a schematic structural diagram of a server according to Embodiment 4 of the present invention; FIG. 8 is a schematic structural diagram of another server according to Embodiment 4 of the present invention; FIG. 9 is a schematic structural diagram of a server according to Embodiment 5 of the present invention; FIG. 10 is a schematic structural diagram of a server according to Embodiment 6 of the present invention. The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. example. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without departing from the inventive scope are the scope of the present invention. The terms "system" and "network" are used interchangeably herein. The term "and/or" in this context is merely an association describing the associated object, indicating that there can be three relationships, for example, A and / or B, which can mean: A exists separately, and both A and B exist separately. B these three situations. The character "/" in this article generally means that the contextual object is an "or" relationship. Embodiment 1
如图 1 所示, 为本实施例提供的一种存储数据的方法, 应用于 分布式存储系统, 所述分布式存储系统包括第一服务器和其他服务 器, 所述方法包括: As shown in FIG. 1 , a method for storing data provided in this embodiment is applied to a distributed storage system, where the distributed storage system includes a first server and other services. The method includes:
101 : 确定所述第一服务器生成的第一数据。 其中, "第一服务器" 可以为分布式存储系统中的任一服务器; "其他服务器" 是指该分布式存储系统中、 除第一服务器之外的所 有服务器。 "第一数据" 可以为第一服务器生成的任一数据。 本实施 例的执行主体可以为 "第一服务器"。 分布式存储系统中的服务器可以安装一个或者多个虚拟机, 也 可以不安装虚拟机。 当服务器上安装有虚拟机时, 该服务器与其上 安装的虚拟机共享该服务器对应的磁盘阵列。 另外, 当服务器上安 装有一个或者多个虚拟机时, 该服务器生成的第一数据可以为: 该 服务器 (物理机) 上安装的一应用生成的数据; 也可以为该服务器 上安装的一虚拟机生成的数据。 进一步地, 当一数据为服务器上安装的一应用生成的数据时, 该服务器会记录该数据与该服务器之间的对应关系; 当一数据为服 务器上安装的一虚拟机生成的数据时, 该服务器会记录该数据与该 虚拟机之间的对应关系。 具体可以通过生成数据路由表来记录该对 应关系。 一般地, 分布式存储系统中的每个服务器均可共享该数据 路由表。 在本文中, 当生成一数据的应用 /虚拟机所在的服务器与存 储该数据的存储空间所对应的服务器为同一服务器时, 认为实现了 对该数据的本地化。  101: Determine first data generated by the first server. The "first server" may be any server in the distributed storage system; the "other server" refers to all servers except the first server in the distributed storage system. "First Data" can be any data generated by the first server. The execution subject of this embodiment may be "first server". A server in a distributed storage system can install one or more virtual machines or not. When a virtual machine is installed on a server, the server shares the disk array corresponding to the server with the virtual machine installed on it. In addition, when one or more virtual machines are installed on the server, the first data generated by the server may be: an application-generated data installed on the server (physical machine); or a virtual machine installed on the server Machine generated data. Further, when the data is data generated by an application installed on the server, the server records the correspondence between the data and the server; when the data is data generated by a virtual machine installed on the server, The server records the correspondence between the data and the virtual machine. Specifically, the corresponding relationship can be recorded by generating a data routing table. In general, each data store in a distributed storage system can share the data routing table. In this paper, when the server where the application/virtual machine that generates a data is located and the server corresponding to the storage space where the data is stored is the same server, it is considered that the localization of the data is realized.
102 : 判断所述第一服务器的剩余存储空间与所述第一数据所占 的存储空间的大小关系。 其中, "服务器的剩余存储空间" 是指该服务器对应的磁盘阵列 和 /或该服务器本身的存储空间中未存储数据的、 可用存储空间。 剩 余存储空间的大小可以为 0 , 也可以包括一个或者多个存储单元。 每 个服务器的剩余存储空间可能因删除已存储的数据、 增加待存储的 数据、 改变该服务器对应的磁盘阵列的大小等而更新。 服务器可以 包括但不限于按照以下几种方式获取其剩余存储空间: 周期性获取 其剩余存储空间, 定期获取其剩余存储空间, 生成一数据时获取其 剩余存储空间等。 本实施例对 "第一数据所占的存储空间" 的大小不进行限定。 在步骤 102 之前, 该方法还可以包括: 获取所述第一数据所占 的存储空间, 以及所述第一服务器的剩余存储空间。 102: Determine a size relationship between a remaining storage space of the first server and a storage space occupied by the first data. The "remaining storage space of the server" refers to the available storage space in the storage space corresponding to the server and/or the storage space of the server itself. The remaining storage space may have a size of 0 or may include one or more storage units. The remaining storage space of each server may be deleted due to deletion of stored data. The data is updated by changing the size of the disk array corresponding to the server. The server may include, but is not limited to, obtaining the remaining storage space in the following manners: periodically acquiring the remaining storage space, periodically obtaining the remaining storage space, acquiring the remaining storage space when generating a data, and the like. This embodiment does not limit the size of the "storage space occupied by the first data". Before the step 102, the method may further include: acquiring a storage space occupied by the first data, and remaining storage space of the first server.
103 : 如果所述第一服务器的剩余存储空间大于或者等于所述第 一数据所占的存储空间, 且所述第一服务器的已使用存储空间大于 所述其他服务器的最小已使用存储空间时, 将所述第一数据存储在 所述第一服务器的剩余存储空间中。 其中, 步骤 103 具体可以包括: 所述第一服务器在确定其剩余 存储空间大于或者等于所述第一数据所占的存储空间, 且所述第一 服务器的已使用存储空间大于所述其他服务器的最小已使用存储空 间时, 为所述第一数据分配存储地址, 并将所述第一数据存储在所 述存储地址对应的存储单元中; 所述存储地址为所述第一服务器的 剩余存储空间中的一个或者多个存储单元对应的存储地址。 103: If the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is greater than the minimum used storage space of the other server, The first data is stored in a remaining storage space of the first server. The step 103 may specifically include: the first server determines that the remaining storage space is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is greater than that of the other server. When the storage space is the smallest, the first data is allocated a storage address, and the first data is stored in a storage unit corresponding to the storage address; the storage address is a remaining storage space of the first server. The storage address corresponding to one or more of the storage units.
示例性的, 通过一个具体示例对 "其他服务器的最小已使用存 储空间" 进行说明: 假设其他服务器由服务器 1、 服务器 2、 服务器 3构成, 该 3个服务器的已使用存储空间的大小分别为: A、 B、 C , 且 A > B > C ; 那么, 其他服务器的最小已使用存储空间为 C。  Exemplarily, the "minimum used storage space of other servers" is explained by a specific example: Assume that other servers are composed of server 1, server 2, and server 3, and the used storage spaces of the three servers are respectively: A, B, C, and A > B > C; then, the minimum used storage space of other servers is C.
进一步地, 为了与现有技术方案进行详细对比, 下面从第一数 据所占的存储空间与分布式存储系统的最小存储单元的最大值的大 小关系的角度对步骤 103 进行说明。 具体的, 在包含特征 "第一服 务器的剩余存储空间大于或者等于第一数据所占的存储空间 " 的情 况下, 步骤 103可以包括以下场景 1和场景 2 : 场景 1:第一数据所占的存储空间大于分布式存储系统的最小存 储单元的最大值, 且第一服务器的已使用存储空间大于其他服务器 的最小已使用存储空间。 场景 2 :第一数据所占的存储空间小于或者等于分布式存储系统 的最小存储单元的最大值, 且第一服务器的已使用存储空间大于其 他服务器的最小已使用存储空间。 其中, 针对场景 1 , 在现有技术方案中, 第一服务器需要对第一 数据进行分块, 并按照 "负载均衡" 的原则, 分别将每个块存储在 分布式存储系统的多个服务器的剩余存储空间中。 针对场景 2 , 在现 有技术方案中, 第一服务器需要将第一数据存储在其他服务器中的 最大剩余存储空间中。 需要说明的是, 实际实现时, 还可能出现以下场景 A和场景 B : 场景 A: 第一数据所占的存储空间大于分布式存储系统的最小 存储单元的最大值, 且第一服务器的已使用存储空间小于或者等于 其他服务器的最小已使用存储空间。 场景 B : 第一数据所占的存储空间小于或者等于分布式存储系 统的最小存储单元的最大值, 且第一服务器的已使用存储空间小于 或者等于其他服务器的最小已使用存储空间。 其中, 本文中提供了针对场景 A的实现方法, 在下述实施例二 中有相应描述。 针对场景 B , 与现有技术方案的实现方法相同, 具 体的, 第一服务器将第一数据存储在其剩余存储空间中。 综述, 由上述场景 1、 场景 2、 场景 A和场景 B可知, 实际实 现时, 本发明实施例提供的存储数据的方法不需要限定第一数据所 占的存储空间的大小, 也不需要限定第一服务器的已使用存储空间 与其他服务器的已使用存储空间的大小关系。 具体实现方式包括但 不限于下述实施例 1和实施例 2所示的方法。 在本发明的一个实施例中, 所述第一服务器包含一虚拟机, 所 述第一数据是所述虚拟机生成的数据; 所述其他服务器包括第二服 务器; 所述方法还包括下述步骤 A 1 -A2 : 步骤 A 1 : 如果所述第一服务器的剩余存储空间小于所述第一数 据所占的存储空间, 则向所述第二服务器发送包含所述第一数据的 第一指示消息; 所述第一指示消息用于指示所述第二服务器将所述 第一数据存储在所述第二服务器的剩余存储空间中。 Further, in order to make a detailed comparison with the prior art solution, step 103 will be described below from the perspective of the relationship between the storage space occupied by the first data and the maximum value of the minimum storage unit of the distributed storage system. Specifically, the inclusion of the feature "the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data" In the following, step 103 may include the following scenario 1 and scenario 2: scenario 1: the storage space occupied by the first data is larger than the maximum storage unit of the distributed storage system, and the used storage space of the first server is larger than other servers. The smallest used storage space. Scenario 2: The storage space occupied by the first data is less than or equal to the maximum storage unit of the distributed storage system, and the used storage space of the first server is larger than the minimum used storage space of other servers. In the prior art solution, the first server needs to block the first data, and stores each block in multiple servers of the distributed storage system according to the principle of “load balancing”. In the remaining storage space. For scenario 2, in the prior art solution, the first server needs to store the first data in the largest remaining storage space in the other servers. It should be noted that, in actual implementation, the following scenario A and scenario B may occur: scenario A: The storage space occupied by the first data is greater than the maximum storage unit of the distributed storage system, and the first server is used. The storage space is less than or equal to the minimum used storage space of other servers. Scenario B: The storage space occupied by the first data is less than or equal to the maximum storage unit of the distributed storage system, and the used storage space of the first server is less than or equal to the minimum used storage space of other servers. Wherein, the implementation method for the scenario A is provided herein, which is correspondingly described in the following embodiment 2. For the scenario B, the implementation method is the same as that of the prior art solution. Specifically, the first server stores the first data in its remaining storage space. It is to be noted that, in the foregoing scenario 1, the scenario 2, the scenario A, and the scenario B, the method for storing data provided by the embodiment of the present invention does not need to limit the size of the storage space occupied by the first data, and does not need to be limited. Used storage space of a server The size relationship with the used storage space of other servers. Specific implementations include, but are not limited to, the methods shown in Embodiments 1 and 2 below. In an embodiment of the present invention, the first server includes a virtual machine, the first data is data generated by the virtual machine, and the other server includes a second server. The method further includes the following steps. A 1 -A2 : Step A 1 : sending a first indication message including the first data to the second server, if the remaining storage space of the first server is smaller than the storage space occupied by the first data The first indication message is used to instruct the second server to store the first data in a remaining storage space of the second server.
步骤 A2 : 在所述虚拟机对应的除所述第一数据之外的其他数据 所占的存储空间小于或者等于所述第二服务器的剩余存储空间时, 将所述虚拟机和所述其他数据迁移到所述第二服务器上。  Step A2: when the storage space occupied by the data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage space of the second server, the virtual machine and the other data are used. Migrate to the second server.
其中, "第二服务器" 可以为该分布式存储系统中的、 除第一服 务器之外的、 满足 "剩余存储空间大于或者等于所述虚拟机对应的 除第一数据之外的其他数据所占的存储空间" 条件的任一服务器。  The second server may be any other than the first data in the distributed storage system except that the remaining storage space is greater than or equal to the first data other than the virtual machine. The storage space "conditions for any server.
步骤 A 1 可以包括: A l l ) 如果所述第一服务器在确定其剩余存 储空间小于所述第一数据所占的存储空间, 则确定与所述虚拟机对 应的除所述第一数据之外的其他数据所占的存储空间的大小; A 12) 将剩余存储空间大于或者等于该存储空间的服务器作为第二服务 器; A 13)向所述第二服务器发送包含所述第一数据的第一指示消息。  Step A 1 may include: A ll) if the first server determines that the remaining storage space is smaller than the storage space occupied by the first data, determining, in addition to the first data, corresponding to the virtual machine The size of the storage space occupied by the other data; A 12) the server having the remaining storage space greater than or equal to the storage space as the second server; A 13) transmitting the first data including the first data to the second server Indicate the message.
示例性的, "将所述虚拟机和所述虚拟机对应的其他数据迁移 到所述第二服务器上" 的具体实现方式如现有技术, 此处不再描述。  Exemplarily, the specific implementation of "migrating the virtual machine and other data corresponding to the virtual machine to the second server" is as described in the prior art, and is not described here.
需要说明的是, 实际实现时, 步骤 A2可以在步骤 A 1之后立即 执行; 也可以在所述虚拟机需要读取第一数据时执行。 其中, 前者 可以描述为: 在将第一数据写入第二服务器时实现第一数据的本地 化; 后者可以描述为: 在所述虚拟机需要读取所述第一数据时实现 第一数据的本地化。 该实施例中, 在 "第一服务器将所述虚拟机迁移到第二服务器 上" 之后, 所述虚拟机成为安装在第二服务器上的一虚拟机, 第一 服务器上不再存在所述虚拟机。 在 "第一服务器将与所述其他数据 迁移到第二服务器上" 之后, 所述其他数据均存储在第二服务器的 存储空间中。 另外, 可以将该可选的实施例称为通过虚拟机迁移的 方式实现第一数据的本地化。 在本发明的另一个实施例中, 所述其他服务器包括第二服务器; 所述方法还包括下述步骤 B 1 -B4 : 步骤 B 1 : 如果所述第一服务器的剩余存储空间小于所述第一数 据所占的存储空间, 则向所述第二服务器发送包含所述第一数据的 第一指示消息; 所述第一指示消息用于指示所述第二服务器将所述 第一数据存储在所述第二服务器的剩余存储空间中。 步骤 B2 : 更新所述第一服务器的剩余存储空间。 步骤 B3 : 当所述第一服务器更新后的剩余存储空间大于或者等 于所述第一数据所占的存储空间时, 向所述第二服务器发送第二指 示消息; 所述第二指示消息用于指示所述第二服务器将所述第一数 据迁移到所述第一服务器。 步骤 B4 : 接收所述第二服务器发送的所述第一数据; 将所述第 一数据存储在所述第一服务器更新后的剩余存储空间中。 其中, 在该实施例中, 第二服务器在向第一服务器发送第一数 据之后, 第二服务器可以将本地存储的第一数据删除, 也可以不删 除。 在前者的实现方式中, 可以将本实施例称为通过第一数据迁移 的方式实现第一数据的本地化; 在后者的实现方式中, 可以认为分 布式存储系统中存储的第一数据的副本由 n副本变成了 n+ 1 副本, 其中, 存储第一数据的副本的方法可以参见下文相关的实施例。 需 要说明的是, 为了与上述可选的实施例对应, 下文中将该可选的实 施例称为通过第一数据迁移的方式实现第一数据的本地化。 在本发明的又一实施例中: 所述第一服务器包含一虚拟机, 所 述第一数据是所述虚拟机生成的数据, 所述其他服务器还包括第三 服务器, 所述方法还包括以下步骤 C : 步骤 C : 所述第一服务器向所述第三服务器发送包含所述第一 数据的副本的第三指示消息, 所述第三指示消息用于指示所述第三 服务器将所述第一数据的副本存储在所述第三服务器的剩余存储空 间中。 It should be noted that, in actual implementation, step A2 may be performed immediately after step A1; or may be performed when the virtual machine needs to read the first data. The former can be described as: localizing the first data when the first data is written to the second server The latter can be described as: localization of the first data is implemented when the virtual machine needs to read the first data. In this embodiment, after the first server migrates the virtual machine to the second server, the virtual machine becomes a virtual machine installed on the second server, and the virtual machine does not exist on the first server. machine. After the "first server will migrate with the other data to the second server", the other data is stored in the storage space of the second server. Additionally, this alternative embodiment may be referred to as localizing the first data by way of virtual machine migration. In another embodiment of the present invention, the other server includes a second server; the method further includes the following steps B 1 -B4 : Step B 1 : if the remaining storage space of the first server is smaller than the first a storage space occupied by the data, sending a first indication message including the first data to the second server; the first indication message is used to indicate that the second server stores the first data in The remaining storage space of the second server. Step B2: Update the remaining storage space of the first server. Step B3: Send a second indication message to the second server when the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, where the second indication message is used. Instructing the second server to migrate the first data to the first server. Step B4: receiving the first data sent by the second server; storing the first data in a remaining storage space after the first server is updated. In this embodiment, after the second server sends the first data to the first server, the second server may delete the first data stored locally or may not delete the first data. In the implementation manner of the former, the embodiment may be referred to as localizing the first data by means of the first data migration; in the implementation manner of the latter, The copy of the first data stored in the cloth storage system is changed from n copies to n+ 1 copies, wherein the method of storing the copy of the first data can be seen in the related embodiments below. It should be noted that, in order to correspond to the foregoing optional embodiment, the optional embodiment is hereinafter referred to as realizing localization of the first data by means of the first data migration. In still another embodiment of the present invention, the first server includes a virtual machine, the first data is data generated by the virtual machine, and the other server further includes a third server, where the method further includes the following Step C: Step C: The first server sends a third indication message that includes a copy of the first data to the third server, where the third indication message is used to indicate that the third server is to be the third A copy of the data is stored in the remaining storage space of the third server.
其中, "第三服务器" 可以用于存储第一数据的副本, 分布式存 储系统中可以包含一个或者多个第三服务器。 实际实现时, 分布式 存储系统中的每个服务器均可获知该分布式存储系统中所有服务器 的剩余存储空间。 该实施例中, 第一服务器可以按照 "负载均衡" 的原则, 选择分布式存储系统中的一个或者多个服务器作为第三服 务器。  The "third server" may be used to store a copy of the first data, and the distributed storage system may include one or more third servers. In actual implementation, each server in the distributed storage system can know the remaining storage space of all servers in the distributed storage system. In this embodiment, the first server may select one or more servers in the distributed storage system as the third server according to the principle of "load balancing".
该实施例通过存储第一数据的副本, 可以达到增强分布式存储 系统的性能的有益效果。 具体的: 当第一数据损坏或者丟失时, 可 以通过调用第一数据的副本使分布式存储系统正常运行, 从而增强 系统的稳定性。 本发明实施例提供的存储数据的方法, 应用于包含第一服务器 和其他服务器的分布式存储系统中, 在第一服务器确定其剩余存储 空间大于或者等于其生成的一数据所占的存储空间, 且第一服务器 的已使用存储空间大于其他服务器的最小已使用存储空间时, 优先 将该数据存储在该服务器的剩余存储空间中。 这样, 第一服务器可 以直接从本地读取该数据, 而不需要从网络中的其他服务器上读取 该数据, 从而达到缩短时延、 提高系统性能的有益效果。 解决了现 有技术中, 因在网络中的其他服务器上读取数据导致的时延长、 系 统性能较差的问题。 实施例二 本实施例提供的存储数据的方法, 应用于分布式存储系统, 所 述分布式存储系统包括第一服务器和其他服务器。 本实施例描述的 是上述实施例一中的场景 A下存储数据的方法。 如图 2所示, 包括: This embodiment can achieve the beneficial effect of enhancing the performance of the distributed storage system by storing a copy of the first data. Specifically: When the first data is damaged or lost, the distributed storage system can be operated normally by calling a copy of the first data, thereby enhancing the stability of the system. The method for storing data provided by the embodiment of the present invention is applied to a distributed storage system including a first server and other servers, where the first server determines that the remaining storage space is greater than or equal to the storage space occupied by the data generated by the first server. When the used storage space of the first server is larger than the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server. In this way, the first server can By reading the data directly from the local, without having to read the data from other servers in the network, the benefits of shortening the delay and improving system performance are achieved. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. Embodiment 2 The method for storing data provided in this embodiment is applied to a distributed storage system, where the distributed storage system includes a first server and other servers. This embodiment describes a method for storing data in scenario A in the first embodiment. As shown in Figure 2, it includes:
201 : 确定所述第一服务器生成的第一数据; 所述第一数据所占 的存储空间大于所述分布式存储系统的最小存储单元的最大值。 201: Determine first data generated by the first server; the storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system.
202 : 判断所述第一服务器的剩余存储空间与所述第一数据所占 的存储空间的大小关系。 202: Determine a size relationship between a remaining storage space of the first server and a storage space occupied by the first data.
203 : 如果所述第一服务器的剩余存储空间大于或者等于所述第 一数据所占的存储空间, 且所述第一服务器的已使用存储空间小于 或者等于所述其他服务器的最小已使用存储空间时, 将所述第一数 据存储在所述第一服务器的剩余存储空间中。 进一步地, 针对本实施例的场景 ( 即场景 A ) , 在现有技术方案 中, 第一服务器需要对第一数据进行分块, 并按照 "负载均衡" 的 原则, 分别将每个块存储在分布式存储系统的多个服务器的剩余存 储空间中。 可选的, 在本发明的一个实施例中, 所述方法还可以包括: 上 述实施例一中的步骤 A 1 -A2 , 或者上述实施例一中的步骤 B 1 -B4 ; 另外, 还可以包括上述实施例一中的步骤 C。 203: If the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is less than or equal to the minimum used storage space of the other server. And storing the first data in a remaining storage space of the first server. Further, for the scenario of the embodiment (ie, scenario A), in the prior art solution, the first server needs to block the first data, and store each block separately according to the principle of “load balancing”. The remaining storage space of multiple servers in a distributed storage system. Optionally, in an embodiment of the present invention, the method may further include: steps A 1 -A2 in the first embodiment, or steps B 1 -B4 in the first embodiment; and Step C in the first embodiment above.
需要说明的是, 本实施例中的相关解释可以参考上述实施例一 的相关部分。 本发明实施例提供的存储数据的方法, 应用于包含第一服务器 和其他服务器的分布式存储系统中, 在第一服务器确定其剩余存储 空间大于或者等于其生成的一数据所占的存储空间, 且第一服务器 的已使用存储空间小于或者等于其他服务器的最小已使用存储空间 时, 优先将该数据存储在该服务器的剩余存储空间中; 其中, 该数 据所占的存储空间大于分布式存储系统的最小存储单元的最大值。 这样, 第一服务器可以直接从本地读取该数据, 而不需要从网络中 的其他服务器上读取该数据, 从而达到缩短时延、 提高系统性能的 有益效果。 解决了现有技术中, 因在网络中的其他服务器上读取数 据导致的时延长、 系统性能较差的问题。 下面通过几个具体的实施例对上述实施例一和实施例二提供的 存储数据的方法进行示例性说明: 实施例 1 本实施例中第一服务器上不包含虚拟机。 本实施例中的 "本地" 是指生成数据的应用所在的服务器。 如图 3所示, 为本实施例提供的一种存储数据的方法, 包括: It should be noted that the related explanation in this embodiment may refer to the foregoing embodiment 1. The relevant part. The method for storing data provided by the embodiment of the present invention is applied to a distributed storage system including a first server and other servers, where the first server determines that the remaining storage space is greater than or equal to the storage space occupied by the data generated by the first server. If the used storage space of the first server is less than or equal to the minimum used storage space of the other server, the data is preferentially stored in the remaining storage space of the server; wherein the data occupies a larger storage space than the distributed storage system. The maximum value of the smallest memory unit. In this way, the first server can directly read the data from the local without reading the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving system performance. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. The method for storing data provided in the foregoing Embodiment 1 and Embodiment 2 is exemplified by the following specific embodiments: Embodiment 1 In this embodiment, the virtual machine is not included in the first server. "Local" in this embodiment refers to a server where an application for generating data is located. As shown in FIG. 3, a method for storing data according to this embodiment includes:
301 : 第一服务器 (物理机) 上安装的一应用生成一数据。 示例性的, 这里的 "应用 " 可以为现有技术中的任何一种应用, 例如, 文字处理应用、 音频处理应用、 视频图片处理应用、 计算机 控制应用、 计算机辅助设计应用、 科学仿真应用等。 假设 4次执行该步骤 301 , 第一服务器(物理机)上安装的一应 用共生成 4个数据, 分别为 D l、 D2、 D3、 D4。 301: An application installed on the first server (physical machine) generates a data. Illustratively, the "application" herein may be any one of the prior art applications, such as word processing applications, audio processing applications, video picture processing applications, computer control applications, computer aided design applications, scientific simulation applications, and the like. Assuming that the step 301 is performed four times, an application installed on the first server (physical machine) generates a total of four data, which are D l, D2, D3, and D4.
302 : 第一服务器获取第一服务器的剩余存储空间和该数据所占 存储空间。 具体地, 步骤 302 可以实现为: 第一服务器上的分布式存储程 序获取第一服务器的剩余存储空间和该数据所占存储空间 302: The first server acquires a remaining storage space of the first server and a storage space occupied by the data. Specifically, the step 302 may be implemented as follows: the distributed storage program on the first server acquires the remaining storage space of the first server and the storage space occupied by the data.
示例性的, 按照步骤 301 中的示例, 4次执行步骤 302, 获取的 第一服务器的剩余存储空间分别为: XI、 X2、 X3、 X4; 数据 Dl、 D2、 D3、 D4所占的空间的大小分别为: Ml、 M2、 M3、 M4。  Exemplarily, according to the example in step 301, step 302 is performed four times, and the remaining storage spaces of the obtained first server are: XI, X2, X3, X4; the space occupied by the data D1, D2, D3, D4 The sizes are: Ml, M2, M3, M4.
303: 第一服务器判断其剩余存储空间是否大于或者等于该数据 所占存储空间。 若是, 则执行步骤 304; 若否, 则执行步骤 305。 具体地, 步骤 303 可以实现为: 第一服务器上的分布式存储程 序判断第一服务器的剩余存储空间是否大于或者等于该数据所占存 储空间。 303: The first server determines whether the remaining storage space is greater than or equal to the storage space occupied by the data. If yes, go to step 304; if no, go to step 305. Specifically, the step 303 may be implemented as: determining, by the distributed storage program on the first server, whether the remaining storage space of the first server is greater than or equal to the storage space occupied by the data.
示例性的, 按照步骤 302中的示例, 4叚设: XI > Ml、 X2 > M2、 X3=M3、 X4 < M4。  Exemplarily, according to the example in step 302, 4: XI > Ml, X2 > M2, X3 = M3, X4 < M4.
304: 第一服务器将该数据存储在第一服务器的剩余存储空间 中。 具体包括: 第一服务器上的分布式存储程序为该数据分配存储 地址, 并将该数据存储在该存储地址对应的存储模块中; 该存储地 址为第一服务器的剩余存储空间中的一个或者多个存储模块对应的 存储地址。 在执行步骤 304之后, 则结束。 示例性的, 按照步骤 303 中的示例, Dl、 D2、 D3 分别存储第 一服务器的 (剩余) 存储空间中。 假设第一服务器为 Dl、 D2、 D3 分配的存储地址分别为: Sl/Dl/offsetl、 Sl/D2/offset2、 Sl/D2/offset3。 其中, SI 表示第一服务器, Sl/Dl/offsetl 表示: 数据 D1 的存储地 址位于第一服务器 S1 的存储空间的 offsetl 处, 其他的存储地址不 再 解译。 第 3 次执行步骤 301 -306之后, 分布式存储系统中记录的数据 路由表如表 1 所示: 304: The first server stores the data in the remaining storage space of the first server. Specifically, the distributed storage program on the first server allocates a storage address to the data, and stores the data in a storage module corresponding to the storage address; the storage address is one or more of the remaining storage spaces of the first server. The storage address corresponding to the storage module. After performing step 304, it ends. Exemplarily, according to the example in step 303, D1, D2, and D3 are respectively stored in the (remaining) storage space of the first server. Assume that the storage addresses allocated by the first server for D1, D2, and D3 are: Sl/Dl/offsetl, Sl/D2/offset2, and Sl/D2/offset3. Wherein, SI represents the first server, and Sl/Dl/offsetl indicates that: the storage address of the data D1 is located at the offset1 of the storage space of the first server S1, and the other storage addresses are not interpreted. After the third execution of steps 301-306, the data routing table recorded in the distributed storage system is shown in Table 1:
表 1  Table 1
Figure imgf000020_0002
Figure imgf000020_0002
305 : 第一服务器向第二服务器发送包含该数据的第一指示消 息; 第一指示消息用于指示第二服务器将该数据存储在第二服务器 的剩余存储空间中。  305: The first server sends a first indication message that includes the data to the second server. The first indication message is used to instruct the second server to store the data in the remaining storage space of the second server.
在执行步骤 305之后, 执行步骤 306。  After performing step 305, step 306 is performed.
306 : 第二服务器根据第一指示消息将该数据存储在第二服务器 的剩余存储空间中。 具体包括: 第二服务器上的分布式存储程序为 该数据分配存储地址, 并将该数据存储在该存储地址对应的存储模 块中; 该存储地址为第二服务器的剩余存储空间中的一个或者多个 存储模块对应的存储地址。  306: The second server stores the data in the remaining storage space of the second server according to the first indication message. Specifically, the distributed storage program on the second server allocates a storage address to the data, and stores the data in a storage module corresponding to the storage address; the storage address is one or more of the remaining storage spaces of the second server. The storage address corresponding to the storage module.
示例性的,按照步骤 303 中的示例, D4存储在第二服务器的(剩 余) 存储空间中。 假设第二服务器为 D4 分配的存储地址分别为: S2/D4/offset4。 其中, S2 表示第二服务器, S2/D4/offset4 表示数据 D4的存储地址位于第二服务器 S2的存储空间的 offset4处。 第 4 次执行步骤 301 -306之后, 分布式存储系统中记录的数据 路由表如表 2所示:
Figure imgf000020_0001
Dl SI XI Sl/Dl/offsetl
Illustratively, according to the example in step 303, D4 is stored in the (remaining) storage space of the second server. Assume that the storage address assigned by the second server to D4 is: S2/D4/offset4. Wherein, S2 represents the second server, and S2/D4/offset4 indicates that the storage address of the data D4 is located at the offset4 of the storage space of the second server S2. After the fourth execution of steps 301-306, the data routing table recorded in the distributed storage system is as shown in Table 2:
Figure imgf000020_0001
Dl SI XI Sl/Dl/offsetl
D2 SI X2 Sl/D2/offset2 D2 SI X2 Sl/D2/offset2
D3 SI X3 Sl/D3/offset3 D3 SI X3 Sl/D3/offset3
D4 SI X4 S2/D4/offset4 由表 2可知, 获取数据 D4的服务器与存储数据 D4的服务器为 为同一服务器。 D4 SI X4 S2/D4/offset4 As shown in Table 2, the server that obtains data D4 and the server that stores data D4 are the same server.
307: 第一服务器更新第一服务器的剩余存储空间, 并周期性检 测第一服务器更新后的剩余存储空间。 具体地, 步骤 307 可以实现为: 第一服务器上的分布式存储程 序更新第一服务器的剩余存储空间, 并周期性检测第一服务器更新 后的剩余存储空间。 307: The first server updates the remaining storage space of the first server, and periodically detects the remaining storage space after the first server is updated. Specifically, the step 307 may be implemented as: the distributed storage program on the first server updates the remaining storage space of the first server, and periodically detects the remaining storage space after the first server is updated.
示例性的, 按照步骤 306 中的示例, 将第 4次执行步骤 301-306 之后, 执行步骤 307 时, 获得的第一服务器更新后的剩余存储空间 表示为 X4' 。 4叚设 X4' > M4。  Exemplarily, according to the example in step 306, after performing step 301-306 for the fourth time, when step 307 is performed, the obtained remaining storage space of the first server is represented as X4'. 4 Set X4' > M4.
308: 第一服务器判断其更新后的剩余存储空间是否大于或者等 于该数据所占的存储空间。 308: The first server determines whether the updated remaining storage space is greater than or equal to the storage space occupied by the data.
若否, 则返回步骤 307; 若是, 则执行步骤 309。 具体地, 步骤 308 可以实现为: 第一服务器上的分布式存储程 序判断第一服务器更新后的剩余存储空间是否大于或者等于该数据 所占的存储空间。  If no, the process returns to step 307; if yes, step 309 is performed. Specifically, the step 308 can be implemented as follows: The distributed storage program on the first server determines whether the remaining storage space after the first server is updated is greater than or equal to the storage space occupied by the data.
示例性的, 按照步骤 307 中的示例, 步骤 308具体为: 第一服 务器判断 X4' 是否大于或者等于 M4。  Exemplarily, according to the example in step 307, step 308 is specifically as follows: The first server determines whether X4' is greater than or equal to M4.
309: 第一服务器向第二服务器发送第二指示消息; 第二指示消 息用于指示第二服务器将该数据发送到第一服务器。 310: 第二服务器根据第二指示消息向第一服务器发送该数据。 309: The first server sends a second indication message to the second server, where the second indication message is used to instruct the second server to send the data to the first server. 310: The second server sends the data to the first server according to the second indication message.
311: 第一服务器将该数据存储在第一服务器更新后的剩余存储 空间中。 执行步骤 311之后, 则结束。 具体地, 步骤 311 可以实现为: 第一服务器上的分布式存储程 序将该数据存储在第一服务器更新后的剩余存储空间中。 示例性的, 按照步骤 307 中的示例, 执行步骤 311 之后, 分布 式存储系统中记录的数据路由表如表 3所示: 表 3311: The first server stores the data in the remaining storage space after the first server is updated. After step 311 is performed, it ends. Specifically, the step 311 may be implemented as: the distributed storage program on the first server stores the data in the remaining storage space after the first server is updated. Exemplarily, according to the example in step 307, after performing step 311, the data routing table recorded in the distributed storage system is shown in Table 3: Table 3
Figure imgf000022_0001
Figure imgf000022_0001
由表 3可知, 获取数据 D4的服务器与存储数据 D4的服务器为 同一服务器。 其中, SI/ D4/ offset4表示数据 D4的存储地址位于第 一服务器 S1 的 offset4处。 可选的, 在步骤 301之后, 该方法还可以包括以下步骤 A和步 骤 B: 步骤 A: 第一服务器向第三服务器发送包含该数据的副本的第 三指示消息, 第三指示消息用于指示第三服务器将该数据的副本存 储在第三服务器的剩余存储空间中。 示例性的 , 按照实施例 1 中的示例, 将 D 1、 D2、 D3、 D4的副 本分别表示为: Dl' 、 D2' 、 D3' 、 D4' 。 步骤 B: 第三服务器根据第三指示消息将该数据的副本存储在 第三服务器的剩余存储空间中。 具体地, 步骤 B可以实现为: 第三服务器上的分布式存储程序 根据第三指示消息将该数据的副本存储在第三服务器的剩余存储空 间中。 As can be seen from Table 3, the server that acquires the data D4 and the server that stores the data D4 are the same server. Wherein SI/D4/offset4 indicates that the storage address of the data D4 is located at the offset 4 of the first server S1. Optionally, after step 301, the method may further include the following steps A and B: Step A: The first server sends a third indication message including a copy of the data to the third server, where the third indication message is used to indicate The third server stores a copy of the data in the remaining storage space of the third server. Illustratively, according to the example in Embodiment 1, the pair of D 1 , D 2 , D 3 , D 4 This is expressed as: Dl', D2', D3', D4'. Step B: The third server stores the copy of the data in the remaining storage space of the third server according to the third indication message. Specifically, step B may be implemented as: the distributed storage program on the third server stores the copy of the data in the remaining storage space of the third server according to the third indication message.
示例性的, 按照实施例 1 中的示例,假设第三服务器为 Dl、 D2、 D3、 D4分配的存储地址分别为: S3/D1' /offset 1, S3/D2' /offset2、 S3/D3' /offset3、 S3/D4' /offset4 , 其中, S3表示第三服务器, S3/D 1 ' /offsetl 表示。 数据 D1 的副本 D1' 存储地址位于第三服务器 S3 的存储空间的 offsetl处, 其他的存储地址不再——解释。 在第 3 次执行步骤 301-306 以及步骤 A、 步骤 B之后, 分布式 存储系统中记录的数据路由表如表 4所示:  Exemplarily, according to the example in Embodiment 1, it is assumed that the storage addresses allocated by the third server for D1, D2, D3, and D4 are: S3/D1' /offset 1, S3/D2' /offset2, S3/D3' /offset3, S3/D4' /offset4 , where S3 represents the third server, S3/D 1 ' /offsetl representation. A copy of the data D1 D1' storage address is located at the offset1 of the storage space of the third server S3, and the other storage addresses are no longer - explained. After the third execution of steps 301-306 and steps A and B, the data routing table recorded in the distributed storage system is shown in Table 4:
表 4  Table 4
Figure imgf000023_0001
D2 SI X2 Sl/D2/offset2 Ό2' S3/D2' /offset2
Figure imgf000023_0001
D2 SI X2 Sl/D2/offset2 Ό2'S3/D2' /offset2
D3 SI X3 Sl/D3/offset3 D3' S3/D3' /offset3D3 SI X3 Sl/D3/offset3 D3' S3/D3' /offset3
D4 SI X4 S2/D4/offset4 Ό4' S3/D4' /offset3 进一步地, 该步骤 A和步骤 B用于增强系统的稳定性, 具体的, 若第二服务器的存储空间中存储的该数据丟失或者损坏时, 第一服 务器可以向第三服务器发送将该数据的副本发送至第一服务器的指 示消息; 使得第三服务器根据根据该指示消息向第一服务器发送该 数据的副本; 第一服务器将该数据的副本存储在第一服务器更新后 的剩余存储空间中。 本发明实施例提供的存储数据的方法, 在第一服务器确定其剩 余存储空间大于或者等于其安装的一应用生成的一数据所占的存储 空间时, 优先将该数据存储在该服务器的剩余存储空间中; 在第一 服务器确定其剩余存储空间小于该数据所占的存储空间时, 将该数 据存储在第二服务器的剩余存储空间中, 并在确定第一服务器更新 后的剩余存储空间大于或者等于该数据所占的存储空间时, 将该数 据存储在第一服务器更新后的剩余存储空间中。 这样, 第一服务器 上安装的应用可以直接从本地 (第一服务器的存储空间 ) 读取该数 据, 不需要从网络中的其他服务器上读取该数据, 从而达到缩短时 延、 提高系统性能的有益效果。 解决了现有技术中, 因在网络中的 其他服务器上读取数据导致的时延长、 系统性能较差的问题。 实施例 2 本实施例中第一服务器上包含虚拟机。 本实施例中的 "本地" 是指生成数据的虚拟机所在的服务器。 如图 4所示, 为本实施例提供的一种存储数据的方法, 包括: D4 SI X4 S2/D4/offset4 Ό4' S3/D4' /offset3 Further, step A and step B are used to enhance the stability of the system, specifically, if the data stored in the storage space of the second server is lost or When damaged, the first server may send an indication message to the third server to send a copy of the data to the first server; causing the third server to send a copy of the data to the first server according to the indication message; the first server A copy of the data is stored in the remaining storage space after the first server is updated. The method for storing data provided by the embodiment of the present invention, when the first server determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by an application installed by the first server, the data is preferentially stored in the remaining storage of the server. In the space; when the first server determines that the remaining storage space is less than the storage space occupied by the data, storing the data in the remaining storage space of the second server, and determining that the remaining storage space after the first server is updated is greater than or When it is equal to the storage space occupied by the data, the data is stored in the remaining storage space after the first server is updated. In this way, the application installed on the first server can directly read the data from the local (the storage space of the first server), and does not need to read the data from other servers in the network, thereby shortening the delay and improving the system performance. Beneficial effect. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. Embodiment 2 In this embodiment, a virtual machine is included on the first server. "Local" in this embodiment refers to a server where the virtual machine that generates data is located. As shown in FIG. 4, a method for storing data according to this embodiment includes:
401: 第一服务器上安装的虚拟机生成一数据。 示例性的, 假设第一服务器上安装有 4个虚拟机 ( VM1、 VM2、 VM3、 VM4), 4执行该步骤 401, 具体为: VM1、 VM2、 VM3、 VM4 分别获取数据 Dl、 D2、 D3、 D4。 401: The virtual machine installed on the first server generates a data. Exemplarily, it is assumed that four virtual machines (VM1, VM2, VM3, VM4) are installed on the first server, and the step 401 is executed. Specifically, VM1, VM2, VM3, and VM4 respectively acquire data D1, D2, and D3. D4.
402: 第一服务器获取第一服务器的剩余存储空间和该数据所占 存储空间。 402: The first server acquires a remaining storage space of the first server and a storage space occupied by the data.
403: 第一服务器判断其剩余存储空间是否大于或者等于该数据 所占存储空间。 若是, 则执行步骤 404; 若否, 则执行步骤 405。  403: The first server determines whether the remaining storage space is greater than or equal to the storage space occupied by the data. If yes, go to step 404; if no, go to step 405.
404: 第一服务器将该数据存储在第一服务器的剩余存储空间 中。 404: The first server stores the data in the remaining storage space of the first server.
在执行步骤 404之后, 则结束。 需要说明的是, 步骤 402-步骤 404 的示例可以参考上述实施例 1 中的步骤 302-304, 此处不再贅述。  After performing step 404, it ends. It should be noted that the examples in step 402 to step 404 may refer to steps 302-304 in the foregoing embodiment 1, and details are not described herein again.
405: 第一服务器确定与步骤 401 中的虚拟机对应的除所述第一 数据之外的其他数据所占的存储空间的大小, 将其标记为 W。 405: The first server determines the size of the storage space occupied by the data other than the first data corresponding to the virtual machine in step 401, and marks it as W.
406: 第一服务器确定分布式存储系统中、 剩余存储空间大于或 者等于 W的服务器, 作为第二服务器。 406: The first server determines, as a second server, a server in the distributed storage system that has a remaining storage space greater than or equal to W.
407: 第一服务器向第二服务器发送包含该数据的第一指示消 息; 第一指示消息用于指示第二服务器将该数据存储在第二服务器 的剩余存储空间中。 407: The first server sends a first indication message that includes the data to the second server. The first indication message is used to instruct the second server to store the data in the remaining storage space of the second server.
408: 第二服务器根据第一指示消息将该数据存储在第二服务器 的剩余存储空间中。  408: The second server stores the data in the remaining storage space of the second server according to the first indication message.
需要说明的是, 步骤 407- 408 中的具体示例可以参考上述实施 例 1 中的步骤 305-306相同, 此处不再贅述。 另外, 实施例 1 中的 表 1和表 2也可以适用于本实施的对应步骤中。 进一步地, 为了清楚对比实施例 1和实施例 2 , 在本实施例中, 上述表 1和表 2可以分别表示为以下表 和表 2' : 表 It should be noted that the specific examples in the steps 407-408 may be the same as the steps 305-306 in the foregoing Embodiment 1, and details are not described herein again. In addition, in the first embodiment Tables 1 and 2 can also be applied to the corresponding steps of the present embodiment. Further, in order to clearly compare Embodiment 1 and Embodiment 2, in the present embodiment, Table 1 and Table 2 above can be respectively expressed as the following Table and Table 2': Table
Figure imgf000026_0001
Figure imgf000026_0001
 Table
Figure imgf000026_0002
Figure imgf000026_0002
由表 2' 可知, 获取 D4的虚拟机 VM4所在的服务器 S 1 与存储 D4的服务器 S2不是同一服务器。  As can be seen from Table 2', the server S 1 where the virtual machine VM4 of D4 is located is not the same server as the server S2 where D4 is stored.
409 : 第一服务器将该虚拟机和该虚拟机生成的其他数据迁移到 第二服务器上。 执行步骤 409之后, 则结束。 示例性的, 假设数据路由表中记录的、 与该虚拟机存在对应关 系的所有数据为: D l、 D2、 D3、 D4 , 则步骤 409具体为: 第一服务 器将该虚拟机和 D l、 D2、 D3迁移到第二服务器上。 示例性的, 按照步骤 408 中的示例, 执行步骤 409之后, 分布 式存储系统中记录的数据路由表如表 3' 所示: 表 y 409: The first server migrates the virtual machine and other data generated by the virtual machine to the second server. After step 409 is performed, it ends. Exemplarily, all the data recorded in the data routing table and corresponding to the virtual machine are: D l, D2, D3, D4, then step 409 is specifically: the first server uses the virtual machine and D l, D2, D3 migrated to the second server. Exemplarily, according to the example in step 408, after step 409, the distribution The data routing table recorded in the storage system is shown in Table 3': Table y
Figure imgf000027_0001
Figure imgf000027_0001
由表 3' 可知, 获取 D4的虚拟机 VM4所在的服务器 S2与存储 D4的服务器 S2为同一服务器。 可选的, 该方法还可以包括上述实施例 1 中的步骤 A和步骤 B。 为了清楚对比实施例 1 和实施例 2, 在本实施例中, 上述表 4 和表 5可以分别表示为以下表 4' 和表 5' : 表 4'  As can be seen from Table 3', the server S2 where the virtual machine VM4 that acquires D4 is located is the same server as the server S2 that stores D4. Optionally, the method may further include step A and step B in the above embodiment 1. In order to clearly compare Embodiment 1 and Embodiment 2, in the present embodiment, Table 4 and Table 5 above can be expressed as Table 4' and Table 5', respectively: Table 4'
Figure imgf000027_0002
VM2 D2 S I X2 S I / D2/ offset2 D2 ' S3/D2' /offset2
Figure imgf000027_0002
VM2 D2 SI X2 SI / D2/ offset2 D2 'S3/D2' /offset2
VM3 D3 S I X3 S I / D3/ offset3 D3 ' S3/D3 ' /offset3VM3 D3 S I X3 S I / D3/ offset3 D3 ' S3/D3 ' /offset3
VM4 D4 S I X4 S2/ D4/ offset4 D4 ' S3/D4' /offset3 本发明实施例提供的存储数据的方法, 在第一服务器确定其剩 余存储空间大于或者等于其上的一虚拟机生成的一数据所占的存储 空间时, 优先将该数据存储在该服务器的剩余存储空间中; 在第一 服务器确定其剩余存储空间小于该数据所占的存储空间时, 将该数 据存储在第二服务器的存储空间中, 并将该虚拟机迁移到第二服务 器上。 这样, 虚拟机可以直接从本地 (第二服务器的存储空间 ) 读 取数据, 不需要从网络中的其他服务器上读取数据, 从而达到缩短 时延、 提高系统性能的有益效果。 解决了现有技术中, 因在网络中 的其他服务器上读取数据导致的时延长、 系统性能较差的问题。 实施例三 如图 5所示, 为本实施例提供的一种服务器 1 , 应用于分布式存 储系统, 所述分布式存储系统还包括其他服务器, 所述服务器 1 用 以执行图 1所示的存储数据的方法, 所述服务器 1 包括: VM4 D4 SI X4 S2/D4/offset4 D4 'S3/D4' /offset3 The method for storing data provided by the embodiment of the present invention, the first server determines that the remaining storage space is greater than or equal to a data generated by a virtual machine thereon. When the storage space is occupied, the data is preferentially stored in the remaining storage space of the server; when the first server determines that the remaining storage space is smaller than the storage space occupied by the data, the data is stored in the storage of the second server. In space, and migrate the virtual machine to the second server. In this way, the virtual machine can directly read data from the local (the storage space of the second server), and does not need to read data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving system performance. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. Embodiment 3 As shown in FIG. 5, a server 1 provided in this embodiment is applied to a distributed storage system, where the distributed storage system further includes other servers, and the server 1 is configured to execute the method shown in FIG. A method of storing data, the server 1 comprising:
确定模块 5 1 , 用于确定所述服务器 1生成的第一数据; 判断模块 52 , 用于判断所述服务器 1 的剩余存储空间与所述第 一数据所占的存储空间的大小关系;  The determining module 5 1 is configured to determine the first data generated by the server 1 ; the determining module 52 is configured to determine a size relationship between a remaining storage space of the server 1 and a storage space occupied by the first data;
存储模块 53 ,用于在所述判断模块 52确定所述服务器 1 的剩余 存储空间大于或者等于所述第一数据所占的存储空间, 且所述服务 器 1 的已使用存储空间大于所述其他服务器的最小已使用存储空间 时, 将所述第一数据存储在所述服务器 1 的剩余存储空间中。  The storage module 53 is configured to determine, in the determining module 52, that the remaining storage space of the server 1 is greater than or equal to the storage space occupied by the first data, and the used storage space of the server 1 is larger than the other server. The first data is stored in the remaining storage space of the server 1 when the minimum used storage space is used.
可选的, 所述服务器 1 包含一虚拟机, 所述第一数据是所述虚 拟机生成的数据; 所述其他服务器包括第二服务器; 如图 6 所示, 所述服务器 1还包括: Optionally, the server 1 includes a virtual machine, where the first data is data generated by the virtual machine; and the other server includes a second server; as shown in FIG. The server 1 further includes:
发送模块 54 ,用于在所述判断模块 52确定所述服务器 1 的剩余 存储空间小于所述第一数据所占的存储空间时, 向所述第二服务器 发送包含所述第一数据的第一指示消息; 所述第一指示消息用于指 示所述第二服务器将所述第一数据存储在所述第二服务器的剩余存 储空间中;  The sending module 54 is configured to: when the determining module 52 determines that the remaining storage space of the server 1 is smaller than the storage space occupied by the first data, send the first data including the first data to the second server The first indication message is used to instruct the second server to store the first data in a remaining storage space of the second server;
迁移模块 55 , 用于在所述虚拟机对应的除所述第一数据之外的 其他数据所占的存储空间小于或者等于所述第二服务器的剩余存储 空间时, 将所述虚拟机和所述其他数据迁移到所述第二服务器上。  The migration module 55 is configured to: when the storage space occupied by the data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage space of the second server, the virtual machine and the The other data is migrated to the second server.
可选的, 所述其他服务器包括第二服务器, 如图 6 所示, 所述 服务器 1还包括:  Optionally, the other server includes a second server. As shown in FIG. 6, the server 1 further includes:
发送模块 54 ,用于在所述判断模块 52确定所述服务器 1 的剩余 存储空间小于所述第一数据所占的存储空间时, 向所述第二服务器 发送包含所述第一数据的第一指示消息; 所述第一指示消息用于指 示所述第二服务器将所述第一数据存储在所述第二服务器的剩余存 储空间中;  The sending module 54 is configured to: when the determining module 52 determines that the remaining storage space of the server 1 is smaller than the storage space occupied by the first data, send the first data including the first data to the second server The first indication message is used to instruct the second server to store the first data in a remaining storage space of the second server;
更新模块 56 , 用于更新所述服务器 1 的剩余存储空间;  An update module 56, configured to update remaining storage space of the server 1;
所述发送模块 54还用于, 当所述服务器 1 更新后的剩余存储空 间大于或者等于所述第一数据所占的存储空间时, 向所述第二服务 器发送第二指示消息; 所述第二指示消息用于指示所述第二服务器 将所述第一数据迁移到所述服务器 1 ;  The sending module 54 is further configured to: when the remaining storage space of the server 1 is greater than or equal to the storage space occupied by the first data, send a second indication message to the second server; The second indication message is used to instruct the second server to migrate the first data to the server 1;
接收模块 57 , 用于接收所述第二服务器发送的所述第一数据; 所述存储模块 53还用于, 将所述第一数据存储在所述服务器 1 更新后的剩余存储空间中。  The receiving module 57 is configured to receive the first data sent by the second server. The storage module 53 is further configured to store the first data in the remaining storage space of the server 1 after the update.
可选的, 所述其他服务器还包括第三服务器;  Optionally, the other server further includes a third server;
所述发送模块 54还用于, 向所述第三服务器发送包含所述第一 数据的副本的第三指示消息, 所述第三指示消息用于指示所述第三 服务器将所述第一数据的副本存储在所述第三服务器的剩余存储空 间中。 示例性的, 本实施例中的服务器 1 具体可以为上述实施例一中 描述的 "第一服务器", 本实施例中的 "第二服务器" 可以为上述实 施例一中描述的 "第二服务器"。 本发明实施例提供的服务器 1 ,应用于还包含其他服务器的分布 式存储系统中, 在服务器 1 确定其剩余存储空间大于或者等于其生 成的一数据所占的存储空间, 且服务器 1 的已使用存储空间大于其 他服务器的最小已使用存储空间时, 优先将该数据存储在该服务器 的剩余存储空间中。 这样, 服务器 1 可以直接从本地读取该数据, 而不需要从网络中的其他服务器上读取该数据, 从而达到缩短时延、 提高系统性能的有益效果。 解决了现有技术中, 因在网络中的其他 服务器上读取数据导致的时延长、 系统性能较差的问题。 实施例四 针对实施例三, 在硬件实现上, 其中的发送模块可以为发送器, 接收模块可以为接收器, 且该发送器和接收器可以集成在一起构成 收发器; 存储模块可以为存储器, 确定模块、 判断模块、 迁移模块 等可以以硬件形式内嵌于或独立于服务器 1 的处理器中, 也可以以 软件形式存储于服务器 1 的存储器中, 以便于处理器调用执行以上 各个模块对应的操作, 该处理器可以为中央处理单元 ( CPU )、 微处 理器、 单片机等。 如图 7所示, 为本发明实施例提供的一种服务器 1 , 应用于分布 式存储系统, 所述分布式存储系统还包括其他服务器, 所述服务器 1 用以执行图 1 所示的存储数据的方法, 所述服务器 1 包括: 总线系 统 7 1、 存储器 72、 处理器 73。 其中, 存储器 72和处理器 73之间是通过总线系统 7 1耦合在一 起的,其中总线系统 71 除包括数据总线之外,还可以包括电源总线、 控制总线和状态信号总线等。 但是为了清楚说明起见, 在图中将各 种总线都标为总线系统 7 1。 存储器 72 , 用于存储一组代码; 存储器 72 中存储的代码用于控制处理器 73 确定所述服务器 1 生成的第一数据; 以及判断所述服务器 1 的剩余存储空间与所述第 一数据所占的存储空间的大小关系; 存储器 72 ,还用于在所述处理器 73确定所述服务器 1 的剩余存 储空间大于或者等于所述第一数据所占的存储空间,且所述服务器 1 的已使用存储空间大于所述其他服务器的最小已使用存储空间时, 在所述处理器的控制下将所述第一数据存储在所述服务器 1 的剩余 存储空间中。 可选的, 所述服务器 1 包含一虚拟机, 所述第一数据是所述虚 拟机生成的数据; 所述其他服务器包括第二服务器; 如图 8 所示, 所述服务器 1还包括: 发送器 74 ,用于在所述处理器 73确定所述服务器 1 的剩余存储 空间小于所述第一数据所占的存储空间时, 向所述第二服务器发送 包含所述第一数据的第一指示消息; 所述第一指示消息用于指示所 述第二服务器将所述第一数据存储在所述第二服务器的剩余存储空 间中; 所述处理器 73还用于, 在所述虚拟机对应的除所述第一数据之 外的其他数据所占的存储空间小于或者等于所述第二服务器的剩余 存储空间时, 将所述虚拟机和所述其他数据迁移到所述第二服务器 上。 可选的, 所述其他服务器包括第二服务器; 所述处理器 73还用于, 更新所述服务器 1 的剩余存储空间; 所述发送器 74还用于, 当所述服务器 1 更新后的剩余存储空间 大于或者等于所述第一数据所占的存储空间时, 向所述第二服务器 发送第二指示消息; 所述第二指示消息用于指示所述第二服务器将 所述第一数据迁移到所述服务器 1 ; 如图 8所示, 所述服务器 1还包括: 接收器 75 , 用于接收所述 第二服务器发送的所述第一数据; 所述存储器 72还用于, 在所述处理器 73 的控制下将所述第一 数据存储在所述服务器 1 更新后的剩余存储空间中。 可选的, 所述其他服务器还包括第三服务器; 所述发送器 74还用于, 向所述第三服务器发送包含所述第一数 据的副本的第三指示消息, 所述第三指示消息用于指示所述第三服 务器将所述第一数据的副本存储在所述第三服务器的剩余存储空间 中。 示例性的, 本实施例中的服务器 1 具体可以为上述实施例一中 描述的 "第一服务器", 本实施例中的 "第二服务器" 可以为上述实 施例一中描述的 "第二服务器"。 The sending module 54 is further configured to: send, to the third server, the first a third indication message of the copy of the data, the third indication message is used to instruct the third server to store a copy of the first data in a remaining storage space of the third server. Exemplarily, the server 1 in this embodiment may be the "first server" described in the first embodiment, and the "second server" in this embodiment may be the "second server" described in the first embodiment. ". The server 1 provided by the embodiment of the present invention is applied to a distributed storage system that further includes other servers, and the server 1 determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, and the server 1 is used. When the storage space is larger than the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server. In this way, the server 1 can directly read the data from the local without having to read the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. Embodiment 4 is directed to Embodiment 3, in hardware implementation, where the sending module may be a transmitter, the receiving module may be a receiver, and the transmitter and the receiver may be integrated to form a transceiver; the storage module may be a memory, The determining module, the judging module, the migration module, and the like may be embedded in or independent of the processor of the server 1 in hardware, or may be stored in the memory of the server 1 in software, so that the processor calls to execute the corresponding modules. Operation, the processor can be a central processing unit (CPU), a microprocessor, a microcontroller, or the like. As shown in FIG. 7 , a server 1 is provided for a distributed storage system, where the distributed storage system further includes other servers, and the server 1 is configured to execute the storage data shown in FIG. 1 . The server 1 includes: a bus system 71, a memory 72, and a processor 73. The memory 72 and the processor 73 are coupled together by a bus system 71. The bus system 71 may include a power bus, a control bus, a status signal bus, and the like in addition to the data bus. However, for the sake of clarity, various buses are labeled as the bus system 71 in the figure. a memory 72 for storing a set of codes; a code stored in the memory 72 for controlling the processor 73 to determine the first data generated by the server 1; and determining a remaining storage space of the server 1 and the first data a storage area of the server 1 When the storage space is larger than the minimum used storage space of the other server, the first data is stored in the remaining storage space of the server 1 under the control of the processor. Optionally, the server 1 includes a virtual machine, the first data is data generated by the virtual machine, and the other server includes a second server. As shown in FIG. 8, the server 1 further includes: sending The controller 74 is configured to: when the processor 73 determines that the remaining storage space of the server 1 is smaller than the storage space occupied by the first data, send a first indication that includes the first data to the second server The first indication message is used to indicate that the second server stores the first data in a remaining storage space of the second server; the processor 73 is further configured to: correspond to the virtual machine The virtual machine and the other data are migrated to the second server when the storage space occupied by the data other than the first data is less than or equal to the remaining storage space of the second server. Optionally, the other server includes a second server; the processor 73 is further configured to: update a remaining storage space of the server 1; the transmitter 74 is further configured to: when the server 1 is updated, Sending a second indication message to the second server when the storage space is greater than or equal to the storage space occupied by the first data; the second indication message is used to instruct the second server to migrate the first data As shown in FIG. 8, the server 1 further includes: a receiver 75, configured to receive the first data sent by the second server; the memory 72 is further configured to: The first data is stored in the remaining storage space of the server 1 after the control of the processor 73. Optionally, the other server further includes a third server, where the transmitter 74 is further configured to: send, to the third server, a third indication message that includes a copy of the first data, where the third indication message is And configured to instruct the third server to store a copy of the first data in a remaining storage space of the third server. Exemplarily, the server 1 in this embodiment may be the "first server" described in the first embodiment, and the "second server" in this embodiment may be the "second server" described in the first embodiment. ".
本发明实施例提供的服务器 1 ,应用于还包含其他服务器的分布 式存储系统中, 在服务器 1 确定其剩余存储空间大于或者等于其生 成的一数据所占的存储空间, 且服务器 1 的已使用存储空间大于其 他服务器的最小已使用存储空间时, 优先将该数据存储在该服务器 的剩余存储空间中。 这样, 服务器 1 可以直接从本地读取该数据, 而不需要从网络中的其他服务器上读取该数据, 从而达到缩短时延、 提高系统性能的有益效果。 解决了现有技术中, 因在网络中的其他 服务器上读取数据导致的时延长、 系统性能较差的问题。 实施例五 The server 1 provided by the embodiment of the present invention is applied to a distributed storage system that further includes other servers, and the server 1 determines that the remaining storage space is greater than or equal to the storage space occupied by a data generated by the server, and the server 1 is used. When the storage space is larger than the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server. In this way, the server 1 can directly read the data from the local without having to read the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance. Solved the prior art, due to other in the network The problem of extended time and poor system performance caused by reading data on the server. Embodiment 5
如图 9所示, 为本实施例提供的一种服务器 2 , 应用于分布式存 储系统, 所述分布式存储系统还包括其他服务器, 所述服务器 2 用 以执行图 2所示的存储数据的方法, 所述服务器 2包括: 确定模块 91 , 用于确定所述服务器 2生成的第一数据; 所述第 一数据所占的存储空间大于所述分布式存储系统的最小存储单元的 最大值;  As shown in FIG. 9, a server 2 provided in this embodiment is applied to a distributed storage system, where the distributed storage system further includes other servers, and the server 2 is configured to execute the stored data shown in FIG. The server 2 includes: a determining module 91, configured to determine first data generated by the server 2; a storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system;
判断模块 92 , 用于判断所述服务器 2的剩余存储空间与所述第 一数据所占的存储空间的大小关系; 存储模块 93 ,用于在所述判断模块 92确定所述服务器 2的剩余 存储空间大于或者等于所述第一数据所占的存储空间, 且所述服务 器 2 的已使用存储空间小于或者等于所述其他服务器的最小已使用 存储空间时, 将所述第一数据存储在所述服务器 2 的剩余存储空间 中。  The determining module 92 is configured to determine a size relationship between the remaining storage space of the server 2 and the storage space occupied by the first data. The storage module 93 is configured to determine, in the determining module 92, the remaining storage of the server 2 The space is greater than or equal to the storage space occupied by the first data, and the used storage space of the server 2 is less than or equal to the minimum used storage space of the other server, and the first data is stored in the In the remaining storage space of server 2.
示例性的, 本实施例中的服务器 2 具体可以为上述实施例一中 描述的 "第一服务器",  Exemplarily, the server 2 in this embodiment may specifically be the "first server" described in the first embodiment.
本发明实施例提供的服务器 2 ,应用于还包含其他服务器的分布 式存储系统中, 在服务器 2 确定其剩余存储空间大于或者等于其生 成的一数据所占的存储空间, 且服务器 2 的已使用存储空间小于或 者等于其他服务器的最小已使用存储空间时, 优先将该数据存储在 该服务器的剩余存储空间中; 其中, 该数据所占的存储空间大于分 布式存储系统的最小存储单元的最大值。 这样, 服务器 2 可以直接 从本地读取该数据, 而不需要从网络中的其他服务器上读取该数据, 从而达到缩短时延、 提高系统性能的有益效果。 解决了现有技术中, 因在网络中的其他服务器上读取数据导致的时延长、 系统性能较差 的问题。 实施例六 针对实施例五, 在硬件实现上, 其中的存储模块可以为存储器, 确定模块、 判断模块可以以硬件形式内嵌于或独立于服务器 2 的处 理器中, 也可以以软件形式存储于服务器 2 的存储器中, 以便于处 理器调用执行以上各个模块对应的操作, 该处理器可以为中央处理 单元 ( CPU )、 微处理器、 单片机等。 如图 10所示, 为本发明实施例提供的一种服务器 2 , 应用于分 布式存储系统, 所述分布式存储系统还包括其他服务器, 所述服务 器 2用以执行图 2所示的存储数据的方法, 所述服务器 1 包括: 总 线系统 10A、 存储器 10B、 处理器 10C。 其中, 存储器 10B和处理器 10C之间是通过总线系统 10A耦合 在一起的, 其中总线系统 10A除包括数据总线之外, 还可以包括电 源总线、 控制总线和状态信号总线等。 但是为了清楚说明起见, 在 图中将各种总线都标为总线系统 i 0 A。 存储器 10B , 用于存储一组代码; 存储器 10B 中存储的代码用于控制处理器 10C确定所述服务器 2生成的第一数据;以及判断所述服务器 2的剩余存储空间与所述第 一数据所占的存储空间的大小关系; 所述第一数据所占的存储空间 大于所述分布式存储系统的最小存储单元的最大值; 存储器 10B , 还用于在所述处理器 10C确定所述服务器 2 的剩 余存储空间大于或者等于所述第一数据所占的存储空间, 且所述服 务器 2 的已使用存储空间小于或者等于所述其他服务器的最小已使 用存储空间时, 在所述处理器 10C 的控制下将所述第一数据存储在 所述服务器 2的剩余存储空间中。 示例性的, 本实施例中的服务器 2 具体可以为上述实施例一中 描述的 "第一服务器", 本发明实施例提供的服务器 2 ,应用于还包含其他服务器的分布 式存储系统中, 在服务器 2 确定其剩余存储空间大于或者等于其生 成的一数据所占的存储空间, 且服务器 2 的已使用存储空间小于或 者等于其他服务器的最小已使用存储空间时, 优先将该数据存储在 该服务器的剩余存储空间中; 其中, 该数据所占的存储空间大于分 布式存储系统的最小存储单元的最大值。 这样, 服务器 2 可以直接 从本地读取该数据, 而不需要从网络中的其他服务器上读取该数据, 从而达到缩短时延、 提高系统性能的有益效果。 解决了现有技术中, 因在网络中的其他服务器上读取数据导致的时延长、 系统性能较差 的问题。 所属领域的技术人员可以清楚地了解到, 为描述的方便和简洁, 上述描述的系统, 装置和模块的具体工作过程, 可以参考前述方法 实施例中的对应过程, 在此不再贅述。 The server 2 provided by the embodiment of the present invention is applied to a distributed storage system that further includes other servers. The server 2 determines that the remaining storage space is greater than or equal to the storage space occupied by the data generated by the server 2, and the server 2 is used. When the storage space is less than or equal to the minimum used storage space of other servers, the data is preferentially stored in the remaining storage space of the server; wherein the storage space occupied by the data is greater than the maximum storage unit of the distributed storage system. . In this way, the server 2 can directly read the data from the local without reading the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance. Solved in the prior art, The problem of extended time and poor system performance due to reading data on other servers in the network. Embodiment 6 is directed to the fifth embodiment. In the hardware implementation, the storage module may be a memory, and the determining module and the determining module may be embedded in the hardware of the server 2 in hardware or may be stored in software. In the memory of the server 2, in order to facilitate the processor to perform operations corresponding to the above modules, the processor may be a central processing unit (CPU), a microprocessor, a single chip microcomputer or the like. As shown in FIG. 10, a server 2 is provided for a distributed storage system, where the distributed storage system further includes other servers, and the server 2 is configured to execute the storage data shown in FIG. The server 1 includes: a bus system 10A, a memory 10B, and a processor 10C. The memory 10B and the processor 10C are coupled together by the bus system 10A. The bus system 10A may include a power bus, a control bus, a status signal bus, and the like in addition to the data bus. However, for the sake of clarity, the various buses are labeled as bus system i 0 A in the figure. a memory 10B for storing a set of codes; a code stored in the memory 10B for controlling the processor 10C to determine the first data generated by the server 2; and determining the remaining storage space of the server 2 and the first data a size relationship of the storage space; the storage space occupied by the first data is greater than a maximum value of a minimum storage unit of the distributed storage system; and the memory 10B is further configured to determine the server 2 at the processor 10C The remaining storage space is greater than or equal to the storage space occupied by the first data, and the used storage space of the server 2 is less than or equal to the minimum used storage space of the other server, in the processor 10C Controlling the first data in storage The remaining storage space of the server 2. Exemplarily, the server 2 in this embodiment may be the "first server" described in the first embodiment, and the server 2 provided in the embodiment of the present invention is applied to a distributed storage system that further includes other servers. The server 2 determines that the remaining storage space is greater than or equal to the storage space occupied by one of the data generated by the server 2, and when the used storage space of the server 2 is less than or equal to the minimum used storage space of the other server, the data is preferentially stored in the server. The remaining storage space; wherein, the data occupies a storage space larger than the maximum storage unit of the distributed storage system. In this way, the server 2 can directly read the data from the local without reading the data from other servers in the network, thereby achieving the beneficial effects of shortening the delay and improving the system performance. The problem of prolonged time and poor system performance due to reading data on other servers in the network is solved in the prior art. A person skilled in the art can clearly understand that, for the convenience and brevity of the description, the specific working process of the system, the device and the module described above can refer to the corresponding process in the foregoing method embodiment, and details are not described herein again.
在本申请所提供的几个实施例中, 应该理解到, 所揭露的系统, 装置和方法, 可以通过其它的方式实现。 例如, 以上所描述的装置 实施例仅仅是示意性的, 例如, 所述模块的划分, 仅仅为一种逻辑 功能划分, 实际实现时可以有另外的划分方式, 例如多个模块或组 件可以结合或者可以集成到另一个系统, 或一些特征可以忽略, 或 不执行。 另一点, 所显示或讨论的相互之间的耦合或直接耦合或通 信连接可以是通过一些接口, 装置或模块的间接耦合或通信连接, 可以是电性, 机械或其它的形式。 所述作为分离部件说明的模块可以是或者也可以不是物理上分 开的, 作为模块显示的部件可以是或者也可以不是物理模块, 即可 以位于一个地方, 或者也可以分布到多个网络模块上。 可以根据实 际的需要选择其中的部分或者全部模块来实现本实施例方案的 目 的。 另外, 在本发明各个实施例中的各功能模块可以集成在一个处 理模块中, 也可以是各个模块单独物理包括, 也可以两个或两个以 上模块集成在一个模块中。 上述集成的模块既可以采用硬件的形式 实现, 也可以采用硬件加软件功能模块的形式实现。 In the several embodiments provided by the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be another division manner, for example, multiple modules or components may be combined or Can be integrated into another system, or some features can be ignored, or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or module, and may be in an electrical, mechanical or other form. The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules. Located in one place, or distributed to multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment. In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may be physically included separately, or two or more modules may be integrated into one module. The above integrated modules can be implemented in the form of hardware or in the form of hardware plus software function modules.
上述以软件功能模块的形式实现的集成的模块, 可以存储在一 个计算机可读取存储介质中。 上述软件功能模块存储在一个存储介 质中, 包括若干指令用以使得一台计算机设备(可以是个人计算机, 服务器, 或者网络设备等) 执行本发明各个实施例所述方法的部分 步骤。 而前述的存储介质包括: U盘、 移动硬盘、 ROM ( Read-Only Memory , 只读存储器)、 RAM ( Random Access Memory , 随机存取 存储器)、 磁碟或者光盘等各种可以存储程序代码的介质。  The above-described integrated modules implemented in the form of software function modules can be stored in a computer readable storage medium. The software function modules described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform portions of the steps of the various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a disk or an optical disk, and the like, which can store program codes. .
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对其限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通技术人员应当理解: 其依然可以对前述各实施例所记 载的技术方案进行修改, 或者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不使相应技术方案的本质脱离本发明各实 施例技术方案的精神和范围。  It should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that: The technical solutions described in the foregoing embodiments are modified, or some of the technical features are equivalently replaced. The modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

权 利 要 求 书 claims
1、 一种存储数据的方法, 其特征在于, 应用于分布式存储系统, 所述分布式存储系统包括第一服务器和其他服务器, 所述方法包括: 确定所述第一服务器生成的第一数据; 1. A method of storing data, characterized in that it is applied to a distributed storage system, the distributed storage system includes a first server and other servers, the method includes: determining the first data generated by the first server ;
判断所述第一服务器的剩余存储空间与所述第一数据所占的存 储空间的大小关系; Determine the relationship between the remaining storage space of the first server and the storage space occupied by the first data;
如果所述第一服务器的剩余存储空间大于或者等于所述第一数 据所占的存储空间, 且所述第一服务器的已使用存储空间大于所述其 他服务器的最小已使用存储空间时, 将所述第一数据存储在所述第一 服务器的剩余存储空间中。 If the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is greater than the minimum used storage space of the other servers, all The first data is stored in the remaining storage space of the first server.
2、 根据权利要求 1 所述的方法, 其特征在于, 所述第一服务器 包含一虚拟机, 所述第一数据是所述虚拟机生成的数据; 所述其他服 务器包括第二服务器; 所述方法还包括: 2. The method according to claim 1, characterized in that: the first server includes a virtual machine, the first data is data generated by the virtual machine; the other servers include a second server; Methods also include:
如果所述第一服务器的剩余存储空间小于所述第一数据所占的 存储空间, 则向所述第二服务器发送包含所述第一数据的第一指示消 息; 所述第一指示消息用于指示所述第二服务器将所述第一数据存储 在所述第二服务器的剩余存储空间中; If the remaining storage space of the first server is less than the storage space occupied by the first data, send a first indication message containing the first data to the second server; the first indication message is used to Instruct the second server to store the first data in the remaining storage space of the second server;
在所述虚拟机对应的除所述第一数据之外的其他数据所占的存 储空间小于或者等于所述第二服务器的剩余存储空间时, 将所述虚拟 机和所述其他数据迁移到所述第二服务器上。 When the storage space occupied by other data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage space of the second server, migrate the virtual machine and the other data to the second server. on the second server.
3、 根据权利要求 1 所述的方法, 其特征在于, 所述其他服务器 包括第二服务器; 所述方法还包括: 3. The method according to claim 1, wherein the other servers include a second server; the method further includes:
如果所述第一服务器的剩余存储空间小于所述第一数据所占的 存储空间, 则向所述第二服务器发送包含所述第一数据的第一指示消 息; 所述第一指示消息用于指示所述第二服务器将所述第一数据存储 在所述第二服务器的剩余存储空间中; 更新所述第一服务器的剩余存储空间; If the remaining storage space of the first server is less than the storage space occupied by the first data, send a first indication message containing the first data to the second server; the first indication message is used to Instruct the second server to store the first data in the remaining storage space of the second server; Update the remaining storage space of the first server;
当所述第一服务器更新后的剩余存储空间大于或者等于所述第 一数据所占的存储空间时, 向所述第二服务器发送第二指示消息; 所 述第二指示消息用于指示所述第二服务器将所述第一数据迁移到所 述第一服务器; When the updated remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, a second indication message is sent to the second server; the second indication message is used to indicate that the The second server migrates the first data to the first server;
接收所述第二服务器发送的所述第一数据; Receive the first data sent by the second server;
将所述第一数据存储在所述第一服务器更新后的剩余存储空间 中。 The first data is stored in the updated remaining storage space of the first server.
4、 根据权利要求 1 -3 任一项所述的方法, 其特征在于, 所述其 他服务器还包括第三服务器, 所述方法还包括: 4. The method according to any one of claims 1 to 3, characterized in that the other servers also include a third server, and the method further includes:
向所述第三服务器发送包含所述第一数据的副本的第三指示消 息, 所述第三指示消息用于指示所述第三服务器将所述第一数据的副 本存储在所述第三服务器的剩余存储空间中。 Send a third instruction message containing a copy of the first data to the third server, where the third instruction message is used to instruct the third server to store the copy of the first data in the third server. of remaining storage space.
5、 一种存储数据的方法, 其特征在于, 应用于分布式存储系统, 所述分布式存储系统包括第一服务器和其他服务器, 所述方法包括: 确定所述第一服务器生成的第一数据; 所述第一数据所占的存储 空间大于所述分布式存储系统的最小存储单元的最大值; 5. A method of storing data, characterized in that it is applied to a distributed storage system, the distributed storage system includes a first server and other servers, the method includes: determining the first data generated by the first server ; The storage space occupied by the first data is greater than the maximum value of the minimum storage unit of the distributed storage system;
判断所述第一服务器的剩余存储空间与所述第一数据所占的存 储空间的大小关系; Determine the relationship between the remaining storage space of the first server and the storage space occupied by the first data;
如果所述第一服务器的剩余存储空间大于或者等于所述第一数 据所占的存储空间, 且所述第一服务器的已使用存储空间小于或者等 于所述其他服务器的最小已使用存储空间时, 将所述第一数据存储在 所述第一服务器的剩余存储空间中。 If the remaining storage space of the first server is greater than or equal to the storage space occupied by the first data, and the used storage space of the first server is less than or equal to the minimum used storage space of the other servers, The first data is stored in the remaining storage space of the first server.
6、 一种服务器, 其特征在于, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 6. A server, characterized in that it is used in a distributed storage system. The distributed storage system also includes other servers. The servers include:
确定模块, 用于确定所述服务器生成的第一数据; 判断模块, 用于判断所述服务器的剩余存储空间与所述第一数据 所占的存储空间的大小关系; Determining module, used to determine the first data generated by the server; A judgment module, used to judge the size relationship between the remaining storage space of the server and the storage space occupied by the first data;
存储模块, 用于在所述判断模块确定所述服务器的剩余存储空间 大于或者等于所述第一数据所占的存储空间, 且所述服务器的已使用 存储空间大于所述其他服务器的最小已使用存储空间时, 将所述第一 数据存储在所述服务器的剩余存储空间中。 A storage module configured to determine, in the judgment module, that the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, and that the used storage space of the server is greater than the minimum used storage space of the other servers. When storage space is required, the first data is stored in the remaining storage space of the server.
7、 根据权利要求 6 所述的服务器, 其特征在于, 所述服务器包 含一虚拟机, 所述第一数据是所述虚拟机生成的数据; 所述其他服务 器包括第二服务器, 所述服务器还包括: 7. The server according to claim 6, characterized in that: the server includes a virtual machine, the first data is data generated by the virtual machine; the other servers include a second server, and the server further include:
发送模块, 用于在所述判断模块确定所述服务器的剩余存储空间 小于所述第一数据所占的存储空间时, 向所述第二服务器发送包含所 述第一数据的第一指示消息; 所述第一指示消息用于指示所述第二服 务器将所述第一数据存储在所述第二服务器的剩余存储空间中; A sending module configured to send a first indication message containing the first data to the second server when the judgment module determines that the remaining storage space of the server is less than the storage space occupied by the first data; The first instruction message is used to instruct the second server to store the first data in the remaining storage space of the second server;
迁移模块, 用于在所述虚拟机对应的除所述第一数据之外的其他 数据所占的存储空间小于或者等于所述第二服务器的剩余存储空间 时, 将所述虚拟机和所述其他数据迁移到所述第二服务器上。 A migration module configured to migrate the virtual machine to the second server when the storage space occupied by other data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage space of the second server. Other data is migrated to the second server.
8、 根据权利要求 6 所述的服务器, 其特征在于, 所述其他服务 器包括第二服务器, 所述服务器还包括: 8. The server according to claim 6, wherein the other servers include a second server, and the server further includes:
发送模块, 用于在所述判断模块确定所述服务器的剩余存储空间 小于所述第一数据所占的存储空间时, 向所述第二服务器发送包含所 述第一数据的第一指示消息; 所述第一指示消息用于指示所述第二服 务器将所述第一数据存储在所述第二服务器的剩余存储空间中; A sending module configured to send a first indication message containing the first data to the second server when the judgment module determines that the remaining storage space of the server is less than the storage space occupied by the first data; The first instruction message is used to instruct the second server to store the first data in the remaining storage space of the second server;
更新模块, 用于更新所述服务器的剩余存储空间; An update module, used to update the remaining storage space of the server;
所述发送模块还用于, 当所述服务器更新后的剩余存储空间大于 或者等于所述第一数据所占的存储空间时, 向所述第二服务器发送第 二指示消息; 所述第二指示消息用于指示所述第二服务器将所述第一 数据迁移到所述服务器; The sending module is also configured to send a second indication message to the second server when the updated remaining storage space of the server is greater than or equal to the storage space occupied by the first data; the second indication The message is used to instruct the second server to transfer the first Data migration to said server;
接收模块, 用于接收所述第二服务器发送的所述第一数据; 所述存储模块还用于, 将所述第一数据存储在所述服务器更新后 的剩余存储空间中。 The receiving module is configured to receive the first data sent by the second server; the storage module is also configured to store the first data in the remaining storage space after the server updates.
9、 根据权利要求 6-8 任一项所述的服务器, 其特征在于, 所述 其他服务器还包括第三服务器; 9. The server according to any one of claims 6-8, characterized in that the other servers also include a third server;
所述发送模块还用于, 向所述第三服务器发送包含所述第一数据 的副本的第三指示消息, 所述第三指示消息用于指示所述第三服务器 将所述第一数据的副本存储在所述第三服务器的剩余存储空间中。 The sending module is further configured to send a third instruction message containing a copy of the first data to the third server, where the third instruction message is used to instruct the third server to send the copy of the first data to the third server. The copy is stored in the remaining storage space of the third server.
10、 一种服务器, 其特征在于, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 10. A server, characterized in that it is used in a distributed storage system. The distributed storage system also includes other servers. The servers include:
处理器, 用于确定所述服务器生成的第一数据; 以及判断所述服 务器的剩余存储空间与所述第一数据所占的存储空间的大小关系; 存储器, 用于在所述处理器确定所述服务器的剩余存储空间大于 或者等于所述第一数据所占的存储空间, 且所述服务器的已使用存储 空间大于所述其他服务器的最小已使用存储空间时, 在所述处理器的 控制下将所述第一数据存储在所述服务器的剩余存储空间中。 A processor, used to determine the first data generated by the server; and to judge the relationship between the remaining storage space of the server and the storage space occupied by the first data; a memory, used to determine the first data generated by the processor. When the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, and the used storage space of the server is greater than the minimum used storage space of the other servers, under the control of the processor The first data is stored in the remaining storage space of the server.
1 1、 根据权利要求 10 所述的服务器, 其特征在于, 所述服务器 包含一虚拟机, 所述第一数据是所述虚拟机生成的数据; 所述其他服 务器包括第二服务器, 所述服务器还包括: 1 1. The server according to claim 10, characterized in that: the server includes a virtual machine, the first data is data generated by the virtual machine; the other servers include a second server, the server Also includes:
发送器, 用于在所述处理器确定所述服务器的剩余存储空间小于 所述第一数据所占的存储空间时, 向所述第二服务器发送包含所述第 一数据的第一指示消息; 所述第一指示消息用于指示所述第二服务器 将所述第一数据存储在所述第二服务器的剩余存储空间中; A sender configured to send a first indication message containing the first data to the second server when the processor determines that the remaining storage space of the server is less than the storage space occupied by the first data; The first instruction message is used to instruct the second server to store the first data in the remaining storage space of the second server;
所述处理器还用于, 在所述虚拟机对应的除所述第一数据之外的 其他数据所占的存储空间小于或者等于所述第二服务器的剩余存储 空间时, 将所述虚拟机和所述其他数据迁移到所述第二服务器上。 The processor is further configured to ensure that the storage space occupied by other data other than the first data corresponding to the virtual machine is less than or equal to the remaining storage of the second server. When space is available, migrate the virtual machine and other data to the second server.
12、 根据权利要求 10 所述的服务器, 其特征在于, 所述其他服 务器包括第二服务器; 12. The server according to claim 10, wherein the other servers include a second server;
所述处理器还用于, 更新所述服务器的剩余存储空间; The processor is also used to update the remaining storage space of the server;
所述发送器还用于, 当所述服务器更新后的剩余存储空间大于或 者等于所述第一数据所占的存储空间时, 向所述第二服务器发送第二 指示消息; 所述第二指示消息用于指示所述第二服务器将所述第一数 据迁移到所述服务器; The sender is also configured to send a second indication message to the second server when the updated remaining storage space of the server is greater than or equal to the storage space occupied by the first data; the second indication The message is used to instruct the second server to migrate the first data to the server;
所述服务器还包括: 接收器, 用于接收所述第二服务器发送的所 述第一数据; The server also includes: a receiver, configured to receive the first data sent by the second server;
所述存储器还用于, 在所述处理器的控制下将所述第一数据存储 在所述服务器更新后的剩余存储空间中。 The memory is also used to store the first data in the updated remaining storage space of the server under the control of the processor.
13、 根据权利要求 10- 12任一项所述的服务器, 其特征在于, 所 述其他服务器还包括第三服务器; 13. The server according to any one of claims 10 to 12, characterized in that the other servers also include a third server;
所述发送器还用于, 向所述第三服务器发送包含所述第一数据的 副本的第三指示消息, 所述第三指示消息用于指示所述第三服务器将 所述第一数据的副本存储在所述第三服务器的剩余存储空间中。 The sender is further configured to send a third instruction message containing a copy of the first data to the third server, where the third instruction message is used to instruct the third server to send the copy of the first data to the third server. The copy is stored in the remaining storage space of the third server.
14、 一种服务器, 其特征在于, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 14. A server, characterized in that it is applied to a distributed storage system. The distributed storage system also includes other servers. The servers include:
确定模块, 用于确定所述服务器生成的第一数据; 所述第一数据 所占的存储空间大于所述分布式存储系统的最小存储单元的最大值; 判断模块, 用于判断所述服务器的剩余存储空间与所述第一数据 所占的存储空间的大小关系; Determining module, used to determine the first data generated by the server; The storage space occupied by the first data is greater than the maximum value of the minimum storage unit of the distributed storage system; Determining module, used to determine the server's The relationship between the remaining storage space and the storage space occupied by the first data;
存储模块, 用于在所述判断模块确定所述服务器的剩余存储空间 大于或者等于所述第一数据所占的存储空间, 且所述服务器的已使用 存储空间小于或者等于所述其他服务器的最小已使用存储空间时, 将 所述第一数据存储在所述服务器的剩余存储空间中。 A storage module configured to determine, in the judgment module, that the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, and that the used storage space of the server is less than or equal to the minimum storage space of the other servers. When storage space has been used, the The first data is stored in the remaining storage space of the server.
15、 一种服务器, 其特征在于, 应用于分布式存储系统, 所述分 布式存储系统还包括其他服务器, 所述服务器包括: 15. A server, characterized in that it is applied to a distributed storage system. The distributed storage system also includes other servers. The servers include:
处理器, 用于确定所述服务器生成的第一数据; 以及判断所述服 务器的剩余存储空间与所述第一数据所占的存储空间的大小关系; 所 述第一数据所占的存储空间大于所述分布式存储系统的最小存储单 元的最大值; A processor, configured to determine the first data generated by the server; and determine the size relationship between the remaining storage space of the server and the storage space occupied by the first data; the storage space occupied by the first data is greater than The maximum value of the minimum storage unit of the distributed storage system;
存储器, 用于在所述处理器确定所述服务器的剩余存储空间大于 或者等于所述第一数据所占的存储空间, 且所述服务器的已使用存储 空间小于或者等于所述其他服务器的最小已使用存储空间时, 在所述 处理器的控制下将所述第一数据存储在所述服务器的剩余存储空间 中。 Memory, used when the processor determines that the remaining storage space of the server is greater than or equal to the storage space occupied by the first data, and the used storage space of the server is less than or equal to the minimum used storage space of the other servers. When the storage space is used, the first data is stored in the remaining storage space of the server under the control of the processor.
PCT/CN2014/071224 2014-01-23 2014-01-23 Data storage method and device WO2015109483A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2014/071224 WO2015109483A1 (en) 2014-01-23 2014-01-23 Data storage method and device
CN201480000338.5A CN104205780B (en) 2014-01-23 2014-01-23 A kind of method and apparatus of data storage

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2014/071224 WO2015109483A1 (en) 2014-01-23 2014-01-23 Data storage method and device

Publications (1)

Publication Number Publication Date
WO2015109483A1 true WO2015109483A1 (en) 2015-07-30

Family

ID=52088184

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/071224 WO2015109483A1 (en) 2014-01-23 2014-01-23 Data storage method and device

Country Status (2)

Country Link
CN (1) CN104205780B (en)
WO (1) WO2015109483A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106202350A (en) * 2016-07-05 2016-12-07 浪潮(北京)电子信息产业有限公司 A kind of distributed file system simplifies the method and system of configuration automatically
CN106909321A (en) * 2017-02-24 2017-06-30 郑州云海信息技术有限公司 A kind of control method and device based on storage system
CN107092443B (en) * 2017-04-28 2020-04-07 杭州宏杉科技股份有限公司 Data migration method and device
CN107172222A (en) * 2017-07-27 2017-09-15 郑州云海信息技术有限公司 A kind of date storage method and device based on distributed memory system
CN109783576B (en) * 2019-01-02 2022-05-31 佛山市顺德区美的洗涤电器制造有限公司 Household appliance and data storage method and device thereof
CN110109622A (en) * 2019-04-28 2019-08-09 平安科技(深圳)有限公司 A kind of data processing method and relevant apparatus based on middleware
CN110134332B (en) * 2019-04-28 2022-03-08 平安科技(深圳)有限公司 Data storage method and related device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060031305A1 (en) * 2004-04-29 2006-02-09 International Business Machines Corporation Managing on-demand email storage
CN102508736A (en) * 2011-10-11 2012-06-20 宇龙计算机通信科技(深圳)有限公司 Backup method of application program in communication terminal and communication terminal
CN103064639A (en) * 2012-12-28 2013-04-24 华为技术有限公司 Method and device for storing data

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6958881B1 (en) * 2003-11-26 2005-10-25 Western Digital Technologies, Inc. Disk drive control system having a servo processing accelerator circuit
CN101771715B (en) * 2008-12-26 2014-04-16 华为技术有限公司 Method, device and system for establishing distribution type network
CN103092927B (en) * 2012-12-29 2016-01-20 华中科技大学 File rapid read-write method under a kind of distributed environment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060031305A1 (en) * 2004-04-29 2006-02-09 International Business Machines Corporation Managing on-demand email storage
CN102508736A (en) * 2011-10-11 2012-06-20 宇龙计算机通信科技(深圳)有限公司 Backup method of application program in communication terminal and communication terminal
CN103064639A (en) * 2012-12-28 2013-04-24 华为技术有限公司 Method and device for storing data

Also Published As

Publication number Publication date
CN104205780A (en) 2014-12-10
CN104205780B (en) 2017-06-27

Similar Documents

Publication Publication Date Title
WO2015109483A1 (en) Data storage method and device
US20200278880A1 (en) Method, apparatus, and system for accessing storage device
US20200259899A1 (en) System and method for sharing san storage
US10409508B2 (en) Updating of pinned storage in flash based on changes to flash-to-disk capacity ratio
JP5088366B2 (en) Virtual computer control program, virtual computer control system, and virtual computer migration method
US9098466B2 (en) Switching between mirrored volumes
US10552089B2 (en) Data processing for managing local and distributed storage systems by scheduling information corresponding to data write requests
KR20200017363A (en) MANAGED SWITCHING BETWEEN ONE OR MORE HOSTS AND SOLID STATE DRIVES (SSDs) BASED ON THE NVMe PROTOCOL TO PROVIDE HOST STORAGE SERVICES
US20080263544A1 (en) Computer system and communication control method
US20150113218A1 (en) Distributed Data Processing Method and Apparatus
US20200241982A1 (en) System, and control method and program for input/output requests for storage systems
WO2015176636A1 (en) Distributed database service management system
JP5352490B2 (en) Server image capacity optimization
US20160077996A1 (en) Fibre Channel Storage Array Having Standby Controller With ALUA Standby Mode for Forwarding SCSI Commands
US10331470B2 (en) Virtual machine creation according to a redundancy policy
KR102062478B1 (en) Methods, terminals, devices, and computer readable storage media to improve the performance of virtual computers
KR20170076666A (en) System and method for providing a dynamic cloud with subnet administration (sa) query caching
JP2016539399A (en) Data write request processing method and storage array
JP6663478B2 (en) Data migration method and computer system
KR20180086791A (en) Cloud system for surpporting big data process and managing method thereof
WO2015010646A1 (en) Hybrid memory data access method, module, processor and terminal device
US10025510B1 (en) Technique for copying unallocated logical regions of thin logical units
WO2019080150A1 (en) Dual active storage system and address allocation method
WO2014059578A1 (en) Embedded multimedia card partitioned storage space adjustment method and terminal
CN111225003B (en) NFS node configuration method and device

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: 14879563

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: 14879563

Country of ref document: EP

Kind code of ref document: A1