WO2024082857A1 - Data migration method and system, and related apparatus - Google Patents

Data migration method and system, and related apparatus Download PDF

Info

Publication number
WO2024082857A1
WO2024082857A1 PCT/CN2023/117343 CN2023117343W WO2024082857A1 WO 2024082857 A1 WO2024082857 A1 WO 2024082857A1 CN 2023117343 W CN2023117343 W CN 2023117343W WO 2024082857 A1 WO2024082857 A1 WO 2024082857A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
storage area
migration
server
migrated
Prior art date
Application number
PCT/CN2023/117343
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 WO2024082857A1 publication Critical patent/WO2024082857A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers

Definitions

  • the embodiments of the present application relate to the technical field of data migration, and in particular, to a method, system and related apparatus for data migration.
  • the present application provides a method, system and related devices for data migration, which can not only realize online data migration, but also improve the efficiency of data migration and provide a good user experience.
  • the present application provides a data migration method, which is applied to a computing device, comprising:
  • the first data is processed according to the write request, and the first data is migrated from the source data storage area to the target storage area for storage;
  • the first data is stored in a source data storage area, and the source data storage area and the target storage area are located in the same computing device or in different computing devices.
  • a migration operation of the first data may be triggered by a read request or a write request for the first data.
  • the first data can be sent and received between the different computing devices.
  • the migration efficiency can be improved on the basis of realizing online migration.
  • the method after receiving a read request or a write request for the first data, the method further includes:
  • the first data is processed according to the read request or the write request.
  • the first data when the first data does not need to be migrated or has already been migrated, the first data can be directly processed for read requests or write requests without migrating the first data from the source data storage area to the target storage area.
  • the first data in various scenarios can be fully covered, various situations can be taken into consideration, and multiple migrations can be avoided.
  • the storage address of the first data in the source data storage area is a first address
  • the processing of the first data according to the read request and migrating the first data from the source data storage area to the target storage area for storage specifically includes:
  • the first data may be read from the first address according to the read request and stored in a second address in the target storage area.
  • the first data may be stored in a block storage, object storage, or other storage methods, which are not limited thereto.
  • the data block or the single object needs to be split according to the size of the data actually read so that the partial data after the splitting process is exactly the first data.
  • the first data may be returned to the user.
  • the storage address of the first data in the source data storage area is a first address
  • the storage method of the first data is block storage
  • the processing of the first data according to the write request and migrating the first data from the source data storage area to the target storage area specifically includes:
  • the first data is read from the first address according to the write request and stored in the second address of the target storage area; and the first data stored in the first address and the second address is written;
  • the data block is data that is migrated once in the block storage; the alignment means that the size of the first data is an integer multiple of the size of the data block.
  • a prerequisite for responding to a write request is that write-write mutual exclusion must be satisfied, that is, the data targeted by two write requests cannot have an intersection.
  • the user may be notified of the completion of the response to the write request.
  • the computing device when the computing device determines that the size of the data block of the first data is not aligned, the computing device continues to acquire a mutex lock of the data block;
  • the second data is read from the first location and stored in a second address in the target storage area.
  • the storage method of the first data is object storage, and the storage address of the first data in the source data storage area is a first address.
  • the processing of the first data according to the write request and migrating the first data from the source data storage area to the target storage area specifically includes:
  • the first data is read from the first address and stored in the second address in the target storage area, and a write process is performed on the first data stored in the first address and the second address.
  • the write processing operation of the object storage can only act on the entire object, so there is no need to perform alignment judgment between the first data and a single object.
  • the migration metadata record table is updated, and the migration metadata record table records the migration status of the first data.
  • the migration status includes any one of the following: the first data needs to be migrated but has not been migrated, has been migrated, and does not need to be migrated.
  • the state of the migration metadata record table may be converted from "N" to "Y".
  • a background migration task may be started to determine the data to be migrated, and the system begins to migrate the data blocks or single objects to be migrated in sequence in the background.
  • an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in the first aspect.
  • an embodiment of the present application provides a computer-readable storage medium, comprising computer instructions.
  • the computer instructions When the computer instructions are executed on an electronic device, the electronic device executes the method of the first aspect.
  • the electronic device provided in the second aspect and the computer-readable storage medium provided in the third aspect are both used to execute the method provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here.
  • FIG1 is a schematic diagram of a data migration system according to an embodiment of the present application.
  • FIG. 2 is a schematic block diagram of the structure of a server 100 provided in an embodiment of the present application.
  • FIG3 is a flow chart of a method for data migration in response to a read request provided in an embodiment of the present application.
  • FIG4 is a flow chart of another data migration method in response to a read request provided in an embodiment of the present application.
  • FIG5 is a flow chart of a data migration method in response to a write request provided in an embodiment of the present application.
  • FIG6 is a flow chart of another method for data migration in response to a write request provided in an embodiment of the present application.
  • FIG. 7 is a flow chart of a background data migration method provided in an embodiment of the present application.
  • FIG8 is a flow chart of another background data migration method provided in an embodiment of the present application.
  • first and second are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated.
  • a feature defined as “first” or “second” may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality” means two or more.
  • GUI graphical user interface
  • Data migration can refer to the process of selecting, preparing, extracting, and transforming data and permanently transferring it from one computer storage system to another. There are many reasons for data migration, which may include but are not limited to server or storage device replacement, maintenance or upgrade, application migration, website integration, disaster recovery, and data center migration. In some implementations, data migration can be understood as copying data stored in one computer storage system and copying it to another computer storage system.
  • some data migration methods do not support online migration. For example, if a user needs to access the data being migrated, he needs to wait until the data migration is completed before accessing the data. In other words, the electronic device cannot respond to the read and write requests for the data during the data migration process.
  • Some data migration methods are less efficient. For example, when the system uses snapshots to migrate data, it is necessary to export data from the source data storage area and then import the exported data into the target storage area after the migration. If during the data migration process, a user operation triggers a write request resulting in new data, and the new data also needs to be migrated, then it is necessary to repeatedly export the new data from the source data storage area and then import the exported new data into the target storage area after the migration.
  • an embodiment of the present application provides a data migration method.
  • data migration is divided into two forms: foreground migration and background migration.
  • the foreground migration method specifically refers to: firstly determining a data set to be migrated, wherein the data set to be migrated may be determined by a manager.
  • the system receives a read request or a write request for first data from a user, the system starts to migrate the first data.
  • the first data belongs to the data set to be migrated.
  • the system When the system receives a read request for the operation of the first data from the user, the system reads the first data from the source data storage area, migrates it to the target storage area, and then returns the first data in the target storage area to the user.
  • the system When the system receives a write request from the user for an operation on the first data, the system reads the first data from the source data storage area, migrates it to the target storage area, then performs double-write processing on the first data in the source data storage area and the first data in the target storage area, and then returns the first data in the target storage area to the user; or the system first reads the first data, performs write processing, stores the first data after the write processing in the source data storage area, and then migrates the first data after the write processing to the source data storage area.
  • the background migration method specifically refers to: firstly determining the data to be migrated, and then the system starts to migrate the data blocks or single objects to be migrated in sequence in the background.
  • foreground migration has a higher priority than background migration. That is, when the system receives a read request or a write request from a user for the first data, the system may preferentially select the foreground migration method for migration. When the system does not receive any read request or write request, the system may only select the background migration method to migrate the data targeted by the migration instruction.
  • a storage address at which the first data is stored in the source data storage area may be referred to as a first address
  • a storage address at which the first data is stored in the target data storage area may be referred to as a second address.
  • data after the first data is written may be referred to as second data.
  • the above method can ensure that when the system receives a user's read request or write request for the first data, the system only needs to read the first data once in the source data storage area to ensure that the user's read request or write request and migration task are implemented.
  • the migration efficiency can be improved compared with the method in which the system first receives the migration instruction and then receives the read request or write request. This is because the system cannot guarantee that the data received by the migration instruction and the data received by the read request or write request are the same data during the migration process. This will cause the system to read a certain data twice in the source data storage area when implementing the user's read request or write request and the migration task.
  • the data migration method provided in the embodiment of the present application can not only realize the online migration of data, but also improve the efficiency of data migration and provide a good user experience.
  • Figure 1 is a schematic diagram of the framework of a data migration system provided in an embodiment of the present application.
  • the data migration system may include but is not limited to a source data storage area, a target data storage area, a data migration tool, a storage medium, etc.
  • the data migration system may be applied to application scenarios such as local data migration to the cloud, data migration between clouds, and cloud data migration to the local.
  • the above-mentioned source data storage area and target data storage area may refer to the logical storage location of data blocks or single objects in the server, and the above-mentioned storage medium may refer to the physical storage location of data blocks or single objects in the server.
  • the source data storage area may refer to a database storing unmigrated data.
  • Common databases may include but are not limited to relational database manager (My Structured Query Language, MYSQL), Oracle database, Microsoft SQL Server, etc.
  • the types of data stored in the source data storage area may include but are not limited to block storage, file storage, object storage, etc.
  • the source data storage area may be used as a volume or a logical unit number (Logical Unit Number, lun), and the data stored in the source data storage area may be divided into data blocks of the same size (for example, a data block may be 1MB in size).
  • the data when data stored in a source data storage area is migrated, the data may be migrated in units of data blocks.
  • the source data storage area when the data stored in the source data storage area is stored in the form of object storage, the source data storage area can be used as a bucket, and the data stored in the source data storage area is a single object. In other words, data migration can be performed by unit amount of data.
  • the target data storage area may refer to a database storing migrated data.
  • the types of data stored in the target data storage area may include but are not limited to block storage, file storage, and object storage, etc. The detailed description of the storage type can refer to the above content and will not be repeated here.
  • the source data storage area and the target data storage area may be located on the same hardware device or on different hardware devices.
  • the rectangle a shown in the source data storage area and the rectangle b shown in the source data storage area shown in Figure 1 can represent a data block or a single object.
  • multiple data blocks or single objects need to be migrated.
  • the data block or single object of rectangle a can be migrated to rectangle b.
  • the data block or single object represented by rectangle b is the data of the data block or single object of rectangle a after migration, and the data is consistent in content.
  • the data migration tool can capture requests, distribute data, store and update migration metadata record tables, and perform background migration tasks, etc.
  • the capture of the request can be used to monitor a read request or a write request from a user for the first data, so as to start the foreground migration task.
  • the capture of the request can be completed at the Device Mapper layer in Linux.
  • the capture of the request can also be completed at the client. This is not limited in the embodiments of the present application.
  • the data migration tool after completing the capture of the request, obtains the logical address of the first data targeted by the request from the source data storage area, and reads the first data from the storage medium according to the logical address.
  • the source data storage area and the target data storage area are logical storage locations of the first data
  • the storage medium is the physical storage location of the first data
  • the storage medium may refer to a carrier for storing the first data, such as a floppy disk, an optical disk, a high-density digital video disc (Digital Video Disc, DVD), a hard disk, a flash memory, a USB flash drive, a compact flash (Compact Flash, CF) card, a secure digital memory card (Secure Digital Memory Card, SD card), a multimedia card (Multi-Media Card, MMC card), a smart media (Smart Media, SM) card, a memory stick (Memory Stick), an extreme digital-picture card (Extreme Digital-Picture Card, xD card), etc.
  • a carrier for storing the first data such as a floppy disk, an optical disk, a high-density digital video disc (Digital Video Disc, DVD), a hard disk, a flash memory, a USB flash drive, a compact flash (Compact Flash, CF) card, a secure digital memory card (Secure Digital Memory Card, SD card), a multimedia card
  • the data distribution can be used to perform migration processing on the first data after the data migration tool reads the first data.
  • the data migration tool can determine whether the first data needs to be migrated, that is, whether the first data belongs to the data set to be migrated. If the first data belongs to the data set to be migrated, the data migration tool can migrate the first data to the target storage area.
  • the migration metadata record table is used to record the migration status of the data (e.g., not migrated, migrated, and initial state).
  • the data migration tool can store and update the migration metadata record table. Specifically, reference can be made to the migration metadata record tables shown in Table 1 and Table 2.
  • Table 1 exemplarily shows a block storage migration metadata record table
  • Table 2 exemplarily shows an object storage migration metadata record table.
  • the migration metadata record table may include an index and a migration status.
  • the migration metadata record table may also include any one or more of the following items: the identifier of the server where the data is stored when it has not been migrated, the identifier of the server where the data is stored after it has been migrated, the logical location where the data is stored when it has not been migrated, and the logical location where the data is stored after it has been migrated, etc. In the embodiments of the present application, this is not limited.
  • the indexes shown in Table 1 and Table 2 may be used to represent a structure for sorting data in the source data storage area.
  • the indexes may be used to quickly view specific data in the source data storage area.
  • the index “Block 1" represents the index of data blocks of the same size (for example, 1MB) in data stored in the form of block storage
  • the index "Obeject 1" represents the index of a single object in data stored in the form of object storage.
  • the index of data is related to the storage type of the data.
  • the index of the data is volume ID + logical address
  • the index of the data is file system ID (File system ID) + directory (Directory) + file name (File name) + offset address (Offset)
  • the index of the data is key (Key) + version number (Version).
  • the migration status shown in Table 1 and Table 2 indicates whether the data in the source data storage area is in a migration state.
  • the status "Y" indicates that the data indicated by the specific index in the row is currently in a state where migration is required and has been completed.
  • the status "N" indicates that the data indicated by the specific index in the row is currently in a state where the data needs to be migrated but has not been migrated, or needs to be migrated and is being migrated but has not been completely migrated.
  • the status "NA" indicates that the data indicated by the specific index in the row is currently in a state where migration is not required and is not in an unmigrated state.
  • the data migration tool can also change the state of the data in real time. For example, when data 1 needs to be migrated and after the migration is completed, the state of data 1 can be changed from “N” to "Y". Generally, data 1 will not be changed from "Y" to "N”.
  • the same data indicated by the indexes in different migration metadata record tables may be in different states in different tables.
  • the state of data 1 in table A is "Y”
  • the state in table B is "N"
  • data 1 has been migrated from the logical location in table A where it was stored before migration to the logical location where it is stored after migration, but has not yet been migrated from the logical location in table B where it was stored before migration to the logical location where it is stored after migration.
  • Logical location of storage is
  • the server 100 stores a migration metadata record table that records the status of the data of the migration unit
  • the migration metadata record table is updateable and persistent. Therefore, in the embodiment of the present application, breakpoint resumption and retry migration can be supported. For example, when a network problem occurs and the data cannot be copied, the data copying is interrupted, and the original migration task is not affected. When the network is restored, the data copying continues from the interruption point.
  • the migration tool continues to restore the original migration process and migrates the unmigrated data and dirty blocks to the target.
  • the data blocks or single objects processed at the moment the network problem occurs are reprocessed to achieve accurate migration tasks.
  • multiple tasks can be migrated to different targets.
  • Two different migration tasks for the same source data storage area are independent of each other and will not affect each other.
  • For simultaneous migration of different source data storage areas there will be multiple migration tasks in the background, and there will also be migration metadata tables for different migration tasks.
  • Multiple migration tasks are also independent of each other and will not affect each other.
  • the background migration task is different from the foreground migration task. It refers to scanning the data to be migrated in real time and in sequence, determining the unmigrated unit data in the data to be migrated, and migrating the unmigrated unit data (such as data blocks or single objects) in the data to be migrated.
  • the data to be migrated is 100 units of data, namely data 1 to data 100. If there is no read request or write request for any of the data from data 1 to data 100, the background migration task starts scanning from data 1 to data 100, and determines that data 1 is unmigrated data when scanning data 1, and migrates data 1. The remaining 99 data are migrated in the same way.
  • the foreground migration task will migrate data 10 first, and then the background migration task will scan from data 1 to data 100, and then migrate data 1-data 9, data 11-data 100 in order, and when scanning data 1, it will be determined that data 1 is not migrated data, and data 1 will be migrated. The remaining 98 data will be migrated in the same way, but when scanning data 10, it will be determined that data 10 is migrated data, and data 10 will not be migrated.
  • the server 100 provided in the embodiment of the present application is as follows.
  • FIG. 2 is a schematic diagram of the structure of the server 100 provided in an embodiment of the present application.
  • the server 100 may include: one or more processors 101, a memory 102, a communication interface 103, a transmitter 105, a receiver 106, a coupler 107, and an antenna 108.
  • the above components may be connected via a bus 104 or other means, and FIG2 takes the connection via a bus as an example. Among them:
  • the processor 101 can be used to read and execute computer-readable instructions. Specifically, the processor 101 can be used to call a program stored in the memory 102, such as an implementation program of the data migration method provided in the embodiment of the present application on the server 100, and execute the instructions contained in the program. The processor 101 can also be used to determine whether migration is required based on the migration metadata record table.
  • the memory 102 is coupled to the processor 101 and is used to store various software programs and/or multiple sets of instructions.
  • the memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage devices, flash memory devices or other non-volatile solid-state storage devices.
  • the memory 102 may store information such as the data set to be migrated and the migration metadata record table.
  • the memory 102 may store an operating system (hereinafter referred to as system), such as embedded operating systems such as uCOS, VxWorks, RTLinux, etc.
  • system such as embedded operating systems such as uCOS, VxWorks, RTLinux, etc.
  • the memory 102 may also store a network communication program, which may be used to communicate with clients and other servers.
  • the communication interface 103 can be used for communication between the server 100 and other devices.
  • the communication interface 103 may be a 3G communication interface, a long term evolution (LTE) (4G) communication interface, a 5G communication interface, a WLAN Communication interface, WAN communication interface, etc.
  • LTE long term evolution
  • the server 100 may also be configured with a wired communication interface 103 to support wired communication.
  • the transmitter 105 and the receiver 106 can be regarded as a wireless modem.
  • the transmitter 105 can be used to transmit the signal output by the processor 101.
  • the receiver 106 can be used to receive the signal.
  • the number of the transmitter 105 and the number of the receiver 106 can be one or more.
  • the antenna 108 may be used to convert electromagnetic energy in the transmission line into electromagnetic waves in free space, or to convert electromagnetic waves in free space into electromagnetic energy in the transmission line.
  • the coupler 107 may be used to divide the mobile communication signal into multiple paths and distribute the signals to multiple receivers 106 .
  • the antenna 108 of the network device may be implemented as a large-scale antenna array.
  • server 100 shown in FIG. 2 is only one implementation of the embodiment of the present application. In actual applications, the server 100 may also include more or fewer components, which is not limited here.
  • the server stored in the source data storage area and the target storage area can be the same or two different servers.
  • the data migration tool may be run on a server stored in a source data storage area, or on a server stored in a target storage area, or on other servers other than the above.
  • the data migration tool may be run simultaneously on the server stored in the source data storage area and the server stored in the target storage area. In the embodiments of the present application, this is not limited.
  • the processor 101 can be used to respond to the user's read requests and write requests, and intercept and process the requests.
  • the processor 101 may also determine whether the data needs to be migrated according to the migration metadata record table.
  • the processor 101 may also update the state information of the data in the migration metadata record table after the data migration is completed.
  • the memory 102 may be used to store information such as data to be migrated, data that has been migrated, and a migration metadata record table.
  • the communication interface 103 may be used to establish a communication connection with an electronic device used by a user.
  • the transmitter 105 can be used to return the data required by the user to the electronic device used by the user, the receiver 106 can be used to receive the user's read request or write request, and the receiver 106 can also be used to receive migration instructions for the first data. For example, the receiver 106 can also be used to receive migration instructions for the first data sent by the control center.
  • server stored in the source data storage area and the server stored in the target storage area in the data migration system in Figure 1 are not the same server 100 shown in Figure 2, the server stored in the source data storage area is server 110, and the server stored in the target storage area is server 120.
  • the data migration tool can run on server 110 and server 120 at the same time, and server 100 includes server 110 and server 120.
  • the processor 101 of the server 110 can be used to respond to the user's read request and write request and intercept the request.
  • the processor 101 of the server 110 can also determine whether the data needs to be migrated according to the migration metadata record table.
  • the processor 101 of the server 110 can update the migration metadata record table after sending the data to be migrated.
  • the memory 102 of the server 110 may be used to store data to be migrated and information such as a migration metadata record table.
  • the communication interface 103 of the server 110 may be used to establish a communication connection with the server 120 .
  • the transmitter 105 of the server 110 may be used to send the data to be migrated to the server 120 .
  • the receiver 106 of the server 110 may be used to receive a read request or a write request from a user.
  • the receiver 106 of the server 110 may also be used to receive a migration instruction for the first data sent by the control center.
  • the processor 101 of the server 120 may update the migration metadata record table after receiving the data to be migrated sent by the server 110 .
  • the memory 102 of the server 120 may be used to store information such as migrated data and migration metadata record tables.
  • the communication interface 103 of the server 120 may be used to establish a communication connection with the server 110 .
  • the transmitter 105 of the server 120 may be used to send a prompt message to the server 110 indicating that the data to be migrated has been migrated, and the receiver 106 of the server 120 may be used to receive the data to be migrated sent by the server 110 .
  • server 100 may be referred to as a computing device.
  • the electronic device used by the user may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, as well as a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and/or a smart city device.
  • PDA personal digital assistant
  • AR augmented reality
  • VR virtual reality
  • AI artificial intelligence
  • wearable device a vehicle-mounted device
  • smart home device a smart home device and/or a smart city device.
  • a method for data migration provided in an embodiment of the present application is described below. This embodiment takes the case where the server 100 responds to a user's read request for data to be migrated as an example to introduce the method for data migration.
  • Fig. 3 shows a schematic flow chart of a data migration method in response to a read request provided in an embodiment of the present application.
  • the data storage mode is block storage
  • the migration unit is a data block as an example.
  • the server 100 responds to a user's read request for first data.
  • the user can input an operation to the server 100 according to his/her needs, and the server 100 can respond with a read request for the first data.
  • the read request for the first data may include, but is not limited to: the logical address of the first data in the source data storage area, the index, and the data payload length, etc., wherein the data payload length refers to the effective payload data length excluding the header and the length in the read request information.
  • the server 100 may receive a migration instruction for the first data sent by the control center before responding to the read request.
  • the system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
  • the status of the first data in the migration metadata record table will not be "NA” but "Y” or "N".
  • the state of the first data may refer to:
  • the state of the first data is the state of the first data divided into corresponding multiple data blocks; if the size of the first data is less than the data block, the state of the first data is the state of the data block corresponding to the first data.
  • the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
  • the status corresponding to the index carried in the read request for the first data is "Y", it can be determined that the first data has completed migration; if in the migration metadata record table, the status corresponding to the index carried in the read request for the first data is "N”, it can be determined that the first data has not been migrated or is in the process of migrating and has not yet completed migration.
  • the server 100 determines that the first data has been migrated, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again, and S304 is executed.
  • the server 100 determines that the first data has not been migrated, but it can be known from S303 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S305 is executed.
  • the migration metadata record table may record that the state of the first data may be "N+".
  • S304 Read the first data from the source data storage area and return it to the user.
  • the server 100 may read the first data from the source data storage area based on the read request and return the first data to the user.
  • the cloud can obtain the logical address of the first data based on the read request of the first data sent by the local user, and then obtain the physical address of the first data based on the mapping relationship between the logical address and the physical address, and read the first data from the physical address, and then the cloud sends the read first data to the local user.
  • S305 Read the first data from the source data storage area, migrate the first data to the target storage area, update the migration metadata record table, and then return the first data to the user.
  • the server 100 may migrate the first data from the source data storage area to the target storage area. For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
  • the server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
  • the two physical addresses stored in the server 100 before and after the first data migration may be the same or different.
  • the server 100 may update the migration metadata record table.
  • the state of the migration metadata record table may be converted from "N" to "Y".
  • the server 100 needs to split the data block according to the size of the data actually read, so that the part of the data after the splitting process is exactly the first data.
  • the size of the first data that the user wants to read is 0.5MB
  • the size of the data block is 1MB.
  • the size of the data block read out by the server 100 from the source data storage area is 1MB, wherein the 1MB data block includes 0.5MB of first data and 0.5MB of other data.
  • the server 100 needs to divide the 1MB data block, select 0.5MB of first data therefrom, and return the 0.5MB of first data to the user.
  • Fig. 4 shows a flow chart of another data migration method in response to a read request provided in an embodiment of the present application.
  • the data storage mode is object storage
  • the migration unit is a single object as an example.
  • the server 100 responds to a user's read request for first data.
  • the user may perform input operations to the server 100 according to his/her own needs, and the server 100 may respond with a read request for the first data.
  • the read request for the first data may include but is not limited to: the logical address of the first data in the source data storage area, index and data payload length, etc., wherein the data payload length refers to the effective payload data length excluding the header and length in the read request information.
  • the server 100 may receive a migration request for the first data from the control center before responding to the read request. instruction.
  • the system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
  • the status of the first data in the migration metadata record table will not be "NA” but "Y” or "N".
  • the state of the first data may refer to:
  • the state of the first data is the state of the first data divided into corresponding multiple single objects; if the size of the first data is less than a single object, the state of the first data is the state of the single object corresponding to the first data.
  • the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
  • the state corresponding to the index carried in the read request for the first data is "Y"
  • the state corresponding to the index carried in the read request for the first data is "N"
  • the server 100 determines that the first data has been migrated, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again, and S404 is executed.
  • the server 100 determines that the first data has not been migrated, but it can be known from S403 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S405 is executed.
  • the migration metadata record table may record that the state of the first data may be "N+".
  • S404 Read the first data from the source data storage area and return it to the user.
  • the server 100 may read the first data from the source data storage area based on the read request and return the first data to the user.
  • the cloud can obtain the logical address of the first data based on the read request of the first data sent by the local user, and then obtain the physical address of the first data based on the mapping relationship between the logical address and the physical address, and read the first data from the physical address, and then the cloud sends the read first data to the local user.
  • S405 Read the first data from the source data storage area, migrate the first data to the target storage area, update the migration metadata record table, and then return the first data to the user.
  • the server 100 may migrate the first data from the source data storage area to the target storage area. For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
  • the server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to the logical address L2 mapping relationship.
  • the two physical addresses stored in the server 100 before and after the first data migration may be the same or different.
  • the server 100 may update the migration metadata record table.
  • the state of the migration metadata record table may be converted from "N" to "Y".
  • the server 100 needs to split the single object according to the size of the data actually read, so that the portion of data after the splitting process is exactly the first data.
  • the size of the first data that the user wants to read is 0.5MB
  • the size of the single object is 1MB.
  • the size of the single object read by the server 100 from the source data storage area is 1MB, where the 1MB single object includes 0.5MB of first data and 0.5MB of other data.
  • the server 100 needs to split the 1MB single object, select 0.5MB of first data from it, and return the 0.5MB of first data to the user.
  • online migration can be realized, and it can be ensured that when the system receives a user's read request for the first data, the system only needs to read the first data once in the source data storage area to ensure that the user's read request and migration task are realized. In this way, the migration efficiency can be improved.
  • This embodiment takes the case where the server 100 responds to a user's write request for data to be migrated as an example to introduce the data migration method.
  • Fig. 5 shows a schematic flow chart of a data migration method in response to a write request provided in an embodiment of the present application.
  • the data storage mode is block storage
  • the migration unit is a data block as an example.
  • the server 100 responds to a user's write request for first data.
  • the user may perform input operations to the server 100 according to his/her own needs, and the server 100 may respond with a write request for the first data.
  • the write request for the first data may include but is not limited to: a logical address of the first data in the source data storage area, an index, a data payload length, and a modification content, etc.
  • the server 100 needs to satisfy write-write mutual exclusion in responding to the user's write request for the first data, that is, the data targeted by the two write requests cannot have an intersection.
  • S502 Determine whether the first data needs to be migrated. If not, write the first data to the source data storage area, and store the written first data in the source data storage area.
  • the server 100 may receive a migration instruction for the first data issued by the system before responding to the write request.
  • the system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
  • the status of the first data in the migration metadata record table will not be "NA” but "Y” or "N".
  • the server 100 determines that the first data does not need to be migrated, that is, there is no migration instruction for the first data, the status of the first data in the migration metadata record table is "NA", and the server 100 can directly process the first data according to the write request to obtain the first data after writing, and store the first data after writing in the source data storage area, that is, the logical address of the first data and the first data after writing is the same.
  • the server 100 may notify the user of the completion of the write request. For example, if the user deletes document M, the server 100 may The server 100 notifies the user that the write request for the document M has been completed by displaying a prompt message (eg, a pop-up window) such as a text message "Document M has been deleted".
  • a prompt message eg, a pop-up window
  • the server 100 is not limited to the way in which the write request has been completed.
  • the state of the first data may refer to:
  • the state of the first data is a state in which the first data is divided into a corresponding plurality of data blocks.
  • the state of the first data is the state of the data block corresponding to the first data.
  • S503 Determine whether the first data has been migrated. If so, double-write the first data in the source data storage area and the target storage area.
  • the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
  • the status corresponding to the index carried in the write request for the first data is "Y"
  • the status corresponding to the index carried in the write request for the first data is "N”
  • the server 100 determines that the first data has completed migration, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again.
  • the server 100 can process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
  • the server 100 can notify the user of the completion of the write request, which is not described in detail here.
  • the server 100 determines that the first data has not been migrated, but it can be known from S502 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S504 is executed.
  • the migration metadata record table may record that the state of the first data may be "N+".
  • the server 100 determines that the first data is being migrated but has not been completely migrated, the first data does not need to be migrated from the source data storage area to the target storage area again.
  • the server 100 can process the first data in the source data storage area and the first data in the target storage area according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
  • the server 100 can notify the user of the completion of the write request, which will not be described in detail here.
  • S504 Determine whether the data block to be migrated is aligned with the first data.
  • the migration unit when the data is stored in block storage, the migration unit is a data block, and the server 100 can determine whether the data block is aligned with the first data.
  • the data block is not aligned with the first data.
  • the size of the first data is 0.5MB and the size of the data block is 1MB
  • the data block is not aligned with the first data.
  • the migration unit of the first data is 1.5, and the data block is not aligned with the first data.
  • the size of the first data is not an integer multiple of the data block, the data block is not aligned with the first data.
  • the data block is aligned with the first data.
  • the size of the first data is 1MB and the size of the data block is 1MB
  • the data block is aligned with the first data.
  • the migration unit of the first data is 2, and the data block is aligned with the first data.
  • the size of the first data is an integer multiple of the data block, the data block is aligned with the first data.
  • the size of the data block is consistent with the size of the first data or the size of the first data is the same as the size of the first data.
  • the size is an integer multiple of the size of the data block, and S505 is executed.
  • the first type is that the size of the first data is smaller than the data block size, in which case S506 is executed;
  • the second type is that the size of the first data is larger than the data block size and is not an integer multiple of the data block size.
  • the first data can be divided into two parts, the first part can be data whose size is the maximum integer multiple of the data block size, and the second part can be data from the first data without the first part.
  • the first part of the data is executed in S505, and the second part of the data is executed in S506.
  • S505 Migrate the first data to the target storage area, double-write the first data in the source data storage area and the target storage area, and update the migration metadata record table.
  • the server 100 may migrate the first data from a source data storage area to a target storage area.
  • the logical address of the first data in the source data storage area is L1
  • the physical address corresponding to the logical address L1 is W1
  • the mapping relationship is that the logical address L1 maps the physical address W1.
  • the server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
  • server 110 stored in the source data storage area when the server stored in the source data storage area and the server stored in the target storage area are not the same server, that is, the server stored in the source data storage area is server 110, and the server stored in the target storage area is server 120, server 110 stored in the source data storage area sends the first data stored at logical address L1 and physical address W1 to server 120 stored in the target storage area, and server 120 stores the first data in the target storage area.
  • the logical address of the first data in server 120 stored in the target storage area is L2, and the physical address is W2.
  • the two physical addresses stored in the server before and after the migration of the first data may be the same or different. That is, the storage medium where the first data is physically stored in the source data storage area and the storage medium where the first data is physically stored in the target data storage area may be the same or different. In the embodiment of the present application, this is not limited.
  • the server 100 may double-write the first data in the source data storage area and the first data in the target storage area. Specifically, the server 100 may process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
  • the server 100 may update the migration metadata record table.
  • the state of the first data in the migration metadata record table may be converted from "N" to "Y".
  • the server 100 may notify the user of information on completion of the write request, which may be referred to the above content and will not be elaborated here.
  • S506 Write the first data in the source data storage area, migrate the written first data to the target storage area, and update the migration metadata record table.
  • the first data in S506 is not aligned with the size of the data block, so that the data targeted by other write requests may overlap with the first data targeted by this write request, that is, the same area may be written. Therefore, before writing the first data in the source data storage area, it is necessary to obtain a mutex lock in the data block. If the acquisition of the mutex lock fails, it is repeated until the acquisition succeeds.
  • the acquisition of the mutex lock successfully may mean stopping the write operation on the first data in other threads and only executing the write operation in S506. In this way, the write-write conflict phenomenon can be avoided.
  • the server 100 may write the first data in the source data storage area. Specifically, the server 100 may write the first data stored in the source data storage area according to the write request, and store the first data after writing in the source data storage area. In some implementations, the first data after writing may be referred to as the second data.
  • the server 100 may migrate the first data from the source data storage area to the target storage area.
  • the logical address of the first data in the source data storage area is L1
  • the physical address corresponding to the logical address L1 is W1
  • the mapping relationship is that the logical address L1 maps the physical address W1.
  • the server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
  • server 110 stored in the source data storage area when the server stored in the source data storage area and the server stored in the target storage area are not the same but on different servers 100, that is, the server stored in the source data storage area is server 110 and the server stored in the target storage area is server 120, server 110 stored in the source data storage area sends the first data stored in the logical address L1 to server 120 stored in the target storage area, and server 120 stores the first data in the target source target storage area.
  • the logical address of the first data in server 120 stored in the target source target storage area is L2.
  • the two physical addresses stored in the server 100 before and after the first data is migrated may be the same or different. That is, the storage medium where the first data is physically stored in the source data storage area and the storage medium where the first data is physically stored in the target data storage area may be the same or different. In the embodiment of the present application, this is not limited.
  • the server 100 may update the migration metadata record table.
  • the state of the first data in the migration metadata record table may be converted from "N" to "Y".
  • the server 100 may notify the user of the completion of the write request, which will not be elaborated here.
  • online migration can be realized, and because the migration of data is triggered by a write request, it can be ensured that when the system receives a user's write request for first data, the system only needs to read the first data once in the source data storage area to ensure that the user's write request and migration task are realized. In this way, the migration efficiency can be improved.
  • Fig. 6 shows a flow chart of another data migration method in response to a write request provided in an embodiment of the present application.
  • the data storage mode is object storage
  • the migration unit is a single object as an example.
  • S601 The server 100 responds to a user's write request for first data.
  • the user can input an operation to the server 100 according to his/her needs, and the server 100 can respond with a write request for the first data.
  • the write request for the first data may include but is not limited to: the logical address of the first data in the source data storage area, index, data payload length, and modified content, etc.
  • the server 100 needs to satisfy write-write mutual exclusion in responding to the user's write request for the first data, that is, the data targeted by the two write requests cannot have an intersection.
  • S602 Determine whether the first data needs to be migrated. If not, write the first data in the source data storage area and store the written first data in the source data storage area.
  • the server 100 may receive a migration instruction for the first data issued by the system before responding to the write request.
  • the system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
  • the status of the first data in the migration metadata record table will not be "NA” but "Y” or "N".
  • the server 100 determines that the first data does not need to be migrated, that is, there is no migration instruction for the first data, the status of the first data in the migration metadata record table is "NA", and the server 100 can directly write the first data according to the write request to obtain the first data after writing, and store the first data after writing in the source data storage area, that is, the logical address of the first data before the write process and the first data after the write process are the same.
  • the server 100 may notify the user of the completion of the write request. For example, if the user deletes document M, the server 100 may The server 100 notifies the user that the write request for the document M has been completed by displaying a prompt message (eg, a pop-up window) such as a text message "Document M has been deleted".
  • a prompt message eg, a pop-up window
  • the server 100 is not limited to the way in which the write request has been completed.
  • the state of the first data may mean: if the size of the first data is greater than or equal to a single object, then the state of the first data is the state of the first data divided into corresponding multiple single objects; if the size of the first data is smaller than a single object, then the state of the first data is the state of the single object corresponding to the first data.
  • S603 Determine whether the first data has been migrated, and if so, double-write the first data in the source data storage area and the target storage area.
  • the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
  • the status corresponding to the index carried in the write request for the first data is "Y"
  • the status corresponding to the index carried in the write request for the first data is "N”
  • the server 100 determines that the first data has completed migration, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again.
  • the server 100 can process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
  • the server 100 can notify the user of the completion of the write request, which is not described in detail here.
  • the server 100 determines that the first data has not been migrated, but it can be known from S602 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S604 is executed.
  • the migration metadata record table may record that the state of the first data may be "N+".
  • the server 100 determines that the first data is being migrated but has not been completely migrated, the first data does not need to be migrated from the source data storage area to the target storage area again.
  • the server 100 can write the first data in the source data storage area and the first data in the target storage area according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
  • the server 100 can notify the user of the completion of the write request, which will not be described in detail here.
  • S604 Migrate the first data to the target storage area, double-write the first data in the source data storage area and the target storage area, and update the migration metadata record table.
  • the first data since the first data is stored in an object storage manner and writing to an object generally involves writing to the entire object, there is no need to determine whether the first data is aligned with a single object as in S504. Instead, when the first data needs to be migrated and has not been migrated, the write operation is directly responded to and the migration task of the first data is completed.
  • the server 100 may migrate the first data from the source data storage area to the target storage area. For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
  • the server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
  • server 110 stored in the source data storage area when the server stored in the source data storage area is not the same as the server stored in the target storage area, that is, the source
  • server 110 stored in the source data storage area sends the first data stored at logical address L1 and physical address W1 to server 120 stored in the target storage area
  • server 120 stores the first data in the target storage area.
  • the logical address of the first data in server 120 stored in the target storage area is L2, and the physical address is W2.
  • the two physical addresses stored in the server before and after the migration of the first data may be the same or different. That is, the storage medium where the first data is physically stored in the source data storage area and the storage medium where the first data is physically stored in the target data storage area may be the same or different. In the embodiment of the present application, this is not limited.
  • the server 100 may double-write the first data in the source data storage area and the first data in the target storage area.
  • the server 100 can process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
  • the server 100 may update the migration metadata record table.
  • the state of the first data in the migration metadata record table may be converted from "N" to "Y".
  • the server 100 may notify the user of the completion of the write request, which will not be elaborated here.
  • This embodiment takes the case where there is no user read request or write request for the data to be migrated as an example to introduce the data migration method.
  • FIG7 shows a flow chart of a background data migration method provided in an embodiment of the present application.
  • the flow chart takes block storage as an example. It is worth noting that if the source data storage area targeted by the background data migration method has a migration instruction, the following specific steps will no longer determine whether there is a migration instruction.
  • S701 sequentially traverse the source data storage area to be migrated, and determine whether the currently scanned data block has been migrated.
  • the server 100 may sequentially traverse the source data storage area to be migrated. For example, if the source data storage area to be migrated is data 1 to data 100, which has 100 data blocks in total, the server 100 scans from data 1 to data 100, and determines whether each data block has been migrated.
  • the server 100 may determine whether the currently scanned data block has completed migration.
  • the status corresponding to the currently scanned data block is "Y" in the migration metadata record table, it can be determined that the currently scanned data block has completed migration;
  • the state corresponding to the currently scanned data block is "N" in the migration metadata record table, it can be determined that the currently scanned data block has not been migrated or is being migrated and the migration has not yet been completed.
  • the server 100 determines that the currently scanned data block has completed migration, the status of the currently scanned data block in the migration metadata record table is "Y", and the currently scanned data block does not need to be migrated from the source data storage area to the target storage area again, so the next data block of the current data block in the source data storage area is scanned.
  • the source data storage area to be migrated is data 1-data 100, which has 100 data blocks in total.
  • the server 100 determines that data 1 has been migrated, and then the server 100 scans data 2 to determine whether data 2 has been migrated.
  • the server 100 determines that the currently scanned data block has not been migrated, the status of the currently scanned data block in the migration metadata record table is "N", and S502 is executed.
  • S702 Determine whether the currently scanned data block is being processed.
  • the server 100 may determine whether the currently scanned data block is being processed, that is, determine whether the currently scanned data block is being migrated.
  • the migration metadata record table may record that the status of the currently scanned data block may be "N+".
  • S701 is executed to scan the next data block of the current data block in the source data storage area.
  • the source data storage area to be migrated is data 1-data 100, which has 100 data blocks in total.
  • the server 100 determines that data 1 is being migrated, and then the server 100 scans data 2 to determine whether data 2 has completed migration.
  • S703 is executed.
  • S703 Read the currently scanned data block from the source data storage area, migrate the data block to the target storage area, and update the migration metadata record table.
  • the server 100 may migrate the currently scanned data block from the source data storage area to the target storage area.
  • the logical address of the currently scanned data block in the source data storage area is L1
  • the physical address corresponding to the logical address L1 is W1
  • the mapping relationship is that the logical address L1 maps the physical address W1.
  • the server 100 migrates the currently scanned data block from the source data storage area to the target storage area, which may mean changing the logical address of the currently scanned data block from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
  • the two physical addresses of the currently scanned data block stored in the server 100 before and after the migration may be the same or different.
  • the server 100 may update the migration metadata record table.
  • the state of the migration metadata record table may be converted from "N" to "Y".
  • FIG8 shows a flow chart of a background data migration method provided in an embodiment of the present application.
  • the flow chart takes object storage as an example. It is worth noting that if the source data storage area targeted by the background data migration method has a migration instruction, the following specific steps will no longer determine whether there is a migration instruction.
  • the server 100 may sequentially traverse the source data storage area to be migrated.
  • the source data storage area to be migrated is data 1 to data 100, which contains 100 objects in total.
  • the server 100 scans from data 1 to data 100, and determines whether each object has been migrated.
  • the server 100 may determine whether the migration of a single object currently being scanned has been completed.
  • the status corresponding to the currently scanned single object is "Y" in the migration metadata record table, it can be determined that the currently scanned single object has completed migration;
  • the status corresponding to the currently scanned single object is "N" in the migration metadata record table, it can be determined that the currently scanned single object has not been migrated or is being migrated and the migration has not yet been completed.
  • the server 100 determines that the migration of the single object currently being scanned has been completed, the status of the single object currently being scanned in the migration metadata record table is "Y", and the single object currently being scanned does not need to be migrated from the source data storage area to the target storage area again, so the next data block of the current single object in the source data storage area is scanned.
  • the source data storage area to be migrated is data 1-data 100, which contains 100 objects in total.
  • the server 100 determines that data 1 has been migrated, and then the server 100 scans data 2 to determine whether data 2 has been migrated.
  • the server 100 determines that the currently scanned single object has not been migrated, the status of the currently scanned single object in the migration metadata record table is "N", and S802 is executed.
  • S802 Determine whether the single object currently being scanned is being processed.
  • the server 100 may determine whether the currently scanned single object is being processed. Whether the object is being migrated.
  • the migration metadata record table may record that the status of the currently scanned single object may be "N+".
  • S801 is executed to scan the next object of the current single object in the source data storage area.
  • the source data storage area to be migrated is data 1-data 100, which contains 100 objects in total.
  • the server 100 determines that data 1 is being migrated, and then the server 100 scans data 2 to determine whether data 2 has completed migration.
  • the server 100 may migrate a single object currently being scanned from a source data storage area to a target storage area.
  • the logical address of the currently scanned single object in the source data storage area is L1
  • the physical address corresponding to the logical address L1 is W1
  • the mapping relationship is that the logical address L1 maps to the physical address W1.
  • the server 100 migrates the currently scanned single object from the source data storage area to the target storage area, which may refer to changing the logical address of the currently scanned single object from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to that the logical address L2 maps to the physical address W1.
  • the two physical addresses of the single object currently being scanned stored in the server 100 before and after the migration may be the same or different.
  • the server 100 may update the migration metadata record table.
  • the state of the migration metadata record table may be converted from "N" to "Y".
  • the corresponding data migration is completed during the data reading and writing process, and the remaining data is migrated through the background migration task.
  • the computer program product includes one or more computer instructions.
  • the computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means.
  • the computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated.
  • the available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
  • SSD solid state drive
  • the processes can be completed by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium.
  • the program When the program is executed, it can include the processes of the above-mentioned method embodiments.
  • the aforementioned storage medium includes: ROM or random access memory RAM, magnetic disk or optical disk, etc. The medium of the code.

