CN107688508A - A kind of image file space optimization method and system - Google Patents

A kind of image file space optimization method and system Download PDF

Info

Publication number
CN107688508A
CN107688508A CN201610630261.0A CN201610630261A CN107688508A CN 107688508 A CN107688508 A CN 107688508A CN 201610630261 A CN201610630261 A CN 201610630261A CN 107688508 A CN107688508 A CN 107688508A
Authority
CN
China
Prior art keywords
snapshot
data
image file
target data
current
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN201610630261.0A
Other languages
Chinese (zh)
Inventor
杨维
张友加
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Shenxinfu Electronic Technology Co Ltd
Original Assignee
Shenzhen Shenxinfu Electronic Technology Co Ltd
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 Shenzhen Shenxinfu Electronic Technology Co Ltd filed Critical Shenzhen Shenxinfu Electronic Technology Co Ltd
Priority to CN201610630261.0A priority Critical patent/CN107688508A/en
Publication of CN107688508A publication Critical patent/CN107688508A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • G06F11/1453Management of the data involved in backup or backup restore using de-duplication of the data

Landscapes

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

Abstract

The invention provides a kind of image file space optimization method and system, methods described to include:Snapshot is carried out to the current image file based on qcow2 forms to form first object snapshot at current time, determine target data, the first object snapshot is analyzed to obtain the variance data between the first snapshot data and the second snapshot data, all variance datas and the target data are merged to form the target data after merging, snapshot is carried out to the target data after the merging to form target data snapshot.The method provided by the present embodiment, the image file of virtual machine can be optimized, so as to reduce the disk space shared by the image file of virtual machine, optimize in disk space using the size in space, improve the utilization rate of disk space.

Description

