WO2016070641A1 - Data storage method and device, and data reading method and device - Google Patents

Data storage method and device, and data reading method and device Download PDF

Info

Publication number
WO2016070641A1
WO2016070641A1 PCT/CN2015/083472 CN2015083472W WO2016070641A1 WO 2016070641 A1 WO2016070641 A1 WO 2016070641A1 CN 2015083472 W CN2015083472 W CN 2015083472W WO 2016070641 A1 WO2016070641 A1 WO 2016070641A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
server
disk
file
vhd
Prior art date
Application number
PCT/CN2015/083472
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 中兴通讯股份有限公司
Publication of WO2016070641A1 publication Critical patent/WO2016070641A1/en

Links

Images

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

Definitions

  • the present invention relates to the field of communications, and in particular, to a data storage method, device, and reading method and device
  • the network diskless system is a technology that saves the operating system image on the server.
  • the client does not have a hard disk locally or does not use a local hard disk.
  • the preboot execution environment (PXE) is used to boot from the network.
  • the client operating system is stored on the server and requires an efficient and flexible management method.
  • the traditional method is to use a virtual hard disk in the raw RAW format, and then use the Internet Small Computer System Interface (iSCSI). Sharing to the client, using RAW format takes up a lot of disk space, inconvenient to backup, etc.
  • RAW mainly has the following shortcomings: (1) wasting storage space: using the bare format RAW format hard disk needs to allocate all the space in advance If you create a 10G hard disk for the user, you must first create a 10G file on the server. You cannot allocate space as needed by the user. (2) Inconvenient maintenance: The virtual hard disk file is generally larger. And the RAW format does not support snapshots, so backups can only be copied, The way of pasting is slow and wastes space, and maintenance is inconvenient.
  • the RAW format has a problem that the disk space is large, the backup is inconvenient, and the sub-image is not supported, and an effective solution has not been proposed.
  • Embodiments of the present invention provide a method, an apparatus, and a reading method and apparatus for saving data to solve at least one of the above problems.
  • a data saving method including: a server receives a write request for data; and under the trigger of the write request, the server writes the data to a local virtual
  • the sector in the virtual hard disk (VHD) file is saved and saved.
  • the method includes: the server determines whether a sector corresponding to the write request has been allocated, where In the case of being allocated, the server allocates the sector for the data; in the event that the determination has been assigned, the server is triggered to write the data to the sector.
  • the server determines whether a sector corresponding to the write request has been allocated, and the server obtains a Block allocation table (BAT) table from the local VHD file; the server A determination is made as to whether a sector corresponding to the write request has been allocated according to the BAT table.
  • BAT Block allocation table
  • the method further includes: sending, when the operating system image file changes, an incremental portion of the operating system image file that is changed to the client.
  • the method further includes: the server receiving a read request for the VHD file; reading data corresponding to the read request from a difference disk; and confirming that the data corresponding to the read request is in the difference In the case where the disk is not recorded, the data is read from the parent disk of the difference disk, wherein the data stored in the difference disk is data changed in the parent disk.
  • the method further includes: mounting the VHD file as a raw device file, and providing the operating system image file to the client.
  • a method for reading data includes: receiving, by the server, a read request for an operating system image file; and triggering, by the read request, the server The data corresponding to the read request is read in the local virtual hard disk VHD file.
  • the reading, by the server, the data corresponding to the read request from the local VHD file includes: reading data corresponding to the read request from the difference disk; and confirming that the data corresponding to the read request is in the difference disk If the data is not recorded, the data is read from the parent disk of the difference disk, wherein the data stored in the difference disk is data changed in the parent disk.
  • a data saving apparatus configured to be applied to a server, comprising: a receiving module configured to receive a write request for data; and a writing module configured to be in the write Under the trigger of the request, the data is written to the sector in the local virtual hard disk VHD file and saved.
  • a data reading device the device being applied to a server, comprising: a receiving module configured to receive a read request for an operating system image file; and a reading module And being configured to read data corresponding to the read request from a local VHD file under the trigger of the read request.
  • the server receives the write request for the data; under the trigger of the write request, the server writes the data to the sector in the local virtual hard disk VHD file and saves it.
  • the RAW format in the related art solves the problem that the RAW format occupies a large disk space, is inconvenient to backup, and does not support the sub-image.
  • the disk space is allocated on demand, the backup is convenient, and the snapshot and sub-image are supported.
  • FIG. 1 is a flow chart of a method for saving data according to an embodiment of the present invention
  • FIG. 2 is a flow chart of a method of reading data according to an embodiment of the present invention.
  • FIG. 3 is a structural block diagram of a data saving apparatus according to an embodiment of the present invention.
  • FIG. 4 is a block diagram showing the structure of a data reading apparatus according to an embodiment of the present invention.
  • FIG. 5 is a structural diagram of a VHD file according to an embodiment of the present invention.
  • FIG. 6 is a flow chart of a VHD read in accordance with an embodiment of the present invention.
  • FIG. 7 is a flow chart of writing a VHD file according to an embodiment of the present invention.
  • FIG. 8 is a flow chart of creating a sub-image of a VHD according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a method for saving data according to an embodiment of the present invention. As shown in FIG. 1, the process includes the following steps:
  • Step S102 the server receives a write request for data
  • Step S104 under the trigger of the write request, the server writes the data into the sector in the local virtual hard disk VHD file and saves it.
  • the server uses the VHD format to write and manage the operating system image file.
  • the storage space is wasted, and the maintenance is inconvenient, and the above steps solve the above problems, thereby achieving the above problem. Allocate disk space on demand, easy backup, support for snapshots and submirrors.
  • the server determines whether the sector corresponding to the write request has been allocated, wherein, in the case where the determination is not allocated, The server allocates sectors for the data; in the case where it is determined that it has been allocated, the trigger server writes operating system data to the sector. Therefore, the server allocates sectors according to the write request, realizing on-demand allocation and dynamically allocating disk space.
  • the server needs to determine whether the sector corresponding to the write request has been allocated.
  • the server obtains the BAT table from the local VHD file, and the server determines the sector corresponding to the write request according to the BAT table. Has it been assigned?
  • the incremental portion of the changes in the operating system image file is sent to the client when the operating system image file changes. Through this step, only the incremental part of the operating system image file is sent to the client, which improves storage efficiency and reduces storage space.
  • the data corresponding to the read request is first read from the difference disk, and if the data corresponding to the read request is confirmed to be unrecorded in the difference disk, The data is read from the parent disk of the differencing disk, where the data stored in the differencing disk is the data that changed in the parent disk. This saves storage space.
  • the VHD file is mounted as a raw device file and an operating system image file is provided to the client.
  • the raw device file is equivalent to a physical hard disk.
  • FIG. 2 is a flowchart of a data reading method according to an embodiment of the present invention. As shown in FIG. 2, the process includes the following steps:
  • Step S202 the server receives a read request for an operating system image file.
  • Step S204 the server reads the data corresponding to the read request from the local virtual hard disk VHD file under the trigger of the read request.
  • the server saves the operating system image in the VHD format.
  • the storage space is wasted, and the maintenance is inconvenient, the above steps solve the above problem, thereby achieving the disk space allocated on demand. , the effect of using snapshots for backups.
  • the data corresponding to the read request is first read from the difference disk, and if the data corresponding to the read request is confirmed to be unrecorded in the difference disk, The data is read from the parent disk of the differencing disk, where the data stored in the differencing disk is the data that changed in the parent disk. Thereby improving the efficiency of reading files.
  • FIG. 3 is a structural block diagram of a data saving apparatus according to an embodiment of the present invention.
  • the apparatus is applied to a server.
  • the apparatus includes: a receiving module 32 configured to receive a write request for an operating system image file;
  • the write module 34 is configured to write the operating system data to the sector in the local virtual hard disk VHD file and save it under the trigger of the write request.
  • FIG. 4 is a structural block diagram of a data reading apparatus according to an embodiment of the present invention.
  • the apparatus is applied to a server.
  • the apparatus includes: a receiving module 42 configured to receive a read request for an operating system image file.
  • the read module 44 is configured to read the operating system data from the local VHD file under the trigger of the read request.
  • each of the above modules may be implemented by software or hardware.
  • the foregoing may be implemented by, but not limited to, the foregoing modules are all located in the same processor; or, the above modules are respectively located.
  • the first processor, the second processor, and the third processor In the first processor, the second processor, and the third processor.
  • VHD Microsoft Virtual Hard Disk format, a virtual disk format that supports dynamic and nutrient disks.
  • the Microsoft Hyper-v virtualization platform uses VHD as a virtual machine hard disk. Similar formats include VMDK and QCOW2.
  • PXE A network boot protocol. This is implemented in a general network card.
  • iPXE An upgraded version of the PXE protocol.
  • Networkless disk Boot the computer from the network through PXE or iPXE. All data is saved on the remote server. There is no hard disk in the local.
  • iSCSI A storage protocol that shares block devices (such as disks) over an IP network.
  • the client uses the iSCSI shared hard disk to be the same as the local hard disk. It can partition and format the disk.
  • This alternative embodiment develops a method for saving and managing images using a virtual hard disk (VHD) format.
  • VHD format has the advantages of space-on-demand allocation, snapshot creation and encryption, and the like.
  • the image is migrated directly to the virtualization platform.
  • the optional embodiment is designed to save the image file in the VHD format.
  • the optional embodiment has a method for directly reading and writing a VHD file without using a third-party tool; After receiving the VHD read and write request, first open the VHD file to obtain the BAT of the VHD. The table determines whether the corresponding sector is allocated in the VHD file and the position of the sector in the file according to the BAT table. If the sector corresponding to the write request is not allocated in the VHD file, the corresponding data block is to be allocated and modified.
  • the system will first read the bat entry of the difference disk x block. If the value is 0xFFFFFF, indicating that the data is not recorded in the difference disk, then the xth block of the parent disk of the difference disk should be read; if the value of the bat entry is not 0xFFFFFF, whether the x block in the batmap can be used is full. (or analyze the bitmap in the block data area) to determine whether it needs to penetrate into the parent disk to make up the difference. If it is full, it does not need to process the parent disk; if it is not full, then look at the bitmap in the data area of the block. Bit 0, 0 is penetrated into the parent disk to make up the difference, and 1 is directly read.
  • VHD files A major feature of VHD files is that disk space is allocated on demand. When a VHD file is created, no data block (disk space) is allocated. When the VHD receives a write disk operation, it will detect the corresponding bat table. If the value of the bat table is 0xFFFFFF , indicating that the corresponding data block is not allocated in the VHD file, then allocate the data block by increasing the size of the VHD file (by writing a number of zeros at the end of the file), and modifying the corresponding value in the bat table. The offset of the new data block in the VHD file;
  • VHD files support the snapshot function.
  • the snapshot technology can be used to quickly back up data. It is much faster than copying and pasting files directly.
  • VHD snapshots are created by creating sub-images of VHDs (also called differential disks). (Because the VHD sub-image is created without assigning data blocks, only a small content such as a VHD file header and a BAT table is created, so the speed is fast). After the sub-image is created, the read and write operations are performed only for the sub-image, and the parent image is no longer operated. The results of reading and writing are stored in the sub-image, which plays a role in the backup of the parent image;
  • the optional embodiment introduces a zhong xing virtualization environments (ZXVE) platform (operating system, ZTE virtualization platform), and the VHD can be hung by the ZXVE.
  • ZXVE zhong xing virtualization environments
  • the server mounts the VHD as a bare device
  • the VHD raw device is shared by iSCSI;
  • the client starts up with the PXE network, obtains the address from the DHCP server for iPXE startup, and enters the iPXE to select the operating system to be started to start by the shared iSCSI;
  • the client sends a read and write request for the iSCSI disk to the server.
  • the server After receiving the request, the server reads and writes the VHD and returns the result to the client (for detailed reading and writing of the VHD, please refer to the attached figure).
  • the network diskless system needs to occupy a large amount of network bandwidth, which has high requirements on the network and affects the user experience.
  • This alternative embodiment designs a local data cache and incremental update method to improve access to the network and improve diskless users. Use experience
  • the system checks whether the data requested by the user exists in the buffer. If the data is cached, the data is directly retrieved from the buffer area and returned to the user, and the data does not need to be fetched through the network;
  • the server in the network requests the data, and saves the data in the buffer after the data is acquired, so that it can be used again until all the data is cached locally. Great savings in network bandwidth.
  • the cached data may be inconsistent in the server data (such as the administrator updating the image on the server, installing the software, etc.), and the client requests to update the system after the administrator modifies the server parent image. Calculate the variable sector of the sub-image intersecting parent image, and send the variable part to the client. The client writes the changed part to the local buffer according to the server-side data, and restarts the computer after the client change part is updated.
  • FIG. 5 is a structural diagram of a VHD file according to an embodiment of the present invention. As shown in FIG. 5, the structure of a VHD file needs to be parsed for directly reading and writing a VHD file;
  • FIG. 6 is a flow chart of VHD reading according to an embodiment of the present invention. As shown in FIG. 6, the process includes the following steps:
  • Step S602 opening the VHD
  • Step S604 acquiring a BAT table
  • Step S606 determining the content of the corresponding index in the BAT table according to the sector number to be read;
  • Step S608 it is determined whether the value in the BAT table is 0xFFFFFFFF, if the determination is yes, step S610 is performed, if the determination is no, step S614 is performed;
  • Step S610 indicating that the content of the sector to be read is 0;
  • Step S612 returning the sector content to 0 to the user
  • Step S614 reading the corresponding position of the VHD according to the content of the BAT table, the read size is 2M, and the first sector represents the use bitmap of each sector in the data block;
  • Step S616 it is determined whether the sector bitmap value is 1, if the determination is yes, step S618 is performed, if the determination result is no, step S620 is performed;
  • Step S620 finding a parent node of the VHD file, and reading the parent node according to the reading process to obtain the sector content;
  • Step S622 return.
  • the system first reads the bat entry of the difference disk x block. If the value is 0xFFFFFF, indicating that the data is not recorded in the difference disk, then the xth block of the parent disk of the difference disk should be read; if the value of the bat entry is not 0xFFFFFF, whether the x block in the batmap can be used is full. (or analyze the bitmap in the block data area) to determine whether it needs to penetrate into the parent disk to make up the difference. If it is full, it does not need to process the parent disk; if it is not full, then look at the bitmap in the data area of the block. Bit 0, 0 is penetrated into the parent disk to make up the difference, and 1 is directly read.
  • FIG. 7 is a flowchart of writing a VHD file according to an embodiment of the present invention. As shown in FIG. 7, the process includes the following steps:
  • Step S702 opening the VHD
  • Step S704 acquiring a BAT table
  • Step S706 determining the content of the corresponding index in the BAT table according to the sector number to be read;
  • Step S708 it is determined whether the value in the BAT table is 0xFFFFFFFF, if the determination is yes, step S710 is performed, if the determination is no, step S714 is performed;
  • Step S710 indicating that the storage space of the data block where the sector to be written is not allocated, and increasing the size of the VHD file to allocate space for the data block;
  • Step S712 after the data block is allocated, the BAT table of the VHD file and the batmap of the data block are modified, and the user data is written into the corresponding position of the file;
  • Step S714 modifying the batmap of the data block, and writing the user data to the location corresponding to the file.
  • FIG. 8 is a flowchart of creating a sub-mirror of a VHD according to an embodiment of the present invention, filling a sub-mirror VHD header according to attributes such as a capacity of a mirror, a block size, and the like, and writing a UUID and path information of the parent image to the sub-image so as to be able to pass the sub-mirror. Find the parent image.
  • the RAW format is replaced by a dynamic virtual disk VHD according to an optional embodiment of the present invention, which can effectively improve the utilization and maintainability of the storage space, and the system design a local cache system to reduce the occupation of the network by the client.
  • VHD dynamic virtual disk VHD
  • the method provided by the optional embodiment can cache the server data and the client write back to a local hard disk (if any) to reduce the network pressure, thereby improving the user experience.
  • a local hard disk if any
  • the client can update the changed part of the image to the local by incremental update method, which greatly improves the update speed.
  • a storage medium is further provided, wherein the software includes the above-mentioned software, including but not limited to: an optical disk, a floppy disk, a hard disk, an erasable memory, and the like.
  • modules or steps of the present invention described above can be implemented by a general-purpose computing device that can be centralized on a single computing device or distributed across a network of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein.
  • the steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps thereof are fabricated as a single integrated circuit module.
  • the invention is not limited to any specific combination of hardware and software.
  • the foregoing embodiments of the present invention are applied to the field of communications, and solve the problem that the RAW format in the related art has a large disk space, is inconvenient to backup, and does not support sub-mirror, thereby achieving disk space allocation on demand, convenient backup, and support.

