CN115857801A - Data migration method and device, electronic equipment and storage medium - Google Patents

Data migration method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115857801A
CN115857801A CN202211475787.8A CN202211475787A CN115857801A CN 115857801 A CN115857801 A CN 115857801A CN 202211475787 A CN202211475787 A CN 202211475787A CN 115857801 A CN115857801 A CN 115857801A
Authority
CN
China
Prior art keywords
data block
target
storage medium
data
target data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211475787.8A
Other languages
Chinese (zh)
Inventor
胡盛泳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202211475787.8A priority Critical patent/CN115857801A/en
Publication of CN115857801A publication Critical patent/CN115857801A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a data migration method, a data migration device, an electronic device and a storage medium. The method comprises the following steps: determining a target data block to be migrated; copying the data content of a target data block stored on a source storage medium to a target storage medium, and recording data block information of the target data block, wherein the data block information comprises storage position information and data content; adding a read-write lock to the target data block to suspend reading and writing of the target data block; and migrating the storage position information and the data content to a target storage medium, and releasing the read-write lock to finish the migration of the target data block. In the method, the service is normally executed in the process of copying the data block to be migrated to the target storage medium, the read-write condition of the data block in the period is recorded, and the read-write lock of the data block is set when the recorded content is migrated, so that the read-write operation of the data block by the service is suspended, and the time for adding the read-write lock to the data block is shortened.

Description