Landscapes

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

Abstract

A data migration method and system, and a related apparatus. The method comprises: when a server (100) receives a read request or a write request for first data, the server (100) triggering a migration operation for the first data, and then responding to the processing of the read request or the write request for the first data after the migration is completed. By means of the present solution, online migration of data can be realized, the efficiency of data migration can also be improved, and the user experience is good.

Description

数据迁移的方法、系统及相关装置Data migration method, system and related device
本申请要求于2022年10月20日提交国家知识产权局、申请号为202211292048.5、申请名称为“数据迁移的方法、系统及相关装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on October 20, 2022, with application number 202211292048.5 and application name “Methods, systems and related devices for data migration”, the entire contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请实施例涉及数据迁移技术领域,尤其涉及数据迁移的方法、系统及相关装置。The embodiments of the present application relate to the technical field of data migration, and in particular, to a method, system and related apparatus for data migration.
背景技术Background technique
当原有的存储介质容量紧张、新老存储软件替换、硬件生命周期到期时,需要进行数据迁移。目前,随着云计算的兴起,应用上云或者云厂商的替代,用户的选择的存储方式也在变化,这样也需要进行数据迁移。When the original storage medium capacity is insufficient, the old storage software is replaced with the new one, or the hardware life cycle expires, data migration is required. At present, with the rise of cloud computing, applications on the cloud or the replacement of cloud vendors, the storage methods selected by users are also changing, which also requires data migration.
如何在实现在线迁移的情况下,提高数据迁移的效率是本领域亟待解决的问题。How to improve the efficiency of data migration while achieving online migration is an urgent problem to be solved in this field.
发明内容Summary of the invention
本申请提供了一种数据迁移的方法、系统及相关装置,不仅可以实现数据的在线迁移,还可以提高数据迁移的效率,用户体验感良好。The present application provides a method, system and related devices for data migration, which can not only realize online data migration, but also improve the efficiency of data migration and provide a good user experience.
第一方面,本申请提供了一种数据迁移方法,该方法应用于计算设备,包括:In a first aspect, the present application provides a data migration method, which is applied to a computing device, comprising:
接收到针对于第一数据的读请求或者写请求;Receiving a read request or a write request for first data;
根据该读请求对该第一数据进行处理,并将该第一数据从源数据存储区域中迁移至目标存储区域中存储;Processing the first data according to the read request, and migrating the first data from the source data storage area to the target storage area for storage;
或者,根据该写请求对该第一数据进行处理,并将该第一数据从源数据存储区域中迁移至目标存储区域中存储;Alternatively, the first data is processed according to the write request, and the first data is migrated from the source data storage area to the target storage area for storage;
其中,该第一数据存储在源数据存储区域中,该源数据存储区域与目标存储区域位于同一台计算设备中或者不同的计算设备中。The first data is stored in a source data storage area, and the source data storage area and the target storage area are located in the same computing device or in different computing devices.
在一种可能的实现方式中,本申请实施例可以是由针对于第一数据的读请求或写请求来触发第一数据的迁移操作。In a possible implementation, in an embodiment of the present application, a migration operation of the first data may be triggered by a read request or a write request for the first data.
在一种可能的实现方式中,当源数据存储区域与目标存储区域位于不同的计算设备中时,不同的计算设备之间可以进行第一数据的发送与接收操作。In a possible implementation, when the source data storage area and the target storage area are located in different computing devices, the first data can be sent and received between the different computing devices.
由上述方法可知,可以确保当系统接收到用户对第一数据的读请求或写请求时,只需要系统在源数据存储区域中对第一数据进行一次读取即可以保证实现用户的读请求或写请求以及迁移任务。It can be seen from the above method that when the system receives a user's read request or write request for the first data, it can ensure that the user's read request or write request and migration task are implemented by the system only needing to read the first data once in the source data storage area.
这样,相对于系统先接收迁移指令,再接收读请求或写请求的方法,可以在实现在线迁移的基础上提高迁移效率。In this way, compared with the method in which the system first receives the migration instruction and then receives the read request or the write request, the migration efficiency can be improved on the basis of realizing online migration.
结合第一方面,在一些实施方式中,在接收到针对于第一数据的读请求或者写请求之后,该方法还包括:In combination with the first aspect, in some implementations, after receiving a read request or a write request for the first data, the method further includes:
在确定该第一数据需要迁移且该第一数据还未进行迁移的情况下,根据该读请求或者写请求对该第一数据进行处理。When it is determined that the first data needs to be migrated and the first data has not been migrated, the first data is processed according to the read request or the write request.
在一种可能的实现方式中,当该第一数据不需要迁移或者该第一数据已经被迁移的情况下,可以直接对第一数据进行读请求或者写请求的相关处理,不对该第一数据进行从源数据存储区域中迁移至目标存储区域存储的操作。In one possible implementation, when the first data does not need to be migrated or has already been migrated, the first data can be directly processed for read requests or write requests without migrating the first data from the source data storage area to the target storage area.
这样,可以全方位覆盖各种场景下的第一数据,考虑其多种情况,避免出现多次迁移的情况。 In this way, the first data in various scenarios can be fully covered, various situations can be taken into consideration, and multiple migrations can be avoided.
结合第一方面,在一些实施方式中,该第一数据在该源数据存储区域中的存储地址为第一地址,In combination with the first aspect, in some implementations, the storage address of the first data in the source data storage area is a first address,
该根据该读请求对所述第一数据进行处理,并将该第一数据从源数据存储区域中迁移至目标存储区域中存储,具体包括:The processing of the first data according to the read request and migrating the first data from the source data storage area to the target storage area for storage specifically includes:
可以根据该读请求从该第一地址中读取该第一数据并存储在该目标存储区域中的第二地址中。The first data may be read from the first address according to the read request and stored in a second address in the target storage area.
在一种可能的实现方式中,该第一数据的存储方式可以为块存储、对象存储等存储方式,对此不作限定。In a possible implementation, the first data may be stored in a block storage, object storage, or other storage methods, which are not limited thereto.
在一种可能的实施方式中,若读请求所对应的第一数据的大小小于数据块或单个对象的大小,需要对数据块或单个对象按照实际读取的数据大小进行切割处理,使得切割处理之后的部分数据恰好为第一数据。In a possible implementation, if the size of the first data corresponding to the read request is smaller than the size of the data block or the single object, the data block or the single object needs to be split according to the size of the data actually read so that the partial data after the splitting process is exactly the first data.
在一种可能的实施方式中,当第一数据完成源数据存储区域中迁移至目标存储区域中存储之后,可以返回至用户。In a possible implementation manner, after the first data is migrated from the source data storage area to the target storage area for storage, the first data may be returned to the user.
这样可以实现针对于第一数据的读请求,还可以提高迁移第一数据的效率。In this way, a read request for the first data can be implemented and the efficiency of migrating the first data can be improved.
结合第一方面,在一些实施方式中,该第一数据在该源数据存储区域中的存储地址为第一地址,该第一数据的存储方式为块存储,In combination with the first aspect, in some implementations, the storage address of the first data in the source data storage area is a first address, and the storage method of the first data is block storage.
该根据该写请求对该第一数据进行处理,并将该第一数据从源数据存储区域中迁移至目标存储区域中,具体包括:The processing of the first data according to the write request and migrating the first data from the source data storage area to the target storage area specifically includes:
判断该第一数据与数据块的大小是否对齐;Determining whether the sizes of the first data and the data block are aligned;
在该确定该第一数据与数据块的大小对齐的情况下,根据该写请求从该第一地址读取该第一数据并存储在该目标存储区域中的第二地址中;对存储在该第一地址和该第二地址中的所述第一数据进行写处理;In the case where it is determined that the first data is aligned with the size of the data block, the first data is read from the first address according to the write request and stored in the second address of the target storage area; and the first data stored in the first address and the second address is written;
其中,该数据块为块存储中单次进行迁移的数据;该对齐是指该第一数据的大小是数据块的大小的整数倍。The data block is data that is migrated once in the block storage; the alignment means that the size of the first data is an integer multiple of the size of the data block.
在一种可能的实现方式中,响应写请求的前提条件为需要满足写写互斥,即两个写请求针对的数据不可以有交集。In a possible implementation, a prerequisite for responding to a write request is that write-write mutual exclusion must be satisfied, that is, the data targeted by two write requests cannot have an intersection.
在一种可能的实现方式中,在完成对该第一地址和该第二地址中的所述第一数据进行写处理之后,可以将响应写请求完成的信息通知用户。In a possible implementation, after the write processing of the first data in the first address and the second address is completed, the user may be notified of the completion of the response to the write request.
这样可以避免出现写写互斥的情况。This can avoid the situation where write-write mutual exclusion occurs.
结合第一方面,在一些实施方式中,在该计算设备确定该第一数据该数据块的大小没有对齐的情况下,该计算设备持续获取所述数据块的互斥锁;In conjunction with the first aspect, in some implementations, when the computing device determines that the size of the data block of the first data is not aligned, the computing device continues to acquire a mutex lock of the data block;
根据该写请求对存储在该第一地址的该第一数据进行写处理,得到第二数据,并将该第二数据存储至该第一地址;Perform write processing on the first data stored at the first address according to the write request to obtain second data, and store the second data at the first address;
从该第一位置读取该第二数据并存储在该目标存储区域中的第二地址中。The second data is read from the first location and stored in a second address in the target storage area.
这样可以解决第一数据的大小与单次迁移的数据大小不对齐的问题,以此实现针对于第一数据的写处理。In this way, the problem that the size of the first data is not aligned with the size of the data of a single migration can be solved, thereby implementing write processing for the first data.
结合第一方面,在一些实施方式中,该第一数据的存储方式为对象存储,该第一数据在该源数据存储区域中的存储地址为第一地址,In combination with the first aspect, in some implementations, the storage method of the first data is object storage, and the storage address of the first data in the source data storage area is a first address.
该根据该写请求对该第一数据进行处理,并将该第一数据从源数据存储区域中迁移至目标存储区域中,具体包括:The processing of the first data according to the write request and migrating the first data from the source data storage area to the target storage area specifically includes:
根据该写请求,从该第一地址中读取该第一数据并存储在该目标存储区域中的第二地址中,对存储在所述第一地址和所述第二地址中的所述第一数据进行写处理。According to the write request, the first data is read from the first address and stored in the second address in the target storage area, and a write process is performed on the first data stored in the first address and the second address.
在一种可能的实现方式中,对象存储的写处理操作只能作用于整个对象,因此,无需进行第一数据与单个对象的对齐判断。 In a possible implementation, the write processing operation of the object storage can only act on the entire object, so there is no need to perform alignment judgment between the first data and a single object.
这样可以实现针对于对象存储类型的第一数据的写请求,还可以提高迁移第一数据的效率。In this way, a write request for the first data of the object storage type can be implemented, and the efficiency of migrating the first data can be improved.
结合第一方面,在一些实施方式中,在该第一数据完成迁移之后,更新迁移元数据记录表,该迁移元数据记录表记录所述第一数据的迁移状态,该迁移状态包括所述第一数据需要迁移但未被迁移、已经迁移、不需要迁移中的任意一种。In combination with the first aspect, in some embodiments, after the first data is migrated, the migration metadata record table is updated, and the migration metadata record table records the migration status of the first data. The migration status includes any one of the following: the first data needs to be migrated but has not been migrated, has been migrated, and does not need to be migrated.
在一种可能的实现方式中,第一数据从源数据存储区域迁移至目标存储区域之后,在迁移元数据记录表的状态可以由“N”转换为“Y”。In a possible implementation, after the first data is migrated from the source data storage area to the target storage area, the state of the migration metadata record table may be converted from "N" to "Y".
在一种可能的实现方式中,当计算设备未接收到第一数据的读请求以及写请求时,可以启动后台迁移任务,确定出待迁移的数据,系统在后台开始按顺序对待迁移的数据块或者单个对象进行迁移。In a possible implementation, when the computing device does not receive a read request or a write request for the first data, a background migration task may be started to determine the data to be migrated, and the system begins to migrate the data blocks or single objects to be migrated in sequence in the background.
第二方面,本申请实施例提供了一种电子设备,该电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该电子设备执行如第一方面描述的方法。In a second aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in the first aspect.
第三方面,本申请实施例提供一种计算机可读存储介质,包括计算机指令,当上述计算机指令在电子设备上运行时,使得上述电子设备执行如第一方面的方法。In a third aspect, an embodiment of the present application provides a computer-readable storage medium, comprising computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method of the first aspect.
可以理解地,上述第二方面提供的电子设备和第三方面提供的计算机可读存储介质均用于执行本申请实施例所提供的方法。因此,其所能达到的有益效果可参考对应方法中的有益效果,此处不再赘述。It is understandable that the electronic device provided in the second aspect and the computer-readable storage medium provided in the third aspect are both used to execute the method provided in the embodiment of the present application. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method, which will not be repeated here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1为本申请实施例提供的一种数据迁移系统的框架示意图。FIG1 is a schematic diagram of a data migration system according to an embodiment of the present application.
图2为本申请实施例提供的一种服务器100的结构示意框图。FIG. 2 is a schematic block diagram of the structure of a server 100 provided in an embodiment of the present application.
图3为本申请实施例提供的一种响应读请求的数据迁移方法的流程示意图。FIG3 is a flow chart of a method for data migration in response to a read request provided in an embodiment of the present application.
图4为本申请实施例提供的另一种响应读请求的数据迁移方法的流程示意图。FIG4 is a flow chart of another data migration method in response to a read request provided in an embodiment of the present application.
图5为本申请实施例提供的一种响应写请求的数据迁移方法的流程示意图。FIG5 is a flow chart of a data migration method in response to a write request provided in an embodiment of the present application.
图6为本申请实施例提供的另一种响应写请求的数据迁移方法的流程示意图。FIG6 is a flow chart of another method for data migration in response to a write request provided in an embodiment of the present application.
图7为本申请实施例提供的一种后台数据迁移方法的流程示意图。FIG. 7 is a flow chart of a background data migration method provided in an embodiment of the present application.
图8为本申请实施例提供的另一种后台数据迁移方法的流程示意图。FIG8 is a flow chart of another background data migration method provided in an embodiment of the present application.
具体实施方式Detailed ways
下面将结合附图对本申请实施例中的技术方案进行清楚、详尽地描述。其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;文本中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,另外,在本申请实施例的描述中,“多个”是指两个或多于两个。The technical solutions in the embodiments of the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, "/" means or, for example, A/B can mean A or B; "and/or" in the text is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为暗示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征,在本申请实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.
本申请以下实施例中的术语“用户界面(user interface,UI)”,是应用程序或操作系统与用户之间进行交互和信息交换的介质接口,它实现信息的内部形式与用户可以接受形式之间的转换。用户界面是通过java、可扩展标记语言(extensible markup language,XML)等特定计算机语言编写的源代码,界面源代码在电子设备上经过解析,渲染,最终呈现为用户可以识别的内容。用户界面常用的表现形式是图形用户界面(graphic user interface,GUI),是指采用图形方式显示的与计算机操作相关的用户界面。它可以是在电子设备的显示屏中显示的文本、图标、按钮、菜单、选项卡、文本框、对话框、状态栏、导航栏、Widget等可视的界面元素。 The term "user interface (UI)" in the following embodiments of the present application refers to a medium interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface is a source code written in a specific computer language such as Java and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device and finally presented as content that can be recognized by the user. The commonly used form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operation displayed in a graphical manner. It can be a visual interface element such as text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, widgets, etc. displayed on the display screen of an electronic device.
数据迁移(data migration)可以是指选择、准备、提取和转换数据,并将数据从一个计算机存储系统永久地传输到另一个计算机存储系统的过程。进行数据迁移有多种原因,其中可以包括但不限于服务器或存储设备更换、维护或升级、应用程序迁移、网站集成、灾难恢复以及数据中心迁移。在一些实现方式中,数据迁移可以理解成对存储在一个计算机存储系统数据进行复制,拷贝在另一个计算机存储系统内。Data migration can refer to the process of selecting, preparing, extracting, and transforming data and permanently transferring it from one computer storage system to another. There are many reasons for data migration, which may include but are not limited to server or storage device replacement, maintenance or upgrade, application migration, website integration, disaster recovery, and data center migration. In some implementations, data migration can be understood as copying data stored in one computer storage system and copying it to another computer storage system.
目前来说,有些数据迁移的方法不支持在线迁移。例如,若用户需要对正在迁移的数据进行访问,需要等待数据迁移完毕之后才能访问上述数据。也就是说,数据在迁移的过程中电子设备无法响应针对于该数据的读写请求。At present, some data migration methods do not support online migration. For example, if a user needs to access the data being migrated, he needs to wait until the data migration is completed before accessing the data. In other words, the electronic device cannot respond to the read and write requests for the data during the data migration process.
还有些数据迁移的方法的效率较低。例如,当系统采用打快照的方式对数据进行迁移时,需要从源数据存储区域中导出数据,再将导出的数据导入至迁移之后的目标存储区域中。若在对数据进行迁移的过程中,用户操作触发了写请求导致出现新增数据,而新增数据也需要进行迁移,那么需要重复从源数据存储区域中导出新增数据,再将导出的新增数据导入至迁移之后的目标存储区域中。Some data migration methods are less efficient. For example, when the system uses snapshots to migrate data, it is necessary to export data from the source data storage area and then import the exported data into the target storage area after the migration. If during the data migration process, a user operation triggers a write request resulting in new data, and the new data also needs to be migrated, then it is necessary to repeatedly export the new data from the source data storage area and then import the exported new data into the target storage area after the migration.
为了改善上述数据迁移的方法所产生的问题,本申请实施例提供了一种数据迁移的方法。在该方法中,数据迁移分为前台迁移和后台迁移两种形式。In order to improve the problems caused by the above data migration method, an embodiment of the present application provides a data migration method. In this method, data migration is divided into two forms: foreground migration and background migration.
其中,前台迁移的方法具体是指:首先确定出待迁移的数据集,其中,待迁移的数据集可以是由管理人员确定的。当系统接收到用户对第一数据的读请求或写请求时,系统开始对第一数据进行迁移。其中,第一数据属于待迁移的数据集。The foreground migration method specifically refers to: firstly determining a data set to be migrated, wherein the data set to be migrated may be determined by a manager. When the system receives a read request or a write request for first data from a user, the system starts to migrate the first data. The first data belongs to the data set to be migrated.
当系统接收到用户对第一数据的操作请求是读请求时,系统将第一数据从源数据存储区域读取出来,迁移至目标存储区域,然后再将该目标存储区域中的第一数据返回给用户。When the system receives a read request for the operation of the first data from the user, the system reads the first data from the source data storage area, migrates it to the target storage area, and then returns the first data in the target storage area to the user.
当系统接收到用户对第一数据的操作请求是写请求时,系统将第一数据从源数据存储区域读取出来,迁移至目标存储区域,然后对源数据存储区域的第一数据与目标存储区域中的第一数据进行双写处理,再将该目标存储区域中的第一数据返回给用户;或者系统先对第一数据读取出来,进行写处理,将写处理之后的第一数据存储至源数据存储区域,再将写处理之后的第一数据迁移至源数据存储区域。When the system receives a write request from the user for an operation on the first data, the system reads the first data from the source data storage area, migrates it to the target storage area, then performs double-write processing on the first data in the source data storage area and the first data in the target storage area, and then returns the first data in the target storage area to the user; or the system first reads the first data, performs write processing, stores the first data after the write processing in the source data storage area, and then migrates the first data after the write processing to the source data storage area.
后台迁移的方法具体是指:首先确定出待迁移的数据,系统在后台开始按顺序对待迁移的数据块或者单个对象进行迁移。The background migration method specifically refers to: firstly determining the data to be migrated, and then the system starts to migrate the data blocks or single objects to be migrated in sequence in the background.
在一些实现方式中,前台迁移的优先级高于后台迁移。也就是说,当系统接收到用户对第一数据的读请求或写请求时,系统可以优先选择前台迁移的方法进行迁移。当系统未接收到任何读请求或写请求时,系统仅可以选择后台迁移的方法来对需要迁移指令所针对的数据进行迁移。In some implementations, foreground migration has a higher priority than background migration. That is, when the system receives a read request or a write request from a user for the first data, the system may preferentially select the foreground migration method for migration. When the system does not receive any read request or write request, the system may only select the background migration method to migrate the data targeted by the migration instruction.
在一些实现方式中,第一数据存储在源数据存储区域中的存储地址可以被称为第一地址,第一数据存储在目标数据存储区域中的存储地址可以被称为第二地址。In some implementations, a storage address at which the first data is stored in the source data storage area may be referred to as a first address, and a storage address at which the first data is stored in the target data storage area may be referred to as a second address.
在一些实现方式中,第一数据进行写处理之后的数据可以被称为第二数据。In some implementations, data after the first data is written may be referred to as second data.
通过上述方法,可以确保当系统接收到用户对第一数据的读请求或写请求时,只需要系统在源数据存储区域中对第一数据进行一次读取即可以保证实现用户的读请求或写请求以及迁移任务。The above method can ensure that when the system receives a user's read request or write request for the first data, the system only needs to read the first data once in the source data storage area to ensure that the user's read request or write request and migration task are implemented.
这样,相对于系统先接收迁移指令,再接收读请求或写请求的方法,可以提高迁移效率。这是因为系统在迁移过程中不能保证接收迁移指令的数据与接收读请求或写请求的数据是同一数据,这样会造成当实现用户的读请求或写请求以及迁移任务时,系统可能会在源数据存储区域中对某一个数据进行两次读取的现象。In this way, the migration efficiency can be improved compared with the method in which the system first receives the migration instruction and then receives the read request or write request. This is because the system cannot guarantee that the data received by the migration instruction and the data received by the read request or write request are the same data during the migration process. This will cause the system to read a certain data twice in the source data storage area when implementing the user's read request or write request and the migration task.
因此,本申请实施例所提供的数据迁移的方法不仅可以实现数据的在线迁移,还可以提高数据迁移的效率,用户体验感良好。Therefore, the data migration method provided in the embodiment of the present application can not only realize the online migration of data, but also improve the efficiency of data migration and provide a good user experience.
为了更加清楚地介绍本申请实施例提供的方法,下面先介绍本申请实施例提供的数据迁移系统框架。In order to more clearly introduce the method provided in the embodiment of the present application, the data migration system framework provided in the embodiment of the present application is first introduced below.
参考图1,图1为本申请实施例提供的数据迁移系统的框架示意图。 Refer to Figure 1, which is a schematic diagram of the framework of a data migration system provided in an embodiment of the present application.
数据迁移系统可以包括但不限于源数据存储区域、目标数据存储区域、数据迁移工具以及存储介质等等。该数据迁移系统可以应用于本地数据迁移至云端、云端之间进行数据迁移以及云端数据迁移至本地等应用场景。The data migration system may include but is not limited to a source data storage area, a target data storage area, a data migration tool, a storage medium, etc. The data migration system may be applied to application scenarios such as local data migration to the cloud, data migration between clouds, and cloud data migration to the local.
值得说明的是,上述源数据存储区域与目标数据存储区域可以是指服务器中数据块或者单个对象的逻辑存储位置,上述存储介质可以是指服务器中数据块或者单个对象的物理存储位置。It is worth noting that the above-mentioned source data storage area and target data storage area may refer to the logical storage location of data blocks or single objects in the server, and the above-mentioned storage medium may refer to the physical storage location of data blocks or single objects in the server.
其中,源数据存储区域可以是指存储有未迁移的数据的数据库,常见的数据库可以包括但不限于关系型数据库管理器(My Structured Query Language,MYSQL)、Oracle数据库、Microsoft SQL Server等等。Among them, the source data storage area may refer to a database storing unmigrated data. Common databases may include but are not limited to relational database manager (My Structured Query Language, MYSQL), Oracle database, Microsoft SQL Server, etc.
源数据存储区域存储数据的类型可以包括但不限于块存储、文件存储以及对象存储等等。例如,当源数据存储区域中存储的数据是以块存储的形式存储时,源数据存储区域可以作为卷或者逻辑单元号(Logical Unit Number,lun),此时源数据存储区域中存储的数据可以被划分为大小一致的数据块(例如数据块可以是1MB大小的数据)。The types of data stored in the source data storage area may include but are not limited to block storage, file storage, object storage, etc. For example, when the data stored in the source data storage area is stored in the form of block storage, the source data storage area may be used as a volume or a logical unit number (Logical Unit Number, lun), and the data stored in the source data storage area may be divided into data blocks of the same size (for example, a data block may be 1MB in size).
在一些实现方式中,当源数据存储区域中存储的数据进行迁移时,数据可以是以数据块为单位进行迁移。In some implementations, when data stored in a source data storage area is migrated, the data may be migrated in units of data blocks.
又例如,当源数据存储区域中存储的数据是以对象存储的形式存储时,源数据存储区域可以作为桶,此时源数据存储区域中存储的数据为单个对象。也就是说,数据进行迁移可以按数据的单位量进行迁移。For another example, when the data stored in the source data storage area is stored in the form of object storage, the source data storage area can be used as a bucket, and the data stored in the source data storage area is a single object. In other words, data migration can be performed by unit amount of data.
目标数据存储区域可以是指存储有已迁移的数据的数据库。同样,目标数据存储区域存储数据的类型可以包括但不限于块存储、文件存储以及对象存储等等,存储类型的详细说明可以参考上述内容,在此不做赘述。The target data storage area may refer to a database storing migrated data. Similarly, the types of data stored in the target data storage area may include but are not limited to block storage, file storage, and object storage, etc. The detailed description of the storage type can refer to the above content and will not be repeated here.
在一些实现方式中,源数据存储区域与目标数据存储区域可以位于同一硬件设备上,也可以位于不同硬件设备上。In some implementations, the source data storage area and the target data storage area may be located on the same hardware device or on different hardware devices.
图1中所示的源数据存储区域中所示的长方形a以及源数据存储区域中所示的长方形b可以表示数据块或者单个对象。也就是说若要完成源数据存储区域中待迁移的数据集的迁移任务,则需要对多个数据块或者单个对象进行迁移。The rectangle a shown in the source data storage area and the rectangle b shown in the source data storage area shown in Figure 1 can represent a data block or a single object. In other words, to complete the migration task of the data set to be migrated in the source data storage area, multiple data blocks or single objects need to be migrated.
例如,一次完整的迁移任务中,可以将长方形a数据块或者单个对象迁移至长方形b中,长方形b所表示的数据块或者单个对象为长方形a数据块或者单个对象迁移之后的数据,其数据在内容上是一致的。For example, in a complete migration task, the data block or single object of rectangle a can be migrated to rectangle b. The data block or single object represented by rectangle b is the data of the data block or single object of rectangle a after migration, and the data is consistent in content.
数据迁移工具可以实现请求的捕获、数据的分发、存储并更新迁移元数据记录表以及后台迁移任务等等。The data migration tool can capture requests, distribute data, store and update migration metadata record tables, and perform background migration tasks, etc.
具体的,请求的捕获可以用于监测来自用户针对于第一数据的读请求或写请求,以此来开启前台迁移任务。Specifically, the capture of the request can be used to monitor a read request or a write request from a user for the first data, so as to start the foreground migration task.
请求的捕获所实现的具体位置可以有所不同。在一些实施方式中,可以在Linux中的Device Mapper层完成请求的捕获。当数据所存储的服务器连接有对应的客户端,也可以在客户端完成请求的捕获。在本申请实施例中对此不作限定。The specific location where the capture of the request is implemented may be different. In some implementations, the capture of the request can be completed at the Device Mapper layer in Linux. When the server where the data is stored is connected to the corresponding client, the capture of the request can also be completed at the client. This is not limited in the embodiments of the present application.
在一些实现方式中,数据迁移工具在完成请求的捕获之后,从源数据存储区域中获取请求所针对的第一数据的逻辑地址,并根据该逻辑地址从存储介质中读取出第一数据。In some implementations, after completing the capture of the request, the data migration tool obtains the logical address of the first data targeted by the request from the source data storage area, and reads the first data from the storage medium according to the logical address.
也即是说,源数据存储区域以及目标数据存储区域为第一数据的逻辑存储位置,存储介质为第一数据的物理存储位置。That is to say, the source data storage area and the target data storage area are logical storage locations of the first data, and the storage medium is the physical storage location of the first data.
存储介质可以是指存储第一数据的载体,例如软盘、光盘、高密度数字视频光盘(Digital Video Disc,DVD)、硬盘、闪存、U盘、紧凑式闪存(Compact Flash,CF)卡、安全数码卡(Secure Digital Memory Card,SD卡)、多媒体卡(Multi-Media Card,MMC卡)、智能媒体(Smart Media,SM)卡、记忆棒(Memory Stick)、极限数字显卡(Extreme Digital-Picture Card,xD卡)等。 The storage medium may refer to a carrier for storing the first data, such as a floppy disk, an optical disk, a high-density digital video disc (Digital Video Disc, DVD), a hard disk, a flash memory, a USB flash drive, a compact flash (Compact Flash, CF) card, a secure digital memory card (Secure Digital Memory Card, SD card), a multimedia card (Multi-Media Card, MMC card), a smart media (Smart Media, SM) card, a memory stick (Memory Stick), an extreme digital-picture card (Extreme Digital-Picture Card, xD card), etc.
数据的分发可以用于在数据迁移工具读取到第一数据之后对第一数据进行迁移处理。在一些实现方式中,数据迁移工具可以判断第一数据是否需要进行迁移,即第一数据是否属于待迁移数据集。若第一数据属于待迁移数据集,数据迁移工具可以将第一数据迁移至目标存储区域。The data distribution can be used to perform migration processing on the first data after the data migration tool reads the first data. In some implementations, the data migration tool can determine whether the first data needs to be migrated, that is, whether the first data belongs to the data set to be migrated. If the first data belongs to the data set to be migrated, the data migration tool can migrate the first data to the target storage area.
迁移元数据记录表用于记录数据的迁移状态(例如未迁移、已迁移以及初始态)。在一些实现方式中,数据迁移工具可以存储并更新迁移元数据记录表。具体的,可以参考表1、表2所示的迁移元数据记录表。
The migration metadata record table is used to record the migration status of the data (e.g., not migrated, migrated, and initial state). In some implementations, the data migration tool can store and update the migration metadata record table. Specifically, reference can be made to the migration metadata record tables shown in Table 1 and Table 2.
表1
Table 1
表2Table 2
如表1、表2所示,表1示例性示出了块存储迁移元数据记录表,表2示例性示出了对象存储迁移元数据记录表。As shown in Table 1 and Table 2, Table 1 exemplarily shows a block storage migration metadata record table, and Table 2 exemplarily shows an object storage migration metadata record table.
迁移元数据记录表可以包括索引以及迁移状态,迁移元数据记录表还可以包括以下任意一项或几项:数据未迁移时所存储的服务器的标识、数据已迁移后所存储的服务器的标识、数据未迁移时所存储的逻辑位置以及数据已迁移后所存储的逻辑位置等等,在本申请实施例中,对此不作限定。The migration metadata record table may include an index and a migration status. The migration metadata record table may also include any one or more of the following items: the identifier of the server where the data is stored when it has not been migrated, the identifier of the server where the data is stored after it has been migrated, the logical location where the data is stored when it has not been migrated, and the logical location where the data is stored after it has been migrated, etc. In the embodiments of the present application, this is not limited.
其中,表1、表2中示出的索引可以用来表示对源数据存储区域中数据进行排序的一种结构,使用索引可快速查看源数据存储区域中的特定的数据。The indexes shown in Table 1 and Table 2 may be used to represent a structure for sorting data in the source data storage area. The indexes may be used to quickly view specific data in the source data storage area.
例如,索引“Block 1”表示的是以块存储的形式存储的数据中被划分成同样大小(例如1MB)的数据块的索引,索引“Obeject 1”表示的是以对象存储的形式存储的数据中单个对象的索引。For example, the index "Block 1" represents the index of data blocks of the same size (for example, 1MB) in data stored in the form of block storage, and the index "Obeject 1" represents the index of a single object in data stored in the form of object storage.
在一些实现方式中,数据的索引与数据的存储类型有关。In some implementations, the index of data is related to the storage type of the data.
例如,若某一数据的存储类型为块存储,则该数据的索引为卷ID+逻辑地址;若某一数据的存储类型为文件存储,则该数据的索引为文件系统ID(File system ID)+目录(Directory)+文件名(File name)+偏移地址(Offset);若某一数据的存储类型为对象存储,则该数据的索引为键(Key)+版本号(Version)。For example, if the storage type of certain data is block storage, the index of the data is volume ID + logical address; if the storage type of certain data is file storage, the index of the data is file system ID (File system ID) + directory (Directory) + file name (File name) + offset address (Offset); if the storage type of certain data is object storage, the index of the data is key (Key) + version number (Version).
表1、表2中示出的迁移状态表示的是源数据存储区域中数据是否处于迁移状态。The migration status shown in Table 1 and Table 2 indicates whether the data in the source data storage area is in a migration state.
其中,状态“Y”表示该行中具体索引所指示的数据目前处于需要进行迁移并已经完成迁移的情况。The status "Y" indicates that the data indicated by the specific index in the row is currently in a state where migration is required and has been completed.
状态“N”表示该行中具体索引所指示的数据目前处于需要进行迁移但未进行迁移,或者需要进行迁移并正在迁移但没有完全迁移完毕的情况。The status "N" indicates that the data indicated by the specific index in the row is currently in a state where the data needs to be migrated but has not been migrated, or needs to be migrated and is being migrated but has not been completely migrated.
状态“NA”表示该行中具体索引所指示的数据目前处于不需要进行迁移,不处于未迁移状态的情况。The status "NA" indicates that the data indicated by the specific index in the row is currently in a state where migration is not required and is not in an unmigrated state.
在一些实现方式中,数据迁移工具还可以实时更改数据的状态。例如,当数据1需要进行迁移并完成迁移之后,数据1的状态可以由“N”转换为“Y”。一般情况下,数据1不会由“Y”转换为“N”。In some implementations, the data migration tool can also change the state of the data in real time. For example, when data 1 needs to be migrated and after the migration is completed, the state of data 1 can be changed from "N" to "Y". Generally, data 1 will not be changed from "Y" to "N".
不同迁移元数据记录表中索引所指示的同一数据在不同的表中可能处于不同的状态。例如,数据1在表A中的状态为“Y”,在表B中的状态为“N”,也就是说,数据1已经从表A中未迁移时所存储的逻辑位置迁移至已迁移后所存储的逻辑位置,但是还未从表B中未迁移时所存储的逻辑位置迁移至已迁移后所 存储的逻辑位置。The same data indicated by the indexes in different migration metadata record tables may be in different states in different tables. For example, the state of data 1 in table A is "Y", and the state in table B is "N", that is, data 1 has been migrated from the logical location in table A where it was stored before migration to the logical location where it is stored after migration, but has not yet been migrated from the logical location in table B where it was stored before migration to the logical location where it is stored after migration. Logical location of storage.
值得说明的是,由于服务器100中存储有迁移元数据记录表,记录有迁移单位的数据的状态,迁移元数据记录表具有更新性与持久性,因此,在本申请实施例中,可以支持断点续传以及重试迁移。例如,当出现网络问题导致无法复制数据时,则中断复制数据,原有的迁移任务不受影响。当网络恢复之后,从中断处继续复制数据。It is worth noting that since the server 100 stores a migration metadata record table that records the status of the data of the migration unit, the migration metadata record table is updateable and persistent. Therefore, in the embodiment of the present application, breakpoint resumption and retry migration can be supported. For example, when a network problem occurs and the data cannot be copied, the data copying is interrupted, and the original migration task is not affected. When the network is restored, the data copying continues from the interruption point.
又例如,若在网络出现问题导致无法复制的期间,而系统正在响应写请求,并正在进行对已经迁移的数据块或者对象进行写处理时,则将该数据块或对象在迁移元数据记录表中对应的状态记录为“N”,表示该数据块或对象指示为脏块需要继续迁移。当网络恢复后,迁移工具继续恢复原来的迁移过程,并将未迁移的数据和脏块迁移到目标中。也就是说,对网络出现问题那一刻所处理的数据块或者单个对象进行重新处理,以此来实现完成准确的迁移任务。For another example, if a network problem causes replication to fail, and the system is responding to a write request and is writing a data block or object that has already been migrated, the corresponding status of the data block or object in the migration metadata record table is recorded as "N", indicating that the data block or object is indicated as a dirty block and needs to continue to be migrated. When the network is restored, the migration tool continues to restore the original migration process and migrates the unmigrated data and dirty blocks to the target. In other words, the data blocks or single objects processed at the moment the network problem occurs are reprocessed to achieve accurate migration tasks.
在一些实现方式中,对于同一个源数据存储区域,可以实现多个任务迁移到不同的目标中,同一个源数据存储区域的两个不同的迁移任务是相互独立的,不会相互影响。对于不同源数据存储区域的同时进行迁移,后台也会有多个迁移任务,也有针对于不同迁移任务的各自的迁移元数据表,多个迁移任务之间也是相互独立,不会影响。In some implementations, for the same source data storage area, multiple tasks can be migrated to different targets. Two different migration tasks for the same source data storage area are independent of each other and will not affect each other. For simultaneous migration of different source data storage areas, there will be multiple migration tasks in the background, and there will also be migration metadata tables for different migration tasks. Multiple migration tasks are also independent of each other and will not affect each other.
后台迁移任务区别于前台迁移任务,指的是实时按顺序扫描待迁移的数据,判断出待迁移的数据中未迁移的单位数据,并对上述待迁移的数据中的未迁移的单位数据(例如数据块或单个对象)进行迁移。The background migration task is different from the foreground migration task. It refers to scanning the data to be migrated in real time and in sequence, determining the unmigrated unit data in the data to be migrated, and migrating the unmigrated unit data (such as data blocks or single objects) in the data to be migrated.
例如,待迁移的数据为数据1-数据100共100个单位数据,若无针对于数据1-数据100中任一数据的读请求或写请求,后台迁移任务从数据1开始扫描直到数据100,并在扫描数据1时判断数据1为未迁移数据,对数据1进行迁移,其余99个数据同理进行迁移;For example, the data to be migrated is 100 units of data, namely data 1 to data 100. If there is no read request or write request for any of the data from data 1 to data 100, the background migration task starts scanning from data 1 to data 100, and determines that data 1 is unmigrated data when scanning data 1, and migrates data 1. The remaining 99 data are migrated in the same way.
若存在一个针对于数据10的读请求或写请求,前台迁移任务率先将数据10进行迁移,然后后台迁移任务从数据1开始扫描直到数据100,并再按顺序将数据1-数据9、数据11-数据100进行迁移,并在扫描数据1时判断数据1为未迁移数据,对数据1进行迁移,其余98个数据同理进行迁移,但在扫描数据10时判断数据10为已迁移数据,不对数据10进行迁移。If there is a read request or write request for data 10, the foreground migration task will migrate data 10 first, and then the background migration task will scan from data 1 to data 100, and then migrate data 1-data 9, data 11-data 100 in order, and when scanning data 1, it will be determined that data 1 is not migrated data, and data 1 will be migrated. The remaining 98 data will be migrated in the same way, but when scanning data 10, it will be determined that data 10 is migrated data, and data 10 will not be migrated.
这样,只需要迁移前台未读写过的数据块或者单个对象,已经读写过的数据不会重复迁移,减少数据的读写,提升了迁移效率。In this way, only the data blocks or single objects that have not been read or written in the foreground need to be migrated, and the data that has been read and written will not be migrated repeatedly, which reduces the reading and writing of data and improves the migration efficiency.
为了更加清楚的介绍本申请实施例提供的方法,下面本申请实施例提供的服务器100。In order to more clearly introduce the method provided in the embodiment of the present application, the server 100 provided in the embodiment of the present application is as follows.
参考图2,图2为本申请实施例提供的服务器100的结构示意图。Refer to Figure 2, which is a schematic diagram of the structure of the server 100 provided in an embodiment of the present application.
如图2所示,服务器100可以包括:一个或者多个处理器101、存储器102、通信接口103、发射器105、接收器106、耦合器107以及天线108。上述部件可以通过总线104或者其他方式进行连接,图2是以通过总线连接为例。其中:As shown in FIG2 , the server 100 may include: one or more processors 101, a memory 102, a communication interface 103, a transmitter 105, a receiver 106, a coupler 107, and an antenna 108. The above components may be connected via a bus 104 or other means, and FIG2 takes the connection via a bus as an example. Among them:
在本申请实施例中,处理器101可以用于读取和执行计算机可读指令。具体的,处理器101可以用于调用存储于存储器102中的程序,例如本申请实施例提供的数据迁移方法在服务器100的实现程序,并执行该程序包含的指令。处理器101还可以用于根据迁移元数据记录表确定是否需要进行迁移。In the embodiment of the present application, the processor 101 can be used to read and execute computer-readable instructions. Specifically, the processor 101 can be used to call a program stored in the memory 102, such as an implementation program of the data migration method provided in the embodiment of the present application on the server 100, and execute the instructions contained in the program. The processor 101 can also be used to determine whether migration is required based on the migration metadata record table.
存储器102与处理器101耦合,用于存储各种软件程序和/或多组指令。具体的,存储器102可包括高速随机存取的存储器,并且也可包括非易失性存储器,例如一个或多个磁盘存储设备、闪存设备或其他非易失性固态存储设备。The memory 102 is coupled to the processor 101 and is used to store various software programs and/or multiple sets of instructions. Specifically, the memory 102 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more disk storage devices, flash memory devices or other non-volatile solid-state storage devices.
存储器102可以存储待迁移的数据集以及迁移元数据记录表等信息。The memory 102 may store information such as the data set to be migrated and the migration metadata record table.
存储器102可以存储操作系统(下述简称系统),例如uCOS、VxWorks、RTLinux等嵌入式操作系统。存储器102还可以存储网络通信程序,该网络通信程序可用于与客户端以及其他服务器进行通信。The memory 102 may store an operating system (hereinafter referred to as system), such as embedded operating systems such as uCOS, VxWorks, RTLinux, etc. The memory 102 may also store a network communication program, which may be used to communicate with clients and other servers.
通信接口103可用于服务器100与其他通信设备。The communication interface 103 can be used for communication between the server 100 and other devices.
具体的,通信接口103可以是3G通信接口、长期演进(LTE)(4G)通信接口、5G通信接口、WLAN 通信接口、WAN通信接口等等。不限于无线通信接口,服务器100还可以配置有线的通信接口103来支持有线通信。Specifically, the communication interface 103 may be a 3G communication interface, a long term evolution (LTE) (4G) communication interface, a 5G communication interface, a WLAN Communication interface, WAN communication interface, etc. Not limited to the wireless communication interface, the server 100 may also be configured with a wired communication interface 103 to support wired communication.
发射器105和接收器106可看作一个无线调制解调器。发射器105可用于对处理器101输出的信号进行发射处理。接收器106可用于接收信号。The transmitter 105 and the receiver 106 can be regarded as a wireless modem. The transmitter 105 can be used to transmit the signal output by the processor 101. The receiver 106 can be used to receive the signal.
在服务器100中,发射器105和接收器106的数量均可以是一个或者多个。In the server 100 , the number of the transmitter 105 and the number of the receiver 106 can be one or more.
天线108可用于将传输线中的电磁能转换成自由空间中的电磁波,或者将自由空间中的电磁波转换成传输线中的电磁能。The antenna 108 may be used to convert electromagnetic energy in the transmission line into electromagnetic waves in free space, or to convert electromagnetic waves in free space into electromagnetic energy in the transmission line.
耦合器107可用于将移动通信号分成多路,分配给多个的接收器106。The coupler 107 may be used to divide the mobile communication signal into multiple paths and distribute the signals to multiple receivers 106 .
可理解的,网络设备的天线108可以实现为大规模天线阵列。It is understandable that the antenna 108 of the network device may be implemented as a large-scale antenna array.
需要说明的,图2所示的服务器100仅仅是本申请实施例的一种实现方式,实际应用中,服务器100还可以包括更多或更少的部件,这里不作限制。It should be noted that the server 100 shown in FIG. 2 is only one implementation of the embodiment of the present application. In actual applications, the server 100 may also include more or fewer components, which is not limited here.
值得说明的,根据用户的不同需求以及其他方面的综合考虑,源数据存储区域和目标存储区域所存储的服务器可以为同一个,也可以为不同的两个服务器。It is worth noting that, according to different needs of users and comprehensive considerations of other aspects, the server stored in the source data storage area and the target storage area can be the same or two different servers.
数据迁移工具可以运行在源数据存储区域所存储的服务器上,也可以运行在目标存储区域所存储的服务器上,还可以运行在除上述情况以外的其他服务器上。The data migration tool may be run on a server stored in a source data storage area, or on a server stored in a target storage area, or on other servers other than the above.
在一些实施方式中,数据迁移工具可以同时运行在源数据存储区域所存储的服务器上以及目标存储区域所存储的服务器上。在本申请实施例中,对此不作限定。In some implementations, the data migration tool may be run simultaneously on the server stored in the source data storage area and the server stored in the target storage area. In the embodiments of the present application, this is not limited.
当图1中数据迁移系统中源数据存储区域所存储的服务器和目标存储区域所存储的服务器为同一个图2所示的服务器100,并且数据迁移工具运行服务器100上时,处理器101可以用于响应用户的读请求和写请求,并对请求进行拦截处理。When the server stored in the source data storage area and the server stored in the target storage area in the data migration system in Figure 1 are the same server 100 shown in Figure 2, and the data migration tool runs on the server 100, the processor 101 can be used to respond to the user's read requests and write requests, and intercept and process the requests.
处理器101还可以根据迁移元数据记录表判断数据是否需要进行迁移。处理器101还可以在数据完成迁移之后更新数据在迁移元数据记录表上的状态信息。The processor 101 may also determine whether the data needs to be migrated according to the migration metadata record table. The processor 101 may also update the state information of the data in the migration metadata record table after the data migration is completed.
存储器102可以用于存储待迁移的数据、已迁移的数据以及迁移元数据记录表等信息。The memory 102 may be used to store information such as data to be migrated, data that has been migrated, and a migration metadata record table.
通信接口103可以用于与用户所使用的电子设备进行通信连接。The communication interface 103 may be used to establish a communication connection with an electronic device used by a user.
发射器105可以用于将用户所需要的数据返回给用户所使用的电子设备,接收器106可以用于接收用户的读请求或写请求,接收器106还可以用于接收针对于第一数据的迁移指令,例如接收器106还可以用于接收控制中心发送的针对于第一数据的迁移指令。The transmitter 105 can be used to return the data required by the user to the electronic device used by the user, the receiver 106 can be used to receive the user's read request or write request, and the receiver 106 can also be used to receive migration instructions for the first data. For example, the receiver 106 can also be used to receive migration instructions for the first data sent by the control center.
当图1中数据迁移系统中源数据存储区域所存储的服务器和目标存储区域所存储的服务器不为同一个图2所示的服务器100时,源数据存储区域所存储的服务器为服务器110,目标存储区域所存储的服务器为服务器120,数据迁移工具可以同时运行服务器110以及服务器120上,服务器100包括服务器110以及服务器120。When the server stored in the source data storage area and the server stored in the target storage area in the data migration system in Figure 1 are not the same server 100 shown in Figure 2, the server stored in the source data storage area is server 110, and the server stored in the target storage area is server 120. The data migration tool can run on server 110 and server 120 at the same time, and server 100 includes server 110 and server 120.
服务器110的处理器101可以用于响应用户的读请求和写请求,并对请求进行拦截处理。服务器110的处理器101还可以根据迁移元数据记录表判断数据是否需要进行迁移。服务器110的处理器101可以在发送待迁移的数据完毕之后,更新迁移元数据记录表。The processor 101 of the server 110 can be used to respond to the user's read request and write request and intercept the request. The processor 101 of the server 110 can also determine whether the data needs to be migrated according to the migration metadata record table. The processor 101 of the server 110 can update the migration metadata record table after sending the data to be migrated.
服务器110的存储器102可以用于存储待迁移的数据以及迁移元数据记录表等信息。The memory 102 of the server 110 may be used to store data to be migrated and information such as a migration metadata record table.
服务器110的通信接口103可以用于与服务器120进行通信连接。The communication interface 103 of the server 110 may be used to establish a communication connection with the server 120 .
服务器110的发射器105可以用于向服务器120发送待迁移的数据。The transmitter 105 of the server 110 may be used to send the data to be migrated to the server 120 .
服务器110的接收器106可以用于接收用户的读请求或写请求,服务器110的接收器106还可以用于接收控制中心发送的针对于第一数据的迁移指令。The receiver 106 of the server 110 may be used to receive a read request or a write request from a user. The receiver 106 of the server 110 may also be used to receive a migration instruction for the first data sent by the control center.
服务器120的处理器101可以在接收服务器110发送待迁移的数据完毕之后,更新迁移元数据记录表。The processor 101 of the server 120 may update the migration metadata record table after receiving the data to be migrated sent by the server 110 .
服务器120的存储器102可以用于存储已迁移的数据以及迁移元数据记录表等信息。 The memory 102 of the server 120 may be used to store information such as migrated data and migration metadata record tables.
服务器120的通信接口103可以用于与服务器110进行通信连接。The communication interface 103 of the server 120 may be used to establish a communication connection with the server 110 .
服务器120的发射器105可以用于向服务器110发送待迁移的数据已完成迁移的提示信息,服务器120的接收器106可以用于接收服务器110所发送待迁移的数据。The transmitter 105 of the server 120 may be used to send a prompt message to the server 110 indicating that the data to be migrated has been migrated, and the receiver 106 of the server 120 may be used to receive the data to be migrated sent by the server 110 .
在一些实现方式中,服务器100可以被称为计算设备。In some implementations, server 100 may be referred to as a computing device.
在一些实现方式中,用户所使用的电子设备可以是手机、平板电脑、桌面型计算机、膝上型计算机、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本,以及蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、人工智能(artificial intelligence,AI)设备、可穿戴式设备、车载设备、智能家居设备和/或智慧城市设备,本申请实施例对该电子设备的具体类型不作特殊限制。In some implementations, the electronic device used by the user may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, as well as a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and/or a smart city device. The embodiments of the present application do not impose any special restrictions on the specific type of the electronic device.
下面介绍本申请实施例中提供的一种数据迁移的方法。该实施例以服务器100响应用户针对于待迁移的数据的读请求的情况为例介绍数据迁移的方法。A method for data migration provided in an embodiment of the present application is described below. This embodiment takes the case where the server 100 responds to a user's read request for data to be migrated as an example to introduce the method for data migration.
图3示出了本申请实施例中提供的一种响应读请求的数据迁移方法的流程示意图。在该实施例中以数据的存储方式为块存储,迁移单位为数据块为例。Fig. 3 shows a schematic flow chart of a data migration method in response to a read request provided in an embodiment of the present application. In this embodiment, the data storage mode is block storage, and the migration unit is a data block as an example.
S301、服务器100响应用户针对于第一数据的读请求。S301. The server 100 responds to a user's read request for first data.
在一些实施方式中,用户根据自身需求,可以向服务器100进行输入操作,服务器100可以响应针对第一数据进行读请求。其中,第一数据的读请求可以包括但不限于:第一数据的在源数据存储区域中的逻辑地址,索引以及数据净荷长度等等,其中,数据净荷长度是指读请求信息中除去报头和长度之外的有效净荷数据长度。In some implementations, the user can input an operation to the server 100 according to his/her needs, and the server 100 can respond with a read request for the first data. The read request for the first data may include, but is not limited to: the logical address of the first data in the source data storage area, the index, and the data payload length, etc., wherein the data payload length refers to the effective payload data length excluding the header and the length in the read request information.
S302、判断第一数据是否需要进行迁移。S302: Determine whether the first data needs to be migrated.
在一些实施方式中,服务器100可以在响应读请求之前接收到控制中心下发的针对于第一数据的迁移指令。In some implementations, the server 100 may receive a migration instruction for the first data sent by the control center before responding to the read request.
系统可以是由于服务器100的剩余容纳空间,或者服务器100进行升级更新,或者是服务器100造到了损坏等原因下发的迁移指令,还可以是基于管理人员的输入操作而下发的迁移指令。在本申请实施例中,对此不作限定。The system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
并且,若存在针对于第一数据的迁移指令,则迁移元数据记录表中第一数据的状态不会是“NA”,而是“Y”或者“N”。Furthermore, if there is a migration instruction for the first data, the status of the first data in the migration metadata record table will not be "NA" but "Y" or "N".
当服务器100判断出第一数据需要进行迁移时,即存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“Y”或者“N”,则执行S303。When the server 100 determines that the first data needs to be migrated, that is, there is a migration instruction for the first data, and the status of the first data in the migration metadata record table is "Y" or "N", S303 is executed.
当服务器100判断出第一数据不需要进行迁移时,即不存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“NA”,则执行S304。When the server 100 determines that the first data does not need to be migrated, that is, there is no migration instruction for the first data, and the status of the first data in the migration metadata record table is "NA", S304 is executed.
在一些实现方式中,由于迁移元数据记录表中的记录单位是以数据块的大小为单位的,上述第一数据的状态可以是指:In some implementations, since the record unit in the migration metadata record table is in the size of a data block, the state of the first data may refer to:
若第一数据的大小大于或等于数据块,则第一数据的状态为第一数据所分割成对应多个数据块的状态,若第一数据的大小小于数据块,则第一数据的状态为第一数据所对应数据块的状态。If the size of the first data is greater than or equal to the data block, the state of the first data is the state of the first data divided into corresponding multiple data blocks; if the size of the first data is less than the data block, the state of the first data is the state of the data block corresponding to the first data.
S303、判断第一数据是否已经完成迁移。S303: Determine whether the first data has been migrated.
在一些实现方式中,服务器100可以根据迁移元数据记录表判断出第一数据是否已经完成迁移。In some implementations, the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
例如,若在迁移元数据记录表中,针对于第一数据的读请求中携带的索引所对应的状态为“Y”,则可以判断出第一数据已经完成迁移;若在迁移元数据记录表中,针对于第一数据的读请求中携带的索引所对应的状态为“N”,则可以判断出第一数据未迁移或正在迁移中并且还未完成迁移。For example, if in the migration metadata record table, the status corresponding to the index carried in the read request for the first data is "Y", it can be determined that the first data has completed migration; if in the migration metadata record table, the status corresponding to the index carried in the read request for the first data is "N", it can be determined that the first data has not been migrated or is in the process of migrating and has not yet completed migration.
当服务器100判断出第一数据已经完成迁移时,第一数据在迁移元数据记录表中的状态为“Y”,第一数据无需再次从源数据存储区域迁移至目标存储区域,则执行S304。 When the server 100 determines that the first data has been migrated, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again, and S304 is executed.
当服务器100判断出第一数据未进行迁移,但从S303中可知存在有针对于第一数据的迁移指令时,第一数据在迁移元数据记录表中的状态为“N”,则执行S305。When the server 100 determines that the first data has not been migrated, but it can be known from S303 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S305 is executed.
进一步的,在一种可能的实现方式中,若第一数据处于正在迁移但没有完全迁移完毕的情况下,迁移元数据记录表可以记录第一数据的状态可以为“N+”。Furthermore, in a possible implementation, if the first data is being migrated but has not been completely migrated, the migration metadata record table may record that the state of the first data may be "N+".
当服务器100判断出第一数据处于正在迁移但没有完全迁移完毕时,第一数据无需重新进行迁移,执行S304。When the server 100 determines that the first data is being migrated but has not been completely migrated, the first data does not need to be migrated again, and S304 is executed.
S304、从源数据存储区域读取出第一数据,并返回给用户。S304: Read the first data from the source data storage area and return it to the user.
在一些实现方式中,服务器100可以基于读请求从源数据存储区域中读取出第一数据,将第一数据返回至用户。In some implementations, the server 100 may read the first data from the source data storage area based on the read request and return the first data to the user.
具体的,若第一数据存储在云端,用户想要读取第一数据,则云端可以根据本地用户所发送的第一数据的读请求获得第一数据的逻辑地址,再根据逻辑地址与物理地址的映射关系得到第一数据的物理地址,并从该物理地址中读取出第一数据,然后云端将读取出来的第一数据发送至本地用户。Specifically, if the first data is stored in the cloud and the user wants to read the first data, the cloud can obtain the logical address of the first data based on the read request of the first data sent by the local user, and then obtain the physical address of the first data based on the mapping relationship between the logical address and the physical address, and read the first data from the physical address, and then the cloud sends the read first data to the local user.
S305、从源数据存储区域读取出第一数据,将第一数据迁移至目标存储区域,并更新迁移元数据记录表,再将第一数据返回给用户。S305: Read the first data from the source data storage area, migrate the first data to the target storage area, update the migration metadata record table, and then return the first data to the user.
在一些实现方式中,服务器100可以将第一数据从源数据存储区域迁移至目标存储区域。例如,当源数据存储区域与目标存储区域存储在同一个服务器100上时,第一数据的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。In some implementations, the server 100 may migrate the first data from the source data storage area to the target storage area. For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
服务器100将第一数据从源数据存储区域迁移至目标存储区域可以是指将第一数据的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射物理地址W1。The server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
可选的,第一数据迁移前后在服务器100中所存储的两个物理地址可以相同的,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses stored in the server 100 before and after the first data migration may be the same or different. In the embodiment of the present application, there is no limitation on this.
在一些实现方式中,服务器100在完成第一数据从源数据存储区域迁移至目标存储区域后,可以更新迁移元数据记录表。In some implementations, after completing the migration of the first data from the source data storage area to the target storage area, the server 100 may update the migration metadata record table.
例如,第一数据从源数据存储区域迁移至目标存储区域之后,在迁移元数据记录表的状态可以由“N”转换为“Y”。For example, after the first data is migrated from the source data storage area to the target storage area, the state of the migration metadata record table may be converted from "N" to "Y".
在一种可能的实施方式中,若用户想要读取的第一数据的大小小于数据块,服务器100需要对数据块按照实际读取的数据大小进行切割处理,使得切割处理之后的部分数据恰好为第一数据。In a possible implementation, if the size of the first data that the user wants to read is smaller than the data block, the server 100 needs to split the data block according to the size of the data actually read, so that the part of the data after the splitting process is exactly the first data.
例如,用户想要读取的第一数据大小为0.5MB,而数据块大小为1MB,此时,服务器100从源数据存储区域中读取出的数据块大小为1MB,其中,1MB的数据块包括有0.5MB的第一数据和0.5MB的其他数据,服务器100需要将1MB大小的数据块划分开,从其中选择出0.5MB的第一数据,并将该0.5MB的第一数据返回给用户。For example, the size of the first data that the user wants to read is 0.5MB, and the size of the data block is 1MB. At this time, the size of the data block read out by the server 100 from the source data storage area is 1MB, wherein the 1MB data block includes 0.5MB of first data and 0.5MB of other data. The server 100 needs to divide the 1MB data block, select 0.5MB of first data therefrom, and return the 0.5MB of first data to the user.
图4示出了本申请实施例中提供的另一种响应读请求的数据迁移方法的流程示意图。在该实施例中以数据的存储方式为对象存储,迁移单位为单个对象为例。Fig. 4 shows a flow chart of another data migration method in response to a read request provided in an embodiment of the present application. In this embodiment, the data storage mode is object storage, and the migration unit is a single object as an example.
S401、服务器100响应用户针对于第一数据的读请求。S401. The server 100 responds to a user's read request for first data.
在一些实施方式中,用户根据自身需求,可以向服务器100进行输入操作,服务器100可以响应针对第一数据进行读请求。In some implementations, the user may perform input operations to the server 100 according to his/her own needs, and the server 100 may respond with a read request for the first data.
其中,第一数据的读请求可以包括但不限于:第一数据的在源数据存储区域中的逻辑地址,索引以及数据净荷长度等等,其中,数据净荷长度是指读请求信息中除去报头和长度之外的有效净荷数据长度。The read request for the first data may include but is not limited to: the logical address of the first data in the source data storage area, index and data payload length, etc., wherein the data payload length refers to the effective payload data length excluding the header and length in the read request information.
S402、判断第一数据是否需要进行迁移。S402: Determine whether the first data needs to be migrated.
在一些实施方式中,服务器100可以在响应读请求之前接收到控制中心下发的针对于第一数据的迁移 指令。In some implementations, the server 100 may receive a migration request for the first data from the control center before responding to the read request. instruction.
系统可以是由于服务器100的剩余容纳空间,或者服务器100进行升级更新,或者是服务器100造到了损坏等原因下发的迁移指令,还可以是基于管理人员的输入操作而下发的迁移指令。在本申请实施例中,对此不作限定。The system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
并且,若存在针对于第一数据的迁移指令,则迁移元数据记录表中第一数据的状态不会是“NA”,而是“Y”或者“N”。Furthermore, if there is a migration instruction for the first data, the status of the first data in the migration metadata record table will not be "NA" but "Y" or "N".
当服务器100判断出第一数据需要进行迁移时,即存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“Y”或者“N”,则执行S403。When the server 100 determines that the first data needs to be migrated, that is, there is a migration instruction for the first data, and the status of the first data in the migration metadata record table is "Y" or "N", S403 is executed.
当服务器100判断出第一数据不需要进行迁移时,即不存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“NA”,则执行S404。When the server 100 determines that the first data does not need to be migrated, that is, there is no migration instruction for the first data, and the status of the first data in the migration metadata record table is "NA", S404 is executed.
在一些实现方式中,由于迁移元数据记录表中的记录单位是以单个对象的大小为单位的,上述第一数据的状态可以是指:In some implementations, since the record unit in the migration metadata record table is based on the size of a single object, the state of the first data may refer to:
若第一数据的大小大于或等于单个对象,则第一数据的状态为第一数据所分割成对应多个单个对象的状态,若第一数据的大小小于单个对象,则第一数据的状态为第一数据所对应单个对象的状态。If the size of the first data is greater than or equal to a single object, the state of the first data is the state of the first data divided into corresponding multiple single objects; if the size of the first data is less than a single object, the state of the first data is the state of the single object corresponding to the first data.
S403、判断第一数据是否已经完成迁移。S403: Determine whether the first data has been migrated.
在一些实现方式中,服务器100可以根据迁移元数据记录表判断出第一数据是否已经完成迁移。In some implementations, the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
例如,若在迁移元数据记录表中,针对于第一数据的读请求中携带的索引所对应的状态为“Y”,则可以判断出第一数据已经完成迁移;For example, if in the migration metadata record table, the state corresponding to the index carried in the read request for the first data is "Y", it can be determined that the first data has been migrated;
若在迁移元数据记录表中,针对于第一数据的读请求中携带的索引所对应的状态为“N”,则可以判断出第一数据未迁移或正在迁移中并且还未完成迁移。If in the migration metadata record table, the state corresponding to the index carried in the read request for the first data is "N", it can be determined that the first data has not been migrated or is being migrated and the migration has not yet been completed.
当服务器100判断出第一数据已经完成迁移时,第一数据在迁移元数据记录表中的状态为“Y”,第一数据无需再次从源数据存储区域迁移至目标存储区域,则执行S404。When the server 100 determines that the first data has been migrated, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again, and S404 is executed.
当服务器100判断出第一数据未进行迁移,但从S403中可知存在有针对于第一数据的迁移指令时,第一数据在迁移元数据记录表中的状态为“N”,则执行S405。When the server 100 determines that the first data has not been migrated, but it can be known from S403 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S405 is executed.
进一步的,在一种可能的实现方式中,若第一数据处于正在迁移但没有完全迁移完毕的情况下,迁移元数据记录表可以记录第一数据的状态可以为“N+”。Furthermore, in a possible implementation, if the first data is being migrated but has not been completely migrated, the migration metadata record table may record that the state of the first data may be "N+".
当服务器100判断出第一数据处于正在迁移但没有完全迁移完毕时,第一数据无需重新进行迁移,执行S404。When the server 100 determines that the first data is being migrated but has not been completely migrated, the first data does not need to be migrated again, and S404 is executed.
S404、从源数据存储区域读取出第一数据,并返回给用户。S404: Read the first data from the source data storage area and return it to the user.
在一些实现方式中,服务器100可以基于读请求从源数据存储区域中读取出第一数据,将第一数据返回至用户。In some implementations, the server 100 may read the first data from the source data storage area based on the read request and return the first data to the user.
具体的,若第一数据存储在云端,用户想要读取第一数据,则云端可以根据本地用户所发送的第一数据的读请求获得第一数据的逻辑地址,再根据逻辑地址与物理地址的映射关系得到第一数据的物理地址,并从该物理地址中读取出第一数据,然后云端将读取出来的第一数据发送至本地用户。Specifically, if the first data is stored in the cloud and the user wants to read the first data, the cloud can obtain the logical address of the first data based on the read request of the first data sent by the local user, and then obtain the physical address of the first data based on the mapping relationship between the logical address and the physical address, and read the first data from the physical address, and then the cloud sends the read first data to the local user.
S405、从源数据存储区域读取出第一数据,将第一数据迁移至目标存储区域,并更新迁移元数据记录表,再将第一数据返回给用户。S405: Read the first data from the source data storage area, migrate the first data to the target storage area, update the migration metadata record table, and then return the first data to the user.
在一些实现方式中,服务器100可以将第一数据从源数据存储区域迁移至目标存储区域。例如,当源数据存储区域与目标存储区域存储在同一个服务器100上时,第一数据的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。In some implementations, the server 100 may migrate the first data from the source data storage area to the target storage area. For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
服务器100将第一数据从源数据存储区域迁移至目标存储区域可以是指将第一数据的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射 物理地址W1。The server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to the logical address L2 mapping relationship. Physical address W1.
可选的,第一数据迁移前后在服务器100中所存储的两个物理地址可以相同的,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses stored in the server 100 before and after the first data migration may be the same or different. In the embodiment of the present application, there is no limitation on this.
在一些实现方式中,服务器100在完成第一数据从源数据存储区域迁移至目标存储区域后,可以更新迁移元数据记录表。In some implementations, after completing the migration of the first data from the source data storage area to the target storage area, the server 100 may update the migration metadata record table.
例如,第一数据从源数据存储区域迁移至目标存储区域之后,在迁移元数据记录表的状态可以由“N”转换为“Y”。For example, after the first data is migrated from the source data storage area to the target storage area, the state of the migration metadata record table may be converted from "N" to "Y".
在一种可能的实施方式中,若用户想要读取的第一数据的大小小于单个对象,服务器100需要对单个对象按照实际读取的数据大小进行切割处理,使得切割处理之后的部分数据恰好为第一数据。例如,用户想要读取的第一数据大小为0.5MB,而单个对象大小为1MB,此时,服务器100从源数据存储区域中读取出的单个对象大小为1MB,其中,1MB的单个对象包括有0.5MB的第一数据和0.5MB的其他数据,服务器100需要将1MB大小的单个对象划分开,从其中选择出0.5MB的第一数据,并将该0.5MB的第一数据返回给用户。In a possible implementation, if the size of the first data that the user wants to read is smaller than a single object, the server 100 needs to split the single object according to the size of the data actually read, so that the portion of data after the splitting process is exactly the first data. For example, the size of the first data that the user wants to read is 0.5MB, and the size of the single object is 1MB. At this time, the size of the single object read by the server 100 from the source data storage area is 1MB, where the 1MB single object includes 0.5MB of first data and 0.5MB of other data. The server 100 needs to split the 1MB single object, select 0.5MB of first data from it, and return the 0.5MB of first data to the user.
实施上述方法,可以实现在线迁移,并且可以确保当系统接收到用户对第一数据的读请求时,只需要系统在源数据存储区域中对第一数据进行一次读取即可以保证实现用户的读请求以及迁移任务。这样,可以提高迁移效率。By implementing the above method, online migration can be realized, and it can be ensured that when the system receives a user's read request for the first data, the system only needs to read the first data once in the source data storage area to ensure that the user's read request and migration task are realized. In this way, the migration efficiency can be improved.
下面介绍本申请实施例中提供的另一种数据迁移的方法。该实施例以服务器100响应用户针对于待迁移的数据的写请求的情况为例介绍数据迁移的方法。Another data migration method provided in an embodiment of the present application is described below. This embodiment takes the case where the server 100 responds to a user's write request for data to be migrated as an example to introduce the data migration method.
图5示出了本申请实施例中提供的一种响应写请求的数据迁移方法的流程示意图。在该实施例中以数据的存储方式为块存储,迁移单位为数据块为例。Fig. 5 shows a schematic flow chart of a data migration method in response to a write request provided in an embodiment of the present application. In this embodiment, the data storage mode is block storage, and the migration unit is a data block as an example.
S501、服务器100响应用户针对于第一数据的写请求。S501. The server 100 responds to a user's write request for first data.
在一些实施方式中,用户根据自身需求,可以向服务器100进行输入操作,服务器100可以响应针对第一数据进行写请求。In some implementations, the user may perform input operations to the server 100 according to his/her own needs, and the server 100 may respond with a write request for the first data.
其中,第一数据的写请求可以包括但不限于:第一数据在源数据存储区域中的逻辑地址,索引、数据净荷长度以及修改内容等等。The write request for the first data may include but is not limited to: a logical address of the first data in the source data storage area, an index, a data payload length, and a modification content, etc.
在一些实现方式中,服务器100响应写请求存在前置条件:服务器100响应用户针对于第一数据的写请求需要满足写写互斥,即两个写请求针对的数据不可以有交集。In some implementations, there is a prerequisite for the server 100 to respond to the write request: the server 100 needs to satisfy write-write mutual exclusion in responding to the user's write request for the first data, that is, the data targeted by the two write requests cannot have an intersection.
若出现两个写请求针对的数据有交集的情况,需要采取加锁互斥的方式,避免出现写写冲突的现象。If the data targeted by two write requests overlap, a mutually exclusive lock method is required to avoid write-write conflicts.
S502、判断第一数据是否需要进行迁移,若否,则写源数据存储区域中第一数据,并将写之后的第一数据存储至源数据存储区域。S502: Determine whether the first data needs to be migrated. If not, write the first data to the source data storage area, and store the written first data in the source data storage area.
在一些实施方式中,服务器100可以在响应写请求之前接收到系统下发的针对于第一数据的迁移指令。In some implementations, the server 100 may receive a migration instruction for the first data issued by the system before responding to the write request.
系统可以是由于服务器100的剩余容纳空间,或者服务器100进行升级更新,或者是服务器100造到了损坏等原因下发的迁移指令,还可以是基于管理人员的输入操作而下发的迁移指令。在本申请实施例中,对此不作限定。The system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
并且,若存在针对于第一数据的迁移指令,则迁移元数据记录表中第一数据的状态不会是“NA”,而是“Y”或者“N”。Furthermore, if there is a migration instruction for the first data, the status of the first data in the migration metadata record table will not be "NA" but "Y" or "N".
当服务器100判断出第一数据不需要进行迁移时,即不存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“NA”,服务器100可以直接根据写请求,对第一数据进行处理得到写之后的第一数据,并将写之后的第一数据存储至源数据存储区域中,即第一数据与写之后的第一数据的逻辑地址为同一个。When the server 100 determines that the first data does not need to be migrated, that is, there is no migration instruction for the first data, the status of the first data in the migration metadata record table is "NA", and the server 100 can directly process the first data according to the write request to obtain the first data after writing, and store the first data after writing in the source data storage area, that is, the logical address of the first data and the first data after writing is the same.
可选的,服务器100可以将完成写请求的信息通知给用户。例如,用户删除文档M,服务器100可以 通过显示提示信息(例如显示弹窗)如文本信息“已删除文档M”的方式来通知用户服务器100已完成用户针对文档M的写请求。在本申请实施例中,对服务器100通知用户已完成写请求的方式不做限定。Optionally, the server 100 may notify the user of the completion of the write request. For example, if the user deletes document M, the server 100 may The server 100 notifies the user that the write request for the document M has been completed by displaying a prompt message (eg, a pop-up window) such as a text message "Document M has been deleted". In the embodiment of the present application, the server 100 is not limited to the way in which the write request has been completed.
当服务器100判断出第一数据需要进行迁移时,即存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“Y”或者“N”,则执行S503。When the server 100 determines that the first data needs to be migrated, that is, there is a migration instruction for the first data, and the status of the first data in the migration metadata record table is "Y" or "N", S503 is executed.
在一些实现方式中,由于迁移元数据记录表中的记录单位是以数据块的大小为单位的,上述第一数据的状态可以是指:In some implementations, since the record unit in the migration metadata record table is in the size of a data block, the state of the first data may refer to:
若第一数据的大小大于或等于数据块,则第一数据的状态为第一数据所分割成对应多个数据块的状态。If the size of the first data is greater than or equal to the data block, the state of the first data is a state in which the first data is divided into a corresponding plurality of data blocks.
若第一数据的大小小于数据块,则第一数据的状态为第一数据所对应数据块的状态。If the size of the first data is smaller than the data block, the state of the first data is the state of the data block corresponding to the first data.
S503、判断第一数据是否已经完成迁移,若是,则双写源数据存储区域与目标存储区域中的第一数据。S503: Determine whether the first data has been migrated. If so, double-write the first data in the source data storage area and the target storage area.
在一些实现方式中,服务器100可以根据迁移元数据记录表判断出第一数据是否已经完成迁移。In some implementations, the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
例如,若在迁移元数据记录表中,针对于第一数据的写请求中携带的索引所对应的状态为“Y”,则可以判断出第一数据已经完成迁移;若在迁移元数据记录表中,针对于第一数据的写请求中携带的索引所对应的状态为“N”,则可以判断出第一数据未迁移或正在迁移中并且还未完成迁移。For example, if in the migration metadata record table, the status corresponding to the index carried in the write request for the first data is "Y", it can be determined that the first data has completed migration; if in the migration metadata record table, the status corresponding to the index carried in the write request for the first data is "N", it can be determined that the first data has not been migrated or is in the process of migrating and has not yet completed migration.
当服务器100判断出第一数据已经完成迁移时,第一数据在迁移元数据记录表中的状态为“Y”,第一数据无需再次从源数据存储区域迁移至目标存储区域,服务器100可以根据写请求分别对源数据存储区域的第一数据以及目标存储区域的第一数据进行处理,并将写之后的源数据存储区域中的第一数据存储至源数据存储区域中,将写之后的目标存储区域中的第一数据存储至目标存储区域中。When the server 100 determines that the first data has completed migration, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again. The server 100 can process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
这样,在第一数据已经完成迁移之后,而源数据存储区域中的第一数据还未被删除的情况下,双写源数据存储区域与目标存储区域中的第一数据可以保持第一数据的内容一致性。可选的,服务器100可以将完成写请求的信息通知给用户,在此不做赘述。In this way, after the first data has been migrated, and the first data in the source data storage area has not been deleted, double-writing the first data in the source data storage area and the target storage area can maintain the content consistency of the first data. Optionally, the server 100 can notify the user of the completion of the write request, which is not described in detail here.
当服务器100判断出第一数据未进行迁移,但从S502中可知存在有针对于第一数据的迁移指令时,第一数据在迁移元数据记录表中的状态为“N”,则执行S504。When the server 100 determines that the first data has not been migrated, but it can be known from S502 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S504 is executed.
进一步的,在一种可能的实现方式中,若第一数据处于正在迁移但没有完全迁移完毕的情况下,迁移元数据记录表可以记录第一数据的状态可以为“N+”。Furthermore, in a possible implementation, if the first data is being migrated but has not been completely migrated, the migration metadata record table may record that the state of the first data may be "N+".
当服务器100判断出第一数据处于正在迁移但没有完全迁移完毕时,第一数据无需再次从源数据存储区域迁移至目标存储区域,服务器100可以根据写请求分别对源数据存储区域的第一数据以及目标存储区域的第一数据进行处理,并将写之后的源数据存储区域中的第一数据存储至源数据存储区域中,将写之后的目标存储区域中的第一数据存储至目标存储区域中。可选的,服务器100可以将完成写请求的信息通知给用户,在此不做赘述。When the server 100 determines that the first data is being migrated but has not been completely migrated, the first data does not need to be migrated from the source data storage area to the target storage area again. The server 100 can process the first data in the source data storage area and the first data in the target storage area according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area. Optionally, the server 100 can notify the user of the completion of the write request, which will not be described in detail here.
S504、判断进行迁移的数据块与第一数据是否对齐。S504: Determine whether the data block to be migrated is aligned with the first data.
在一些实现方式中,当数据的存储方式为块存储时,迁移单位为数据块,服务器100可以判断数据块与第一数据对齐。In some implementations, when the data is stored in block storage, the migration unit is a data block, and the server 100 can determine whether the data block is aligned with the first data.
例如,若第一数据的大小为0.5MB,数据块的大小为1MB,则数据块与第一数据不对齐。也就是说,第一数据的大小小于数据块大小时,数据块与第一数据不对齐。For example, if the size of the first data is 0.5MB and the size of the data block is 1MB, the data block is not aligned with the first data. In other words, when the size of the first data is smaller than the size of the data block, the data block is not aligned with the first data.
若第一数据的大小为1.5MB,数据块大小为1MB,则第一数据的迁移单位为1.5,数据块与第一数据不对齐。也就是说,第一数据的大小不为数据块整数倍时,数据块与第一数据不对齐。If the size of the first data is 1.5MB and the data block size is 1MB, the migration unit of the first data is 1.5, and the data block is not aligned with the first data. In other words, when the size of the first data is not an integer multiple of the data block, the data block is not aligned with the first data.
又例如,若第一数据的大小为1MB,数据块的大小为1MB,则数据块与第一数据对齐。也就是说,第一数据的大小等于数据块大小时,数据块与第一数据对齐。For another example, if the size of the first data is 1MB and the size of the data block is 1MB, the data block is aligned with the first data. In other words, when the size of the first data is equal to the size of the data block, the data block is aligned with the first data.
若第一数据的大小为2MB,数据块大小为1MB,则第一数据的迁移单位为2,数据块与第一数据对齐。也就是说,第一数据的大小为数据块整数倍时,数据块与第一数据对齐。If the size of the first data is 2MB and the data block size is 1MB, the migration unit of the first data is 2, and the data block is aligned with the first data. In other words, when the size of the first data is an integer multiple of the data block, the data block is aligned with the first data.
当服务器100判断出数据块与第一数据对齐时,数据块的大小与第一数据的大小一致或者第一数据的 大小是数据块的大小的整数倍,执行S505。When the server 100 determines that the data block is aligned with the first data, the size of the data block is consistent with the size of the first data or the size of the first data is the same as the size of the first data. The size is an integer multiple of the size of the data block, and S505 is executed.
当服务器100判断出数据块与第一数据不对齐时,可以分为两种情况:When the server 100 determines that the data block is not aligned with the first data, there are two cases:
第一种,第一数据的大小小于数据块大小,此时,执行S506;The first type is that the size of the first data is smaller than the data block size, in which case S506 is executed;
第二种,第一数据的的大小大于数据块大小且不是数据块大小的整数倍,此时,可以将第一数据分为两部分,第一部分可以是大小为数据块大小的最大整数倍的数据,第二部分可以是第一数据中去掉第一部分的数据。其中,第一部分的数据执行S505,第二部分的数据执行S506。The second type is that the size of the first data is larger than the data block size and is not an integer multiple of the data block size. In this case, the first data can be divided into two parts, the first part can be data whose size is the maximum integer multiple of the data block size, and the second part can be data from the first data without the first part. The first part of the data is executed in S505, and the second part of the data is executed in S506.
S505、将第一数据迁移至目标存储区域,双写源数据存储区域与目标存储区域中的第一数据,并更新迁移元数据记录表。S505: Migrate the first data to the target storage area, double-write the first data in the source data storage area and the target storage area, and update the migration metadata record table.
在一些实现方式中,服务器100可以将第一数据从源数据存储区域迁移至目标存储区域。In some implementations, the server 100 may migrate the first data from a source data storage area to a target storage area.
例如,当源数据存储区域与目标存储区域存储在同一个服务器100上时,第一数据的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
服务器100将第一数据从源数据存储区域迁移至目标存储区域可以是指将第一数据的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射物理地址W1。The server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
又例如,当源数据存储区域存储的服务器与目标存储区域存储的服务器不为同一个服务器上时,即源数据存储区域所存储的服务器为服务器110,目标存储区域所存储的服务器为服务器120时,源数据存储区域所存储的服务器110将存储在逻辑地址L1和物理地址W1的第一数据发送给目标存储区域所存储的服务器120,服务器120将第一数据存储在目标存储区域中,第一数据在目标存储区域所存储的服务器120中的逻辑地址为L2,物理地址为W2。For another example, when the server stored in the source data storage area and the server stored in the target storage area are not the same server, that is, the server stored in the source data storage area is server 110, and the server stored in the target storage area is server 120, server 110 stored in the source data storage area sends the first data stored at logical address L1 and physical address W1 to server 120 stored in the target storage area, and server 120 stores the first data in the target storage area. The logical address of the first data in server 120 stored in the target storage area is L2, and the physical address is W2.
可选的,第一数据迁移前后在服务器中所存储的两个物理地址可以相同的,也可以是不同的。即存储在源数据存储区域中第一数据所物理存储的存储介质与存储在目标数据存储区域中第一数据所物理存储的存储介质可以是同一个,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses stored in the server before and after the migration of the first data may be the same or different. That is, the storage medium where the first data is physically stored in the source data storage area and the storage medium where the first data is physically stored in the target data storage area may be the same or different. In the embodiment of the present application, this is not limited.
在一些实现方式中,服务器100可以双写源数据存储区域中的第一数据和目标存储区域中的第一数据。具体的,服务器100可以根据写请求分别对源数据存储区域的第一数据以及目标存储区域的第一数据进行处理,并将写之后的源数据存储区域中的第一数据存储至源数据存储区域中,将写之后的目标存储区域中的第一数据存储至目标存储区域中。In some implementations, the server 100 may double-write the first data in the source data storage area and the first data in the target storage area. Specifically, the server 100 may process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
在一些实现方式中,服务器100在完成双写源数据存储区域中的第一数据和目标存储区域中的第一数据后,可以更新迁移元数据记录表。例如,第一数据在迁移元数据记录表中的状态可以由“N”转换为“Y”。In some implementations, after completing the double writing of the first data in the source data storage area and the first data in the target storage area, the server 100 may update the migration metadata record table. For example, the state of the first data in the migration metadata record table may be converted from "N" to "Y".
可选的,服务器100可以将完成写请求的信息通知给用户,可以参考上述内容的,在此不做赘述。Optionally, the server 100 may notify the user of information on completion of the write request, which may be referred to the above content and will not be elaborated here.
S506、对源数据存储区域中的第一数据进行写处理,然后将写之后的第一数据迁移至目标存储区域,并更新迁移元数据记录表。S506: Write the first data in the source data storage area, migrate the written first data to the target storage area, and update the migration metadata record table.
在一些实现方式中,S506中的第一数据与数据块的大小不对齐,这样可以会出现其他写请求针对的数据于本次写请求针对的第一数据存在重叠区域,即可能会对同一区域进行写操作。因此,在写源数据存储区域中的第一数据之前需要获取数据块内的互斥锁。若获取互斥锁失败,则一直重复获取直至获取成功。In some implementations, the first data in S506 is not aligned with the size of the data block, so that the data targeted by other write requests may overlap with the first data targeted by this write request, that is, the same area may be written. Therefore, before writing the first data in the source data storage area, it is necessary to obtain a mutex lock in the data block. If the acquisition of the mutex lock fails, it is repeated until the acquisition succeeds.
其中,获取互斥锁成功可以是指停止其他线程中对第一数据的写操作,仅执行S506中的写操作。这样,可以避免出现写写冲突的现象。The acquisition of the mutex lock successfully may mean stopping the write operation on the first data in other threads and only executing the write operation in S506. In this way, the write-write conflict phenomenon can be avoided.
在一些实现方式中,服务器100可以对源数据存储区域中的第一数据进行写处理。具体的,服务器100可以根据写请求对存储在源数据存储区域的第一数据进行写处理,并将写之后的第一数据存储至源数据存储区域中。在一些实现方式中,写之后的第一数据可以被称为第二数据In some implementations, the server 100 may write the first data in the source data storage area. Specifically, the server 100 may write the first data stored in the source data storage area according to the write request, and store the first data after writing in the source data storage area. In some implementations, the first data after writing may be referred to as the second data.
在一些实现方式中,服务器100可以将第一数据从源数据存储区域迁移至目标存储区域。例如,当源 数据存储区域与目标存储区域存储在同一个服务器100上时,第一数据的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。In some implementations, the server 100 may migrate the first data from the source data storage area to the target storage area. When the data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
服务器100将第一数据从源数据存储区域迁移至目标存储区域可以是指将第一数据的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射物理地址W1。The server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
又例如,当源数据存储区域存储的服务器与目标存储区域存储的服务器不为同一个在不同的服务器100上时,即源数据存储区域所存储的服务器为服务器110,目标存储区域所存储的服务器为服务器120时,源数据存储区域所存储的服务器110将存储在逻辑地址L1的第一数据发送给目标存储区域所存储的服务器120,服务器120将第一数据存储在目标源目标存储区域中,第一数据在目标源目标存储区域所存储的服务器120中的逻辑地址为L2。For another example, when the server stored in the source data storage area and the server stored in the target storage area are not the same but on different servers 100, that is, the server stored in the source data storage area is server 110 and the server stored in the target storage area is server 120, server 110 stored in the source data storage area sends the first data stored in the logical address L1 to server 120 stored in the target storage area, and server 120 stores the first data in the target source target storage area. The logical address of the first data in server 120 stored in the target source target storage area is L2.
可选的,第一数据迁移前后在服务器100中所存储的两个物理地址可以相同的,也可以是不同的。即存储在源数据存储区域中第一数据所物理存储的存储介质与存储在目标数据存储区域中第一数据所物理存储的存储介质可以是同一个,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses stored in the server 100 before and after the first data is migrated may be the same or different. That is, the storage medium where the first data is physically stored in the source data storage area and the storage medium where the first data is physically stored in the target data storage area may be the same or different. In the embodiment of the present application, this is not limited.
在一些实现方式中,服务器100在完成第一数据从源数据存储区域迁移至目标存储区域后,可以更新迁移元数据记录表。例如,第一数据在迁移元数据记录表中的状态可以由“N”转换为“Y”。In some implementations, after completing the migration of the first data from the source data storage area to the target storage area, the server 100 may update the migration metadata record table. For example, the state of the first data in the migration metadata record table may be converted from "N" to "Y".
可选的,服务器100可以将完成写请求的信息通知给用户,在此不做赘述。Optionally, the server 100 may notify the user of the completion of the write request, which will not be elaborated here.
实施上述方法,可以实现在线迁移,并且由于通过写请求触发数据的迁移,可以确保当系统接收到用户对第一数据的写请求时,只需要系统在源数据存储区域中对第一数据进行一次读取即可以保证实现用户的写请求以及迁移任务。这样,可以提高迁移效率。By implementing the above method, online migration can be realized, and because the migration of data is triggered by a write request, it can be ensured that when the system receives a user's write request for first data, the system only needs to read the first data once in the source data storage area to ensure that the user's write request and migration task are realized. In this way, the migration efficiency can be improved.
图6示出了本申请实施例中提供的另一种响应写请求的数据迁移方法的流程示意图。在该实施例中以数据的存储方式为对象存储,迁移单位为单个对象为例。Fig. 6 shows a flow chart of another data migration method in response to a write request provided in an embodiment of the present application. In this embodiment, the data storage mode is object storage, and the migration unit is a single object as an example.
S601、服务器100响应用户针对于第一数据的写请求。S601: The server 100 responds to a user's write request for first data.
在一些实施方式中,用户根据自身需求,可以向服务器100进行输入操作,服务器100可以响应针对第一数据进行写请求。其中,第一数据的写请求可以包括但不限于:第一数据在源数据存储区域中的逻辑地址,索引、数据净荷长度以及修改内容等等。In some implementations, the user can input an operation to the server 100 according to his/her needs, and the server 100 can respond with a write request for the first data. The write request for the first data may include but is not limited to: the logical address of the first data in the source data storage area, index, data payload length, and modified content, etc.
在一些实现方式中,服务器100响应写请求存在前置条件:服务器100响应用户针对于第一数据的写请求需要满足写写互斥,即两个写请求针对的数据不可以有交集。In some implementations, there is a prerequisite for the server 100 to respond to the write request: the server 100 needs to satisfy write-write mutual exclusion in responding to the user's write request for the first data, that is, the data targeted by the two write requests cannot have an intersection.
若出现两个写请求针对的数据有交集的情况,需要采取加锁互斥的方式,避免出现写写冲突的现象。If the data targeted by two write requests overlap, a mutually exclusive lock method is required to avoid write-write conflicts.
S602、判断第一数据是否需要进行迁移,若否,则对源数据存储区域中第一数据进行写处理,并将写之后的第一数据存储至源数据存储区域。S602: Determine whether the first data needs to be migrated. If not, write the first data in the source data storage area and store the written first data in the source data storage area.
在一些实施方式中,服务器100可以在响应写请求之前接收到系统下发的针对于第一数据的迁移指令。In some implementations, the server 100 may receive a migration instruction for the first data issued by the system before responding to the write request.
系统可以是由于服务器100的剩余容纳空间,或者服务器100进行升级更新,或者是服务器100造到了损坏等原因下发的迁移指令,还可以是基于管理人员的输入操作而下发的迁移指令。在本申请实施例中,对此不作限定。The system may issue a migration instruction due to the remaining storage space of the server 100, the server 100 being upgraded, or the server 100 being damaged, or may issue a migration instruction based on an input operation by a manager. This is not limited in the embodiments of the present application.
并且,若存在针对于第一数据的迁移指令,则迁移元数据记录表中第一数据的状态不会是“NA”,而是“Y”或者“N”。Furthermore, if there is a migration instruction for the first data, the status of the first data in the migration metadata record table will not be "NA" but "Y" or "N".
当服务器100判断出第一数据不需要进行迁移时,即不存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“NA”,服务器100可以直接根据写请求,对第一数据进行写处理得到写之后的第一数据,并将写之后的第一数据存储至源数据存储区域中,即写处理之前第一数据与写处理之后的第一数据的逻辑地址为同一个。When the server 100 determines that the first data does not need to be migrated, that is, there is no migration instruction for the first data, the status of the first data in the migration metadata record table is "NA", and the server 100 can directly write the first data according to the write request to obtain the first data after writing, and store the first data after writing in the source data storage area, that is, the logical address of the first data before the write process and the first data after the write process are the same.
可选的,服务器100可以将完成写请求的信息通知给用户。例如,用户删除文档M,服务器100可以 通过显示提示信息(例如显示弹窗)如文本信息“已删除文档M”的方式来通知用户服务器100已完成用户针对文档M的写请求。在本申请实施例中,对服务器100通知用户已完成写请求的方式不做限定。Optionally, the server 100 may notify the user of the completion of the write request. For example, if the user deletes document M, the server 100 may The server 100 notifies the user that the write request for the document M has been completed by displaying a prompt message (eg, a pop-up window) such as a text message "Document M has been deleted". In the embodiment of the present application, the server 100 is not limited to the way in which the write request has been completed.
当服务器100判断出第一数据需要进行迁移时,即存在有针对于第一数据的迁移指令,第一数据在迁移元数据记录表中的状态为“Y”或者“N”,则执行S603。When the server 100 determines that the first data needs to be migrated, that is, there is a migration instruction for the first data, and the status of the first data in the migration metadata record table is "Y" or "N", S603 is executed.
在一些实现方式中,由于迁移元数据记录表中的记录单位是以单个对象的大小为单位的,上述第一数据的状态可以是指:若第一数据的大小大于或等于单个对象,则第一数据的状态为第一数据所分割成对应多个单个对象的状态,若第一数据的大小小于单个对象,则第一数据的状态为第一数据所对应单个对象的状态。In some implementations, since the record unit in the migration metadata record table is based on the size of a single object, the state of the first data may mean: if the size of the first data is greater than or equal to a single object, then the state of the first data is the state of the first data divided into corresponding multiple single objects; if the size of the first data is smaller than a single object, then the state of the first data is the state of the single object corresponding to the first data.
S603、判断第一数据是否已经完成迁移,若是,则双写源数据存储区域与目标存储区域中的第一数据。S603: Determine whether the first data has been migrated, and if so, double-write the first data in the source data storage area and the target storage area.
在一些实现方式中,服务器100可以根据迁移元数据记录表判断出第一数据是否已经完成迁移。In some implementations, the server 100 may determine whether the first data has been migrated based on the migration metadata record table.
例如,若在迁移元数据记录表中,针对于第一数据的写请求中携带的索引所对应的状态为“Y”,则可以判断出第一数据已经完成迁移;若在迁移元数据记录表中,针对于第一数据的写请求中携带的索引所对应的状态为“N”,则可以判断出第一数据未迁移或正在迁移中并且还未完成迁移。For example, if in the migration metadata record table, the status corresponding to the index carried in the write request for the first data is "Y", it can be determined that the first data has completed migration; if in the migration metadata record table, the status corresponding to the index carried in the write request for the first data is "N", it can be determined that the first data has not been migrated or is in the process of migrating and has not yet completed migration.
当服务器100判断出第一数据已经完成迁移时,第一数据在迁移元数据记录表中的状态为“Y”,第一数据无需再次从源数据存储区域迁移至目标存储区域,服务器100可以根据写请求分别对源数据存储区域的第一数据以及目标存储区域的第一数据进行处理,并将写之后的源数据存储区域中的第一数据存储至源数据存储区域中,将写之后的目标存储区域中的第一数据存储至目标存储区域中。When the server 100 determines that the first data has completed migration, the status of the first data in the migration metadata record table is "Y", and the first data does not need to be migrated from the source data storage area to the target storage area again. The server 100 can process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
这样,在第一数据已经完成迁移之后,而源数据存储区域中的第一数据还未被删除的情况下,双写源数据存储区域与目标存储区域中的第一数据可以保持第一数据的内容一致性。可选的,服务器100可以将完成写请求的信息通知给用户,在此不做赘述。In this way, after the first data has been migrated, and the first data in the source data storage area has not been deleted, double-writing the first data in the source data storage area and the target storage area can maintain the content consistency of the first data. Optionally, the server 100 can notify the user of the completion of the write request, which is not described in detail here.
当服务器100判断出第一数据未进行迁移,但从S602中可知存在有针对于第一数据的迁移指令时,第一数据在迁移元数据记录表中的状态为“N”,则执行S604。When the server 100 determines that the first data has not been migrated, but it can be known from S602 that there is a migration instruction for the first data, the state of the first data in the migration metadata record table is "N", and S604 is executed.
进一步的,在一种可能的实现方式中,若第一数据处于正在迁移但没有完全迁移完毕的情况下,迁移元数据记录表可以记录第一数据的状态可以为“N+”。Furthermore, in a possible implementation, if the first data is being migrated but has not been completely migrated, the migration metadata record table may record that the state of the first data may be "N+".
当服务器100判断出第一数据处于正在迁移但没有完全迁移完毕时,第一数据无需再次从源数据存储区域迁移至目标存储区域,服务器100可以根据写请求分别对源数据存储区域的第一数据以及目标存储区域的第一数据进行写处理,并将写之后的源数据存储区域中的第一数据存储至源数据存储区域中,将写之后的目标存储区域中的第一数据存储至目标存储区域中。可选的,服务器100可以将完成写请求的信息通知给用户,在此不做赘述。When the server 100 determines that the first data is being migrated but has not been completely migrated, the first data does not need to be migrated from the source data storage area to the target storage area again. The server 100 can write the first data in the source data storage area and the first data in the target storage area according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area. Optionally, the server 100 can notify the user of the completion of the write request, which will not be described in detail here.
S604、将第一数据迁移至目标存储区域,双写源数据存储区域与目标存储区域中的第一数据,并更新迁移元数据记录表。S604: Migrate the first data to the target storage area, double-write the first data in the source data storage area and the target storage area, and update the migration metadata record table.
在一些实现方式中,由于第一数据的存储方式为对象存储,而对对象进行写处理一般都是对整个对象进行写处理,因此,不存在需要类似S504来对第一数据与单个对象是否对齐进行判断。而是直接在第一数据需要进行迁移并且还未被迁移的情况下,响应写操作并完成第一数据的迁移任务。In some implementations, since the first data is stored in an object storage manner and writing to an object generally involves writing to the entire object, there is no need to determine whether the first data is aligned with a single object as in S504. Instead, when the first data needs to be migrated and has not been migrated, the write operation is directly responded to and the migration task of the first data is completed.
在一些实现方式中,服务器100可以将第一数据从源数据存储区域迁移至目标存储区域。例如,当源数据存储区域与目标存储区域存储在同一个服务器100上时,第一数据的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。In some implementations, the server 100 may migrate the first data from the source data storage area to the target storage area. For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the first data in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
服务器100将第一数据从源数据存储区域迁移至目标存储区域可以是指将第一数据的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射物理地址W1。The server 100 migrates the first data from the source data storage area to the target storage area, which may mean changing the logical address of the first data from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
又例如,当源数据存储区域存储的服务器与目标存储区域存储的服务器不为同一个服务器上时,即源 数据存储区域所存储的服务器为服务器110,目标存储区域所存储的服务器为服务器120时,源数据存储区域所存储的服务器110将存储在逻辑地址L1和物理地址W1的第一数据发送给目标存储区域所存储的服务器120,服务器120将第一数据存储在目标存储区域中,第一数据在目标存储区域所存储的服务器120中的逻辑地址为L2,物理地址为W2。For another example, when the server stored in the source data storage area is not the same as the server stored in the target storage area, that is, the source When the server stored in the data storage area is server 110 and the server stored in the target storage area is server 120, server 110 stored in the source data storage area sends the first data stored at logical address L1 and physical address W1 to server 120 stored in the target storage area, and server 120 stores the first data in the target storage area. The logical address of the first data in server 120 stored in the target storage area is L2, and the physical address is W2.
可选的,第一数据迁移前后在服务器中所存储的两个物理地址可以相同的,也可以是不同的。即存储在源数据存储区域中第一数据所物理存储的存储介质与存储在目标数据存储区域中第一数据所物理存储的存储介质可以是同一个,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses stored in the server before and after the migration of the first data may be the same or different. That is, the storage medium where the first data is physically stored in the source data storage area and the storage medium where the first data is physically stored in the target data storage area may be the same or different. In the embodiment of the present application, this is not limited.
在一些实现方式中,服务器100可以双写源数据存储区域中的第一数据和目标存储区域中的第一数据。In some implementations, the server 100 may double-write the first data in the source data storage area and the first data in the target storage area.
具体的,服务器100可以根据写请求分别对源数据存储区域的第一数据以及目标存储区域的第一数据进行处理,并将写之后的源数据存储区域中的第一数据存储至源数据存储区域中,将写之后的目标存储区域中的第一数据存储至目标存储区域中。Specifically, the server 100 can process the first data in the source data storage area and the first data in the target storage area respectively according to the write request, and store the first data in the source data storage area after writing in the source data storage area, and store the first data in the target storage area after writing in the target storage area.
在一些实现方式中,服务器100在完成双写源数据存储区域中的第一数据和目标存储区域中的第一数据后,可以更新迁移元数据记录表。例如,第一数据在迁移元数据记录表中的状态可以由“N”转换为“Y”。In some implementations, after completing the double writing of the first data in the source data storage area and the first data in the target storage area, the server 100 may update the migration metadata record table. For example, the state of the first data in the migration metadata record table may be converted from "N" to "Y".
可选的,服务器100可以将完成写请求的信息通知给用户,在此不做赘述。Optionally, the server 100 may notify the user of the completion of the write request, which will not be elaborated here.
下面介绍本申请实施例中提供的另一种数据迁移的方法。该实施例以不存在用户针对于待迁移的数据的读请求以及写请求的情况为例介绍数据迁移的方法。Another data migration method provided in an embodiment of the present application is described below. This embodiment takes the case where there is no user read request or write request for the data to be migrated as an example to introduce the data migration method.
图7示出了本申请实施例中提供的一种后台数据迁移方法的流程示意图。该流程示意图以块存储为例。值得说明的是,后台数据迁移方法所针对的源数据存储区域具有迁移指令,下述具体步骤中不再判断是否具有迁移指令。FIG7 shows a flow chart of a background data migration method provided in an embodiment of the present application. The flow chart takes block storage as an example. It is worth noting that if the source data storage area targeted by the background data migration method has a migration instruction, the following specific steps will no longer determine whether there is a migration instruction.
S701、按顺序遍历待迁移的源数据存储区域,判断当前扫描的数据块是否已经完成迁移。S701 , sequentially traverse the source data storage area to be migrated, and determine whether the currently scanned data block has been migrated.
在一些实现方式中,服务器100可以按顺序遍历待迁移的源数据存储区域。例如,待迁移的源数据存储区域为数据1-数据100共100个数据块,则服务器100从数据1开始扫描直到数据100,并判断每一个数据块是否已经完成迁移。In some implementations, the server 100 may sequentially traverse the source data storage area to be migrated. For example, if the source data storage area to be migrated is data 1 to data 100, which has 100 data blocks in total, the server 100 scans from data 1 to data 100, and determines whether each data block has been migrated.
在一些实现方式中,服务器100可以判断当前扫描的数据块是否已经完成迁移。In some implementations, the server 100 may determine whether the currently scanned data block has completed migration.
例如,若在迁移元数据记录表中,当前扫描的数据块对应的状态为“Y”,则可以判断出当前扫描的数据块已经完成迁移;For example, if the status corresponding to the currently scanned data block is "Y" in the migration metadata record table, it can be determined that the currently scanned data block has completed migration;
若在迁移元数据记录表中,当前扫描的数据块对应的状态为“N”,则可以判断出当前扫描的数据块未迁移或正在迁移中并且还未完成迁移。If the state corresponding to the currently scanned data block is "N" in the migration metadata record table, it can be determined that the currently scanned data block has not been migrated or is being migrated and the migration has not yet been completed.
当服务器100判断出当前扫描的数据块已经完成迁移时,当前扫描的数据块在迁移元数据记录表中的状态为“Y”,当前扫描的数据块无需再次从源数据存储区域迁移至目标存储区域,则扫描源数据存储区域中当前数据块的下一个数据块。When the server 100 determines that the currently scanned data block has completed migration, the status of the currently scanned data block in the migration metadata record table is "Y", and the currently scanned data block does not need to be migrated from the source data storage area to the target storage area again, so the next data block of the current data block in the source data storage area is scanned.
例如,待迁移的源数据存储区域为数据1-数据100共100个数据块,服务器100判断数据1已经完成迁移,则服务器100扫描数据2,判断数据2是否已完成迁移。For example, the source data storage area to be migrated is data 1-data 100, which has 100 data blocks in total. The server 100 determines that data 1 has been migrated, and then the server 100 scans data 2 to determine whether data 2 has been migrated.
当服务器100判断出当前扫描的数据块未进行迁移时,当前扫描的数据块在迁移元数据记录表中的状态为“N”,则执行S502。When the server 100 determines that the currently scanned data block has not been migrated, the status of the currently scanned data block in the migration metadata record table is "N", and S502 is executed.
S702、判断当前扫描的数据块是否正在处理中。S702: Determine whether the currently scanned data block is being processed.
在一些实现方式中,服务器100可以判断当前扫描的数据块是否正在处理中,即判断当前扫描的数据块是否正在进行迁移。In some implementations, the server 100 may determine whether the currently scanned data block is being processed, that is, determine whether the currently scanned data block is being migrated.
在一种可能的实现方式中,若当前扫描的数据块处于正在迁移但没有完全迁移完毕的情况下,迁移元数据记录表可以记录当前扫描的数据块的状态可以为“N+”。In a possible implementation, if the currently scanned data block is in the process of being migrated but has not been completely migrated, the migration metadata record table may record that the status of the currently scanned data block may be "N+".
在本申请实施例中,除了上述方法还存在其他可以判断数据块是否正在进行迁移,对此不作限定。 In the embodiment of the present application, in addition to the above method, there are other methods for determining whether a data block is being migrated, which are not limited to this.
当服务器100判断当前扫描的数据块正在进行迁移,当前扫描的数据块无需再次从源数据存储区域迁移至目标存储区域,则执行S701,扫描源数据存储区域中当前数据块的下一个数据块。When the server 100 determines that the currently scanned data block is being migrated and the currently scanned data block does not need to be migrated again from the source data storage area to the target storage area, S701 is executed to scan the next data block of the current data block in the source data storage area.
例如,待迁移的源数据存储区域为数据1-数据100共100个数据块,服务器100判断数据1正在进行迁移,则服务器100扫描数据2,判断数据2是否已完成迁移。For example, the source data storage area to be migrated is data 1-data 100, which has 100 data blocks in total. The server 100 determines that data 1 is being migrated, and then the server 100 scans data 2 to determine whether data 2 has completed migration.
当服务器100判断当前扫描的数据块没有正在进行迁移,则执行S703。When the server 100 determines that the currently scanned data block is not being migrated, S703 is executed.
S703、从源数据存储区域中读取出当前扫描的数据块,将该数据块迁移至目标存储区域,并更新迁移元数据记录表。S703: Read the currently scanned data block from the source data storage area, migrate the data block to the target storage area, and update the migration metadata record table.
在一些实现方式中,服务器100可以将当前扫描的数据块从源数据存储区域迁移至目标存储区域。In some implementations, the server 100 may migrate the currently scanned data block from the source data storage area to the target storage area.
例如,当源数据存储区域与目标存储区域存储在同一个服务器100上时,当前扫描的数据块的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the currently scanned data block in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps the physical address W1.
服务器100将当前扫描的数据块从源数据存储区域迁移至目标存储区域可以是指将当前扫描的数据块的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射物理地址W1。The server 100 migrates the currently scanned data block from the source data storage area to the target storage area, which may mean changing the logical address of the currently scanned data block from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to map the logical address L2 to the physical address W1.
可选的,当前扫描的数据块迁移前后在服务器100中所存储的两个物理地址可以相同的,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses of the currently scanned data block stored in the server 100 before and after the migration may be the same or different. In the embodiment of the present application, there is no limitation on this.
在一些实现方式中,服务器100在完成当前扫描的数据块从源数据存储区域迁移至目标存储区域后,可以更新迁移元数据记录表。In some implementations, after completing the migration of the currently scanned data block from the source data storage area to the target storage area, the server 100 may update the migration metadata record table.
例如,当前扫描的数据块从源数据存储区域迁移至目标存储区域之后,在迁移元数据记录表的状态可以由“N”转换为“Y”。For example, after the currently scanned data block is migrated from the source data storage area to the target storage area, the state of the migration metadata record table may be converted from "N" to "Y".
图8示出了本申请实施例中提供的一种后台数据迁移方法的流程示意图。该流程示意图以对象存储为例。值得说明的是,后台数据迁移方法所针对的源数据存储区域具有迁移指令,下述具体步骤中不再判断是否具有迁移指令。FIG8 shows a flow chart of a background data migration method provided in an embodiment of the present application. The flow chart takes object storage as an example. It is worth noting that if the source data storage area targeted by the background data migration method has a migration instruction, the following specific steps will no longer determine whether there is a migration instruction.
S801、按顺序遍历待迁移的源数据存储区域,判断当前扫描的单个对象是否已经完成迁移。S801 , sequentially traverse the source data storage area to be migrated, and determine whether the migration of the single object currently scanned has been completed.
在一些实现方式中,服务器100可以按顺序遍历待迁移的源数据存储区域。In some implementations, the server 100 may sequentially traverse the source data storage area to be migrated.
例如,待迁移的源数据存储区域为数据1-数据100共100个对象,则服务器100从数据1开始扫描直到数据100,并判断每一个对象是否已经完成迁移。For example, the source data storage area to be migrated is data 1 to data 100, which contains 100 objects in total. The server 100 scans from data 1 to data 100, and determines whether each object has been migrated.
在一些实现方式中,服务器100可以判断当前扫描的单个对象是否已经完成迁移。In some implementations, the server 100 may determine whether the migration of a single object currently being scanned has been completed.
例如,若在迁移元数据记录表中,当前扫描的单个对象对应的状态为“Y”,则可以判断出当前扫描的单个对象已经完成迁移;For example, if the status corresponding to the currently scanned single object is "Y" in the migration metadata record table, it can be determined that the currently scanned single object has completed migration;
若在迁移元数据记录表中,当前扫描的单个对象对应的状态为“N”,则可以判断出当前扫描的单个对象未迁移或正在迁移中并且还未完成迁移。If the status corresponding to the currently scanned single object is "N" in the migration metadata record table, it can be determined that the currently scanned single object has not been migrated or is being migrated and the migration has not yet been completed.
当服务器100判断出当前扫描的单个对象已经完成迁移时,当前扫描的单个对象在迁移元数据记录表中的状态为“Y”,当前扫描的单个对象无需再次从源数据存储区域迁移至目标存储区域,则扫描源数据存储区域中当前单个对象的下一个数据块。When the server 100 determines that the migration of the single object currently being scanned has been completed, the status of the single object currently being scanned in the migration metadata record table is "Y", and the single object currently being scanned does not need to be migrated from the source data storage area to the target storage area again, so the next data block of the current single object in the source data storage area is scanned.
例如,待迁移的源数据存储区域为数据1-数据100共100个对象,服务器100判断数据1已经完成迁移,则服务器100扫描数据2,判断数据2是否已完成迁移。For example, the source data storage area to be migrated is data 1-data 100, which contains 100 objects in total. The server 100 determines that data 1 has been migrated, and then the server 100 scans data 2 to determine whether data 2 has been migrated.
当服务器100判断出当前扫描的单个对象未进行迁移时,当前扫描的单个对象在迁移元数据记录表中的状态为“N”,则执行S802。When the server 100 determines that the currently scanned single object has not been migrated, the status of the currently scanned single object in the migration metadata record table is "N", and S802 is executed.
S802、判断当前扫描的单个对象是否正在处理中。S802: Determine whether the single object currently being scanned is being processed.
在一些实现方式中,服务器100可以判断当前扫描的单个对象是否正在处理中,即判断当前扫描的单 个对象是否正在进行迁移。In some implementations, the server 100 may determine whether the currently scanned single object is being processed. Whether the object is being migrated.
在一种可能的实现方式中,若当前扫描的单个对象处于正在迁移但没有完全迁移完毕的情况下,迁移元数据记录表可以记录当前扫描的单个对象的状态可以为“N+”。In a possible implementation, if the currently scanned single object is in the process of being migrated but has not been completely migrated, the migration metadata record table may record that the status of the currently scanned single object may be "N+".
在本申请实施例中,除了上述方法还存在其他可以判断单个对象是否正在进行迁移,对此不作限定。In the embodiment of the present application, in addition to the above method, there are other methods for determining whether a single object is being migrated, which are not limited to this.
当服务器100判断当前扫描的单个对象正在进行迁移,当前扫描的单个对象无需再次从源数据存储区域迁移至目标存储区域,则执行S801,扫描源数据存储区域中当前单个对象的下一个对象。When the server 100 determines that the currently scanned single object is being migrated and the currently scanned single object does not need to be migrated again from the source data storage area to the target storage area, S801 is executed to scan the next object of the current single object in the source data storage area.
例如,待迁移的源数据存储区域为数据1-数据100共100个对象,服务器100判断数据1正在进行迁移,则服务器100扫描数据2,判断数据2是否已完成迁移。For example, the source data storage area to be migrated is data 1-data 100, which contains 100 objects in total. The server 100 determines that data 1 is being migrated, and then the server 100 scans data 2 to determine whether data 2 has completed migration.
当服务器100判断当前扫描的单个对象没有正在进行迁移,则执行S803。When the server 100 determines that the currently scanned single object is not being migrated, S803 is executed.
S803、从源数据存储区域中读取出当前扫描的单个对象,将该单个对象迁移至目标存储区域,并更新迁移元数据记录表。S803: Read the currently scanned single object from the source data storage area, migrate the single object to the target storage area, and update the migration metadata record table.
在一些实现方式中,服务器100可以将当前扫描的单个对象从源数据存储区域迁移至目标存储区域。In some implementations, the server 100 may migrate a single object currently being scanned from a source data storage area to a target storage area.
例如,当源数据存储区域与目标存储区域存储在同一个服务器100上时,当前扫描的单个对象的在源数据存储区域中的逻辑地址为L1,逻辑地址L1所对应的物理地址为W1,其映射关系为逻辑地址L1映射物理地址W1。服务器100将当前扫描的单个对象从源数据存储区域迁移至目标存储区域可以是指将当前扫描的单个对象的逻辑地址由源数据存储区域中的逻辑地址L1改为目标存储区域中的逻辑地址L2,并且将映射关系改为逻辑地址L2映射物理地址W1。For example, when the source data storage area and the target storage area are stored on the same server 100, the logical address of the currently scanned single object in the source data storage area is L1, and the physical address corresponding to the logical address L1 is W1, and the mapping relationship is that the logical address L1 maps to the physical address W1. The server 100 migrates the currently scanned single object from the source data storage area to the target storage area, which may refer to changing the logical address of the currently scanned single object from the logical address L1 in the source data storage area to the logical address L2 in the target storage area, and changing the mapping relationship to that the logical address L2 maps to the physical address W1.
可选的,当前扫描的单个对象迁移前后在服务器100中所存储的两个物理地址可以相同的,也可以是不同的。在本申请实施例中,对此不作限制。Optionally, the two physical addresses of the single object currently being scanned stored in the server 100 before and after the migration may be the same or different. In the embodiment of the present application, there is no limitation on this.
在一些实现方式中,服务器100在完成当前扫描的单个对象从源数据存储区域迁移至目标存储区域后,可以更新迁移元数据记录表。In some implementations, after completing the migration of a single object currently being scanned from a source data storage area to a target storage area, the server 100 may update the migration metadata record table.
例如,当前扫描的单个对象从源数据存储区域迁移至目标存储区域之后,在迁移元数据记录表的状态可以由“N”转换为“Y”。For example, after a single object currently being scanned is migrated from a source data storage area to a target storage area, the state of the migration metadata record table may be converted from "N" to "Y".
实施上述方法,在数据读写的过程中完成了对应的数据的迁移,剩余的数据通过后台的迁移任务来迁移。By implementing the above method, the corresponding data migration is completed during the data reading and writing process, and the remaining data is migrated through the background migration task.
这样可以在保证数据迁移正确且完整的情况下,提高了在线迁移的效率。且减少了数据源的读请求,提高了存储介质的寿命。This can improve the efficiency of online migration while ensuring that data migration is correct and complete, and reduce the read requests of the data source and extend the life of the storage medium.
本申请的各实施方式可以任意进行组合,以实现不同的技术效果。The various implementation modes of the present application can be combined arbitrarily to achieve different technical effects.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state drive (SSD)), etc.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序 代码的介质。A person skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above-mentioned method embodiments. The aforementioned storage medium includes: ROM or random access memory RAM, magnetic disk or optical disk, etc. The medium of the code.
总之,以上所述仅为本发明技术方案的实施例而已,并非用于限定本发明的保护范围。凡根据本发明的揭露,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。 In short, the above description is only an embodiment of the technical solution of the present invention, and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made according to the disclosure of the present invention shall be included in the protection scope of the present invention.