Abstract

A data storage method and device, and data reading method and device, the storage method comprising: a server receives a write request for data (S102); upon being triggered by the write request, the server writes the data to a sector of a local virtual hard disk (VHD) file and stores the data (S104). The method and device solve the problems of RAW format occupying a large amount of disk space, inconvenient backup, and not supporting a sub-mirror, thus enabling allocation of disk space as needed, convenient backup, and supporting a snapshot and sub-mirror.

Description

数据的保存方法、装置及读取方法、装置Data storage method, device, and reading method, device 技术领域Technical field
本发明涉及通信领域,具体而言,涉及数据的保存方法、装置及读取方法、装置The present invention relates to the field of communications, and in particular, to a data storage method, device, and reading method and device
背景技术Background technique
网络无盘系统是一种将操作系统镜像保存在服务器上,客户机本地没有硬盘或者是不使用本地硬盘,使用预启动执行环境(preboot execute environment,简称为PXE)从网络上引导的技术,大量的客户机操作系统保存在服务器上,需要一种高效灵活的管理方法,传统的方法是使用未经加工RAW格式的虚拟硬盘,然后使用网络小型计算机系统接口(Internet Small Computer System Interface,简称为iSCSI)共享给客户机使用,采用RAW格式存在占用磁盘空间大,不方便备份等特点,例如使用RAW主要有如下不足:(1)浪费存储空间:使用裸格式RAW格式硬盘需事先分配好所有的空间,如给用户创建个10G的硬盘,则要先在服务器上创建一个10G大小的文件,不能做到随着用户的使用按需分配空间;(2)维护不方便:由于虚拟硬盘文件一般较大,且RAW格式不支持快照,所以备份只能采用复制、粘贴的方式,速度慢且浪费空间,维护不方便。The network diskless system is a technology that saves the operating system image on the server. The client does not have a hard disk locally or does not use a local hard disk. The preboot execution environment (PXE) is used to boot from the network. The client operating system is stored on the server and requires an efficient and flexible management method. The traditional method is to use a virtual hard disk in the raw RAW format, and then use the Internet Small Computer System Interface (iSCSI). Sharing to the client, using RAW format takes up a lot of disk space, inconvenient to backup, etc. For example, using RAW mainly has the following shortcomings: (1) wasting storage space: using the bare format RAW format hard disk needs to allocate all the space in advance If you create a 10G hard disk for the user, you must first create a 10G file on the server. You cannot allocate space as needed by the user. (2) Inconvenient maintenance: The virtual hard disk file is generally larger. And the RAW format does not support snapshots, so backups can only be copied, The way of pasting is slow and wastes space, and maintenance is inconvenient.
针对相关技术中,采用RAW格式存在占用磁盘空间大,不方便备份、不支持子镜像的问题,还未提出有效的解决方案。In the related art, the RAW format has a problem that the disk space is large, the backup is inconvenient, and the sub-image is not supported, and an effective solution has not been proposed.
发明内容Summary of the invention
本发明实施例提供了数据的保存方法、装置及读取方法、装置,以至少解决上述问题之一。Embodiments of the present invention provide a method, an apparatus, and a reading method and apparatus for saving data to solve at least one of the above problems.
根据本发明实施例的一个方面,提供了一种数据的保存方法,包括:服务器接收到对数据的写请求;在所述写请求的触发下,所述服务器将所述数据写入到本地虚拟硬盘(Virtual hard disk,简称为VHD)文件中的扇区中,并保存。According to an aspect of the embodiments of the present invention, a data saving method is provided, including: a server receives a write request for data; and under the trigger of the write request, the server writes the data to a local virtual The sector in the virtual hard disk (VHD) file is saved and saved.
进一步地,所述服务器将所述操作系统数据写入到本地VHD文件中的扇区中之前,包括:所述服务器确定与所述写请求对应的扇区是否已被分配,其中,在确定未被分配的情况下,所述服务器为所述数据分配所述扇区;在确定已被分配的情况下,则触发所述服务器将所述数据写入所述扇区。 Further, before the server writes the operating system data into a sector in the local VHD file, the method includes: the server determines whether a sector corresponding to the write request has been allocated, where In the case of being allocated, the server allocates the sector for the data; in the event that the determination has been assigned, the server is triggered to write the data to the sector.
进一步地,所述服务器确定与所述写请求对应的扇区是否已被分配包括:所述服务器从所述本地VHD文件中获取块分配表(Block allocation table,简称为BAT)表;所述服务器根据所述BAT表确定与所述写请求对应的扇区是否已被分配。Further, the server determines whether a sector corresponding to the write request has been allocated, and the server obtains a Block allocation table (BAT) table from the local VHD file; the server A determination is made as to whether a sector corresponding to the write request has been allocated according to the BAT table.
进一步地,所述方法还包括:在所述操作系统镜像文件发生变化时,将所述操作系统镜像文件中发生变化的增量部分发送至客户端。Further, the method further includes: sending, when the operating system image file changes, an incremental portion of the operating system image file that is changed to the client.
进一步地,所述方法还包括:所述服务器接收到对所述VHD文件的读请求;从差异磁盘中读取所述读请求对应的数据;在确认所述读请求对应的数据在所述差异磁盘中未记录的情况下,从所述差异磁盘的父磁盘中读取所述数据,其中,所述差异磁盘中存储的数据为所述父磁盘中发生改变的数据。Further, the method further includes: the server receiving a read request for the VHD file; reading data corresponding to the read request from a difference disk; and confirming that the data corresponding to the read request is in the difference In the case where the disk is not recorded, the data is read from the parent disk of the difference disk, wherein the data stored in the difference disk is data changed in the parent disk.
进一步地,所述方法还包括:将所述VHD文件挂载为裸设备文件,并向客户端提供所述操作系统镜像文件。Further, the method further includes: mounting the VHD file as a raw device file, and providing the operating system image file to the client.
根据本发明实施例的另一个方面,还提供了一种数据的读取方法,包括:所述服务器接收到对操作系统镜像文件的读请求;在所述读请求的触发下,所述服务器从本地虚拟硬盘VHD文件中读取所述读请求对应的数据。According to another aspect of the embodiments of the present invention, a method for reading data includes: receiving, by the server, a read request for an operating system image file; and triggering, by the read request, the server The data corresponding to the read request is read in the local virtual hard disk VHD file.
进一步地,所述服务器从本地VHD文件中读取所述读请求对应的数据包括:从差异磁盘中读取所述读请求对应的数据;在确认所述读请求对应的数据在所述差异磁盘中未记录的情况下,从所述差异磁盘的父磁盘中读取所述数据,其中,所述差异磁盘中存储的数据为所述父磁盘中发生改变的数据。Further, the reading, by the server, the data corresponding to the read request from the local VHD file includes: reading data corresponding to the read request from the difference disk; and confirming that the data corresponding to the read request is in the difference disk If the data is not recorded, the data is read from the parent disk of the difference disk, wherein the data stored in the difference disk is data changed in the parent disk.
根据本发明实施例的一个方面,提供了一种数据的保存装置,所述装置应用于服务器,包括:接收模块,设置为接收到对数据的写请求;写入模块,设置为在所述写请求的触发下,将所述数据写入到本地虚拟硬盘VHD文件中的扇区中,并保存。According to an aspect of an embodiment of the present invention, there is provided a data saving apparatus, the apparatus being applied to a server, comprising: a receiving module configured to receive a write request for data; and a writing module configured to be in the write Under the trigger of the request, the data is written to the sector in the local virtual hard disk VHD file and saved.
根据本发明实施例的另一个方面,还提供了一种操数据的读取装置,所述装置应用于服务器,包括:接收模块,设置为接收到对操作系统镜像文件的读请求;读取模块,设置为在所述读请求的触发下,从本地VHD文件中读取所述读请求对应的数据。According to another aspect of the embodiments of the present invention, there is also provided a data reading device, the device being applied to a server, comprising: a receiving module configured to receive a read request for an operating system image file; and a reading module And being configured to read data corresponding to the read request from a local VHD file under the trigger of the read request.
通过本发明实施例,采用服务器接收到对数据的写请求;在写请求的触发下,服务器将数据写入到本地虚拟硬盘VHD文件中的扇区中,并保存。通过本发明实施例解决了相关技术中采用RAW格式存在占用磁盘空间大,不方便备份、不支持子镜像的问题,进而达到了按需分配磁盘空间,备份方便、支持快照及子镜像的效果。 Through the embodiment of the present invention, the server receives the write request for the data; under the trigger of the write request, the server writes the data to the sector in the local virtual hard disk VHD file and saves it. The RAW format in the related art solves the problem that the RAW format occupies a large disk space, is inconvenient to backup, and does not support the sub-image. The disk space is allocated on demand, the backup is convenient, and the snapshot and sub-image are supported.
附图说明DRAWINGS
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the invention, and are intended to be a part of the invention. In the drawing:
图1是根据本发明实施例的数据的保存方法流程图;1 is a flow chart of a method for saving data according to an embodiment of the present invention;
图2是根据本发明实施例的数据的读取方法流程图;2 is a flow chart of a method of reading data according to an embodiment of the present invention;
图3是根据本发明实施例的数据的保存装置的结构框图;3 is a structural block diagram of a data saving apparatus according to an embodiment of the present invention;
图4是根据本发明实施例的数据的读取装置的结构框图;4 is a block diagram showing the structure of a data reading apparatus according to an embodiment of the present invention;
图5是根据本发明实施例的VHD文件结构图;FIG. 5 is a structural diagram of a VHD file according to an embodiment of the present invention; FIG.
图6是根据本发明实施例的VHD读流程图;6 is a flow chart of a VHD read in accordance with an embodiment of the present invention;
图7是根据本发明实施例的VHD文件写入流程图;7 is a flow chart of writing a VHD file according to an embodiment of the present invention;
图8是根据本发明实施例的VHD创建子镜像流程图。FIG. 8 is a flow chart of creating a sub-image of a VHD according to an embodiment of the present invention.
具体实施方式detailed description
下文中将参考附图并结合实施例来详细说明本发明。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。The invention will be described in detail below with reference to the drawings in conjunction with the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict.
在本实施例中提供了一种操作系统镜像文件的保存方法,图1是根据本发明实施例的数据的保存方法流程图,如图1所示,该流程包括如下步骤:In this embodiment, a method for saving an operating system image file is provided. FIG. 1 is a flowchart of a method for saving data according to an embodiment of the present invention. As shown in FIG. 1, the process includes the following steps:
步骤S102,服务器接收到对数据的写请求;Step S102, the server receives a write request for data;
步骤S104,在写请求的触发下,服务器将该数据写入到本地虚拟硬盘VHD文件中的扇区中,并保存。Step S104, under the trigger of the write request, the server writes the data into the sector in the local virtual hard disk VHD file and saves it.
通过上述步骤,服务器使用VHD格式对操作系统镜像文件进行写入管理,相比于相关技术中,采用RAW格式时,浪费存储空间,维护不方便等问题,上述步骤解决了上述问题,进而达到了按需分配磁盘空间,备份方便、支持快照及子镜像的效果。 Through the above steps, the server uses the VHD format to write and manage the operating system image file. Compared with the related art, when the RAW format is used, the storage space is wasted, and the maintenance is inconvenient, and the above steps solve the above problems, thereby achieving the above problem. Allocate disk space on demand, easy backup, support for snapshots and submirrors.
在一个可选实施例中,服务器将操作系统数据写入到本地VHD文件中的扇区中之前,服务器确定与写请求对应的扇区是否已被分配,其中,在确定未被分配的情况下,服务器为数据分配扇区;在确定已被分配的情况下,则触发服务器将操作系统数据写入该扇区。从而服务器根据写请求进行扇区的分配,实现了按需分配、动态分配磁盘空间。In an optional embodiment, before the server writes the operating system data into the sector in the local VHD file, the server determines whether the sector corresponding to the write request has been allocated, wherein, in the case where the determination is not allocated, The server allocates sectors for the data; in the case where it is determined that it has been allocated, the trigger server writes operating system data to the sector. Therefore, the server allocates sectors according to the write request, realizing on-demand allocation and dynamically allocating disk space.
上述步骤中涉及到服务器需要确定与写请求对应的扇区是否已被分配,在一个可选实施例中,服务器从本地VHD文件中获取BAT表,服务器根据BAT表确定与写请求对应的扇区是否已被分配。In the above steps, the server needs to determine whether the sector corresponding to the write request has been allocated. In an optional embodiment, the server obtains the BAT table from the local VHD file, and the server determines the sector corresponding to the write request according to the BAT table. Has it been assigned?
在一个可选实施例中,在操作系统镜像文件发生变化时,将操作系统镜像文件中发生变化的增量部分发送至客户端。通过该步骤,仅将操作系统镜像文件中发生变化的增量部分发送至客户端,提高了存储效率,减少了存储空间。In an alternative embodiment, the incremental portion of the changes in the operating system image file is sent to the client when the operating system image file changes. Through this step, only the incremental part of the operating system image file is sent to the client, which improves storage efficiency and reduces storage space.
当服务器接收到对VHD文件的读请求时,在一个可选实施例中,首先从差异磁盘中读取读请求对应的数据,在确认读请求对应的数据在差异磁盘中未记录的情况下,从该差异磁盘的父磁盘中读取该数据,其中,差异磁盘中存储的数据为父磁盘中发生改变的数据。从而节省了存储空间。When the server receives the read request for the VHD file, in an optional embodiment, the data corresponding to the read request is first read from the difference disk, and if the data corresponding to the read request is confirmed to be unrecorded in the difference disk, The data is read from the parent disk of the differencing disk, where the data stored in the differencing disk is the data that changed in the parent disk. This saves storage space.
在一个可选实施例中,将VHD文件挂载为裸设备文件,并向客户端提供操作系统镜像文件。其中,该裸设备文件相当于物理硬盘。In an alternative embodiment, the VHD file is mounted as a raw device file and an operating system image file is provided to the client. The raw device file is equivalent to a physical hard disk.
在本实施例中还提供了一种数据的读取方法,图2是根据本发明实施例的数据的读取方法流程图,如图2所示,该流程包括如下步骤:In the embodiment, a data reading method is also provided. FIG. 2 is a flowchart of a data reading method according to an embodiment of the present invention. As shown in FIG. 2, the process includes the following steps:
步骤S202,服务器接收到对操作系统镜像文件的读请求;Step S202, the server receives a read request for an operating system image file.
步骤S204,在读请求的触发下,服务器从本地虚拟硬盘VHD文件中读取读请求对应的数据。Step S204, the server reads the data corresponding to the read request from the local virtual hard disk VHD file under the trigger of the read request.
通过上述步骤,服务器使用VHD格式保存操作系统镜像,相比于相关技术中,采用RAW格式时,浪费存储空间,维护不方便等问题,上述步骤解决了上述问题,进而达到了按需分配磁盘空间,使用快照进行备份的效果。Through the above steps, the server saves the operating system image in the VHD format. Compared with the related art, when the RAW format is adopted, the storage space is wasted, and the maintenance is inconvenient, the above steps solve the above problem, thereby achieving the disk space allocated on demand. , the effect of using snapshots for backups.
当服务器从本地VHD文件中读取数据时,在一个可选实施例中,首先从差异磁盘中读取读请求对应的数据,在确认读请求对应的数据在差异磁盘中未记录的情况下,从差异磁盘的父磁盘中读取数据,其中,差异磁盘中存储的数据为父磁盘中发生改变的数据。从而提高了读取文件的效率。 When the server reads data from the local VHD file, in an optional embodiment, the data corresponding to the read request is first read from the difference disk, and if the data corresponding to the read request is confirmed to be unrecorded in the difference disk, The data is read from the parent disk of the differencing disk, where the data stored in the differencing disk is the data that changed in the parent disk. Thereby improving the efficiency of reading files.
图3是根据本发明实施例的数据的保存装置的结构框图,该装置应用于服务器,如图3所示,该装置包括:接收模块32,设置为接收到对操作系统镜像文件的写请求;写入模块34,设置为在写请求的触发下,将操作系统数据写入到本地虚拟硬盘VHD文件中的扇区中,并保存。3 is a structural block diagram of a data saving apparatus according to an embodiment of the present invention. The apparatus is applied to a server. As shown in FIG. 3, the apparatus includes: a receiving module 32 configured to receive a write request for an operating system image file; The write module 34 is configured to write the operating system data to the sector in the local virtual hard disk VHD file and save it under the trigger of the write request.
图4是根据本发明实施例的数据的读取装置的结构框图,该装置应用于服务器,如图4所示,该装置包括:接收模块42,设置为接收到对操作系统镜像文件的读请求;读取模块44,设置为在读请求的触发下,从本地VHD文件中读取该操作系统数据。4 is a structural block diagram of a data reading apparatus according to an embodiment of the present invention. The apparatus is applied to a server. As shown in FIG. 4, the apparatus includes: a receiving module 42 configured to receive a read request for an operating system image file. The read module 44 is configured to read the operating system data from the local VHD file under the trigger of the read request.
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,对于后者,可以通过以下方式实现,但不限于此:上述各个模块均位于同一处理器中;或者,上述各个模块分别位于第一处理器、第二处理器和第三处理器…中。It should be noted that each of the above modules may be implemented by software or hardware. For the latter, the foregoing may be implemented by, but not limited to, the foregoing modules are all located in the same processor; or, the above modules are respectively located. In the first processor, the second processor, and the third processor.
针对相关技术中存在的上述问题,下面结合可选实施例进行说明,该可选实施例结合了上述可选实施例及其可选实施方式。For the above problems in the related art, the following description will be made in conjunction with an alternative embodiment which combines the above-described alternative embodiments and alternative embodiments thereof.
相关技术术语的解释:Interpretation of related technical terms:
VHD:Microsoft Virtual Hard Disk format,一种虚拟磁盘格式,支持动态及养分磁盘,微软Hyper-v虚拟化平台使用VHD做为虚拟机硬盘,类似的格式还有VMDK、QCOW2等。VHD: Microsoft Virtual Hard Disk format, a virtual disk format that supports dynamic and nutrient disks. The Microsoft Hyper-v virtualization platform uses VHD as a virtual machine hard disk. Similar formats include VMDK and QCOW2.
PXE:一种网络引导协议,一般网卡中有此协议的实现。PXE: A network boot protocol. This is implemented in a general network card.
iPXE:PXE协议的升级版本。iPXE: An upgraded version of the PXE protocol.
网络无盘:通过PXE或iPXE从网络引导计算机,所有数据都保存在远程服务器上,本地可以没有硬盘。Networkless disk: Boot the computer from the network through PXE or iPXE. All data is saved on the remote server. There is no hard disk in the local.
iSCSI:一种通过IP网络将块设备(如磁盘)共享出去的存储协议,客户端使用iSCSI共享硬盘与本地硬盘完全一样,可以对磁盘进行分区、格式化等操作。iSCSI: A storage protocol that shares block devices (such as disks) over an IP network. The client uses the iSCSI shared hard disk to be the same as the local hard disk. It can partition and format the disk.
本可选实施例开发了一种方法,使用虚拟硬盘(virtual hard disk,简称为VHD)格式对镜像进行保存管理,VHD格式具有空间按需分配、可以创建快照及加密等优点,甚至可将此镜像直接迁移到虚拟化平台上。This alternative embodiment develops a method for saving and managing images using a virtual hard disk (VHD) format. The VHD format has the advantages of space-on-demand allocation, snapshot creation and encryption, and the like. The image is migrated directly to the virtualization platform.
针对使用RAW格式保存镜像的缺点,本可选实施例设计出使用VHD格式保存镜像文件,为了使用VHD格式文件,本可选实施例具有不借助第三方工具直接读写VHD文件的方法;服务端在收到VHD读写请求后,首先打开VHD文件,获取VHD的BAT 表,根据BAT表判断出相应的扇区在VHD文件中是否已分配及扇区在文件中的位置,如果对应写请求的扇区在VHD文件中未分配,则要分配相应的数据块及修改BAT表,然后再将数据写入文件的对应位置;如果要读取某个数据块x,系统会首先读取差异磁盘x块的bat entry。如果其值为0xFFFFFFFF,表明差异磁盘中未记录数据,接下来就应该读取本差异磁盘的父磁盘的第x块;如果bat entry其值不为0xFFFFFFFF,则可以通过batmap中x块是否用满(或分析块数据区中的bitmap),来确定是否需要穿透进父磁盘进行补差,如果已用满,则不需再处理父磁盘;如果未用满,再看本块数据区中bitmap哪些位为0,为0的穿透进父磁盘进行补差,为1则直接读取。For the disadvantage of saving the image in the RAW format, the optional embodiment is designed to save the image file in the VHD format. In order to use the VHD format file, the optional embodiment has a method for directly reading and writing a VHD file without using a third-party tool; After receiving the VHD read and write request, first open the VHD file to obtain the BAT of the VHD. The table determines whether the corresponding sector is allocated in the VHD file and the position of the sector in the file according to the BAT table. If the sector corresponding to the write request is not allocated in the VHD file, the corresponding data block is to be allocated and modified. BAT table, and then write the data to the corresponding location of the file; if you want to read a block x, the system will first read the bat entry of the difference disk x block. If the value is 0xFFFFFFFF, indicating that the data is not recorded in the difference disk, then the xth block of the parent disk of the difference disk should be read; if the value of the bat entry is not 0xFFFFFFFF, whether the x block in the batmap can be used is full. (or analyze the bitmap in the block data area) to determine whether it needs to penetrate into the parent disk to make up the difference. If it is full, it does not need to process the parent disk; if it is not full, then look at the bitmap in the data area of the block. Bit 0, 0 is penetrated into the parent disk to make up the difference, and 1 is directly read.
VHD文件的一大特点是按需分配磁盘空间,VHD文件创建时没有分配任何数据块(磁盘空间),当VHD接收到写磁盘操作时,会检测相应的bat表,如果bat表的值为0xFFFFFFFF,则表示相应的数据块未在VHD文件中分配,则通过增大VHD文件的大小分配数据块(通过在文件的末尾写入若干字节的0实现),并修改bat表中相应的值为新数据块在VHD文件中的偏移量;A major feature of VHD files is that disk space is allocated on demand. When a VHD file is created, no data block (disk space) is allocated. When the VHD receives a write disk operation, it will detect the corresponding bat table. If the value of the bat table is 0xFFFFFFFF , indicating that the corresponding data block is not allocated in the VHD file, then allocate the data block by increasing the size of the VHD file (by writing a number of zeros at the end of the file), and modifying the corresponding value in the bat table. The offset of the new data block in the VHD file;
VHD文件的另一大特点是支持快照功能;使用快照技术可实现对数据的快速备份等目的,比直接复制粘贴文件快的多;VHD快照是通过创建VHD的子镜像(也叫差异磁盘)实现的(因为创建VHD子镜像不分配数据块,只需创建VHD文件头及BAT表等很小内容,所以速度快),创建子镜像后读写操作只针对子镜像进行,不再操作母镜像,读写的结果都保存在子镜像中,这样就起到对母镜像备份的作用;Another feature of VHD files is that they support the snapshot function. The snapshot technology can be used to quickly back up data. It is much faster than copying and pasting files directly. VHD snapshots are created by creating sub-images of VHDs (also called differential disks). (Because the VHD sub-image is created without assigning data blocks, only a small content such as a VHD file header and a BAT table is created, so the speed is fast). After the sub-image is created, the read and write operations are performed only for the sub-image, and the parent image is no longer operated. The results of reading and writing are stored in the sub-image, which plays a role in the backup of the parent image;
为了使VHD能通过iSCSI对外提供无盘启动服务,本可选实施例引入中兴虚拟化环境(zhong xing virtualization environments,简称为ZXVE)平台(操作系统,中兴虚拟化平台),借助ZXVE可以将VHD挂载成裸设备文件(相当于物理硬盘),变成裸设备后就可以通过iSCSI对外提供服务;In order to enable the VHD to provide a diskless boot service through the iSCSI, the optional embodiment introduces a zhong xing virtualization environments (ZXVE) platform (operating system, ZTE virtualization platform), and the VHD can be hung by the ZXVE. Loaded into a raw device file (equivalent to a physical hard disk), after being turned into a bare device, it can provide external services through iSCSI;
使用VHD的步骤如下:The steps to use a VHD are as follows:
1、服务器挂载VHD为裸设备;1. The server mounts the VHD as a bare device;
2、将VHD裸设备通过iSCSI共享;2. The VHD raw device is shared by iSCSI;
3、客户端使用PXE网络启动,从DHCP服务器获取地址进行iPXE启动,进入iPXE选择要启动的操作系统通过共享的iSCSI开始启动;3. The client starts up with the PXE network, obtains the address from the DHCP server for iPXE startup, and enters the iPXE to select the operating system to be started to start by the shared iSCSI;
4、客户端将iSCSI盘的读写请求发往服务器; 4. The client sends a read and write request for the iSCSI disk to the server.
5、服务器收到请求后对VHD进行读写,并将结果返回给客户端(VHD详细读写请参照附图)。5. After receiving the request, the server reads and writes the VHD and returns the result to the client (for detailed reading and writing of the VHD, please refer to the attached figure).
网络无盘系统需占用大量的网络带宽,对网络要求较高,会影响用户使用体验,本可选实施例设计一种本地数据缓存及增量更新方法改善对网络的访问,提升无盘用户的使用体验;The network diskless system needs to occupy a large amount of network bandwidth, which has high requirements on the network and affects the user experience. This alternative embodiment designs a local data cache and incremental update method to improve access to the network and improve diskless users. Use experience
在客户端需要向服务器取数据时,系统会检查用户请求的数据是否存在缓冲区中,如果数据已缓存,则直接从缓存区中取出数据返回给用户,不需要通过网络取数据;When the client needs to fetch data from the server, the system checks whether the data requested by the user exists in the buffer. If the data is cached, the data is directly retrieved from the buffer area and returned to the user, and the data does not need to be fetched through the network;
如果缓冲区中没有用户需要的数据,则在网络中的服务器请求数据,并在获取数据后将之保存在缓冲区中,以备下次再使用,直到将全部数据都缓存在本地,这样可以大节约网络带宽。If there is no data required by the user in the buffer, the server in the network requests the data, and saves the data in the buffer after the data is acquired, so that it can be used again until all the data is cached locally. Great savings in network bandwidth.
数据全部缓存后,可能存在缓存的数据于服务器数据可能不一致的情况(如管理员对服务器上的镜像进行补丁更新、安装软件等),在管理员修改服务器母镜像后客户端要求更新系统,服务器计算子镜像相交母镜像的变量扇区,将变量部分发送给客户端,客户端根据服务器端数据将变化部分写入本地缓存区,客户端变化部分更新完成后重启计算机即可。After all the data is cached, there may be cases where the cached data may be inconsistent in the server data (such as the administrator updating the image on the server, installing the software, etc.), and the client requests to update the system after the administrator modifies the server parent image. Calculate the variable sector of the sub-image intersecting parent image, and send the variable part to the client. The client writes the changed part to the local buffer according to the server-side data, and restarts the computer after the client change part is updated.
为使本可选实施例的目的、技术方案和优点更加清楚,以下结合附图对本可选实施例作进一步地详细说明。In order to make the objects, technical solutions and advantages of the present embodiments more clear, the present exemplary embodiments will be further described in detail below with reference to the accompanying drawings.
图5是根据本发明实施例的VHD文件结构图,如图5所示,为直接读写VHD文件需要解析VHD文件的结构;FIG. 5 is a structural diagram of a VHD file according to an embodiment of the present invention. As shown in FIG. 5, the structure of a VHD file needs to be parsed for directly reading and writing a VHD file;
图6是根据本发明实施例的VHD读流程图,如图6所示,该流程包括如下步骤:FIG. 6 is a flow chart of VHD reading according to an embodiment of the present invention. As shown in FIG. 6, the process includes the following steps:
步骤S602,打开VHD;Step S602, opening the VHD;
步骤S604,获取BAT表;Step S604, acquiring a BAT table;
步骤S606,根据要读取的扇区号判断BAT表中相应索引的内容;Step S606, determining the content of the corresponding index in the BAT table according to the sector number to be read;
步骤S608,判断BAT表中的值是否为0xFFFFFFFF,在判断为是的情况下,执行步骤S610,在判断为否的情况下,执行步骤S614;Step S608, it is determined whether the value in the BAT table is 0xFFFFFFFF, if the determination is yes, step S610 is performed, if the determination is no, step S614 is performed;
步骤S610,表示要读取的扇区的内容为0; Step S610, indicating that the content of the sector to be read is 0;
步骤S612,返回扇区内容为0给用户;Step S612, returning the sector content to 0 to the user;
步骤S614,根据BAT表的内容读取VHD相应位置,读取大小为2M,第一个扇区表示数据块内每个扇区的使用位图;Step S614, reading the corresponding position of the VHD according to the content of the BAT table, the read size is 2M, and the first sector represents the use bitmap of each sector in the data block;
步骤S616,判断扇区位图值是否为1,在判断为是的情况下,执行步骤S618,在判断结果为否的情况下,执行步骤S620;Step S616, it is determined whether the sector bitmap value is 1, if the determination is yes, step S618 is performed, if the determination result is no, step S620 is performed;
步骤S618,返回读取到的扇区的内容给用户;Step S618, returning the content of the read sector to the user;
步骤S620,找出VHD文件的父节点,按照读取流程读取父节点获取扇区内容;Step S620, finding a parent node of the VHD file, and reading the parent node according to the reading process to obtain the sector content;
步骤S622,返回。Step S622, return.
进一步地,要读取某个数据块x,系统会首先读取差异磁盘x块的bat entry。如果其值为0xFFFFFFFF,表明差异磁盘中未记录数据,接下来就应该读取本差异磁盘的父磁盘的第x块;如果bat entry其值不为0xFFFFFFFF,则可以通过batmap中x块是否用满(或分析块数据区中的bitmap),来确定是否需要穿透进父磁盘进行补差,如果已用满,则不需再处理父磁盘;如果未用满,再看本块数据区中bitmap哪些位为0,为0的穿透进父磁盘进行补差,为1则直接读取。Further, to read a certain data block x, the system first reads the bat entry of the difference disk x block. If the value is 0xFFFFFFFF, indicating that the data is not recorded in the difference disk, then the xth block of the parent disk of the difference disk should be read; if the value of the bat entry is not 0xFFFFFFFF, whether the x block in the batmap can be used is full. (or analyze the bitmap in the block data area) to determine whether it needs to penetrate into the parent disk to make up the difference. If it is full, it does not need to process the parent disk; if it is not full, then look at the bitmap in the data area of the block. Bit 0, 0 is penetrated into the parent disk to make up the difference, and 1 is directly read.
图7是根据本发明实施例的VHD文件写入流程图,如图7所示,该流程包括如下步骤:FIG. 7 is a flowchart of writing a VHD file according to an embodiment of the present invention. As shown in FIG. 7, the process includes the following steps:
步骤S702,打开VHD;Step S702, opening the VHD;
步骤S704,获取BAT表;Step S704, acquiring a BAT table;
步骤S706,根据要读取的扇区号判断BAT表中相应索引的内容;Step S706, determining the content of the corresponding index in the BAT table according to the sector number to be read;
步骤S708,判断BAT表中的值是否为0xFFFFFFFF,在判断为是的情况下,执行步骤S710,在判断为否的情况下,执行步骤S714;Step S708, it is determined whether the value in the BAT table is 0xFFFFFFFF, if the determination is yes, step S710 is performed, if the determination is no, step S714 is performed;
步骤S710,表示要写入的扇区所在数据块存储空间未分配,增加VHD文件大小给数据块分配空间;Step S710, indicating that the storage space of the data block where the sector to be written is not allocated, and increasing the size of the VHD file to allocate space for the data block;
步骤S712,数据块分配后修改VHD文件的BAT表及数据块的batmap,并将用户数据写入文件对应的位置;Step S712, after the data block is allocated, the BAT table of the VHD file and the batmap of the data block are modified, and the user data is written into the corresponding position of the file;
步骤S714,修改数据块的batmap,并将用户数据写入文件对应的位置。 Step S714, modifying the batmap of the data block, and writing the user data to the location corresponding to the file.
进一步地,写入某个扇区时,首先要判断扇区所在的数据块是否已分配,如果已分配则直接将数据写入对应的位置并修改数据块的batmap即可,如果未分配数据块则要先增加VHD文件的大小分配数据块修改BAT表然后再写入数据;Further, when writing a certain sector, it is first determined whether the data block in which the sector is located has been allocated. If it is allocated, the data is directly written to the corresponding location and the batmap of the data block is modified, if the data block is not allocated. Then increase the size of the VHD file to allocate the data block to modify the BAT table and then write the data;
图8是根据本发明实施例的VHD创建子镜像流程图,根据镜像的容量、块大小等属性填写子镜像VHD头,并将母镜像的UUID及路径信息写入子镜像,以便能通过子镜像找到母镜像。FIG. 8 is a flowchart of creating a sub-mirror of a VHD according to an embodiment of the present invention, filling a sub-mirror VHD header according to attributes such as a capacity of a mirror, a block size, and the like, and writing a UUID and path information of the parent image to the sub-image so as to be able to pass the sub-mirror. Find the parent image.
综上所述,通过本发明可选实施例采用动态虚拟磁盘VHD替换RAW格式,可以有效的提高存储空间的利用率及维护性,同时系统设计了本地缓存系统以减少客户机对网络的占用,启用本地缓存后除首次请求数据需要从网络下载数据外以后可以直接从本地获取数据,甚至在数据全部缓存后可以断开网络,减轻了网络负担。采用新的VHD方式可以有效解决使用RAW格式的不足,大大提升存储空间利用率及维护性;同时使用网络无盘对网络要求比较高,特别是在多客户端情况下会出现网络响应慢的情况,影响客户使用体验,本可选实施例提供的方法,可将服务器数据及客户端回写缓存到本地硬盘(如果有)某块区域以减轻网络压力,这样即可提升用户的使用体验,也具无盘的方便等优点;同时在服务器端操作系统更新时,客户端可采用增量更新的方法将镜像的变化部分更新到本地,大大提升更新的速度。In summary, the RAW format is replaced by a dynamic virtual disk VHD according to an optional embodiment of the present invention, which can effectively improve the utilization and maintainability of the storage space, and the system design a local cache system to reduce the occupation of the network by the client. After enabling the local cache, in addition to the first request data, you need to download data directly from the network, and even disconnect the network after the data is fully cached, reducing the network burden. The new VHD method can effectively solve the problem of using the RAW format, greatly improving the storage space utilization and maintenance; at the same time, using the network without disk has higher requirements on the network, especially in the case of multiple clients, the network response is slow. Involving the customer experience, the method provided by the optional embodiment can cache the server data and the client write back to a local hard disk (if any) to reduce the network pressure, thereby improving the user experience. With the convenience of diskless convenience; at the same time, when the server-side operating system is updated, the client can update the changed part of the image to the local by incremental update method, which greatly improves the update speed.
在另外一个实施例中,还提供了一种软件,该软件用于执行上述实施例及优选实施方式中描述的技术方案。In another embodiment, software is also provided for performing the technical solutions described in the above embodiments and preferred embodiments.
在另外一个实施例中,还提供了一种存储介质,该存储介质中存储有上述软件,该存储介质包括但不限于:光盘、软盘、硬盘、可擦写存储器等。In another embodiment, a storage medium is further provided, wherein the software includes the above-mentioned software, including but not limited to: an optical disk, a floppy disk, a hard disk, an erasable memory, and the like.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,可选地,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。It will be apparent to those skilled in the art that the various modules or steps of the present invention described above can be implemented by a general-purpose computing device that can be centralized on a single computing device or distributed across a network of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein. The steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps thereof are fabricated as a single integrated circuit module. Thus, the invention is not limited to any specific combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 The above description is only the preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes can be made to the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and scope of the present invention are intended to be included within the scope of the present invention.
工业实用性Industrial applicability
上述的本发明实施例,应用于通信领域,解决了相关技术中采用RAW格式存在占用磁盘空间大,不方便备份、不支持子镜像的问题,进而达到了按需分配磁盘空间,备份方便、支持快照及子镜像的效果。 The foregoing embodiments of the present invention are applied to the field of communications, and solve the problem that the RAW format in the related art has a large disk space, is inconvenient to backup, and does not support sub-mirror, thereby achieving disk space allocation on demand, convenient backup, and support. The effect of snapshots and submirrors.