A kind of image file space optimization method and system
Technical field
The present invention relates to computer realm, more particularly to a kind of image file space optimization method and system.
Background technology
Qcow2 is a kind of very general virtual machine image file form, and frequently substantial amounts of data are carried out in virtual machine Operation, will result in image file size and dramatically increases, cause the drastically decline of physical disk free space.
For the utilization rate of lifting disk space, then the operation deleted in virtual machine client data content, when When reference count of a part of aggregate of data in image file in image file is 0, discard can be carried out to image file (those skilled in the art referred to as " dig a hole ") is operated to discharge reference count as the disk space shared by 0 aggregate of data, to subtract The size of small image file, release disk space.
However, the file system for not supporting discard, data are deleted in virtual machine, are drawn in image file With the aggregate of data for being counted as 0, mirror image text of these data in virtual machine also can not be discharged because discard operations can not be performed Occupied space in part, so as to can not effectively utilize disk space.
The content of the invention
The embodiments of the invention provide one kind can optimize virtual machine image file, so as to reduce the thing shared by image file Manage the image file space optimization method and system of disk space.
The embodiments of the invention provide a kind of image file space optimization method, wherein, including:
Snapshot is carried out to the current image file based on qcow2 forms to form first object snapshot, institute at current time State first object snapshot be the original image file based on qcow2 forms n-th snapshot, the first object snapshot include by The original image file is converted to the snapshot data based on qcow2 forms passed through successively during the current image file And at the time of corresponding with each snapshot data, the N is the positive integer of non-zero;
Target data is determined, the target data is changed for the 1st snapshot of the original image file based on qcow2 forms Obtain, data possessed by virtual machine at the time of the target data corresponds to for the 1st snapshot of original image file;
The first object snapshot is analyzed to obtain the variance data between the first snapshot data and the second snapshot data, institute It is that the original image file is converted to the current image file process to state the first snapshot data and second snapshot data Two of moment upper arbitrary neighborhood in middle the passed through snapshot data;
All variance datas and the target data are merged to form the target data after merging;
Snapshot is carried out to the target data after the merging to form target data snapshot, wherein, the target data is fast According to the n-th snapshot for the original image file, and the target data snapshot is the current state of virtual machine.
Optionally, it is described that snapshot is carried out to the current image file based on qcow2 forms to form first at current time Before target snapshot, methods described also includes:
Judge whether the size of the current image file is more than or equal to predetermined threshold value;
If it is determined that the space of the current image file is more than or equal to the predetermined threshold value, it is determined that performs described working as The preceding moment carries out the step of snapshot is to form first object snapshot to the current image file based on qcow2 forms.
Optionally, methods described also includes:
The target data is mounted on network control techology NBD;
It is described to analyze the first object snapshot to obtain the difference number between the first snapshot data and the second snapshot data According to afterwards, methods described also includes:
The variance data between first snapshot data and second snapshot data is written into the NBD to set It is standby upper;
The target data to after the merging carries out snapshot so that before forming target data snapshot, methods described is also wrapped Include:
Disconnect the connection status of the NBD equipment.
Optionally, it is described to analyze the first object snapshot to obtain between the first snapshot data and the second snapshot data Variance data includes:
The cluster inquiry table of the cluster inquiry table of first snapshot data and second snapshot data is contrasted to obtain Different aggregates of data is taken, the variance data is the cluster inquiry table of first snapshot data and the cluster of second snapshot data Different aggregate of data between inquiry table.
Optionally, described pair of all variance data and the target data are merged to form the target after merging Data include:
By number different between the cluster inquiry table of first snapshot data and the cluster inquiry table of second snapshot data Copied to according to cluster in the target data to form the target data after the merging.
Optionally, it is described that snapshot is carried out to the current image file based on qcow2 forms to form first at current time After target snapshot, methods described includes:
The first object snapshot is changed to obtain the original image file, the current image file and by institute State original image file and be converted to the snapshot data passed through successively during the current image file;
Described pair of all variance data and the target data merge with formed merge after target data it Afterwards, methods described also includes:
Delete the current image file.
The embodiments of the invention provide a kind of image file space optimization system, wherein, including:
First snapshot unit, for carrying out snapshot to the current image file based on qcow2 forms with shape at current time Into first object snapshot, the first object snapshot is the n-th snapshot of the original image file based on qcow2 forms, described First object snapshot include being converted to by the original image file pass through successively during the current image file based on The snapshot data of qcow2 forms and it is corresponding with each snapshot data at the time of, the N is the positive integer of non-zero;
Determining unit, for determining target data, the target data is the original image file based on qcow2 forms 1st time snapshot is converted to, and virtual machine has at the time of the target data is corresponded to by the 1st snapshot of original image file Data;
First acquisition unit, for analyzing the first object snapshot to obtain the first snapshot data and the second snapshot data Between variance data, it is described that first snapshot data and second snapshot data are that the original image file is converted to Two of moment upper arbitrary neighborhood in the snapshot data passed through during current image file;
Second acquisition unit, after being merged to all variance datas and the target data to form merging Target data;
Second snapshot unit, for carrying out snapshot to the target data after the merging to form target data snapshot, its In, the target data snapshot is the n-th snapshot of the original image file, and the target data snapshot is virtual machine Current state.
Optionally, the system also includes:
Judging unit, for judging whether the size of the current image file is more than or equal to predetermined threshold value;
The first snapshot unit, it is additionally operable to if it is determined that the space of the current image file is more than or equal to described preset Threshold value, it is determined that snapshot is carried out to the current image file based on qcow2 forms to form first at current time described in performing The step of target snapshot.
Optionally, the system also includes:
Carry unit, for the target data to be mounted into network control techology NBD;
Writing unit, for the variance data between first snapshot data and second snapshot data to be write Enter onto the NBD equipment;
Switching units, for disconnecting the connection status of the NBD equipment.
Optionally, the first acquisition unit, it is additionally operable to the cluster inquiry table of first snapshot data and described second The cluster inquiry table of snapshot data is contrasted to obtain different aggregates of data, and the variance data is first snapshot data Different aggregate of data between cluster inquiry table and the cluster inquiry table of second snapshot data.
Optionally, the second acquisition unit, it is additionally operable to the cluster inquiry table of first snapshot data and described second Different aggregates of data is copied in the target data to form the target after the merging between the cluster inquiry table of snapshot data Data.
Optionally, the system also includes:
Converting unit, for changing the first object snapshot to obtain the original image file, the current mirror image File and the snapshot number passed through successively during the current image file is converted to by the original image file According to;
Unit is deleted, for deleting the current image file.
The invention provides a kind of image file space optimization method and system, the side provided by the present embodiment Method, the image file of virtual machine can be optimized, it is excellent so as to reduce the disk space shared by the image file of virtual machine Change in disk space using the size in space, improved the utilization rate of disk space.
Brief description of the drawings
Fig. 1 is the transfer process schematic diagram of the original image file shown in prior art;
Fig. 2 is a kind of embodiment flow chart of steps of image file space optimization method provided by the present invention;
Fig. 3 is the transfer process schematic diagram of the original image file shown in the present invention;
Fig. 4 is another embodiment flow chart of steps of image file space optimization method provided by the present invention;
Fig. 5 is a kind of example structure schematic diagram of image file space optimization system provided by the present invention.
Embodiment
The image file space optimization method that embodiment is provided for a better understanding of the present invention, below first to qcow2 Form is described in detail.
Qcow2 forms are a kind of virtual machine image file forms that analog processor Qemu is realized, Qemu is in GNU/ The widely used analog processor with GPL license distribution source codes in Linux platform.
Virtual machine (English full name:Virtual Machine) refer to by software simulate there is complete hardware system function , the complete computer operated in a completely isolated environment.By software virtual machine, we can be in a physics One or more virtual computer is simulated on computer, these virtual machines carry out work just as real computer completely Make, such as can be with installation operation system, installation application program, access Internet resources etc..From the point of view of user, it is simply transported An application program of the row on your physical computer, but for the application program run in virtual machine, it just as It is to be operated in real computer.
Qcow2 forms are a kind of virtual machine image file forms that Qemu is realized.
The elementary cell of qcow2 image file data storages based on qcow2 forms is cluster cluster.
The default size of cluster is 64KB, size is may specify when creating qcow2 image files, but size must be 2 time Side (such as 128KB, 256KB, 512KB, 1MB ...).
The content included below to qcow2 image files illustrates, need it is clear that, the present embodiment is to described The content that qcow2 image files are included is optional example, is not limited.
The qcow2 image files can include the first field, and first field is used to indicate the qcow2 image files Relative to the skew of qcow2 image file original positions.
If the qcow2 image files support Copy on write (English full name:Copy-on-write), then qcow2 mirrors As file can include the second field, length of second field for indicating the qcow2 image files character string.
The qcow2 image files can include the 3rd field, and the 3rd field is used for rotating mirror picture with network control techology (English full name:Network Block Device, English abbreviation:Size when NBD) presenting, unit is byte.
The qcow2 image files can include the 4th field, and how many 4th field is used to indicate in current mirror image Individual snapshot, and snapshot time corresponding with each snapshot is also stored in the qcow2 image files.
Further, qcow2 image files support snapshot snapshot mechanism.
The principle of snapshot is carried out to qcow2 image files is:The cluster at qcow2 image file current times during establishment snapshot Inquiry table replicates portion and saved, and is designated as snapshot X.
It is exactly that cluster inquiry table is recovered during recovering to the snapshot Y sometime of qcow2 image files To state at the time of record snapshot Y.
Because the cluster inquiry table that snapshot preserves is also directed to cluster, so some clusters can be pointed to by multiple cluster inquiry tables, and qcow2 is used Reference count table reference count table have been cited how many times to record some cluster.
Below in conjunction with illustrating why data manipulation is carried out in qcow2 image files shown in Fig. 1, qcow2 will result in The size of image file dramatically increases, and causes the drastically decline of physical disk free space.
Original image document creation virtual machine based on the t0 moment, and user environment and data are installed.
In the present embodiment, the form of the original image file is qcow2 forms.
After the original image document creation virtual machine, it is also necessary to user environment is installed and related data just can guarantee that void The normal operation of plan machine.
In the present embodiment, how prior art institute please be referred to by the detailed process of original image document creation virtual machine Show, do not repeat in the present embodiment specifically.
After virtual machine normal operation, snapshot can be created at the t1 moment, i.e., is created at the t1 moment to original image file First time snapshot.
Specifically, create the t1 moment snapshot be exactly based on the original image file of qcow2 forms the t1 moment cluster Inquiry table replicates portion and saved to form the image file at t1 moment.
To the cluster inquiry table illustrate please refer to it is above-mentioned shown in, specifically repeat no more.
Likewise, the detailed process that snapshot is created at the tN-1 moment is identical with the process that snapshot is created at the t1 moment, specifically Repeat no more.
Understand as shown in Figure 1, in the original image file after multiple snapshot operation, you can in current time t5 shape Into the current image file.
Wherein, the form of the current image file is qcow2 forms.
The present embodiment to being converted to current image file by original image file during the number of snapshot that is undergone Do not limit in the present embodiment, in the case of in general, the snapshot more than or equal to 3 times can be undergone.
During current image file is converted to by original image file, the operation for deleting snapshot is can also carry out, its In, specifically how performing the process for the operation for deleting snapshot please refer to shown in prior art, not do in the present embodiment specifically superfluous State.
In the present embodiment, the size of the current image file is probably the several times of the size of original image file, or even Decades of times, reach hundred GB magnitudes.
If not optimizing processing to the current image file, the current image file can take larger disk Space, reduce the utilization rate of disk space.
It is described in detail based on the image file space optimization method that above-mentioned principle is provided the present embodiment, following institute The image file space optimization method shown can optimize to the current image file, so that the institute after optimization State magnetic of the disk space shared by relative to the current image file not optimized shared by current image file Disk space is small, improves the utilization rate of disk space.
Carried out in detail below in conjunction with the detailed process of the image file space optimization method provided shown in Fig. 2 the present embodiment Describe in detail bright:
Step 201, judge whether the size of the current image file based on qcow2 forms is more than or equal to predetermined threshold value, If so, then perform step 202.
Below in conjunction with illustrative to the transfer process of the original image file shown in Fig. 3.
The t5 moment shown in Fig. 3 is current time, the present embodiment judge the current image file at t5 moment whether be more than or Equal to predetermined threshold value.
The present embodiment is not limited the size of the predetermined threshold value, and the predetermined threshold value can be by user according to the need of itself Ask and set, as long as the size of the set predetermined threshold value is less than the size of disk space.
The form of the current image file is qcow2 forms, to the qcow2 forms illustrate please refer to it is above-mentioned It is shown, specifically repeat no more.
In the present embodiment, only when the size of the current image file is more than or equal to predetermined threshold value, it can just carry out Following steps optimize to the current image file, so as to reduce the disk space shared by the image file after optimization, And then lift the utilization rate of disk space.
It can be seen that the step 201 shown in using the present embodiment, the size of the current image file of monitoring that can be at any time, are being supervised When measuring the size of the current image file and being more than or equal to predetermined threshold value, then the current mirror image performed shown in following steps is literary The optimization process of part.
According to the step 201 shown in the present embodiment, monitor that the size of current image file is less than the predetermined threshold value When, then the optimization process of the current image file shown in following steps is not performed.
That is, when the size of the current image file is less than the predetermined threshold value, the current image file will not be made Into the overcharge of disk space, then without being optimized to the current image file.
Need it is clear that, the step 201 described in the present embodiment is optional step, is not limited in the present embodiment specifically.
The present embodiment is illustrative exemplified by performing the step 201.
Step 202, at current time snapshot is carried out to form first object to the current image file based on qcow2 forms Snapshot.
The t5 moment shown in Fig. 3 is current time, and the present embodiment carries out snapshot to current time t5 current image file To form first object snapshot.
When current image file exceedes the predetermined threshold value, you can carry out snapshot to the current image file to be formed First object snapshot.
In the present embodiment, the first object snapshot is the n-th snapshot of original image file.
The first object snapshot have recorded the last state of original image file.
Because the first object snapshot have recorded the last state of virtual machine, then the first object snapshot can be effective Ensure the integrality of virtual-machine data, the loss of data will not be caused.
Specifically, the first object snapshot is included during being converted to the current image file by original image file The snapshot data that passes through successively and it is corresponding with each snapshot data at the time of, the N is the positive integer of non-zero.
Need it is clear that, the present embodiment is not limited N specific value.
Also need it is clear that, be converted to what is passed through successively during the current image file by the original image file The form of the snapshot data is qcow2 forms.
Step 203, determine target data.
The target data is converted to for the 1st snapshot of the original image file based on qcow2 forms, the target Data for virtual machine institute the 1st snapshot when possessed data.
Specifically, during using virtual machine, the operations such as continuous data deletion, addition are had, are reacted virtual The action for such as deleting file, establishment file inside machine.
It is empty at the time of target data shown in the present embodiment is corresponding to the 1st snapshot of the original image file Data possessed by plan machine.
Optionally, the target data is determined, can also be based on the arbitrarily once original image file based on qcow2 forms Snapshot.
Optionally, the target data can be mounted on network control techology NBD by the present embodiment.
Step 204, the conversion first object snapshot with obtain the original image file, the current image file, And the snapshot data passed through successively during the current image file is converted to by the original image file.
The present embodiment can be recovered the snapshot data at each moment of the first object snapshot.
The current image file shown in the present embodiment can play a part of a backup file, once in optimization During there is mistake, then can recover virtual machine image file, so as to ensure the normal operation of virtual machine.
Specifically, as shown in Figure 3, initial time t0 original image text can be recovered according to the first object snapshot Part, the snapshot data of t1 moment (at the time of first time snapshot is carried out to original image file) can be recovered, can be recovered Go out the t2 moment snapshot data of (at the time of second of snapshot is carried out to original image file), the tN-1 moment can be recovered The snapshot data of (at the time of N-1 snapshots are carried out to original image file).
More specifically, during t1 moment snapshot datas are recovered, when cluster inquiry table exactly being returned to record t1 The state at quarter, the specific process for recovering snapshot data please be referred to shown in prior art, do not repeated in the present embodiment specifically.
Step 205, the first object snapshot is analyzed to obtain the difference between the first snapshot data and the second snapshot data Heteromerism evidence.
First snapshot data and second snapshot data are that the original image file is converted to the current mirror As two of moment upper arbitrary neighborhood in the snapshot data that is passed through in file processes.
The present embodiment with it is corresponding with first snapshot data at the time of it is corresponding earlier than with second snapshot data when Exemplified by quarter, after getting first snapshot data and second snapshot data, you can by first snapshot data Cluster inquiry table and the cluster inquiry table of second snapshot data are contrasted to obtain different aggregates of data.
The variance data is the cluster inquiry table of first snapshot data and the cluster inquiry table of second snapshot data Between different aggregate of data.
Step 205 is illustrated below in conjunction with shown in Fig. 3:
It is so that first snapshot data is the original image file as an example, then corresponding with first snapshot data to be Moment t 0;
Because second snapshot data is two adjacent with being engraved during first snapshot data, and with it is described first fast At the time of correspondence according to data earlier than it is corresponding with second snapshot data at the time of, then second snapshot data is the t1 moment Snapshot data, i.e., described second snapshot data are snapshot data when first time snapshot is carried out to the original image file.
Further, by the cluster inquiry table of the first snapshot data (snapshot data corresponding with moment t0) and described second fast According to data (from moment t1 corresponding to snapshot data) cluster inquiry table contrasted to obtain different aggregates of data.
Specifically, first snapshot data (snapshot data corresponding with moment t0) and second snapshot data (with Snapshot data corresponding to moment t1) between variance data be the cluster inquiry table of first snapshot data and described second fast According to aggregate of data different between the cluster inquiry table of data.
Optionally, the variance data between first snapshot data and second snapshot data can be written to In the NBD equipment.
Optionally, it is written to by the variance data between first snapshot data and second snapshot data After the NBD equipment, you can disconnect the connection status of the NBD equipment.
The safety of data can effectively be ensured by disconnecting the connection status of NBD equipment, avoid the loss of data.
The like,
Snapshot data corresponding with the t1 moment can be defined as the first snapshot data, will snapshot data corresponding with the t2 moment It is defined as the second snapshot data, you can determine between first snapshot data and second snapshot data according to step 205 Variance data.
……
Snapshot data corresponding with the tN-1 moment can be defined as the first snapshot data, will snapshot number corresponding with the tN moment According to being defined as the second snapshot data, you can determined according to step 5 between first snapshot data and second snapshot data Variance data.
Step 206, all variance datas and the target data are merged to form the number of targets after merging According to.
Get and all institutes passed through successively during the current image file are converted to by the original image file The variance data between two of arbitrary neighborhood in snapshot data is stated, and all variance datas are entered with the target data Row merges to form the target data after the merging.
Specifically, the detailed process of the target data formed after the merging can be:By the cluster of first snapshot data Different aggregates of data is copied in the target data to be formed between inquiry table and the cluster inquiry table of second snapshot data Target data after the merging.
Step 207, snapshot is carried out to the target data after the merging to form target data snapshot.
Wherein, the target data snapshot is the n-th snapshot of the original image file, and the target data snapshot For the current state of virtual machine.
Step 208, delete the current image file.
In the image file space optimization method provided by the present embodiment, image file can be optimized, it is excellent The detailed process of change for obtain the target data and the first snapshot data of current image file and the second snapshot data it Between variance data, and then the target data and the variance data are merged to obtain the target after the merging Data, the size of the current image file can be effectively reduced using the optimization method shown in the present embodiment, is effectively released Disk space is put, is improved in disk space using the size in space, improves the utilization rate of disk space.
Image file space optimization method shown in Fig. 2 is the application scenarios based on multiple snapshots and reservation snapshot, with Do not retain to no snapshot and the application scenarios of snapshot and illustrate shown in lower combination Fig. 4.
Step 401, judge whether the size of the current image file based on qcow2 forms is more than or equal to predetermined threshold value, If so, then perform step 402.
Step 401 shown in the present embodiment is optional step, the step 201 of specific implementation procedure please in detail as shown in Figure 2, is had Body is not detailed in the present embodiment.
Step 402, at current time snapshot is carried out to form first object to the current image file based on qcow2 forms Snapshot.
The specific implementation procedure of step 402 shown in the present embodiment, please step 202 in detail as shown in Figure 2, was specifically performed Journey is not detailed in the present embodiment.
Step 403, the current image file is directly changed to form the second target data.
Specifically, the current first object snapshot of the image file based on above-mentioned steps 402 is changed to form second Target data.
Step 404, second target data execution snapshot operation is given, to be used as virtual machine current state.
In the second target data, all SNAPSHOT INFOs before first object snapshot shown in the present embodiment have been deleted.
Step 405, delete current image file.
In the image file space optimization method provided by the present embodiment, image file can be optimized, it is excellent The detailed process of change performs to change the first object data to form the second target data to second target data Snapshot operation, so that as virtual machine current state, described work as can be effectively reduced using the optimization method shown in the present embodiment The size of preceding image file, effective release disk space, improve in disk space using the size in space, improve magnetic The utilization rate of disk space.
The present embodiment additionally provides a kind of image file space optimization system, and the image file space shown in the present embodiment is excellent Change system is able to carry out the image file space optimization method shown in Fig. 2, and the specific of the image file space optimization method is held Row flow and acquired beneficial effect in detail as shown in Figure 2, do not repeat specifically please in the present embodiment.
As shown in figure 5, the image file space optimization system includes:
Judging unit 501, for judging whether the size of the current image file is more than or equal to predetermined threshold value;
First snapshot unit 502, for current time to based on qcow2 forms current image file carry out snapshot with Formed first object snapshot, the first object snapshot be the original image file based on qcow2 forms n-th snapshot, institute Stating first object snapshot includes being converted to the base successively passed through during the current image file by the original image file In qcow2 forms snapshot data and it is corresponding with each snapshot data at the time of, the N is the positive integer of non-zero;
The first snapshot unit 502, it is additionally operable to if it is determined that the space of the current image file is more than or equal to described Predetermined threshold value, it is determined that snapshot is carried out to the current image file based on qcow2 forms to be formed at current time described in performing The step of first object snapshot.
Converting unit 503, for changing the first object snapshot to obtain the original image file, the current mirror The snapshot number passed through successively during the current image file is converted to as file and by the original image file According to;
Determining unit 504, for determining target data, the target data is the original image text based on qcow2 forms 1st snapshot of part is converted to, virtual machine institute at the time of the target data corresponds to for the 1st snapshot of original image file The data having;
Carry unit 505, for the target data to be mounted into network control techology NBD;
First acquisition unit 506, for analyzing the first object snapshot to obtain the first snapshot data and the second snapshot Variance data between data, first snapshot data and second snapshot data are that the original image file is converted to Two of moment upper arbitrary neighborhood in the snapshot data passed through during the current image file;
The first acquisition unit 506, it is additionally operable to the cluster inquiry table of first snapshot data and second snapshot The cluster inquiry table of data is contrasted to obtain different aggregates of data, and the variance data is looked into for the cluster of first snapshot data Ask aggregate of data different between table and the cluster inquiry table of second snapshot data.
Writing unit 507, for by the difference number between first snapshot data and second snapshot data According to being written in the NBD equipment;
Second acquisition unit 508, closed for being merged to all variance datas and the target data with being formed Target data after and;
The second acquisition unit 508, it is additionally operable to the cluster inquiry table of first snapshot data and second snapshot Different aggregates of data is copied in the target data to form the target data after the merging between the cluster inquiry table of data.
Switching units 509, for disconnecting the connection status of the NBD equipment.
Second snapshot unit 510, for carrying out snapshot to the target data after the merging to form target data snapshot, Wherein, the target data snapshot is the n-th snapshot of the original image file, and the target data snapshot is virtual machine Current state.
Unit 511 is deleted, for deleting the current image file.
The image file space optimization system provided by the present embodiment, can be optimized to image file, optimization Detailed process to obtain between the first snapshot data and the second snapshot data of the target data and current image file Variance data, and then the target data and the variance data are merged to obtain the number of targets after the merging According to can effectively reduce the big of the current image file using the image file space optimization system shown in the present embodiment It is small, effective release disk space, improve in disk space using the size in space, improve the utilization of disk space Rate.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description, The specific work process of device and unit, the corresponding process in preceding method embodiment is may be referred to, will not be repeated here.
In several embodiments provided herein, it should be understood that disclosed system, apparatus and method can be with Realize by another way.For example, device embodiment described above is only schematical, for example, the unit Division, only a kind of division of logic function, can there is other dividing mode, such as multiple units or component when actually realizing Another system can be combined or be desirably integrated into, or some features can be ignored, or do not perform.It is another, it is shown or The mutual coupling discussed or direct-coupling or communication connection can be the indirect couplings by some interfaces, device or unit Close or communicate to connect, can be electrical, mechanical or other forms.
The unit illustrated as separating component can be or may not be physically separate, show as unit The part shown can be or may not be physical location, you can with positioned at a place, or can also be distributed to multiple On NE.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs 's.
In addition, each functional unit in each embodiment of the present invention can be integrated in a processing unit, can also That unit is individually physically present, can also two or more units it is integrated in a unit.Above-mentioned integrated list Member can both be realized in the form of hardware, can also be realized in the form of SFU software functional unit.
If the integrated unit is realized in the form of SFU software functional unit and is used as independent production marketing or use When, it can be stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially The part to be contributed in other words to prior art or all or part of the technical scheme can be in the form of software products Embody, the computer software product is stored in a storage medium, including some instructions are causing a computer Equipment (can be personal computer, server, or network equipment etc.) performs the complete of each embodiment methods described of the present invention Portion or part steps.And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only storage (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CD etc. are various can store journey The medium of sequence code.
Described above, the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although with reference to before Embodiment is stated the present invention is described in detail, it will be understood by those within the art that:It still can be to preceding State the technical scheme described in each embodiment to modify, or equivalent substitution is carried out to which part technical characteristic;And these Modification is replaced, and the essence of appropriate technical solution is departed from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (12)

  1. A kind of 1. image file space optimization method, it is characterised in that including:
    Snapshot is carried out to the current image file based on qcow2 forms to form first object snapshot at current time, described the One target snapshot is the n-th snapshot of the original image file based on qcow2 forms, and the first object snapshot is included by described Original image file be converted to the snapshot data based on qcow2 forms that passes through successively during the current image file and At the time of corresponding with each snapshot data, the N is the positive integer of non-zero;
    Target data is determined, the target data is changed for the 1st snapshot of the original image file based on qcow2 forms Arrive, data possessed by virtual machine at the time of the target data corresponds to for the 1st snapshot of original image file;
    The first object snapshot is analyzed to obtain the variance data between the first snapshot data and the second snapshot data, described One snapshot data and second snapshot data are converted to institute during the current image file for the original image file Two of moment upper arbitrary neighborhood in the snapshot data passed through;
    All variance datas and the target data are merged to form the target data after merging;
    Snapshot is carried out to the target data after the merging to form target data snapshot, wherein, the target data snapshot is The n-th snapshot of the original image file, and the target data snapshot is the current state of virtual machine.
  2. 2. according to the method for claim 1, it is characterised in that it is described at current time to based on the current of qcow2 forms Image file carries out snapshot so that before forming first object snapshot, methods described also includes:
    Judge whether the size of the current image file is more than or equal to predetermined threshold value;
    If it is determined that the space of the current image file is more than or equal to the predetermined threshold value, it is determined that described in performing when current Carve and the step of snapshot is to form first object snapshot is carried out to the current image file based on qcow2 forms.
  3. 3. method according to claim 1 or 2, it is characterised in that methods described also includes:
    The target data is mounted on network control techology NBD;
    The analysis first object snapshot with obtain the variance data between the first snapshot data and the second snapshot data it Afterwards, methods described also includes:
    The variance data between first snapshot data and second snapshot data is written to the NBD equipment On;
    The target data to after the merging carries out snapshot so that before forming target data snapshot, methods described also includes:
    Disconnect the connection status of the NBD equipment.
  4. 4. method according to claim 1 or 2, it is characterised in that the analysis first object snapshot is to obtain the Variance data between one snapshot data and the second snapshot data includes:
    The cluster inquiry table of the cluster inquiry table of first snapshot data and second snapshot data is contrasted to obtain not Same aggregate of data, the variance data are the cluster inquiry table of first snapshot data and the cluster inquiry of second snapshot data Different aggregate of data between table.
  5. 5. according to the method for claim 4, it is characterised in that described pair of all variance data and the target data Merge is included with forming the target data after merging:
    By aggregate of data different between the cluster inquiry table of first snapshot data and the cluster inquiry table of second snapshot data Copy in the target data to form the target data after the merging.
  6. 6. according to the method for claim 1, it is characterised in that it is described at current time to based on the current of qcow2 forms After image file carries out snapshot to form first object snapshot, methods described includes:
    The first object snapshot is changed to obtain the original image file, the current image file and by the original Beginning image file is converted to the snapshot data passed through successively during the current image file;
    After described pair of all variance data and the target data are merged to form the target data after merging, institute Stating method also includes:
    Delete the current image file.
  7. A kind of 7. image file space optimization system, it is characterised in that including:
    First snapshot unit, for carrying out snapshot to the current image file based on qcow2 forms at current time to form the One target snapshot, the first object snapshot be the original image file based on qcow2 forms n-th snapshot, described first Target snapshot include being converted to by the original image file pass through successively during the current image file based on qcow2 The snapshot data of form and it is corresponding with each snapshot data at the time of, the N is the positive integer of non-zero;
    Determining unit, for determining target data, the target data is the 1 of the original image file based on qcow2 forms Secondary snapshot is converted to, at the time of the target data corresponds to for the 1st snapshot of original image file possessed by virtual machine Data;
    First acquisition unit, for analyzing the first object snapshot to obtain between the first snapshot data and the second snapshot data Variance data, it is described current that first snapshot data and second snapshot data are that the original image file is converted to Two of moment upper arbitrary neighborhood in the snapshot data passed through during image file;
    Second acquisition unit, for all variance datas and the target data to be merged with the mesh to form after merging Mark data;
    Second snapshot unit, for carrying out snapshot to the target data after the merging to form target data snapshot, wherein, institute The n-th snapshot that target data snapshot is the original image file is stated, and the target data snapshot is the current of virtual machine State.
  8. 8. system according to claim 7, it is characterised in that the system also includes:
    Judging unit, for judging whether the size of the current image file is more than or equal to predetermined threshold value;
    The first snapshot unit, it is additionally operable to if it is determined that the space of the current image file is more than or equal to the default threshold Value, it is determined that snapshot is carried out to the current image file based on qcow2 forms to form the first mesh at current time described in performing The step of marking snapshot.
  9. 9. the system according to claim 7 or 8, it is characterised in that the system also includes:
    Carry unit, for the target data to be mounted into network control techology NBD;
    Writing unit, for the variance data between first snapshot data and second snapshot data to be written to In the NBD equipment;
    Switching units, for disconnecting the connection status of the NBD equipment.
  10. 10. the system according to claim 7 or 8, it is characterised in that the first acquisition unit, be additionally operable to described The cluster inquiry table of one snapshot data and the cluster inquiry table of second snapshot data are contrasted to obtain different aggregates of data, institute It is different between the cluster inquiry table of first snapshot data and the cluster inquiry table of second snapshot data to state variance data Aggregate of data.
  11. 11. system according to claim 10, it is characterised in that the second acquisition unit, be additionally operable to described first Different aggregates of data copies to the target between the cluster inquiry table of snapshot data and the cluster inquiry table of second snapshot data To form the target data after the merging in data.
  12. 12. system according to claim 7, it is characterised in that the system also includes:
    Converting unit, for change the first object snapshot with obtain the original image file, the current image file, And the snapshot data passed through successively during the current image file is converted to by the original image file;
    Unit is deleted, for deleting the current image file.
CN201610630261.0A 2016-08-03 2016-08-03 A kind of image file space optimization method and system Pending CN107688508A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610630261.0A CN107688508A (en) 2016-08-03 2016-08-03 A kind of image file space optimization method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610630261.0A CN107688508A (en) 2016-08-03 2016-08-03 A kind of image file space optimization method and system

Publications (1)

Publication Number Publication Date
CN107688508A true CN107688508A (en) 2018-02-13

Family

ID=61151522

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610630261.0A Pending CN107688508A (en) 2016-08-03 2016-08-03 A kind of image file space optimization method and system

Country Status (1)

Country Link
CN (1) CN107688508A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110941511A (en) * 2019-11-21 2020-03-31 深信服科技股份有限公司 Snapshot merging method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103699459A (en) * 2013-12-31 2014-04-02 汉柏科技有限公司 Method and system for incremental backup of virtual machine data based on Qcow2 snapshots
CN103970585A (en) * 2013-01-31 2014-08-06 杭州华三通信技术有限公司 Method and device for creating virtual machine
CN104461773A (en) * 2014-11-18 2015-03-25 国云科技股份有限公司 Backup deduplication method of virtual machine
US9058299B2 (en) * 2013-01-08 2015-06-16 Red Hat Israel, Ltd. Efficient copying between storage devices
CN105022656A (en) * 2014-04-21 2015-11-04 中国电信股份有限公司 Management method and device of virtual machine snapshot

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9058299B2 (en) * 2013-01-08 2015-06-16 Red Hat Israel, Ltd. Efficient copying between storage devices
CN103970585A (en) * 2013-01-31 2014-08-06 杭州华三通信技术有限公司 Method and device for creating virtual machine
CN103699459A (en) * 2013-12-31 2014-04-02 汉柏科技有限公司 Method and system for incremental backup of virtual machine data based on Qcow2 snapshots
CN105022656A (en) * 2014-04-21 2015-11-04 中国电信股份有限公司 Management method and device of virtual machine snapshot
CN104461773A (en) * 2014-11-18 2015-03-25 国云科技股份有限公司 Backup deduplication method of virtual machine

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110941511A (en) * 2019-11-21 2020-03-31 深信服科技股份有限公司 Snapshot merging method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
EP2521966B1 (en) Systems and methods for removing unreferenced data segments from deduplicated data systems
US9158631B1 (en) Systems and methods for providing backup interfaces
US9336224B2 (en) Systems and methods for providing increased scalability in deduplication storage systems
US8200926B1 (en) Methods and systems for creating full backups
CN102667703B (en) For the system and method for the optimization recycling in Virtual Tape Library System
US9594652B1 (en) Systems and methods for decreasing RAID rebuilding time
US8407438B1 (en) Systems and methods for managing virtual storage disk data
US8108446B1 (en) Methods and systems for managing deduplicated data using unilateral referencing
CN105446834B (en) The generation method and device of virtual machine snapshot
US8280854B1 (en) Systems and methods for relocating deduplicated data within a multi-device storage system
US9690666B1 (en) Incremental backup operations in a transactional file system
US8984027B1 (en) Systems and methods for migrating files to tiered storage systems
JP6186374B2 (en) System and method for secure migration to a virtualized platform
EP3380921B1 (en) Systems and methods for taking snapshots in a deduplicated virtual file system
AU2012347883A1 (en) System and method for restoring application data
US8898115B1 (en) Systems and methods for using data archiving to expedite server migration
US10409497B2 (en) Systems and methods for increasing restore speeds of backups stored in deduplicated storage systems
US9996459B2 (en) Reclaiming of sequential storage medium
US10691349B2 (en) Mitigating data loss
CN107688508A (en) A kind of image file space optimization method and system
CN108536822A (en) Data migration method, device, system and storage medium
US10002050B1 (en) Systems and methods for improving rehydration performance in data deduplication systems
US11226739B2 (en) Method, device and computer program product for storage management
EP2820610A1 (en) Systems and methods for maintaining group membership records
CN108459828B (en) Desktop cloud disk redistribution method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180213