Claims (8)

  1. 一种数据迁移方法,所述方法应用于计算设备,其特征在于,包括:A data migration method, the method being applied to a computing device, characterized by comprising:
    接收到针对于第一数据的读请求或者写请求;Receiving a read request or a write request for first data;
    根据所述读请求对所述第一数据进行处理,并将所述第一数据从源数据存储区域中迁移至目标存储区域中存储;Processing the first data according to the read request, and migrating the first data from the source data storage area to the target storage area for storage;
    或者,根据所述写请求对所述第一数据进行处理,并将所述第一数据从源数据存储区域中迁移至目标存储区域中存储;Alternatively, the first data is processed according to the write request, and the first data is migrated from the source data storage area to the target storage area for storage;
    其中,所述第一数据存储在源数据存储区域中,所述源数据存储区域与目标存储区域位于同一台计算设备中或者不同的计算设备中。The first data is stored in a source data storage area, and the source data storage area and the target storage area are located in the same computing device or in different computing devices.
  2. 根据权利要求1所述的方法,其特征在于:在所述接收到针对于第一数据的读请求或者写请求之后,所述方法还包括:The method according to claim 1, characterized in that: after receiving the read request or write request for the first data, the method further comprises:
    在确定所述第一数据需要迁移且所述第一数据还未进行迁移的情况下,根据所述读请求或者写请求对所述第一数据进行处理。When it is determined that the first data needs to be migrated and the first data has not been migrated, the first data is processed according to the read request or the write request.
  3. 根据权利要求1-2中任意一项所述的方法,其特征在于,所述第一数据在所述源数据存储区域中的存储地址为第一地址,The method according to any one of claims 1 to 2, characterized in that the storage address of the first data in the source data storage area is a first address,
    所述根据所述读请求对所述第一数据进行处理,并将所述第一数据从源数据存储区域中迁移至目标存储区域中存储,具体包括:The processing of the first data according to the read request and migrating the first data from the source data storage area to the target storage area for storage specifically includes:
    根据所述读请求从所述第一地址中读取所述第一数据并存储在所述目标存储区域中的第二地址中。The first data is read from the first address according to the read request and stored in a second address in the target storage area.
  4. 根据权利要求1-2中任意一项所述的方法,其特征在于,所述第一数据在所述源数据存储区域中的存储地址为第一地址,所述第一数据的存储方式为块存储,The method according to any one of claims 1 to 2, characterized in that the storage address of the first data in the source data storage area is a first address, and the storage mode of the first data is block storage,
    所述根据所述写请求对所述第一数据进行处理,并将所述第一数据从源数据存储区域中迁移至目标存储区域中,具体包括:The processing of the first data according to the write request and migrating the first data from the source data storage area to the target storage area specifically includes:
    判断所述第一数据与数据块的大小是否对齐;Determining whether the sizes of the first data and the data block are aligned;
    在所述确定所述第一数据与数据块的大小对齐的情况下,根据所述写请求从所述第一地址读取所述第一数据并存储在所述目标存储区域中的第二地址中;对存储在所述第一地址和所述第二地址中的所述第一数据进行写处理;In the case of determining that the first data is aligned with the size of the data block, reading the first data from the first address according to the write request and storing it in the second address of the target storage area; performing write processing on the first data stored in the first address and the second address;
    其中,所述数据块为块存储中单次进行迁移的数据;所述对齐是指所述第一数据的大小是数据块的大小的整数倍。The data block is data that is migrated once in the block storage; and the alignment means that the size of the first data is an integer multiple of the size of the data block.
  5. 根据权利要求4所述的方法,其特征在于:在所述计算设备确定所述第一数据所述数据块的大小没有对齐的情况下,所述计算设备持续获取所述数据块的互斥锁;The method according to claim 4, characterized in that: when the computing device determines that the size of the data block of the first data is not aligned, the computing device continues to acquire a mutex lock of the data block;
    根据所述写请求对存储在所述第一地址的所述第一数据进行写处理,得到第二数据,并将所述第二数据存储至所述第一地址;Perform write processing on the first data stored at the first address according to the write request to obtain second data, and store the second data in the first address;
    从所述第一地址读取所述第二数据并存储在所述目标存储区域中的第二地址中。The second data is read from the first address and stored in a second address in the target storage area.
  6. 根据权利要求1或2所述的方法,其特征在于,所述第一数据的存储方式为对象存储,所述第一数据在所述源数据存储区域中的存储地址为第一地址,The method according to claim 1 or 2 is characterized in that the storage mode of the first data is object storage, and the storage address of the first data in the source data storage area is a first address,
    所述根据所述写请求对所述第一数据进行处理,并将所述第一数据从源数据存储区域中迁移至目标存储区域中,具体包括:The processing of the first data according to the write request and migrating the first data from the source data storage area to the target storage area specifically includes:
    根据所述写请求,从所述第一地址中读取所述第一数据并存储在所述目标存储区域中的第二地址中,对存储在所述第一地址和所述第二地址中的所述第一数据进行写处理。According to the write request, the first data is read from the first address and stored in the second address in the target storage area, and a write process is performed on the first data stored in the first address and the second address.
  7. 根据权利要求1所述的方法,其特征在于:在所述第一数据完成迁移之后,更新迁移元数据记录表,所述迁移元数据记录表记录所述第一数据的迁移状态,所述迁移状态包括所述第一数据需要迁移但未 被迁移、已经迁移、不需要迁移中的任意一种。The method according to claim 1 is characterized in that: after the first data is migrated, a migration metadata record table is updated, wherein the migration metadata record table records the migration status of the first data, the migration status includes the first data needs to be migrated but has not been Any of the following: being migrated, already migrated, or not needing to be migrated.
  8. 一种电子设备,其特征在于,包括存储器和一个或多个处理器;所述存储器与所述一个或多个处理器耦合,用于存储计算机程序代码,所述计算机程序代码包括计算机指令,当所述一个或多个处理器执行所述计算机指令时,使得所述电子设备执行如权利要求1-7中任一项所述的方法。 An electronic device, characterized in that it includes a memory and one or more processors; the memory is coupled to the one or more processors and is used to store computer program code, and the computer program code includes computer instructions. When the one or more processors execute the computer instructions, the electronic device executes the method as described in any one of claims 1-7.