Claims (10)

  1. 一种数据的保存方法,包括:A method of saving data, including:
    服务器接收到对数据的写请求;The server receives a write request for data;
    在所述写请求的触发下,所述服务器将所述数据写入到本地虚拟硬盘VHD文件中的扇区中,并保存。Upon the triggering of the write request, the server writes the data to a sector in the local virtual hard disk VHD file and saves it.
  2. 根据权利要求1所述的方法,其中,所述服务器将所述数据写入到本地VHD文件中的扇区中之前,包括:The method of claim 1 wherein said server prior to writing said data to a sector in a local VHD file comprises:
    所述服务器确定与所述写请求对应的扇区是否已被分配,其中,在确定未被分配的情况下,所述服务器为所述数据分配所述扇区;在确定已被分配的情况下,则触发所述服务器将所述数据写入所述扇区。Determining, by the server, whether a sector corresponding to the write request has been allocated, wherein, in the case where the determination is not assigned, the server allocates the sector for the data; in the case where it is determined that it has been allocated And triggering the server to write the data to the sector.
  3. 根据权利要求2所述的方法,其中,所述服务器确定与所述写请求对应的扇区是否已被分配包括:The method of claim 2, wherein the server determines whether a sector corresponding to the write request has been allocated comprises:
    所述服务器从所述本地VHD文件中获取块分配表BAT表;The server acquires a block allocation table BAT table from the local VHD file;
    所述服务器根据所述BAT表确定与所述写请求对应的扇区是否已被分配。The server determines whether a sector corresponding to the write request has been allocated according to the BAT table.
  4. 根据权利要求3所述的方法,其中,所述方法还包括:The method of claim 3, wherein the method further comprises:
    在所述操作系统镜像文件发生变化时,将所述操作系统镜像文件中发生变化的增量部分发送至客户端。When the operating system image file changes, the incremental portion of the operating system image file is sent to the client.
  5. 根据权利要求1所述的方法,其中,所述方法还包括:The method of claim 1 wherein the method further comprises:
    所述服务器接收到对所述VHD文件的读请求;The server receives a read request for the VHD file;
    从差异磁盘中读取所述读请求对应的数据;Reading data corresponding to the read request from the difference disk;
    在确认所述读请求对应的数据在所述差异磁盘中未记录的情况下,从所述差异磁盘的父磁盘中读取所述数据,其中,所述差异磁盘中存储的数据为所述父磁盘中发生改变的数据。And in the case that the data corresponding to the read request is not recorded in the difference disk, the data is read from a parent disk of the difference disk, wherein the data stored in the difference disk is the parent The changed data in the disk.
  6. 根据权利要求1至5中任一项所述的方法,其中,所述方法还包括:The method of any of claims 1 to 5, wherein the method further comprises:
    将所述VHD文件挂载为裸设备文件,并向客户端提供所述操作系统镜像文件。 The VHD file is mounted as a raw device file, and the operating system image file is provided to the client.
  7. 一种数据的读取方法,包括:A method of reading data, including:
    所述服务器接收到对操作系统镜像文件的读请求;The server receives a read request for an operating system image file;
    在所述读请求的触发下,所述服务器从本地虚拟硬盘VHD文件中读取所述读请求对应的数据。The server reads the data corresponding to the read request from the local virtual hard disk VHD file under the trigger of the read request.
  8. 根据权利要求7所述的方法,其中,所述服务器从本地VHD文件中读取所述读请求对应的数据包括:The method of claim 7, wherein the reading, by the server, the data corresponding to the read request from the local VHD file comprises:
    从差异磁盘中读取所述读请求对应的数据;Reading data corresponding to the read request from the difference disk;
    在确认所述读请求对应的数据在所述差异磁盘中未记录的情况下,从所述差异磁盘的父磁盘中读取所述数据,其中,所述差异磁盘中存储的数据为所述父磁盘中发生改变的数据。And in the case that the data corresponding to the read request is not recorded in the difference disk, the data is read from a parent disk of the difference disk, wherein the data stored in the difference disk is the parent The changed data in the disk.
  9. 一种数据的保存装置,所述装置应用于服务器,包括:A data storage device, the device being applied to a server, comprising:
    接收模块,设置为接收到对数据的写请求;a receiving module configured to receive a write request for data;
    写入模块,设置为在所述写请求的触发下,将所述数据写入到本地虚拟硬盘VHD文件中的扇区中,并保存。The write module is configured to write the data to a sector in the local virtual hard disk VHD file and save it under the trigger of the write request.
  10. 一种数据的读取装置,所述装置应用于服务器,包括:A data reading device, the device being applied to a server, comprising:
    接收模块,设置为接收到对操作系统镜像文件的读请求;a receiving module, configured to receive a read request for an operating system image file;
    读取模块,设置为在所述读请求的触发下,从本地虚拟硬盘VHD文件中读取所述读请求对应的数据。 The reading module is configured to read data corresponding to the read request from the local virtual hard disk VHD file under the trigger of the read request.