Data migration method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a data migration method and apparatus, an electronic device, and a storage medium.
Background
As the amount of internet user data continues to increase, the storage cost will be more and more proportional to the total cost of the database.
Among the solutions, there is a method to implement hierarchical storage of cold and hot data. That is, "hot data" is stored in a solid state disk which is expensive, small in capacity and high in read-write speed, and "cold data" is stored in a mechanical disk which is inexpensive, large in capacity and low in read-write speed. Since the degree of cooling and heating of data changes according to the access of the user, it is necessary to migrate data whose degree of cooling and heating has changed in real time or periodically. At present, before data is migrated, a corresponding service needs to be interrupted, and after the data is migrated, the service is restarted, which may result in a long service interruption time.
Disclosure of Invention
An object of the embodiments of the present application is to provide a data migration method, an apparatus, an electronic device, and a storage medium, which are used to reduce a duration of a service pause in a data migration process.
In a first aspect, an embodiment of the present application provides a data migration method, including:
determining a target data block to be migrated;
copying the data content of a target data block stored on a source storage medium to a target storage medium, and recording data block information of the target data block, wherein the data block information comprises storage position information and updating data;
adding a read-write lock to the target data block to suspend reading and writing of the target data block;
and migrating the storage position information and the updated data to a target storage medium, and releasing the read-write lock to finish the migration of the target data block.
In the embodiment of the application, in the process of copying the data block to be migrated in the target storage medium, the service is normally executed, the read-write condition of the service on the data block in the period is recorded, when the recorded content is migrated, the read-write lock of the data block is set, the read-write operation of the service on the data block is suspended, and after the recorded data is migrated, the read-write lock is released, so that the time for adding the read-write lock to the data block is shortened.
In any embodiment, a method of determining a target data block to be migrated includes:
counting the access times of each data block, and sequencing each data block according to the access times;
and determining a target data block to be migrated according to the size of the data block, the sequence of the data block and the capacity of the storage medium.
According to the data block migration method and device, the data blocks are divided into cold data or hot data through the size of the divided data blocks, the sequence of the access times of the data blocks and the capacity of each storage medium, the target data block to be migrated is determined according to the current storage position of the data block, and the calculated amount of the determined cold and hot data is small.
In any embodiment, the method further comprises:
acquiring a UUID and a data block label ObjiecetID of a snapshot corresponding to each data block, and acquiring a key value of the corresponding data block according to the UUID and the ObjiecetID; wherein, the ObjiectID is obtained by rounding down the size of the data block;
acquiring a sequence number bitmapID stored in a storage medium of each data block, and acquiring a value of the corresponding data block according to the bitmapID and the type of the storage medium;
and generating index information of the data block according to the key value and the value corresponding to the data block.
According to the embodiment of the application, the corresponding index information is generated for each data block in advance, so that the service can find the corresponding data block quickly, and meanwhile, the error probability of the data block in the migration process is reduced.
In any embodiment, before applying the read-write lock to the target data block, the method further comprises:
and receiving the service request, determining a target data block according to the pre-constructed database index information, and performing read-write operation on the target data block.
In the method and the device, in the process of migrating the target data block, the read-write lock is added to the target data block only when the data block information is migrated, and before the read-write lock is added to the target data block, the business can be normally executed, so that the time for locking the target data block is shortened.
In any embodiment, copying data content of a data block stored on a source storage medium to a destination storage medium includes:
and generating an empty new data block on the destination storage medium, and copying the data content of the target data block into the new data block.
In the embodiment of the application, in the process of copying the data block to be migrated in the target storage medium, the service is normally executed, the read-write condition of the service on the data block in the period is recorded, when the recorded content is migrated, the read-write lock of the data block is set, the read-write operation of the service on the data block is suspended, and after the recorded data is migrated, the read-write lock is released, so that the time for adding the read-write lock to the data block is shortened.
In any embodiment, the key value corresponding to the new data block is generated according to the UUID, the ObjiecetID and the suffix identifier of the target data block; the value corresponding to the new data block is generated according to the bitmapID of the target data block and the type of the target storage medium;
after completing the migration of the target data block, the method further comprises:
the suffix identifier in the key value of the new data chunk is deleted.
In the embodiment of the application, after the migration of the target data block is completed, the suffix identifier on the key value in the new data block is deleted, so that the new data block can be accurately found when a service request comes.
In any embodiment, after completing the migration of the target data block, the method further comprises:
and deleting the target data block in the source storage medium to release the storage space in the source storage medium.
In a second aspect, an embodiment of the present application provides a data migration apparatus, including:
the data determining module is used for determining a target data block to be migrated;
the data copying module is used for copying the data content of the target data block stored on the source storage medium to the target storage medium and recording the data block information of the target data block, wherein the data block information comprises storage position information and updating data;
the locking module is used for locking reading and writing of the target data block so as to suspend reading and writing of the target data block;
and the data updating module is used for migrating the storage position information and the updating data to the target storage medium and releasing the read-write lock so as to complete the migration of the target data block.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a memory, and a bus, wherein,
the processor and the memory are communicated with each other through the bus;
the memory stores program instructions executable by the processor, the processor being capable of performing the method of the first aspect when invoked by the program instructions.
In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium, including:
the non-transitory computer readable storage medium stores computer instructions that cause the computer to perform the method of the first aspect.
Additional features and advantages of the present application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the embodiments of the present application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flow chart of a data migration method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a method for determining a target data block according to an embodiment of the present application;
fig. 3 is a schematic view of a virtual disk relationship of a virtual machine according to an embodiment of the present disclosure;
fig. 4 is a schematic diagram illustrating splicing of key values of data chunks provided in an embodiment of the present application;
fig. 5 is a data block index diagram provided in an embodiment of the present application;
fig. 6 is a schematic diagram illustrating splicing of values of data blocks according to an embodiment of the present disclosure;
fig. 7 is a schematic flow chart of another data migration method according to an embodiment of the present application;
fig. 8 is a schematic flow chart of a data migration method according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a data migration apparatus according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings. The following examples are merely used to more clearly illustrate the technical solutions of the present application, and therefore are only examples, and the protection scope of the present application is not limited thereby.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "including" and "having," and any variations thereof, in the description and claims of this application and the description of the above figures are intended to cover non-exclusive inclusions.
In the description of the embodiments of the present application, the technical terms "first", "second", and the like are used only for distinguishing different objects, and are not to be construed as indicating or implying relative importance or implicitly indicating the number, specific order, or primary-secondary relationship of the technical features indicated. In the description of the embodiments of the present application, "a plurality" means two or more unless specifically defined otherwise.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
In the description of the embodiments of the present application, the term "and/or" is only one kind of association relationship describing an associated object, and means that three relationships may exist, for example, a and/or B, and may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter associated objects are in an "or" relationship.
In the description of the embodiments of the present application, the term "plurality" refers to two or more (including two), and similarly, "plural sets" refers to two or more (including two), and "plural pieces" refers to two or more (including two).
In the description of the embodiments of the present application, the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", "clockwise", "counterclockwise", "axial", "radial", "circumferential", and the like, indicate the directions or positional relationships indicated in the drawings, and are only for convenience of description of the embodiments of the present application and for simplicity of description, but do not indicate or imply that the referred device or element must have a specific direction, be constructed and operated in a specific direction, and thus, should not be construed as limiting the embodiments of the present application.
In the description of the embodiments of the present application, unless otherwise explicitly stated or limited, the terms "mounted," "connected," "fixed," and the like are used in a broad sense, and for example, may be fixedly connected, detachably connected, or integrated; mechanical connection or electrical connection is also possible; either directly or indirectly through intervening media, either internally or in any other relationship. The specific meanings of the above terms in the embodiments of the present application can be understood by those of ordinary skill in the art according to specific situations.
At present, before a data block is migrated, reading and writing of the data block need to be suspended, and after the data block is migrated, a reading and writing lock of the data block is released, during which a long time is in a stage where a service cannot be executed, so that a user is stuck when making a service request.
In order to solve the above problems, the present inventors have made long-term studies and have proposed a data processing method that allows a service to be normally executed when copying data content in a data block to be migrated, adds a read-write lock to the data block only when newly generated data is generated during the process of migrating and copying the data content in the data block, and releases the read-write lock after the newly generated data is completely copied. Thus, the timing for locking the data block with the read/write lock is pushed back for a period of time, and the amount of data copied during locking the data block is less, resulting in a shorter time for locking the data block.
It can be understood that the data migration method provided by the embodiment of the present application may be applied to an electronic device, where the electronic device may include a terminal and a server; the terminal may be a smart phone, a tablet computer, a Personal Digital Assistant (PDA), or the like; the server may specifically be an application server, and may also be a Web server.
Fig. 1 is a schematic flow chart of a data migration method provided in an embodiment of the present application, and as shown in fig. 1, the method includes:
step 101: and determining a target data block to be migrated.
In a particular implementation, the electronic device includes multiple types of storage media thereon, each of which includes a block of data. The data block may be obtained by dividing a storage space of the storage medium according to a preset size. In order to reduce the influence on the service in the data block migration process, the data block may be divided into smaller data blocks, for example, the size of each data block may be 1M, and of course, the size may also be other data blocks, which is not specifically limited in this embodiment of the present application.
The types of storage media may include solid state disks, mechanical disks, and the like, with different types of storage media being used to store data blocks of different degrees of cold and heat. The cold and hot degree of the data block can be determined according to the frequency of accessing data in the data block, that is, the frequently accessed data block can be called hot data; the infrequently accessed data blocks are referred to as cold data. Hot data may be stored in solid state disks with fast read and write speeds, and cold data may be stored in machines with slow read and write speeds.
It should be noted that the degree of cooling and heating of the data block may also be divided into more levels, and the types of storage media included in the electronic device may also be more, and the cooling and heating levels of the data block may be made to correspond to the types of storage media included in the electronic device, and different types of storage media are used for storing data blocks of different cooling and heating levels. For convenience of description, the embodiments of the present application are described with reference to storage media including solid state disks and mechanical disks, and data blocks having a cold and hot level including cold data and hot data.
Due to the limited capacity of the solid-state disk, it is impossible to store all data in the electronic device in the solid-state disk, and in order to optimize the user experience, hot data is stored in the data blocks of the solid-state disk, and cold data is stored in the data blocks of the mechanical disk. However, in practical applications, the cold and hot degree of data is not constant, and in the last time period, a certain data block belongs to hot data and may become cold data in the next time period; similarly, cold data from a previous time period may become hot data in a next time period.
Therefore, the electronic device may periodically perform a hot and cold data scan on the data blocks on the storage medium to determine whether there is a target data block that needs to be migrated. It will be appreciated that if hot data is stored on a mechanical disk or cold data is stored on a solid state disk, then the data block is the target data block that needs to be migrated.
Step 102: copying the data content of the target data block stored on the source storage medium to the target storage medium, and recording the data block information of the target data block, wherein the data block information comprises storage position information and updating data.
In a specific implementation process, the source storage medium refers to a storage medium to which the target data block corresponds before migration. The destination storage medium refers to a storage medium to which the target data is to be migrated. For example: if the target data block needs to be migrated to the solid-state disk in the original mechanical disk, the mechanical disk is a source storage medium, and the solid-state disk is a destination storage medium.
After determining the target data block to be migrated, the electronic device copies the data content stored in the target data block to the target storage medium. It will be appreciated that there may be modifications made to the part of the data in the data block that has been copied to the destination storage medium, since it takes time for the service to still perform normally during this period of time when copying the content in the target data block to the storage medium. For example: the target data block comprises data content ABCDE, and during copying the data content to the destination storage medium, B is changed into B', and in order to ensure the correctness of the data and enable the normal execution of the service, the electronic device can record the data block information of the target data block on the source storage medium. The data block information includes storage location information and update data. The storage location information refers to an offset of the changed data in the target data block, that is, a start address of the changed data in the target data block, and includes, for example: b at the start address of the target data block. The update data refers to the specific content of the changed data, for example, B'.
It is understood that the data information block may further include a data length, where the data length refers to the number of bytes occupied by changed data, for example: the number of bytes occupied by B. The data information block may include storage location information and update data of one or more pieces of modified data, or may be empty. When the data information block is empty, it indicates that the data content has not changed in the process of copying the data content in the target data block to the target storage medium.
Step 103: and adding a read-write lock to the target data block to suspend reading and writing of the target data block.
Before copying the data block information to the destination storage medium, the electronic device adds a read-write lock to the target data block on the source storage medium, and it can be understood that after the read-write lock is added to the target data block, the target data block cannot perform read-write operation, and therefore, the service that needs to access the target data block is also suspended from being executed.
Step 104: and migrating the storage position information and the updated data to a target storage medium, and releasing the read-write lock to finish the migration of the target data block.
After the electronic device adds a read-write lock to the target data block, the storage location information contained in the data block information is migrated to the destination storage medium. It can be understood that the purpose of migrating the data block information to the destination storage medium is to locate the data to be updated in the destination storage medium by using the storage location information in the data block information, and replace the located data to be updated by using the update data in the data block information. Thus, the migration of the target data block is completed.
And after the migration of the target data block is completed, releasing the read-write lock of the target data block.
In the embodiment of the application, in the process of copying the data block to be migrated in the target storage medium, the service is normally executed, the read-write condition of the service on the data block in the period is recorded, when the recorded content is migrated, the read-write lock of the data block is set, the read-write operation of the service on the data block is suspended, and after the recorded data is migrated, the read-write lock is released, so that the time for adding the read-write lock to the data block is shortened.
On the basis of the above embodiment, determining a target data block to be migrated includes:
counting the access times of each data block, and sequencing each data block according to the access times;
and determining a target data block to be migrated according to the size of the data block, the sequence of the data block and the capacity of the storage medium.
In a specific implementation process, the number of times of accessing data in each data block in the electronic device within a preset time period (e.g., 24 hours, 40 hours, etc.), that is, the number of times of reading and writing the data, may be counted. The electronic device may sort the data blocks according to the number of accesses, for example: the ordering may be by number of accesses. Whether the data block should fall on the solid-state disk or the mechanical disk is determined according to the access times of the data block. After the cold and hot data interaction, the data with high access frequency falls on the solid-state disk, and the data with low access frequency falls on the mechanical disk.
Fig. 2 is a flowchart illustrating a method for determining a target data block according to an embodiment of the present application, as shown in fig. 2. After sequencing according to the access times of the data blocks, each data block has a sequence number, the sequence number is defined as X, the capacity of a mechanical disk is defined as CH, the capacity of a solid-state disk is defined as CS, the size of the data block is defined as Q, if X is smaller than CS/Q, the data block with the sequence number of X is thermal data, whether the data block falls on the solid-state disk is judged, if the data block is on the solid-state disk, migration is not needed, if the data block is not on the solid-state disk, data interaction is needed, and the data block is a target data block. Otherwise, if X is larger than or equal to CS/Q, the data block with the sequence number X is cold data, whether the data block falls on the mechanical disk or not is judged, if the data block is on the mechanical disk, the data block does not need to be migrated, if the data block is not on the mechanical disk, data interaction is needed, and the data block is a target data block
According to the embodiment of the application, the data blocks are divided into cold data or hot data according to the size of the divided data blocks, the sequence of the access times of the data blocks and the capacity of each storage medium, the target data block to be migrated is determined according to the current storage position of the data block, and the calculated amount of the cold data and the hot data is determined to be small.
On the basis of the above embodiment, the method further includes:
acquiring a UUID and a data block label ObjiecetID of a snapshot corresponding to each data block, and acquiring a key value of the corresponding data block according to the UUID and the ObjiecetID; wherein, the ObjiecetID is obtained according to the address of the data block in the snapshot and the size of the data block;
acquiring a sequence number bitmapID stored in a storage medium of each data block, and acquiring a value of the corresponding data block according to the bitmapID and the type of the storage medium;
and generating index information of the data block according to the key value and the value corresponding to the data block.
In a specific implementation process, in order to accurately find an accessed data block according to a service request and ensure the correctness of the data block in a migration process, an index may be established in advance for the data block in the storage medium. Fig. 3 is a schematic view of a virtual disk relationship of a virtual machine according to an embodiment of the present application, as shown in fig. 3. To build the index, a rocksdb database may be used to store an index of the data blocks, which is an embeddable, persistent key-value store. Fig. 3 includes a solid state disk SSD and two mechanical disk HDDs, each containing data blocks.
The method comprises the steps that an assembly is mapped to a logical concept on a physical disk by a certain section of space of a virtual disk, a snapshot is contained in the assembly and consists of data blocks, in order to find the data blocks, the index relation between the snapshot and the data blocks can be established, each snapshot is provided with a Unique Identifier (UUID) (occupying 16 bytes), and the labels of the data blocks of the snapshots are obtained by calculation according to the addresses of the storage space corresponding to the snapshots occupied by the data blocks and the sizes of the data blocks. For example: the size of the data block is 1M, the address corresponding to the data block is 011, the address is divided by the size of the data block, the obtained value is rounded to become the obj ietid of the data block, the UUID of the snapshot is spliced with the obj ietid of the data block, and the key value of the data block is obtained, which is specifically shown in fig. 4.
Fig. 5 is a data block index diagram according to an embodiment of the present application, as shown in fig. 5. Each data block has a unique serial number bitmapID (numbers in SSD and HDD in the figure) in the corresponding disk, the bitmapID is stored by 8 bytes, and the most significant bit63 is distinguished by 0 and 1 as to whether HDD or SSD, specifically as shown in fig. 6, the value of the data block is the 8 bytes.
According to the embodiment of the application, the corresponding index information is generated for each data block in advance, so that the service can quickly find the corresponding data block, and meanwhile, the probability of errors of the data block in the migration process is reduced.
On the basis of the above embodiment, before applying a read-write lock to the target data block, the method further includes:
and receiving the service request, determining a target data block according to the pre-constructed database index information, and performing read-write operation on the target data block.
In a specific implementation, the electronic device can still normally receive and process the service request before copying the database block information. After receiving the service request, the electronic device determines a target data block according to the index information of each data block in the database, and it can be understood that the target data block may be a data block being migrated. And after the target data block is determined, performing read-write operation on the target data block according to a specific service request.
In the method and the device, in the process of migrating the target data block, the read-write lock is only applied to the target data block when the data block information is migrated, and all services can be normally executed before the read-write lock is applied to the target data block, so that the time for locking the target data block is shortened.
On the basis of the above embodiments, copying the data content of the data block stored on the source storage medium to the destination storage medium includes:
and generating an empty new data block on the destination storage medium, and copying the data content of the target data block into the new data block.
In a specific implementation process, when the electronic device copies the data content of the target data block to the destination storage medium, an empty new data block may be created on the destination storage medium, and it is understood that the size of the new data block is the same as the size of the target data block. After the new data block is created, the data content is copied from the source storage medium into the new data block.
Taking the migration of the target data block from the mechanical disk to the solid-state disk as an example: only one key value can exist in a data block in the electronic equipment, and when a new data block is created, suffix identification, such as temp, needs to be added to the key value of the new data block. The value of the key value with temp suffix is used to represent the bitmapID of the newly created data block stored on the destination storage medium. And finally, updating the original key value of ' snapshot uuid + ObjectId ' to ' Bit63 is 1 ', and Bit0-62 is bitmapID of SSD ' by using the atomicity operation of the database, and deleting the key value pair with temp suffix in the database.
Figure BDA0003959228250000131
In the embodiment of the application, in the process of copying the data block to be migrated in the target storage medium, the service is normally executed, the read-write condition of the service on the data block in the period is recorded, when the recorded content is migrated, the read-write lock of the data block is set, the read-write operation of the service on the data block is suspended, and after the recorded data is migrated, the read-write lock is released, so that the time for adding the read-write lock to the data block is shortened.
Fig. 7 is a schematic flow chart of another data migration method provided in the embodiment of the present application, and fig. 8 is a schematic flow chart of a data migration method provided in the embodiment of the present application, as shown in fig. 7 and fig. 8, the method includes:
step A: a virtual machine running in the electronic equipment receives the service request, finds a corresponding data block through the established index of the database, and performs read-write operation on data in the data block;
and B, step B: the electronic device counts the access frequency of each data block, determines a target data block to be migrated (a stripe 1 with a filling pattern in fig. 7), where taking the example that the target data block on the mechanical disk is migrated onto the solid-state disk, the service in step a is not interrupted, the writing of the service is still on the data block of the mechanical disk, and records the written storage location information and the update data in the memory, and creates an empty new data block on the solid-state disk.
Step C: the electronic device reads the content of the target data block to be migrated of the mechanical disk, copies and copies the content into an empty new data block of the solid-state disk (where the service io is not stopped, if new data is written just before copying the data content, the written new data will also be copied into the new data block of the solid-state disk), and records the data block information of the target data block if new data is written in the copying process.
Step D: and locking the target data block and suspending the service io. In the embodiment of the application, the read-write lock is added in the step D, and only the lock is added when the data block information is copied (see another strip with filling 2 in fig. 7), so that the locking strength is obviously reduced, and the influence on the service in cold and hot data interaction is also reduced.
And E, step E: and D, reading the storage position information and the updating data recorded in the step D from the memory, and writing the updating data into the data block in the solid-state disk.
Step F: and after the data copy is finished, deleting the target data block originally in the mechanical disk, and releasing the space of the mechanical disk.
The data migration method provided by the embodiment of the application can be applied to distributed storage and super-fusion products, and can reduce the influence on the business io in the process of cold and hot data migration. In the first migration process, the data of the data block is not locked, the service can read and write normally, the data can be copied completely, the offset and the length of the newly written data are recorded in the memory, when the record in the memory is copied, the read-write lock is required to be added, the service can read normally, but the writing can be suspended, the 1M data block is locked by the write lock, and the read-write of other data blocks cannot be influenced. After copying the data recorded in the memory, finally pointing the index to the new data block. Because only the write io of the 1M data record is locked in the copying process, the influence on the reading and writing of normal services is greatly reduced, and the pause of the user side can be reduced during the interaction of cold and hot data.
Fig. 9 is a schematic structural diagram of a data migration apparatus according to an embodiment of the present application, where the apparatus may be a module, a program segment, or code on an electronic device. It should be understood that the apparatus corresponds to the above-mentioned embodiment of the method of fig. 1, and can perform various steps related to the embodiment of the method of fig. 1, and the specific functions of the apparatus can be referred to the description above, and the detailed description is appropriately omitted here to avoid redundancy. The device comprises: a data determination module 901, a data copy module 902, a locking module 903, and a data update module 904, wherein:
the data determining module 901 is configured to determine a target data block to be migrated;
the data copying module 902 is configured to copy the data content of the target data block stored on the source storage medium to a destination storage medium, and record data block information of the target data block, where the data block information includes storage location information and update data;
the locking module 903 is configured to lock the target data block by reading and writing, so as to suspend reading and writing of the target data block;
the data update module 904 is configured to migrate the storage location information and the update data to the destination storage medium, and release the read-write lock, so as to complete the migration of the target data block.
On the basis of the foregoing embodiment, the data determining module 901 is specifically configured to:
counting the access times of each data block, and sequencing each data block according to the access times;
and determining the target data block to be migrated according to the size of the data block, the sequence of the data block and the capacity of the storage medium.
On the basis of the above embodiment, the apparatus further includes an index building module configured to:
acquiring a UUID and a data block label ObjiecetID of a snapshot corresponding to each data block, and acquiring a key value of the corresponding data block according to the UUID and the ObjiecetID; wherein the ObjiecetID is obtained according to the address of the data block in the snapshot and the size of the data block;
acquiring a sequence number bitmapID stored in a storage medium of each data block, and acquiring a value of the corresponding data block according to the bitmapID and the type of the storage medium;
and generating index information of the data block according to the key value and the value corresponding to the data block.
On the basis of the above embodiment, the apparatus further includes a service processing module, configured to:
and receiving a service request, determining the target data block according to pre-constructed database index information, and performing read-write operation on the target data block.
On the basis of the foregoing embodiment, the data updating module 904 is specifically configured to:
generating an empty new data block on a destination storage medium, and copying the data content of the target data block into the new data block.
On the basis of the above embodiment, the key value corresponding to the new data block is generated according to the UUID, the obj ie ctid, and the suffix identifier of the target data block; the value corresponding to the new data block is generated according to the bitmapID of the target data block and the type of the target storage medium; the device also includes: a suffix deletion module to:
and deleting the suffix identifier in the key value of the new data block.
On the basis of the above embodiment, the apparatus further includes a data block deleting module, configured to:
deleting the target data block in the source storage medium.
Fig. 10 is a schematic structural diagram of an entity of an electronic device provided in an embodiment of the present application, and as shown in fig. 10, the electronic device includes: a processor (processor) 1001, a memory (memory) 1002, and a bus 1003; wherein the content of the first and second substances,
the processor 1001 and the memory 1002 communicate with each other through the bus 1003;
the processor 1001 is configured to call the program instructions in the memory 1002 to execute the methods provided by the above-mentioned method embodiments, for example, including: determining a target data block to be migrated; copying the data content of the target data block stored on a source storage medium to a target storage medium, and recording data block information of the target data block, wherein the data block information comprises storage position information and updating data; adding a read-write lock to the target data block to suspend reading and writing of the target data block; and migrating the storage position information and the updating data to the target storage medium, and releasing the read-write lock to finish the migration of the target data block.
The processor 1001 may be an integrated circuit chip having signal processing capabilities. The Processor 1001 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. Which may implement or perform the various methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The Memory 1002 may include, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Read Only Memory (EPROM), an Electrically Erasable Read Only Memory (EEPROM), and the like.
The present embodiment discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the method provided by the above-mentioned method embodiments, for example, comprising: determining a target data block to be migrated; copying the data content of the target data block stored on a source storage medium to a target storage medium, and recording data block information of the target data block, wherein the data block information comprises storage position information and updating data; adding a read-write lock to the target data block to suspend reading and writing of the target data block; and migrating the storage position information and the updating data to the target storage medium, and releasing the read-write lock to finish the migration of the target data block.
The present embodiments provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the methods provided by the above method embodiments, for example, including: determining a target data block to be migrated; copying the data content of the target data block stored on a source storage medium to a target storage medium, and recording data block information of the target data block, wherein the data block information comprises storage position information and updating data; adding a read-write lock to the target data block to suspend reading and writing of the target data block; and migrating the storage position information and the updating data to the target storage medium, and releasing the read-write lock to finish the migration of the target data block.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
In addition, units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
Furthermore, the functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. A method of data migration, comprising:
determining a target data block to be migrated;
copying the data content of the target data block stored on a source storage medium to a target storage medium, and recording data block information of the target data block, wherein the data block information comprises storage position information and updating data;
adding a read-write lock to the target data block to suspend reading and writing of the target data block;
and migrating the storage position information and the updating data to the target storage medium, and releasing the read-write lock to finish the migration of the target data block.
2. The method of claim 1, wherein the determining the target data block to be migrated comprises:
counting the access times of each data block, and sequencing each data block according to the access times;
and determining the target data block to be migrated according to the size of the data block, the sequence of the data block and the capacity of the storage medium.
3. The method of claim 2, further comprising:
acquiring a UUID and a data block label ObjiecetID of a snapshot corresponding to each data block, and acquiring a key value of the corresponding data block according to the UUID and the ObjiecetID; wherein the ObjiecetID is obtained according to the address of the data block in the snapshot and the size of the data block;
acquiring a sequence number bitmapID stored in a storage medium of each data block, and acquiring a value of the corresponding data block according to the bitmapID and the type of the storage medium;
and generating index information of the data block according to the key value and the value corresponding to the data block.
4. The method of claim 3, wherein prior to applying a read-write lock to the target data block, the method further comprises:
and receiving a service request, determining the target data block according to pre-constructed database index information, and performing read-write operation on the target data block.
5. The method of claim 3, wherein copying the data content of the data block stored on the source storage medium to the destination storage medium comprises:
generating an empty new data block on a destination storage medium, and copying the data content of the target data block into the new data block.
6. The method according to claim 5, wherein the key value corresponding to the new data block is generated according to the UUID, the obj tiectid and the suffix identifier of the target data block; the value corresponding to the new data block is generated according to the bitmapID of the target data block and the type of the target storage medium;
after completing the migration of the target data block, the method further comprises:
and deleting the suffix identifier in the key value of the new data block.
7. The method of any of claims 1-6, wherein after completing the migration of the target data block, the method further comprises:
deleting the target data block in the source storage medium.
8. A data migration apparatus, comprising:
the data determining module is used for determining a target data block to be migrated;
the data copying module is used for copying the data content of the target data block stored on the source storage medium to a target storage medium and recording the data block information of the target data block, wherein the data block information comprises storage position information and updating data;
the locking module is used for locking the reading and writing of the target data block so as to suspend the reading and writing of the target data block;
and the data updating module is used for migrating the storage position information and the updating data to the target storage medium and releasing the read-write lock so as to complete the migration of the target data block.
9. An electronic device, comprising: a processor, a memory, and a bus, wherein,
the processor and the memory are communicated with each other through the bus;
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any one of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions which, when executed by a computer, cause the computer to perform the method of any one of claims 1-7.
CN202211475787.8A 2022-11-23 2022-11-23 Data migration method and device, electronic equipment and storage medium Pending CN115857801A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211475787.8A CN115857801A (en) 2022-11-23 2022-11-23 Data migration method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211475787.8A CN115857801A (en) 2022-11-23 2022-11-23 Data migration method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115857801A true CN115857801A (en) 2023-03-28