PCT/CN2023/117343 2022-10-20 2023-09-06 Data migration method and system, and related apparatus WO2024082857A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211292048.5 2022-10-20
CN202211292048.5A CN115729463A (en) 2022-10-20 2022-10-20 Data migration method, system and related device

Publications (1)

Publication Number Publication Date
WO2024082857A1 true WO2024082857A1 (en) 2024-04-25

Family

ID=85293958

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/117343 WO2024082857A1 (en) 2022-10-20 2023-09-06 Data migration method and system, and related apparatus

Country Status (2)

Country Link
CN (1) CN115729463A (en)
WO (1) WO2024082857A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115729463A (en) * 2022-10-20 2023-03-03 超聚变数字技术有限公司 Data migration method, system and related device

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073462A (en) * 2010-11-29 2011-05-25 华为技术有限公司 Virtual storage migration method and system and virtual machine monitor
US20130041977A1 (en) * 2011-08-11 2013-02-14 Fujitsu Limited Computer product, migration executing apparatus, and migration method
CN104899218A (en) * 2014-03-06 2015-09-09 腾讯科技(深圳)有限公司 Data reading and writing method and data reading and writing apparatus
CN107402722A (en) * 2017-07-04 2017-11-28 杭州宏杉科技股份有限公司 A kind of data migration method and storage device
CN111427514A (en) * 2020-03-27 2020-07-17 杭州宏杉科技股份有限公司 View migration method and device
CN112578997A (en) * 2019-09-30 2021-03-30 华为技术有限公司 Data migration method, system and related equipment
US20210286541A1 (en) * 2020-03-13 2021-09-16 EMC IP Holding Company LLC Techniques for data migration
CN113867645A (en) * 2021-09-30 2021-12-31 苏州浪潮智能科技有限公司 Data migration and data read-write method and device, computer equipment and storage medium
CN115729463A (en) * 2022-10-20 2023-03-03 超聚变数字技术有限公司 Data migration method, system and related device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073462A (en) * 2010-11-29 2011-05-25 华为技术有限公司 Virtual storage migration method and system and virtual machine monitor
US20130041977A1 (en) * 2011-08-11 2013-02-14 Fujitsu Limited Computer product, migration executing apparatus, and migration method
CN104899218A (en) * 2014-03-06 2015-09-09 腾讯科技(深圳)有限公司 Data reading and writing method and data reading and writing apparatus
CN107402722A (en) * 2017-07-04 2017-11-28 杭州宏杉科技股份有限公司 A kind of data migration method and storage device
CN112578997A (en) * 2019-09-30 2021-03-30 华为技术有限公司 Data migration method, system and related equipment
US20210286541A1 (en) * 2020-03-13 2021-09-16 EMC IP Holding Company LLC Techniques for data migration
CN111427514A (en) * 2020-03-27 2020-07-17 杭州宏杉科技股份有限公司 View migration method and device
CN113867645A (en) * 2021-09-30 2021-12-31 苏州浪潮智能科技有限公司 Data migration and data read-write method and device, computer equipment and storage medium
CN115729463A (en) * 2022-10-20 2023-03-03 超聚变数字技术有限公司 Data migration method, system and related device

Also Published As

Publication number Publication date
CN115729463A (en) 2023-03-03

Similar Documents

Publication Publication Date Title
CN109254733B (en) Method, device and system for storing data
US7660867B2 (en) Virtual computer system and virtual computer migration control method
US10514947B2 (en) Container management apparatus, container management method, and nonvolatile recording medium
JP5541149B2 (en) Snapshot collection program, server, and snapshot collection method
JP2019519025A (en) Division and movement of ranges in distributed systems
US8386707B2 (en) Virtual disk management program, storage device management program, multinode storage system, and virtual disk managing method
CN112395264B (en) Processing method for mapping between logical targets and volumes in distributed storage system
US11797494B2 (en) Snapshot management in distributed file systems
WO2024082857A1 (en) Data migration method and system, and related apparatus
US11580148B2 (en) Document storage and management
CN113806300B (en) Data storage method, system, device, equipment and storage medium
US20210374107A1 (en) Distributed file system and distributed file managing method
US11157456B2 (en) Replication of data in a distributed file system using an arbiter
US20230101774A1 (en) Techniques for performing clipboard-to-file paste operations
US11010408B2 (en) Hydration of a hierarchy of dehydrated files
TWI571754B (en) Method for performing file synchronization control, and associated apparatus
CN114490540B (en) Data storage method, medium, device and computing equipment
US20050278501A1 (en) Method and apparatus for caching storage system
US8943019B1 (en) Lookup optimization during online file system migration
CN114780043A (en) Data processing method and device based on multilayer cache and electronic equipment
CN109343928B (en) Virtual memory file redirection method and system for virtual machine in virtualization cluster
US10685046B2 (en) Data processing system and data processing method
CN111399753A (en) Method and device for writing pictures
US11379147B2 (en) Method, device, and computer program product for managing storage system
WO2024001280A1 (en) Data flow perception method and related apparatus