PCT/CN2015/083472 2014-11-04 2015-07-07 Data storage method and device, and data reading method and device WO2016070641A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410614553.6 2014-11-04
CN201410614553.6A CN105630401A (en) 2014-11-04 2014-11-04 Data storage method, data storage device, data reading method and data reading device

Publications (1)

Publication Number Publication Date
WO2016070641A1 true WO2016070641A1 (en) 2016-05-12

Family

ID=55908517

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/083472 WO2016070641A1 (en) 2014-11-04 2015-07-07 Data storage method and device, and data reading method and device

Country Status (2)

Country Link
CN (1) CN105630401A (en)
WO (1) WO2016070641A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106940626B (en) * 2017-03-17 2020-02-07 郑州云海信息技术有限公司 Method and system for acquiring difference data among multiple disks of virtual machine

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007219703A (en) * 2006-02-15 2007-08-30 Fujitsu Ltd Hard disk storage control program, hard disk storage device and hard disk storage control method
CN102541461A (en) * 2010-12-31 2012-07-04 阿里巴巴集团控股有限公司 Data reading-writing method and device for remote data storage and system thereof
CN102929884A (en) * 2011-08-10 2013-02-13 阿里巴巴集团控股有限公司 Method and device for compressing virtual hard disk image file
CN203909779U (en) * 2014-03-27 2014-10-29 华卫云 Simplified terminal diskless machine room system

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7647468B2 (en) * 2005-12-09 2010-01-12 Microsoft Corporation Compaction, de-fragmentation, and merging of virtual storage device of virtual machine
CN100578470C (en) * 2007-01-31 2010-01-06 浙江大学 Audio/video data access method and device based on raw device
US9928091B2 (en) * 2010-09-30 2018-03-27 Microsoft Technology Licensing, Llc Techniques for streaming virtual machines from a server to a host
CN103729203A (en) * 2012-10-12 2014-04-16 英业达科技有限公司 System and method for reconstructing differencing virtual hard disk file to update operating systems

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007219703A (en) * 2006-02-15 2007-08-30 Fujitsu Ltd Hard disk storage control program, hard disk storage device and hard disk storage control method
CN102541461A (en) * 2010-12-31 2012-07-04 阿里巴巴集团控股有限公司 Data reading-writing method and device for remote data storage and system thereof
CN102929884A (en) * 2011-08-10 2013-02-13 阿里巴巴集团控股有限公司 Method and device for compressing virtual hard disk image file
CN203909779U (en) * 2014-03-27 2014-10-29 华卫云 Simplified terminal diskless machine room system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
XU, YANJUN ET AL.: "Several Virtual Machine Image Formats and Their Performance Evaluation", JOURNAL OF COMPUTER APPLICATIONS, vol. 33, no. S1, 30 June 2013 (2013-06-30), pages 22 - 23, ISSN: 1001-9081 *

Also Published As

Publication number Publication date
CN105630401A (en) 2016-06-01

Similar Documents

Publication Publication Date Title
EP3686739B1 (en) Method and system for enabling agentless backup and restore operations on a container orchestration platform
JP5496254B2 (en) Converting a machine to a virtual machine
US10579404B2 (en) Provisioning virtual desktops with stub virtual disks
US11243707B2 (en) Method and system for implementing virtual machine images
US8677111B2 (en) Booting devices using virtual storage arrays over wide-area networks
US8838542B1 (en) Optimized image archiving
US8498997B2 (en) Server image migration
US10740133B2 (en) Automated data migration of services of a virtual machine to containers
US20030126242A1 (en) Network boot system and method using remotely-stored, client-specific boot images created from shared, base snapshot image
US20110276963A1 (en) Virtual Data Storage Devices and Applications Over Wide Area Networks
CN109558212B (en) Virtualization management method and system of physical equipment, physical equipment and medium
US9720719B2 (en) Method and system for optimizing virtual disk provisioning
WO2020103904A1 (en) Cloud desktop upgrade method, device, cloud server, and storage medium
US10909102B2 (en) Systems and methods for performing scalable Log-Structured Merge (LSM) tree compaction using sharding
US20140082275A1 (en) Server, host and method for reading base image through storage area network
CN111459619A (en) Method and device for realizing service based on cloud platform
WO2016070641A1 (en) Data storage method and device, and data reading method and device
WO2018028321A1 (en) Method and apparatus for managing virtual external storage device, and terminal
JP5428455B2 (en) Virtual machine server, virtual machine control method, and virtual machine control program
US10929168B2 (en) Enhanced data storage and versioning of virtual nodes in a data processing environment
US10747567B2 (en) Cluster check services for computing clusters
US20220244979A1 (en) System and method of vm recovery on s3 compatible object storage
US8065737B1 (en) Virus scanning for block-level distributed application management
CN117075817A (en) Data center virtualized storage optimization method, system, equipment and medium
CN114003335A (en) Method, device, equipment and storage medium for virtual machine live migration

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

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

Country of ref document: EP

Kind code of ref document: A1