Family

ID=85665444

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211475787.8A Pending CN115857801A (en) 2022-11-23 2022-11-23 Data migration method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115857801A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909490A (en) * 2023-09-11 2023-10-20 腾讯科技(深圳)有限公司 Data processing method, device, storage system and computer readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909490A (en) * 2023-09-11 2023-10-20 腾讯科技(深圳)有限公司 Data processing method, device, storage system and computer readable storage medium
CN116909490B (en) * 2023-09-11 2024-01-05 腾讯科技(深圳)有限公司 Data processing method, device, storage system and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN110531940B (en) Video file processing method and device
US11347443B2 (en) Multi-tier storage using multiple file sets
CN106326229B (en) File storage method and device of embedded system
CN111541753A (en) Distributed storage system, method, computer device and medium for block chain data
CN108733306B (en) File merging method and device
CN113568582B (en) Data management method, device and storage equipment
WO2020211236A1 (en) Read-write conflict resolution method and apparatus employing b+ tree and storage medium
CN109804359A (en) For the system and method by write back data to storage equipment
CN111158602A (en) Data layered storage method, data reading method, storage host and storage system
CN104182701A (en) Array control unit, array and data processing method
CN115857801A (en) Data migration method and device, electronic equipment and storage medium
CN115114232A (en) Method, device and medium for enumerating historical version objects
CN112558868A (en) Method, device and equipment for storing configuration data
CN101477447A (en) Disk snap method and apparatus
CN116974458A (en) Method, electronic device and computer program product for processing data
CN111143116A (en) Method and device for processing bad blocks of disk
CN117131014A (en) Database migration method, device, equipment and storage medium
CN109542860B (en) Service data management method based on HDFS and terminal equipment
CN108121504B (en) Data deleting method and device
CN109508140B (en) Storage resource management method and device, electronic equipment and system
CN106557263B (en) For checking pseudo- shared method and apparatus in data block is deleted
CN111966845B (en) Picture management method, device, storage node and storage medium
CN110287064B (en) Method and device for restoring disk data and electronic equipment
CN112416860B (en) Data rollback updating method, device, computer equipment and storage medium
CN113553215A (en) Erasure code data recovery optimization method and device based on environmental information

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination