WO2018059032A1 - Data migration method for virtual node, and virtual node - Google Patents

Data migration method for virtual node, and virtual node Download PDF

Info

Publication number
WO2018059032A1
WO2018059032A1 PCT/CN2017/090613 CN2017090613W WO2018059032A1 WO 2018059032 A1 WO2018059032 A1 WO 2018059032A1 CN 2017090613 W CN2017090613 W CN 2017090613W WO 2018059032 A1 WO2018059032 A1 WO 2018059032A1
Authority
WO
WIPO (PCT)
Prior art keywords
physical node
node
service
migration
migrated
Prior art date
Application number
PCT/CN2017/090613
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 WO2018059032A1 publication Critical patent/WO2018059032A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/214Database migration support
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/4557Distribution of virtual machine instances; Migration and load balancing

Definitions

  • the present invention relates to the field of computer technologies, and in particular, to a data migration method and a virtual node of a virtual node.
  • distributed database technology is a distributed technology commonly used in the field of IT technology. It is mainly applied to webpage page caching, database caching, etc. to meet the requirements of users for the response speed of network systems.
  • a physical node can virtualize multiple virtual nodes, and then map multiple virtual nodes to the ring through a hash algorithm, so that the physical nodes can be mapped on the ring.
  • the range of hash values when multiple physical nodes do not meet the load balancing conditions, the virtual nodes on the physical nodes need to be migrated; for example, when a physical node is added to a distributed database system or a physical node is deleted, the physical node association is adjusted.
  • the number of virtual nodes is such that the number of virtual nodes associated with each physical node tends to be equal, so that all physical nodes of the distributed database system implement load balancing of the virtual nodes.
  • the MVCC Modult i-Version Concurrency Control
  • the migration process avoids the use of locks, thereby having the advantage of low overhead, but This migration mechanism is only applicable to non-relational databases.
  • the embodiment of the invention discloses a data migration method and a physical node of a virtual node, which can implement data migration of a relational database on a physical node.
  • the present application provides a data migration method for a virtual node, where the source physical node and the target physical node include but are not limited to a minicomputer, an x86 server, a personal workstation, or another type of hardware server, a source physical node, and a target physical node.
  • the distributed database system includes multiple physical nodes, and the method of triggering data migration may be: the metadata node detects multiple physical nodes in the distributed database system. The data migration is triggered when the load balancing condition is not met during the running of the service; or the metadata node detects the addition of a new physical node in the distributed database system, triggers data migration; or deletes a certain physical in the distributed database system.
  • the metadata node detects that a virtual node of a physical node on multiple physical nodes needs to perform data migration, the metadata node determines the source physical node and the target physical node, and at least one virtual node to be migrated on the source physical node, and metadata.
  • the node may send a migration indication message to the source physical node, where the migration indication message may carry the identifier of the target physical node and the identifier of the at least one virtual node to be migrated on the source physical node, where the migration indication message may be sent by the metadata node, Can be sent by other nodes in the distributed database system.
  • the source physical node first receives the migration indication message, and determines at least one virtual node and the target physical node to be migrated according to the migration indication message, where the organization of the data on the virtual node may be a relational database, the virtual node includes multiple service objects, and the data structure
  • the information indicates the association relationship of the service tables to which the multiple service objects belong, and the source physical node obtains the to-be-migrated according to the data structure information.
  • One business object belongs to one virtual machine node, and the source physical node migrates all business objects to the target physical node in turn.
  • the data structure information of the virtual node to be migrated by the source physical node acquires the service object to be migrated according to the data structure information, and all the service objects are migrated to the target physical node, thereby implementing logical migration of the relational data.
  • the data structure information of the source physical node is obtained, and the service object to which the at least one virtual node to be migrated belongs according to the data structure information includes: the data structure information includes the data fragment table and the service.
  • the object sub-table, the data fragment table is used to store the mapping relationship between the virtual node and the business object, for example, the mapping between the identifier of the virtual node and the identifier of the business object, and the identifier of the business object may be a hash value.
  • the source physical node obtains the virtual node identifier of each virtual node in the at least one virtual node, and the source physical node queries the virtual node identifier as an index to query one or more service objects to which the at least one virtual node belongs according to the preset data fragmentation table. Obtaining all the business objects on the at least one virtual node. For any one of the business objects, the source physical node obtains the business object identifier of the business object, and queries the business object identifier according to the preset business object subsidiary table.
  • the business table stores a plurality of business records, and the business records can be retrieved in the business table according to the identification of the business object.
  • the source physical node before the source physical node performs the route switching, receives the service access request of the client, and the source physical node performs the service access request according to the service object indicated by the service request, and the source physical node
  • the service access request is recorded in the service log, and the service log is sent to the target physical node.
  • the source physical node adds a timestamp or a version number to the service log, so that the target physical node can distinguish the order of the service logs.
  • the source physical node receives the service access request sent by the client during the migration process of the service object, processes the service access request normally, does not affect the user service, implements online migration, and further passes the source physical node and the target physics.
  • the synchronization of the service logs of the nodes keeps the data of the source physical node and the target physical node synchronized.
  • the method includes: the source physical node sends a migration completion message to the metadata node, where the migration of all the service objects corresponding to the at least one virtual node to be migrated is completed, and the migration is performed.
  • the completion message is used to notify the metadata node that all the service objects to be migrated have been successfully migrated to the target physical node.
  • the metadata node After receiving the migration completion message, the metadata node sends a handover indication message to the source physical node, and the source physical node receives the handover indication message.
  • the transaction includes multiple business access requests, the transaction has the characteristics of integrity, and the transaction execution is completed under the condition that each service access request in multiple service accesses must be successfully executed, if multiple service access requests If any one or more of the business access requests are not successfully executed, the transaction is rolled back to re-execute the transaction.
  • the source physical node receives the handover indication message, if there is a started transaction, and the source physical node waits for the started transaction to be successfully executed, the source physical node returns a handover preparation message to the metadata node, and the handover preparation message indicates that the source physical node is used as the route.
  • the metadata node may send a route switch message to the client after receiving the handover preparation message, where the route switch message may include mapping relationship information between the at least one virtual node to be switched and the target physical node, and the client switches the message according to the route. Update routing information.
  • the integrity of the data between the source physical node and the target physical node is effectively ensured, and the reliability is high.
  • the source physical node migrating all the service objects to the target physical node at the granularity of the service object includes: the source physical node selects a service object to be migrated from all the service objects, and The service object to be migrated is locked, and the service object to be migrated after the lock processing can only be read, and the write operation cannot be performed to prevent the business object to be migrated from being modified.
  • the source physical node sends the service object to be migrated to the service object.
  • the source physical node deletes the service object to be migrated when the service object to be migrated is successfully migrated to the target physical node.
  • the service access request is transferred during the process of migrating the business object, and the occupied resources are small.
  • the method further includes: when the source physical node receives the service access request sent by the client for the service object to be accessed, the source physical node determines to be accessed. Whether the business object has been migrated to the target physical node. If yes, the source physical node returns a routing update message to the client, where the routing update message carries the identifier of the service object to be accessed and the identifier of the target physical node, and the client The physical node where the service object to be accessed is located may be updated according to the routing update message, so that when the client initiates a service access request for the service object to be accessed, the client directly sends a service access request to the target physical node according to the updated routing information.
  • the method further includes: when the business object migration is completed, the source physical node sends a migration completion message to the metadata node, where the migration completion message is used to notify the metadata node to migrate at least one virtual node.
  • the metadata node receives the migration completion message and sends a route switch message to the client.
  • the route switch message is used to instruct the client to update the physical node where the at least one virtual node to be migrated is located.
  • the handover message carries at least one identifier of the virtual node and an identifier of the target physical node, and the client receives the routing switch message to update the routing information.
  • the application provides a method for migrating a virtual node, including: receiving, by the target physical node, a migration indication message; wherein the migration indication message carries an identifier of the source physical node, and the target physical node receives the service sent by the source physical node.
  • the target physical node determines that the data object to be migrated by the source physical node is complete, acquires the data structure information of all the received service objects, and reconstructs at least one virtual node according to the data structure information.
  • the target physical node acquires the data structure information of the migrated business object, reconstructs the virtual node according to the data structure information, and implements data recovery.
  • the method further includes: the target physical node receives the service log sent by the source physical node, and performs service replay according to the service access request included in the log file.
  • the service replay is performed according to the time stamp of the service log or the version number.
  • the method further includes: when the target physical node determines that the service log transmission on the source physical node is completed, acquiring the target replica physical node allocated by the at least one virtual node, storing the service log and the All the business objects included in the at least one virtual node are migrated to the target replica physical node, the target replica service node receives the service object, reorganizes the virtual node according to the received service object, and performs service replay according to the received service log, and performs the virtual node for the virtual node. Backup.
  • two or more virtual nodes that are mutually backed up are configured to meet the reverse affinity rules of the physical nodes, that is, at least two virtual nodes are located at different physical nodes, and the metadata nodes are based on
  • the anti-affinity rule deploys the target physical node of the target physical node to improve the reliability of the virtual node.
  • the application provides a physical node, where the physical node is a source physical node, and the source physical node includes:
  • a receiving module configured to receive a migration indication message
  • a determining module configured to determine, according to the migration indication message, at least one virtual node to be migrated on the target physical node and the source physical node;
  • An obtaining module configured to obtain data structure information of the source physical node itself, and obtain all service objects to which at least one virtual node belongs according to the data structure information;
  • a migration module for migrating all business objects to a target physical node at a granularity of business objects.
  • the data structure information includes a data fragment table and a data attachment table
  • the get module is used to:
  • the method further includes:
  • a first access processing module configured to receive a client to send a service access request
  • the method further includes:
  • a transaction processing module configured to send a migration completion message to the metadata node when the business object migration is completed
  • a handover preparation message is returned to the metadata node; wherein the handover preparation message is used to indicate that the source physical node completes the route switching preparation.
  • the migration module is used to:
  • the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
  • the method further includes:
  • a second access processing module configured to receive, during a migration process of the service object, a service access request sent by the client for the service object to be accessed;
  • routing update message is used to instruct the client to update the physical node where the business object to be accessed is located.
  • the method further includes:
  • the notification module is configured to send a migration completion message to the metadata node when the business object migration is completed; wherein the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
  • the application provides a physical node, where the physical node is a target physical node, and the target physical node includes:
  • a determining module configured to receive a migration indication message, and determine a source physical node according to the migration indication message
  • a receiving module configured to receive a service object sent by a source physical node
  • the reconstruction module is configured to acquire data structure information of the received service object when the migration of the business object of the source physical node is completed, and reconstruct the virtual node according to the data structure information.
  • the method further includes:
  • the service recovery module is configured to receive a service log sent by the source physical node, and perform service replay according to the service log.
  • the service log includes a service access request.
  • the method further includes:
  • the data backup module is configured to determine the physical node of the target replica in the case that the service log transmission on the source physical node is completed, and migrate the stored service log and the virtual node to the physical node of the target replica.
  • FIG. 1 is a schematic structural diagram of a distributed database system according to an embodiment of the present invention.
  • FIG. 2 is a schematic flowchart of a data migration method of a virtual node according to an embodiment of the present invention
  • FIG. 3 is a schematic flowchart of still another method for data migration of a virtual node according to an embodiment of the present invention.
  • 4a is a schematic flowchart of a method for acquiring a service object of a virtual node according to an embodiment of the present invention
  • 4b is a schematic diagram of a data structure of a physical node according to an embodiment of the present invention.
  • 4c is a schematic diagram of a principle of a data migration method for a virtual node according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a physical node according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of still another physical node according to an embodiment of the present disclosure.
  • FIG. 7 is a schematic structural diagram of still another physical node according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of still another physical node according to an embodiment of the present invention.
  • FIG. 1 is a schematic structural diagram of a hash-based distributed database system according to an embodiment of the present invention.
  • a distributed database system includes at least one client, a metadata node, a physical node cluster, and Storage network. At least one client communicates with the metadata node and the physical node cluster through the IP network, wherein the communication interface between the client and the metadata node or the physical node cluster may be a TCP (Transmission Control Protocol) interface or UDP. (User Datagram Protocol) interface.
  • TCP Transmission Control Protocol
  • UDP User Datagram Protocol
  • the metadata node includes a data equalization device, and the metadata node may be deployed in an independent manner, for example, may be deployed by using a minicomputer, an X86 computer, a personal computer server PC server, or may be combined with a physical node cluster.
  • the physical node cluster includes a plurality of physical nodes, and the physical node may be a minicomputer, an X86 computer, or a personal computer server PC server.
  • the data of the plurality of physical nodes may be stored in a storage medium of the storage network, and the plurality of physical nodes and the storage network are The block is read and written by Block IO (block IO), that is, the storage medium is read and written by Block.
  • the storage medium can be HDD (Hard Disk Drive), SSD (Solid State Drives), or memory. .
  • the metadata node mainly stores the metadata (Metadata) of the database system, and the metadata is information about the organization of the data, the data domain and the relationship thereof.
  • the metadata is the data used to describe the data.
  • the data equalization device is responsible for the distributed management capabilities of the distributed database system as a whole. In addition to being deployed in a metadata node, the data equalization device can also be built into various physical nodes. The highly reliable deployment mode of the distributed database system may adopt a dual-machine or a cluster mode, and the present invention is not limited.
  • the data equalization device mainly involves the following functions:
  • Metadata definition store and update the mapping relationship between virtual nodes and physical nodes, copy definition of virtual nodes, load degree and weight coefficient calculation method of weight factors, configuration and storage of deviation coefficients, and fission strategy of virtual nodes.
  • Route management Manage the routing data of the business object, and call the metadata definition unit interface according to the mapping relationship between the virtual node and the physical node.
  • Replication management store and update the primary copy relationship of the virtual node, and is responsible for the management of replication integrity, calling the metadata definition unit interface.
  • Node monitoring monitoring service information and node resource information, calling communication service unit, and acquiring each data service node Information and issue monitoring instructions.
  • Online migration Provides online migration capability in units of data sharding, which has no impact on the business and ensures high availability of migration.
  • the metadata definition interface is used to complete the routing and replication relationship changes.
  • Data equalization Data balancing between physical nodes is achieved according to data equalization conditions.
  • Metadata Synchronization/Persistence Synchronize metadata definition information to each physical node, the driver of the client, and the slave node of the data equalization device.
  • the change information needs to be notified to the above node, and the metadata is persisted to ensure high reliability of the data.
  • Communication service Provides network communication capabilities with peripheral network elements (each physical node, the driver of the client, and the slaver node of the data equalization device).
  • a plurality of physical nodes may deploy an agent agent, and the agent is responsible for information interaction with the data equalization device (for example, reporting node health information, receiving instructions of the data equalization device, and providing self-management of node high availability, for example, domain degradation when the network is abnormal) .
  • the agent is responsible for information interaction with the data equalization device (for example, reporting node health information, receiving instructions of the data equalization device, and providing self-management of node high availability, for example, domain degradation when the network is abnormal) .
  • the driver is also deployed on the client, and the routing information is cached in the driver.
  • the client can complete the route judgment through the cached routing information and access the corresponding physical node, thereby preventing the data balancing device from becoming a bottleneck of the routing query during service access.
  • FIG. 2 is a schematic flowchart of a data migration method of a virtual node according to an embodiment of the present invention, where the method includes but is not limited to the following steps.
  • the metadata node detects that the migration condition is met.
  • the distributed database system includes multiple physical nodes.
  • the migration conditions include, but are not limited to, adding physical nodes to multiple physical nodes, deleting one physical node of multiple physical nodes, or multiple physical nodes that do not meet load balancing conditions.
  • the equilibrium condition includes the equalization of the number of nodes on each physical node and the balance of traffic on each physical node; at this time, the distributed database system needs to perform data migration, so that the distributed database system satisfies the load balancing condition, and the metadata node determines the source physics. At least one virtual node to be migrated on the node, the target physical node, and the source physical node.
  • the distributed database system includes three physical nodes, three physical nodes are physical node a, physical node b, and physical node c, and each of the three physical nodes includes four virtual nodes, when distributed
  • the metadata node detects that the distributed database system does not satisfy the load balancing condition (the load balancing condition is the number of virtual nodes), and the metadata node needs to be separately from the physical node a and the physical node.
  • the load balancing condition is the number of virtual nodes
  • the metadata node determines that the source physical node is the physical node a, the physical node b, and the physical node c, and the target physical node is the physical node d.
  • the metadata node determines that the virtual node to be migrated on the physical node a is any one of the four virtual nodes to be migrated, and the virtual node to be migrated on the physical node b is any one of the four virtual nodes that belong to the physical node c.
  • the virtual node to be migrated is any one of the physical nodes to be migrated.
  • the metadata node sends a migration indication message to the source physical node.
  • the migration indication message is used to indicate that the source physical node performs the migration operation, and the migration indication message may include the identifier of the target physical node and the identifier of the at least one virtual node to be migrated on the source physical node, where the source physical node may determine according to the migration indication message. At least one virtual node to be migrated on the target physical node and the source physical node.
  • the source physical node acquires data structure information of at least one virtual node to be migrated.
  • the virtual node includes multiple service objects, and the service object is an object that is divided according to a preset division rule.
  • the data set for example, the object is divided by the client, and the data set of each client is a business object;
  • the data structure information represents the structure of the data on the physical node, and the data structure information specifically includes the mapping relationship between the physical node and the virtual node, and the virtual node
  • the mapping relationship with the business object, the mapping relationship between the business object and the business table, and the data structure information can be maintained by the metadata node.
  • the source physical node obtains all the service objects corresponding to the at least one virtual node to be migrated according to the data structure information, and the source physical node may acquire the data structure information of the at least one virtual node to be migrated to the metadata node.
  • the source physical node acquires data structure information of each virtual node in the at least one virtual node, and obtains all service objects according to the data structure information.
  • the data on the physical node can be divided into four levels, from top to bottom, respectively, a virtual node, a business object, a service table, and a business record, one virtual node is associated with multiple business objects, and one business object is associated with multiple business tables.
  • a business table stores a plurality of business records;
  • the business object represents a data set to which the objects are divided according to a predefined rule, for example, the objects are divided according to different customers, and each customer is a business object;
  • the objects are divided according to the service type, each The business object is a business object; the business objects are divided according to different orders, each order is a business object;
  • the business table is used to store specific business records.
  • the data structure information can be maintained on the metadata node, and the data structure information represents the data structure of the physical node.
  • the data structure information includes a data fragmentation table, a business object root table, and a business object subsidiary table; the data fragmentation table storage represents the virtual node and the business object.
  • the business object root table stores basic information of the business object, for example, when the business object is a data set of a customer,
  • the business object root table stores the customer's personal information;
  • the business object subsidiary table storage represents the mapping relationship between the business object and the business table.
  • the source physical node obtains the data fragmentation table from the metadata node, and retrieves the data fragmentation table by using the virtual node identifier to obtain the business object identifier of all the business objects to which the at least one virtual node to be migrated belongs.
  • the business object subsidiary table defines a mapping relationship between the business object and the business table, and the source physical node retrieves the preset business object subsidiary table according to the business object identifier to obtain the business table.
  • At least one virtual node to be migrated is a virtual node 1
  • the source physical node acquires a virtual node identifier of the virtual node 1, and retrieves a preset data fragment table according to the virtual node identifier to obtain a virtual
  • the node 1 associates the business object identifier of the business object 11, the business object 12, ..., the business object 1m, and then the source physical node retrieves the preset business object subsidiary table according to the business object identifier to obtain a plurality of related business tables
  • the business object 11 is
  • the business object identifier of the searched business object 11 is associated with the business table 111, the business table 112, ..., the business table 11k; then the source physical node can retrieve the corresponding business record in the business table according to the business object identifier of the business object.
  • the service table 111 as an example, the business record 1111, the business record 1112, ..., the business record 111h stored in the service table
  • the source physical node sends the first service object C1 to the target physical node.
  • the source physical node determines all the service objects to which the at least one virtual node belongs to be migrated, one of the service objects is selected and sent to the target physical node.
  • the source physical node sets a record table for recording the migration status of the service object. In the initial state, the migration status of all service objects is not migrated. When a service object is successfully migrated to the target physical node, the source physical node will The migration status of the business object is changed to migrated.
  • the source physical node receives the service access request sent by the client.
  • the operation object of the service access request is one of all the service objects in S203, and the operation type of the service access request may be a read operation or a write operation.
  • the source physical node generates a service log.
  • the service log includes a service access request
  • the source physical node may further add a timestamp or a version number to the service log, so that the target physical node can distinguish the order of service access requests.
  • the source physical node returns a service access response to the client.
  • the source physical node performs a corresponding operation according to the service access request, and returns a service access response to the client, for example, the operation type of the service access request is a read operation, the service access response carries the read data, and the service access request is operated.
  • the type is a write operation
  • the service access response carries write status information, and the write status information is used to indicate whether the write operation is successful.
  • the source physical node sends a service log to the target physical node.
  • the source physical node sends a service log to the target physical node, and the target physical node caches the received service log.
  • the source physical node may generate a service log every time a service access request is received, and send the service log to the target physical node, or the source physical node receives a service access request to generate a service log, and the generated service is generated.
  • the log is cached. After all the business objects are migrated, all the cached service logs are sent to the target physical node.
  • the source physical node sends the last service object to the target physical node.
  • the number of the service objects corresponding to the at least one virtual node to be migrated is n
  • the source physical node may count the migrated service objects, and the value of each service object is incremented by one, and the count value is equal to all the service objects.
  • the quantity is n, it indicates that all business objects migrate successfully.
  • the target physical node receives the service object sent by the source physical node, and after the source physical node sends all the service objects to be migrated, the source physical node may send a migration completion message to the target physical node, and the migration completion message indicates that the source physical node is to be migrated. All the service objects are sent; after the target physical node determines that all the service objects to be migrated on the source physical node are sent, the data structure information of the source physical node can be obtained from the metadata node, and the target physical node receives the data according to the data structure information. All the business objects that arrive are reorganized to obtain the at least one virtual node.
  • the target physical node may perform service replay according to the cached service log after the indication of the source physical node or the indication of the metadata node, and the target physical node performs log replay according to the timestamp or version number carried in the log file to make the target physical node
  • the execution order of the upper service access request is consistent with the source physical node.
  • the service access request may be skipped.
  • the service log cached by the target physical node includes: service log 1, service log 2, service log 3, and service log 4.
  • the service access request recorded in service log 1 is modified user information, and the version number of the record is 1.0;
  • the service access request recorded in 2 is the modified charging type, and the recorded version number is 1.1;
  • the service access request recorded in the service log 3 is the read consumption record, and the recorded version number is 1.2;
  • the service access request recorded in the service log 4 To modify the user balance, the version number of the record is 1.3. It is assumed that the record number of the version number is incremented according to the sequence, and the service log with a larger version number is newer than the service log with a smaller version number.
  • the target physical node performs service replay according to the above four service logs, the service log 1 and the service log are used. 2.
  • the service replay is performed in the order of service log 3 and service log 4.
  • the source physical node sends a migration complete message to the metadata node.
  • a migration completion message is sent to the metadata node.
  • the migration completion message indicates that all the business objects to be migrated on the source physical node are migrated.
  • the metadata node sends a handover indication message to the source physical node.
  • the handover indication message is used to indicate that the source physical node performs route switching.
  • the source physical node blocks the requested transaction, and waits for the started transaction to complete.
  • the source physical node blocks the transaction requested by the client, and the transaction includes multiple service access requests, and the transaction has the characteristics of integrity. After all the service access requests included in the transaction are successfully executed, the transaction is completed. It is considered that the execution is successful. When any one or more business operation requests included in the transaction are not successfully executed, the transaction needs to be rolled back, and multiple service access requests included in the transaction are re-executed; the source physical node determines that there is a startup. A transaction, and a transaction that has started is not successfully executed, waiting for the execution of the started transaction to complete.
  • the source physical node returns a handover preparation message to the metadata node.
  • the source physical node After the execution of the started transaction is completed, the source physical node returns a handover preparation message to the metadata node, where the handover preparation message indicates that the source physical node has completed the route switching preparation.
  • the source physical node may block the transaction requested by the client after all the service nodes to which the at least one virtual node to be migrated is sent, and the source physical node determines to perform the executed transaction. After completion, the handover preparation message is sent to the metadata node, and the handover preparation message is used to indicate that the source physical node is ready for route switching to ensure the integrity of the transaction.
  • the source physical node may send a handover preparation message to the target physical node, and after receiving the handover preparation message, the target physical node performs service replay according to the cached service log, and the target physical node may obtain the information from the metadata node after the service replay is completed.
  • a physical node of the source physical node, the target physical node sends the cached service log to the physical node of the replica, and the physical node of the replica performs service replay on at least one virtual node according to the service log.
  • the metadata node sends a route switching message to the client.
  • the metadata node when receiving the handover preparation message, the metadata node confirms that the source physical node is prepared as a route switch, and the metadata node acquires the identifier of the target physical node and the identifier of the at least one virtual node to be migrated, and the metadata node sends a route to the client.
  • the switching message is used to indicate that the client updates the physical node where the at least one virtual node is located, and the routing switch message carries the identifier of the at least one virtual node to be migrated and the identifier of the target physical node.
  • the client sends a service access request to the target physical node.
  • the client receives the routing switch message, and changes the mapping relationship between the at least one virtual node and the source physical node to the mapping relationship between the at least one virtual node and the target physical node, and the client sends the service object to the service object to which the at least one virtual node belongs.
  • the service access request is sent to the target physical node according to the changed mapping relationship.
  • the target physical node returns a service access response to the client.
  • the target physical node receives the service access request, performs a corresponding operation according to the service access request, and returns a service access response to the client.
  • the metadata node sends an offline notification message to the source physical node.
  • the offline notification message is used to clean at least one virtual node in the source physical node, and the offline notification message may carry the identifier of the at least one virtual node.
  • the distributed database system includes four physical nodes, which are physical node 1, physical node 2, physical node 3, and physical node 4.
  • Each physical node includes 12 virtual nodes, and each virtual node has 1 deployed.
  • Copy the number in the brackets below is the table of the virtual node, the two virtual nodes of the same number are the master and the copy, which can also be called The primary node and the standby node (or primary or backup fragment), the mapping relationship between the physical node and the virtual node is as follows:
  • Physical node 3 (13,14,15,16,17,18), (2,5,7,10,21,24)
  • the data equalization subsystem of the metadata node calculates that it is necessary to separately migrate the physical node 1. virtual node 1, physical node 2. virtual node 7, physical node 3. virtual node 13, physical node 4. virtual node 19 to physical node 5.
  • the physical node 1. virtual node 1, physical node 2. virtual node 7, physical node 3. virtual node 13, physical node 4. virtual node 19 are sequentially traversed.
  • Physical nodes 1-4 are source physical nodes, and physical nodes 5 are target physical nodes.
  • the structure of the data fragmentation table is defined as
  • Vnode_id int Vnode_id int, / / virtual node ID
  • the identifier can be represented by a hash value.
  • the identifier of all business objects is a list of hash value ranges. It is assumed that the hash value range of all business objects is (O1, O2, O3, O4, O5); then physical node 1 is for each business object.
  • the Hash value traverses the root table of the business object, obtains the root table information of the business object, and retrieves the associated business table by using the hash value of the business object according to the preset business object subsidiary table, where the business table stores multiple business records and physical nodes.
  • the service object to which the virtual node 1 to be migrated belongs is determined, the service object of the virtual node 1 is migrated to the physical node 5 to form a baseline replication.
  • the migration process if an exception occurs, re-migrate and clean the physical node 5.
  • Virtual node 1 is re-migrated by physical node 1.
  • Virtual node 1. During the migration of the business object, the client can continue to access the physical node 1.
  • Virtual node 1 performs a service access request and returns a service access response, physical node 1.
  • the service that virtual node 1 will generate The log is sent to the physical node 5, and the physical node 5 caches the service log.
  • the physical node 5 replays the service according to the cached service log.
  • the physical node 1 blocks the transaction initiated by the client. Due to the characteristics of the transaction integrity, the physical node 1 waits for the started transaction to complete, and then sends a handover preparation message to the metadata node.
  • the node After receiving the handover preparation message, the node sends a routing switch message to the client, where the routing switch message is used to instruct the client to update the mapping relationship between the virtual node 1 and the physical node 1 to the mapping relationship between the virtual node 1 and the physical node 5.
  • the routing switch message is used to instruct the client to update the mapping relationship between the virtual node 1 and the physical node 1 to the mapping relationship between the virtual node 1 and the physical node 5.
  • the data structure information of the virtual node to be migrated by the source physical node acquires the business object to be migrated according to the data structure information, migrates all the business objects to the target physical node, and implements relational data.
  • Logical migration In the method described in FIG. 2, the data structure information of the virtual node to be migrated by the source physical node acquires the business object to be migrated according to the data structure information, migrates all the business objects to the target physical node, and implements relational data. Logical migration.
  • FIG. 3 is a schematic flowchart of still another method for data migration of a virtual node according to an embodiment of the present invention, where the method includes but is not limited to the following steps.
  • the metadata node detects that the migration condition is met.
  • the distributed database system includes multiple physical nodes
  • the migration conditions include, but are not limited to, adding a physical node, deleting a physical node, not satisfying a load balancing condition, or failing to satisfy a data balancing condition.
  • S302 Synchronize metadata between the metadata node and the client.
  • the metadata synchronization parameter is required between the metadata node and the client.
  • the metadata includes but is not limited to the mapping relationship between the physical node and the virtual node, the storage location of the virtual node and the copy, and the data balancing condition.
  • the metadata node sends a migration indication message.
  • the metadata node sends the migration indication message to the source physical node and the target physical node, and triggers migration of the service object on the source physical node.
  • the metadata node sends a migration indication message to each replica physical node of the source physical node.
  • the source physical node acquires data structure information of at least one virtual node to be migrated.
  • the virtual node includes multiple service objects
  • the business object is a data set of objects divided according to a preset division rule.
  • the object is divided by a client, and each customer's data set is a business object; the data structure information is represented.
  • the structure of the data on the physical node, the data structure information specifically includes the mapping relationship between the physical node and the virtual node, the mapping relationship between the virtual node and the business object, the mapping relationship between the business object and the service table, and the data structure information can be maintained by the metadata node.
  • the source physical node obtains all the service objects corresponding to the at least one virtual node to be migrated according to the data structure information, and the source physical node may acquire the data structure information of the at least one virtual node to be migrated to the metadata node.
  • the master-slave replication between the source physical node and the replica physical node is suspended.
  • the reason for suspending master-slave replication is that during the migration process, online service concurrency is still supported.
  • the service data before and after the migration of the same virtual node accesses different physical nodes (source physical node and target physical node).
  • the replica data and It is more difficult to keep the master data consistent.
  • the source physical node performs locking processing on the service object to be migrated.
  • the source physical node selects a business object to be migrated from all the business objects, and locks the business object to be migrated. After the lock processing, the business object to be migrated cannot be modified, that is, the business object to be migrated.
  • the operation can only be a read operation and cannot be a write operation.
  • the source physical node sends the service object to be migrated to the target physical node.
  • the source physical node selects one business object from all the business objects to be migrated to migrate to the target physical node.
  • the source physical node deletes the service object to be migrated.
  • the source physical node deletes the service object to be migrated after the service object to be migrated is sent to the target physical node.
  • the client sends a service access request to the source physical node.
  • the client sends a service access request to the source physical node for the business object to be accessed, and the business object accessed by the service access request is one of all the business objects.
  • the source physical node determines whether the service object to be accessed has been migrated.
  • the source physical node maintains a state table of a business object, and the state table stores a service object for representing the business object.
  • the state of the service object is classified as migrated and not migrated.
  • the source physical node can query whether the status of the service object to be accessed is migrated or not migrated according to the pre-stored state table. If the source physical node directly responds to the service access request, the service access response is returned to the client. If the status of the service object to be accessed is migrated, S310 is performed.
  • the source physical node returns a route change message to the client.
  • the source physical node returns a route change message to the client when the to-be-accessed service object has been migrated, and the route change message indicates that the physical node where the service object to be accessed is changed, and the route update message may carry the target physical node.
  • the client sends a service access request to the target physical node again.
  • the client receives the routing update message, obtains the identifier of the target physical node according to the routing update message, and sends a service access request to the target physical node again.
  • the client receives a service access response returned by the target physical node.
  • the target physical node receives the service access request sent by the client for the service object to be accessed, and the target physical node performs the service access request and returns the service to the client because the service object to be accessed has been successfully migrated to the target physical node.
  • the client receives the service access response returned by the target physical node.
  • the source physical node sends a migration complete message to the metadata node.
  • the source physical node determines that all the service objects to be migrated are migrated, and sends a migration completion message to the metadata node, where the source physical node can count the successfully transferred business objects, and each time the service object is migrated, the count value is increased by one. When the count value is equal to the number of all business objects to be migrated, it is determined that all the business objects to be migrated are migrated.
  • the metadata node sends a route switching message to the client.
  • the routing switch message indicates that the physical node where the virtual node is located is updated, and the routing switch message may carry the identifier of the at least one virtual node and the identifier of the target physical node, and the client receives the routing update message, and at least one virtual according to the routing update message The node is mapped to the target physical node.
  • the metadata node sends an offline notification message to the source physical node.
  • the offline notification message is used to notify the virtual node to go offline.
  • the offline notification message may carry the identifier of the at least one virtual node, and the source physical node receives the offline notification message, and the at least one virtual node may be deleted according to the message notification message.
  • the distributed database system includes four physical nodes, which are physical node 1, physical node 2, physical node 3, and physical node 4.
  • Each physical node includes 12 virtual nodes, and each virtual node has 1 deployed.
  • a copy of the virtual node is numbered in the parentheses below.
  • the two virtual nodes of the same number are the master and the copy. They can also be called the primary node and the standby node (or the primary or backup slice) physical node.
  • the mapping relationship with the virtual node is as follows:
  • Physical node 3 (13,14,15,16,17,18), (2,5,7,10,21,24)
  • the physical node 1 For example, the physical node 1.
  • the migration of the virtual node 1 is taken as an example.
  • the method for obtaining the service object to which the virtual node 1 belongs reference may be made to the description of the embodiment of FIG. 2, and details are not described herein again.
  • the migration process is: traversing the physical node 1. All the business objects under the virtual node 1: business object 1, business object 2, business object 3, business object 4, and business object 5, assuming that the order of migration is one for each of the business objects 1-5 Migration, suspend physical node 1. Master-slave replication between virtual node 1 and replica physical node; physical node 1 locks business object 1 and migrates physical node 1. virtual node 1. business object 1 to physical node 5. virtual Node 1, then cleans up the physical node 1. Virtual node 1. Business object 1; loop processing, and then relocate business object 2, business object 3, business object 4, and business object 5 to physical node 5. virtual node 1.
  • the client initiates a service access request to the physical node 1.
  • virtual node 1. business object 1, and the physical node 1 (the source physical node) determines that the business object 1 has been migrated, and returns a routing update message to the client;
  • the client update routing update message re-initiates a service access request to the physical node 5.
  • virtual node 1. For the migration process of the virtual node 7 of the physical node 2, the virtual node 13 of the physical node 3, and the virtual node 19 of the physical node 4, reference may be made to the above description, and details are not described herein again.
  • the gray squares in Figure 4c represent migrated virtual nodes. When virtual nodes 1, 7, 13, and 19 are migrated to physical node 5, replicas need to be deployed on physical nodes 5, and the rules for anti-affinity are followed when deploying replicas. That is, the master and the copy cannot be on the same physical node.
  • the data structure information of the virtual node to be migrated by the source physical node acquires the business object to be migrated according to the data structure information, migrates all the business objects to the target physical node, and implements the logic of the relational data. migrate.
  • FIG. 5 is a schematic structural diagram of a physical node according to an embodiment of the present invention.
  • the physical node used in the embodiment of the present invention is used to perform the data migration method of the virtual node in FIG. 2, and the terminology and process involved may refer to the diagram. 2 Description of the embodiment.
  • the physical node 5 includes a receiving module 501, a determining module 502, an obtaining module 503, and a migration module 504.
  • a receiving module configured to receive a migration indication message
  • a determining module configured to determine, according to the migration indication message, a target physical node and at least one virtual node to be migrated on the source physical node;
  • An acquiring module configured to acquire data structure information of the source physical node itself, and obtain, according to the data structure information, all service objects to which the at least one virtual node belongs;
  • a migration module configured to migrate the all business objects to the target physical node at a granularity of the business object.
  • the data structure information includes a data fragment table and a data attachment table
  • the obtaining module is used to:
  • it also includes:
  • a first access processing module configured to receive a client to send a service access request
  • it also includes:
  • a transaction processing module configured to send a migration completion message to the metadata node when the business object migration is completed
  • the migration module is configured to:
  • the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
  • the physical node further includes:
  • a second access processing module configured to receive, during a migration process of the business object, a service access request sent by the client for the service object to be accessed;
  • routing update message is used to instruct the client to update the physical node where the to-be-accessed business object is located.
  • it also includes:
  • a notification module configured to send a migration completion message to the metadata node when the business object migration is completed; wherein the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
  • FIG. 6 is a schematic structural diagram of a physical node according to an embodiment of the present invention.
  • the physical node 6 includes a processor 601, a memory 602, and a transceiver 603.
  • the transceiver 603 is configured to transmit and receive data with and from an external device.
  • the number of processors 601 in the physical node 6 may be one or more.
  • processor 601, memory 602, and transceiver 603 may be connected by a bus system or other means.
  • the physical node 6 can be used to perform the method shown in FIG. 2. For the meaning and examples of the terms involved in the embodiment, reference may be made to the corresponding embodiment of FIG. 2. I will not repeat them here.
  • the program code is stored in the memory 602.
  • the processor 601 is configured to call the program code stored in the memory 602 for performing the following operations:
  • All of the business objects are migrated to the target physical node at a granularity of business objects.
  • the data structure information includes a data fragment table and a data attachment table
  • the processor 601 performs, according to the data structure information, all the service objects to which the at least one virtual node to be migrated belongs:
  • the processor 601 is further configured to:
  • the processor 601 is further configured to:
  • the source physical node Upon receiving the handover indication message, the source physical node blocks a transaction initiated by the client;
  • the source physical node returns a handover preparation message to the metadata node, where the handover preparation message is used to indicate that the source physical node completes route switching preparation.
  • the processor 601 performing the migrating the all service objects to the target physical node at a granularity of a service object includes:
  • the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
  • the processor 601 further includes:
  • routing update message is used to instruct the client to update the physical node where the to-be-accessed business object is located.
  • the processor 601 is further configured to:
  • the migration completion message is sent to the metadata node, where the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
  • FIG. 7 is a schematic structural diagram of a physical node according to an embodiment of the present invention.
  • the physical node in the embodiment of the present invention is used to perform the data migration method of the virtual node in FIG. 3, and the terminology and process may refer to FIG. 3 . Description of the embodiments.
  • the physical node 7 includes a determination module 701, a receiving module 702, and a reconstruction module 703.
  • a determining module 701 configured to receive a migration indication message, and determine a source physical node according to the migration indication message
  • the receiving module 702 is configured to receive a service object sent by the source physical node.
  • the reconstruction module 703 is configured to acquire data structure information of the received service object when the migration of the service object of the source physical node is completed, and reconstruct the virtual node according to the data structure information.
  • the physical node 7 further includes:
  • the service recovery module is configured to receive a service log sent by the source physical node, and perform service replay according to the service log.
  • the service log includes a service access request.
  • the physical node 7 further includes:
  • a data backup module configured to determine a target when the service log transmission on the source physical node is completed.
  • the replica physical node migrates the stored service log and the virtual node to the target replica physical node.
  • FIG. 8 is a schematic structural diagram of a physical node according to an embodiment of the present invention.
  • the physical node 8 includes a processor 801, a memory 802, and a transceiver 803.
  • the transceiver 803 is configured to transmit and receive data with and from an external device.
  • the number of processors 801 in the physical node 7 may be one or more.
  • processor 801, memory 802, and transceiver 803 may be coupled by a bus system or other means.
  • the physical node 8 can be used to perform the method shown in FIG. For the meaning and examples of the terms involved in the embodiment, reference may be made to the corresponding embodiment of FIG. 3. I will not repeat them here.
  • the program code is stored in the memory 802.
  • the processor 801 is configured to call program code stored in the memory 802 for performing the following operations:
  • the processor 801 is further configured to:
  • the target physical node receives the service log sent by the source physical node, and performs service replay according to the service log.
  • the service log includes a service access request.
  • the processor 801 is further configured to:
  • the target replica physical node is determined, and the stored service log and the virtual node are migrated to the target replica physical node.
  • the foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.

Abstract

A data migration method for a virtual node, comprising: a source physical node receives a migration indication message; the source physical node determines, according to the migration indication message, a target physical node and at least one virtual node to be migrated on the source physical node; obtain data structure information of the source physical node, and obtain all service objects to which the at least one virtual node belongs according to the data structure information; the source physical node migrates all the service objects to the target physical node by using the service objects as granularity. Also provided is a physical node which can achieve the migration of relational data.

Description

一种虚拟节点的数据迁移方法和虚拟节点Data migration method and virtual node of virtual node
本申请要求于2016年9月30日提交中国专利局、申请号为201610877920.0,发明名称为“一种虚拟节点的数据迁移方法和虚拟节点”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to Chinese Patent Application No. 201610877920.0, filed on Sep. 30, 2016, entitled "A Data Transfer Method and Virtual Node of a Virtual Node", the entire contents of which are incorporated by reference. In this application.
技术领域Technical field
本发明涉及计算机技术领域,尤其涉及一种虚拟节点的数据迁移方法和虚拟节点。The present invention relates to the field of computer technologies, and in particular, to a data migration method and a virtual node of a virtual node.
背景技术Background technique
目前,分布式数据库技术是IT技术领域中普遍使用的一项分布式技术,其主要应用于网页页面缓存、数据库缓存等方面以满足用户对网络系统响应速度的要求。At present, distributed database technology is a distributed technology commonly used in the field of IT technology. It is mainly applied to webpage page caching, database caching, etc. to meet the requirements of users for the response speed of network systems.
在基于一致性哈希算法的分布式数据库系统中,物理节点可虚拟出多个虚拟节点,然后将多个虚拟节点通过哈希算法映射到环上,这样物理节点可增大在环上映射的哈希值范围。在分布式数据库系统中多个物理节点不满足负载均衡条件时,需要对物理节点上的虚拟节点进行迁移;例如在分布式数据库系统新增物理节点或删除物理节点时,通过调整各个物理节点关联的虚拟节点的数量,使各个物理节点关联的虚拟节点的数量趋于相等,使分布式数据库系统的所有物理节点实现虚拟节点的负载均衡。在目前的虚拟节点迁移方案中,MVCC(Mult i-Vers ion Concurrency Control,多版本并发控制)机制进行对分布式数据库中的数据进行迁移,迁移过程避免使用锁,从而具有开销小的优点,但是这种迁移机制仅适用于非关系型数据库。In a distributed database system based on a consistent hash algorithm, a physical node can virtualize multiple virtual nodes, and then map multiple virtual nodes to the ring through a hash algorithm, so that the physical nodes can be mapped on the ring. The range of hash values. In a distributed database system, when multiple physical nodes do not meet the load balancing conditions, the virtual nodes on the physical nodes need to be migrated; for example, when a physical node is added to a distributed database system or a physical node is deleted, the physical node association is adjusted. The number of virtual nodes is such that the number of virtual nodes associated with each physical node tends to be equal, so that all physical nodes of the distributed database system implement load balancing of the virtual nodes. In the current virtual node migration scheme, the MVCC (Mult i-Version Concurrency Control) mechanism performs migration on data in a distributed database, and the migration process avoids the use of locks, thereby having the advantage of low overhead, but This migration mechanism is only applicable to non-relational databases.
发明内容Summary of the invention
本发明实施例公开了一种虚拟节点的数据迁移方法及物理节点,能够实现对物理节点上的关系型数据库的数据进行迁移。The embodiment of the invention discloses a data migration method and a physical node of a virtual node, which can implement data migration of a relational database on a physical node.
第一方面,本申请提供了一种虚拟节点的数据迁移方法,源物理节点和目标物理节点包括但不限于小型机、x86服务器、个人工作站或其他类型的硬件服务器,源物理节点和目标物理节点为分布式数据库系统中的物理节点,在分布式数据库系统中,分布式数据库系统包括多个物理节点,触发数据迁移的方式可以是:元数据节点检测到分布式数据库系统中的多个物理节点在业务运行的过程中不满足负载均衡条件时,触发数据迁移;或者,元数据节点检测到分布式数据库系统中增加新的物理节点,触发数据迁移;或者删除分布式数据库系统中的某个物理节点时,触发数据迁移;或者手动触发分布式数据库系统中某个物理节点上虚拟节点的数据迁移。元数据节点检测到多个物理节点上某个物理节点的虚拟节点需要进行数据迁移时,元数据节点确定源物理节点和目标物理节点,以及源物理节点上待迁移的至少一个虚拟节点,元数据节点可以向源物理节点发送迁移指示消息,迁移指示消息中可携带目标物理节点的标识和源物理节点上待迁移的至少一个虚拟节点的标识,其中,迁移指示消息可以由元数据节点发送,也可以由分布式数据库系统中其他节点发送。源物理节点首先接收迁移指示消息,根据迁移指示消息确定待迁移的至少一个虚拟节点和目标物理节点,其中虚拟节点上的数据的组织形式可以为关系数据库,虚拟节点包括多个业务对象,数据结构信息表示多个业务对象所属的业务表的关联关系,源物理节点根据数据结构信息得到待迁移的至 少一个虚拟机节点所属的所有业务对象,源物理节点将所有业务对象依次迁移到目标物理节点上。上述实施例,源物理节点待迁移的虚拟节点的数据结构信息,根据数据结构信息获取待迁移的业务对象,将所有业务对象迁移到目标物理节点,实现了关系型数据的逻辑迁移。In a first aspect, the present application provides a data migration method for a virtual node, where the source physical node and the target physical node include but are not limited to a minicomputer, an x86 server, a personal workstation, or another type of hardware server, a source physical node, and a target physical node. In the distributed database system, the distributed database system includes multiple physical nodes, and the method of triggering data migration may be: the metadata node detects multiple physical nodes in the distributed database system. The data migration is triggered when the load balancing condition is not met during the running of the service; or the metadata node detects the addition of a new physical node in the distributed database system, triggers data migration; or deletes a certain physical in the distributed database system. When a node is triggered, data migration is triggered; or data migration of a virtual node on a physical node in a distributed database system is manually triggered. When the metadata node detects that a virtual node of a physical node on multiple physical nodes needs to perform data migration, the metadata node determines the source physical node and the target physical node, and at least one virtual node to be migrated on the source physical node, and metadata. The node may send a migration indication message to the source physical node, where the migration indication message may carry the identifier of the target physical node and the identifier of the at least one virtual node to be migrated on the source physical node, where the migration indication message may be sent by the metadata node, Can be sent by other nodes in the distributed database system. The source physical node first receives the migration indication message, and determines at least one virtual node and the target physical node to be migrated according to the migration indication message, where the organization of the data on the virtual node may be a relational database, the virtual node includes multiple service objects, and the data structure The information indicates the association relationship of the service tables to which the multiple service objects belong, and the source physical node obtains the to-be-migrated according to the data structure information. One business object belongs to one virtual machine node, and the source physical node migrates all business objects to the target physical node in turn. In the foregoing embodiment, the data structure information of the virtual node to be migrated by the source physical node acquires the service object to be migrated according to the data structure information, and all the service objects are migrated to the target physical node, thereby implementing logical migration of the relational data.
在本申请的一种可能的实施方式中,获取源物理节点的数据结构信息,以及根据数据结构信息得到待迁移的至少一个虚拟节点所属的业务对象包括:数据结构信息包括数据分片表和业务对象附属表,数据分片表用于存放虚拟节点与业务对象的映射关系,例如存放虚拟节点的标识与业务对象的标识之间的映射关系,业务对象的标识可以为哈希值表示。源物理节点获取至少一个虚拟节点中每个虚拟节点的虚拟节点标识,源物理节点根据预设的数据分片表以虚拟节点标识为索引查询至少一个虚拟节点各自所属的一个或多个业务对象,得到至少一个虚拟节点上所有业务对象,对于所有业务对象中的任意一个业务对象,源物理节点获取业务对象的业务对象标识,根据预设的业务对象附属表以业务对象标识为索引查询业务对象所属的业务表,业务表存放有多条业务记录,可以根据业务对象的标识在业务表重检索业务记录。In a possible implementation manner of the present application, the data structure information of the source physical node is obtained, and the service object to which the at least one virtual node to be migrated belongs according to the data structure information includes: the data structure information includes the data fragment table and the service. The object sub-table, the data fragment table is used to store the mapping relationship between the virtual node and the business object, for example, the mapping between the identifier of the virtual node and the identifier of the business object, and the identifier of the business object may be a hash value. The source physical node obtains the virtual node identifier of each virtual node in the at least one virtual node, and the source physical node queries the virtual node identifier as an index to query one or more service objects to which the at least one virtual node belongs according to the preset data fragmentation table. Obtaining all the business objects on the at least one virtual node. For any one of the business objects, the source physical node obtains the business object identifier of the business object, and queries the business object identifier according to the preset business object subsidiary table. The business table, the business table stores a plurality of business records, and the business records can be retrieved in the business table according to the identification of the business object.
在本申请的一种可能的实施方式中,在源物理节点执行路由切换之前,源物理节点接收客户端的业务访问请求,源物理节点根据业务请求所指示的业务对象执行业务访问请求,源物理节点将业务访问请求记录到业务日志中,将业务日志发送给目标物理节点。其中,源物理节点每生成一个业务日志,可以为业务日志增加时间戳或版本号,以便于目标物理节点区分业务日志的先后顺序。上述实施例,源物理节点在业务对象的迁移过程中,接收到客户端发送的业务访问请求,正常处理业务访问请求,不需要影响用户业务,实现了在线迁移,另外通过源物理节点与目标物理节点的业务日志的同步,使源物理节点和目标物理节点的数据保持同步。In a possible implementation manner of the present application, before the source physical node performs the route switching, the source physical node receives the service access request of the client, and the source physical node performs the service access request according to the service object indicated by the service request, and the source physical node The service access request is recorded in the service log, and the service log is sent to the target physical node. The source physical node adds a timestamp or a version number to the service log, so that the target physical node can distinguish the order of the service logs. In the above embodiment, the source physical node receives the service access request sent by the client during the migration process of the service object, processes the service access request normally, does not affect the user service, implements online migration, and further passes the source physical node and the target physics. The synchronization of the service logs of the nodes keeps the data of the source physical node and the target physical node synchronized.
在本申请的一种可能的实施方式中,还包括:源物理节点在待迁移的至少一个虚拟节点对应的所有业务对象迁移完成的情况下,源物理节点向元数据节点发送迁移完成消息,迁移完成消息用于通知元数据节点待迁移的所有业务对象已成功迁移至目标物理节点,元数据节点接收到迁移完成消息后,向源物理节点发送切换指示消息,源物理节点接收到切换指示消息时,阻塞客户端发起的事务,事务包括多个业务访问请求,事务具有完整性的特点,事务执行完成的条件是多个业务访问中每个业务访问请求必须全部成功执行,如果多个业务访问请求中任意一个或多个业务访问请求没有成功执行,事务就会进行回滚,从而重新执行事务。源物理节点接收到切换指示消息时,如果存在已启动的事务,源物理节点等待已启动的事务成功执行后,源物理节点向元数据节点返回切换准备消息,切换准备消息表示源物理节点作为路由切换的准备,元数据节点收到切换准备消息后,可向客户端发送路由切换消息,路由切换消息可包括待切换的至少一个虚拟节点与目标物理节点的映射关系信息,客户端根据路由切换消息更新路由信息。上述实施例,有效的保证源物理节点和目标物理节点之间的数据的完整性,可靠性高。In a possible implementation manner of the present application, the method includes: the source physical node sends a migration completion message to the metadata node, where the migration of all the service objects corresponding to the at least one virtual node to be migrated is completed, and the migration is performed. The completion message is used to notify the metadata node that all the service objects to be migrated have been successfully migrated to the target physical node. After receiving the migration completion message, the metadata node sends a handover indication message to the source physical node, and the source physical node receives the handover indication message. Blocking client-initiated transactions, the transaction includes multiple business access requests, the transaction has the characteristics of integrity, and the transaction execution is completed under the condition that each service access request in multiple service accesses must be successfully executed, if multiple service access requests If any one or more of the business access requests are not successfully executed, the transaction is rolled back to re-execute the transaction. When the source physical node receives the handover indication message, if there is a started transaction, and the source physical node waits for the started transaction to be successfully executed, the source physical node returns a handover preparation message to the metadata node, and the handover preparation message indicates that the source physical node is used as the route. After the handover is prepared, the metadata node may send a route switch message to the client after receiving the handover preparation message, where the route switch message may include mapping relationship information between the at least one virtual node to be switched and the target physical node, and the client switches the message according to the route. Update routing information. In the above embodiment, the integrity of the data between the source physical node and the target physical node is effectively ensured, and the reliability is high.
在本申请的一种可能的实施方式中,源物理节点以业务对象为粒度将所有业务对象迁移到目标物理节点包括:源物理节点从所述所有业务对象中选择一个待迁移的业务对象,将待迁移的业务对象进行加锁处理,加锁处理后待迁移的业务对象只能进行读操作,不能进行写操作,避免待迁移的业务对象被修改;源物理节点将待迁移的业务对象发送给目标物理节点,源物理节点在确认待迁移的业务对象成功迁移到目标物理节点时,删除待迁移的业务对象。上述实施例,在迁移业务对象的过程中进行业务访问请求的转移,占用资源少。 In a possible implementation manner of the present application, the source physical node migrating all the service objects to the target physical node at the granularity of the service object includes: the source physical node selects a service object to be migrated from all the service objects, and The service object to be migrated is locked, and the service object to be migrated after the lock processing can only be read, and the write operation cannot be performed to prevent the business object to be migrated from being modified. The source physical node sends the service object to be migrated to the service object. On the target physical node, the source physical node deletes the service object to be migrated when the service object to be migrated is successfully migrated to the target physical node. In the foregoing embodiment, the service access request is transferred during the process of migrating the business object, and the occupied resources are small.
在本申请的一种可能的实施方式中,还包括:在业务对象的迁移过程中,源物理节点接收到客户端发送的针对待访问的业务对象的业务访问请求时,源物理节点判断待访问的业务对象是否已迁移到目标物理节点,若为是,源物理节点向客户端返回路由更新消息,其中,路由更新消息中可携带待访问的业务对象的标识和目标物理节点的标识,客户端可根据路由更新消息更新待访问的业务对象所在的物理节点,这样客户端下次针对待访问的业务对象发起业务访问请求时,根据更新后的路由信息直接向目标物理节点发送业务访问请求。In a possible implementation manner of the present application, the method further includes: when the source physical node receives the service access request sent by the client for the service object to be accessed, the source physical node determines to be accessed. Whether the business object has been migrated to the target physical node. If yes, the source physical node returns a routing update message to the client, where the routing update message carries the identifier of the service object to be accessed and the identifier of the target physical node, and the client The physical node where the service object to be accessed is located may be updated according to the routing update message, so that when the client initiates a service access request for the service object to be accessed, the client directly sends a service access request to the target physical node according to the updated routing information.
在本申请的一种可能的实施方式中,还包括:在业务对象迁移完成时,源物理节点向元数据节点发送迁移完成消息,迁移完成消息用于通知元数据节点待迁移的至少一个虚拟节点所属的所有业务对象迁移完成,元数据节点接收到迁移完成消息,向客户端发送路由切换消息,路由切换消息用于指示客户端更新待迁移的至少一个虚拟节点所在的物理节点,此时的路由切换消息中可携带至少一个的虚拟节点的标识与目标物理节点的标识,客户端接收路由切换消息更新路由信息。In a possible implementation manner of the present application, the method further includes: when the business object migration is completed, the source physical node sends a migration completion message to the metadata node, where the migration completion message is used to notify the metadata node to migrate at least one virtual node. After the migration of all the service objects is completed, the metadata node receives the migration completion message and sends a route switch message to the client. The route switch message is used to instruct the client to update the physical node where the at least one virtual node to be migrated is located. The handover message carries at least one identifier of the virtual node and an identifier of the target physical node, and the client receives the routing switch message to update the routing information.
第二方面,本申请提供了一种虚拟节点的迁移方法,包括:目标物理节点接收迁移指示消息;其中,迁移指示消息中可携带源物理节点的标识,目标物理节点接收源物理节点发送的业务对象;目标物理节点确定源物理节点待迁移的业务对象发送完毕时,获取接收到的所有业务对象的数据结构信息,根据数据结构信息重建至少一个虚拟节点。上述实施例,目标物理节点获取迁移过来的业务对象的数据结构信息,根据数据结构信息重构虚拟节点,实现数据的恢复。In a second aspect, the application provides a method for migrating a virtual node, including: receiving, by the target physical node, a migration indication message; wherein the migration indication message carries an identifier of the source physical node, and the target physical node receives the service sent by the source physical node. The target physical node determines that the data object to be migrated by the source physical node is complete, acquires the data structure information of all the received service objects, and reconstructs at least one virtual node according to the data structure information. In the above embodiment, the target physical node acquires the data structure information of the migrated business object, reconstructs the virtual node according to the data structure information, and implements data recovery.
在本申请的一种可能的实施方式中,还包括:目标物理节点接收源物理节点发送的业务日志,根据日志文件中包括的业务访问请求进行业务重演。例如根据业务日志的时间戳或版本号的先后顺序进行业务重演。In a possible implementation manner of the present application, the method further includes: the target physical node receives the service log sent by the source physical node, and performs service replay according to the service access request included in the log file. For example, the service replay is performed according to the time stamp of the service log or the version number.
在本申请的一种可能的实施方式中,还包括:目标物理节点确定源物理节点上的业务日志发送完成时,获取至少一个虚拟节点分配的目标副本物理节点,将存储的业务日志和所述至少一个虚拟节点包括的所有业务对象迁移到目标副本物理节点上,目标副本业务节点接收业务对象,根据接收到的业务对象重组虚拟节点,以及根据接收到的业务日志进行业务重演,为虚拟节点进行备份。需要说明的是,两个或两个以上互为备份的虚拟节点部署时满足物理节点的反亲和性的规则,即互为至少两个的虚拟节点分别位于不同的物理节点,元数据节点根据反亲和性的规则部署目标物理节点的目标副本物理节点,由提高虚拟节点的可靠性。In a possible implementation manner of the present application, the method further includes: when the target physical node determines that the service log transmission on the source physical node is completed, acquiring the target replica physical node allocated by the at least one virtual node, storing the service log and the All the business objects included in the at least one virtual node are migrated to the target replica physical node, the target replica service node receives the service object, reorganizes the virtual node according to the received service object, and performs service replay according to the received service log, and performs the virtual node for the virtual node. Backup. It should be noted that two or more virtual nodes that are mutually backed up are configured to meet the reverse affinity rules of the physical nodes, that is, at least two virtual nodes are located at different physical nodes, and the metadata nodes are based on The anti-affinity rule deploys the target physical node of the target physical node to improve the reliability of the virtual node.
第三方面,本申请提供了一种物理节点,物理节点为源物理节点,源物理节点包括:In a third aspect, the application provides a physical node, where the physical node is a source physical node, and the source physical node includes:
接收模块,用于接收迁移指示消息;a receiving module, configured to receive a migration indication message;
确定模块,用于根据迁移指示消息确定目标物理节点和源物理节点上待迁移的至少一个虚拟节点;a determining module, configured to determine, according to the migration indication message, at least one virtual node to be migrated on the target physical node and the source physical node;
获取模块,用于获取源物理节点自身的数据结构信息,以及根据数据结构信息得到至少一个虚拟节点所属的所有业务对象;An obtaining module, configured to obtain data structure information of the source physical node itself, and obtain all service objects to which at least one virtual node belongs according to the data structure information;
迁移模块,用于以业务对象为粒度将所有业务对象迁移到目标物理节点。A migration module for migrating all business objects to a target physical node at a granularity of business objects.
在一种可能的实施方式中,数据结构信息包括数据分片表和数据附属表;In a possible implementation manner, the data structure information includes a data fragment table and a data attachment table;
获取模块用于:The get module is used to:
根据数据分片表查询至少一个虚拟节点所属的一个或多个业务对象,以及根据业务对象附属表查询多个业务对象中每个业务对象所属的业务表。 Querying one or more business objects to which at least one virtual node belongs according to the data fragmentation table, and querying a business table to which each of the plurality of business objects belongs according to the business object attachment table.
在一种可能的实施方式中,还包括:In a possible implementation manner, the method further includes:
第一访问处理模块,用于接收客户端发送业务访问请求;a first access processing module, configured to receive a client to send a service access request;
执行业务访问请求,以及向客户端返回业务访问响应;Performing a business access request and returning a business access response to the client;
将业务访问请求记录到业务日志中,以及将业务日志发送给目标物理节点。Log the service access request to the service log and send the service log to the target physical node.
在一种可能的实施方式中,还包括:In a possible implementation manner, the method further includes:
事务处理模块,用于在业务对象迁移完成的情况下,向元数据节点发送迁移完成消息;a transaction processing module, configured to send a migration completion message to the metadata node when the business object migration is completed;
接收元数据节点根据迁移完成消息返回的切换指示消息;Receiving a handover indication message returned by the metadata node according to the migration completion message;
接收到切换指示消息时,阻塞客户端发起的事务;Blocking the transaction initiated by the client when receiving the handover indication message;
在已启动的事务成功执行的情况下,向元数据节点返回切换准备消息;其中,切换准备消息用于表示源物理节点完成路由切换准备。In the case that the initiated transaction is successfully executed, a handover preparation message is returned to the metadata node; wherein the handover preparation message is used to indicate that the source physical node completes the route switching preparation.
在一种可能的实施方式中,迁移模块用于:In a possible implementation, the migration module is used to:
从所有业务对象中选择一个待迁移的业务对象,将待迁移的业务对象进行加锁处理;Select a business object to be migrated from all the business objects, and lock the business object to be migrated;
确认待迁移的业务对象成功迁移到目标物理节点时,删除待迁移的业务对象。When the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
在一种可能的实施方式中,还包括:In a possible implementation manner, the method further includes:
第二访问处理模块,用于在业务对象的迁移过程中,接收客户端发送的针对待访问的业务对象的业务访问请求;a second access processing module, configured to receive, during a migration process of the service object, a service access request sent by the client for the service object to be accessed;
判断待访问的业务对象是否已迁移到目标物理节点;Determining whether the business object to be accessed has been migrated to the target physical node;
若为是,向客户端返回路由更新消息;其中,路由更新消息用于指示客户端更新待访问的业务对象所在的物理节点。If yes, return a routing update message to the client; where the routing update message is used to instruct the client to update the physical node where the business object to be accessed is located.
在一种可能的实施方式中,还包括:In a possible implementation manner, the method further includes:
通知模块,用于在业务对象迁移完成时,向元数据节点发送迁移完成消息;其中,迁移完成消息用于表示至少一个虚拟节点所属的所有业务对象迁移完成。The notification module is configured to send a migration completion message to the metadata node when the business object migration is completed; wherein the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
第四方面,本申请提供了一种物理节点,物理节点为目标物理节点,目标物理节点包括:In a fourth aspect, the application provides a physical node, where the physical node is a target physical node, and the target physical node includes:
确定模块,用于接收迁移指示消息,以及根据迁移指示消息确定源物理节点;a determining module, configured to receive a migration indication message, and determine a source physical node according to the migration indication message;
接收模块,用于接收源物理节点发送的业务对象;a receiving module, configured to receive a service object sent by a source physical node;
重建模块,用于在确定源物理节点的业务对象迁移完成时,获取接收到的业务对象的数据结构信息,根据数据结构信息重建虚拟节点。The reconstruction module is configured to acquire data structure information of the received service object when the migration of the business object of the source physical node is completed, and reconstruct the virtual node according to the data structure information.
在一种可能的实施方式中,还包括:In a possible implementation manner, the method further includes:
业务恢复模块,用于接收到源物理节点发送的业务日志,根据业务日志进行业务重演;其中,业务日志包括业务访问请求。The service recovery module is configured to receive a service log sent by the source physical node, and perform service replay according to the service log. The service log includes a service access request.
在一种可能的实施方式中,还包括:In a possible implementation manner, the method further includes:
数据备份模块,用于确定源物理节点上的业务日志发送完成的情况下,确定目标副本物理节点,将存储的业务日志和该虚拟节点迁移到目标副本物理节点上。The data backup module is configured to determine the physical node of the target replica in the case that the service log transmission on the source physical node is completed, and migrate the stored service log and the virtual node to the physical node of the target replica.
附图说明DRAWINGS
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。 In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the description of the prior art will be briefly described below. Obviously, the drawings in the following description are Some embodiments of the present invention may also be used to obtain other drawings based on these drawings without departing from the art.
图1是本发明实施例提供的一种分布式数据库系统的结构示意图;1 is a schematic structural diagram of a distributed database system according to an embodiment of the present invention;
图2是本发明实施例提供的一种虚拟节点的数据迁移方法的流程示意图;2 is a schematic flowchart of a data migration method of a virtual node according to an embodiment of the present invention;
图3是本发明实施例提供的又一种虚拟节点的数据迁移方法的流程示意图;3 is a schematic flowchart of still another method for data migration of a virtual node according to an embodiment of the present invention;
图4a是本发明实施例提供的一种虚拟节点的业务对象的获取方法的流程示意图;4a is a schematic flowchart of a method for acquiring a service object of a virtual node according to an embodiment of the present invention;
图4b是本发明实施例提供的一种物理节点的数据结构的示意图;4b is a schematic diagram of a data structure of a physical node according to an embodiment of the present invention;
图4c是本发明实施例提供的一种虚拟节点的数据迁移方法的原理示意图;4c is a schematic diagram of a principle of a data migration method for a virtual node according to an embodiment of the present invention;
图5是本发明实施例提供的一种物理节点的结构示意图;FIG. 5 is a schematic structural diagram of a physical node according to an embodiment of the present disclosure;
图6是本发明实施例提供的又一种物理节点的结构示意图;FIG. 6 is a schematic structural diagram of still another physical node according to an embodiment of the present disclosure;
图7是本发明实施例提供的又一种物理节点的结构示意图;FIG. 7 is a schematic structural diagram of still another physical node according to an embodiment of the present disclosure;
图8是本发明实施例提供的又一种物理节点的结构示意图。FIG. 8 is a schematic structural diagram of still another physical node according to an embodiment of the present invention.
具体实施方式detailed description
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明的一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is obvious that the described embodiments are a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
参见图1,为本发明实施例提供的基于哈希一致性的分布式数据库系统的结构示意图,在本发明实施例中,分布式数据库系统包括至少一个客户端、元数据节点、物理节点集群和存储网络。至少一个客户端通过IP网络分别与元数据节点和物理节点集群进行通信,其中,客户端与元数据节点或物理节点集群之间的通信接口可以TCP(Transmission Control Protocol,传输控制协议)接口或UDP(User Datagram Protocol,用户数据报协议)接口。元数据节点包括数据均衡装置,元数据节点可以采用独立部署的方式,例如可采用小型机、X86计算机、个人计算机服务器PC server进行部署,也可以和物理节点集群合设。物理节点集群包括多个物理节点,物理节点可以为小型机、X86计算机或个人计算机服务器PC server等,多个物理节点的数据可存储在存储网络的存储介质中,多个物理节点与存储网络之间通过Block IO(块IO)进行读写,即以Block的方式对存储介质进行读写,存储介质可以是HDD(Hard Disk Drive,硬盘驱动器)、SSD(Solid State Drives,固态硬盘)或内存等。FIG. 1 is a schematic structural diagram of a hash-based distributed database system according to an embodiment of the present invention. In the embodiment of the present invention, a distributed database system includes at least one client, a metadata node, a physical node cluster, and Storage network. At least one client communicates with the metadata node and the physical node cluster through the IP network, wherein the communication interface between the client and the metadata node or the physical node cluster may be a TCP (Transmission Control Protocol) interface or UDP. (User Datagram Protocol) interface. The metadata node includes a data equalization device, and the metadata node may be deployed in an independent manner, for example, may be deployed by using a minicomputer, an X86 computer, a personal computer server PC server, or may be combined with a physical node cluster. The physical node cluster includes a plurality of physical nodes, and the physical node may be a minicomputer, an X86 computer, or a personal computer server PC server. The data of the plurality of physical nodes may be stored in a storage medium of the storage network, and the plurality of physical nodes and the storage network are The block is read and written by Block IO (block IO), that is, the storage medium is read and written by Block. The storage medium can be HDD (Hard Disk Drive), SSD (Solid State Drives), or memory. .
其中,元数据节点主要存储了数据库系统的元数据(Metadata),元数据是关于数据的组织、数据域及其关系的信息,简言之,元数据就是用于描述数据的数据。数据均衡装置负责分布式数据库系统整体的分布式管理能力。数据均衡装置除了可以部署在元数据节点中,还可以内置到各个物理节点中。分布式数据库系统的高可靠部署方式可采用双机或集群方式,本发明不限。数据均衡装置主要涉及以下几个方面的功能:Among them, the metadata node mainly stores the metadata (Metadata) of the database system, and the metadata is information about the organization of the data, the data domain and the relationship thereof. In short, the metadata is the data used to describe the data. The data equalization device is responsible for the distributed management capabilities of the distributed database system as a whole. In addition to being deployed in a metadata node, the data equalization device can also be built into various physical nodes. The highly reliable deployment mode of the distributed database system may adopt a dual-machine or a cluster mode, and the present invention is not limited. The data equalization device mainly involves the following functions:
元数据定义:存储和更新虚拟节点与物理节点间的映射关系、虚拟节点的副本定义、权重因子的负载度及权重系数计算方法、偏差系数的配置和存储、虚拟节点的裂变策略等。Metadata definition: store and update the mapping relationship between virtual nodes and physical nodes, copy definition of virtual nodes, load degree and weight coefficient calculation method of weight factors, configuration and storage of deviation coefficients, and fission strategy of virtual nodes.
路由管理:管理业务对象的路由数据,根据虚拟节点与物理节点间的映射关系,调用元数据定义单元接口。Route management: Manage the routing data of the business object, and call the metadata definition unit interface according to the mapping relationship between the virtual node and the physical node.
复制管理:存储和更新虚拟节点的主副本复制关系,并负责复制完整性的管控,调用元数据定义单元接口。Replication management: store and update the primary copy relationship of the virtual node, and is responsible for the management of replication integrity, calling the metadata definition unit interface.
节点监控:监控业务信息和节点资源信息,调用通信服务单元,获取各数据服务节点 的信息,并下发监控指令。Node monitoring: monitoring service information and node resource information, calling communication service unit, and acquiring each data service node Information and issue monitoring instructions.
在线迁移:提供按数据分片为单位的在线迁移能力,支持对业务无影响,保证迁移的高可用性。调用元数据定义接口完成路由和复制关系的变更。Online migration: Provides online migration capability in units of data sharding, which has no impact on the business and ensures high availability of migration. The metadata definition interface is used to complete the routing and replication relationship changes.
数据均衡:根据数据均衡条件,实现物理节点之间的数据均衡。Data equalization: Data balancing between physical nodes is achieved according to data equalization conditions.
元数据同步/持久化:将元数据定义信息同步给各个物理节点、客户端的驱动(Driver)和数据均衡装置的从(Slaver)节点。元数据变更时,需要将变更信息通知到上述节点,并对元数据进行持久化,便于保证数据的高可靠性。Metadata Synchronization/Persistence: Synchronize metadata definition information to each physical node, the driver of the client, and the slave node of the data equalization device. When the metadata is changed, the change information needs to be notified to the above node, and the metadata is persisted to ensure high reliability of the data.
通信服务:提供与周边网元(各个物理节点、客户端的Driver和数据均衡装置的Slaver节点)的网络通信能力。Communication service: Provides network communication capabilities with peripheral network elements (each physical node, the driver of the client, and the slaver node of the data equalization device).
多个物理节点可部署代理Agent,Agent负责与数据均衡装置进行信息交互(例如:上报节点健康性信息、接收数据均衡装置的指令,并提供节点高可用性的自我管理,例如网络异常时角色降级)。A plurality of physical nodes may deploy an agent agent, and the agent is responsible for information interaction with the data equalization device (for example, reporting node health information, receiving instructions of the data equalization device, and providing self-management of node high availability, for example, domain degradation when the network is abnormal) .
另外,在客户端还部署了驱动Driver,Driver中缓存路由信息。这样,客户端可以通过缓存的路由信息完成路由判断,访问对应的物理节点,从而避免数据均衡装置成为业务访问时路由查询的瓶颈。In addition, the driver is also deployed on the client, and the routing information is cached in the driver. In this way, the client can complete the route judgment through the cached routing information and access the corresponding physical node, thereby preventing the data balancing device from becoming a bottleneck of the routing query during service access.
请参见图2,图2是本发明实施例提供的一种虚拟节点的数据迁移方法的流程示意图,该方法包括但不限于如下步骤。Referring to FIG. 2, FIG. 2 is a schematic flowchart of a data migration method of a virtual node according to an embodiment of the present invention, where the method includes but is not limited to the following steps.
S201、元数据节点检测满足迁移条件。S201. The metadata node detects that the migration condition is met.
具体地,元数据节点检测分布式数据库系统中多个物理节点需要进行数据迁移时,确定源物理节点、目标物理节点以及源物理节点上待迁移的至少一个虚拟节点。分布式数据库系统包括多个物理节点,迁移条件为包括但不限于:多个物理节点新增物理节点、删除多个物理节点中的某个物理节点或多个物理节点不满足负载均衡条件,负载均衡条件包括每个物理节点上节点的数量均衡、每个物理节点上的业务量均衡;此时分布式数据库系统需要进行数据迁移,使分布式数据库系统满足负载均衡条件,元数据节点确定源物理节点、目标物理节点以及源物理节点上待迁移的至少一个虚拟节点。Specifically, when the metadata node detects that multiple physical nodes in the distributed database system need to perform data migration, the source physical node, the target physical node, and the at least one virtual node to be migrated on the source physical node are determined. The distributed database system includes multiple physical nodes. The migration conditions include, but are not limited to, adding physical nodes to multiple physical nodes, deleting one physical node of multiple physical nodes, or multiple physical nodes that do not meet load balancing conditions. The equilibrium condition includes the equalization of the number of nodes on each physical node and the balance of traffic on each physical node; at this time, the distributed database system needs to perform data migration, so that the distributed database system satisfies the load balancing condition, and the metadata node determines the source physics. At least one virtual node to be migrated on the node, the target physical node, and the source physical node.
示例性的,分布式数据库系统中包括3个物理节点,3个物理节点分别为物理节点a、物理节点b和物理节点c,3个物理节点中每个物理节点包括4个虚拟节点,当分布式数据库系统中新增一个物理节点d时,元数据节点检测到分布式数据库系统不满足负载均衡条件(负载均衡条件为虚拟节点的数量均衡),元数据节点需要分别从物理节点a、物理节点b和物理节点c中选择一个虚拟节点,将选择的虚拟节点迁移到物理节点d,则元数据节点确定源物理节点为物理节点a、物理节点b和物理节点c,目标物理节点为物理节点d,元数据节点确定物理节点a上待迁移的虚拟节点为所属的4个虚拟节点中的任意一个,物理节点b上待迁移的虚拟节点为所属的4个虚拟节点中的任意一个,物理节点c上待迁移的虚拟节点为待迁移的物理节点中的任意一个。Exemplarily, the distributed database system includes three physical nodes, three physical nodes are physical node a, physical node b, and physical node c, and each of the three physical nodes includes four virtual nodes, when distributed When a physical node d is added to the database system, the metadata node detects that the distributed database system does not satisfy the load balancing condition (the load balancing condition is the number of virtual nodes), and the metadata node needs to be separately from the physical node a and the physical node. b. Select a virtual node in the physical node c and migrate the selected virtual node to the physical node d. The metadata node determines that the source physical node is the physical node a, the physical node b, and the physical node c, and the target physical node is the physical node d. The metadata node determines that the virtual node to be migrated on the physical node a is any one of the four virtual nodes to be migrated, and the virtual node to be migrated on the physical node b is any one of the four virtual nodes that belong to the physical node c. The virtual node to be migrated is any one of the physical nodes to be migrated.
S202、元数据节点向源物理节点下发迁移指示消息。S202. The metadata node sends a migration indication message to the source physical node.
具体地,迁移指示消息用于指示源物理节点进行迁移操作,迁移指示消息可包括目标物理节点的标识和源物理节点上待迁移的至少一个虚拟节点的标识,源物理节点可根据迁移指示消息确定目标物理节点和源物理节点上待迁移的至少一个虚拟节点。Specifically, the migration indication message is used to indicate that the source physical node performs the migration operation, and the migration indication message may include the identifier of the target physical node and the identifier of the at least one virtual node to be migrated on the source physical node, where the source physical node may determine according to the migration indication message. At least one virtual node to be migrated on the target physical node and the source physical node.
S203、源物理节点获取待迁移的至少一个虚拟节点的数据结构信息S203. The source physical node acquires data structure information of at least one virtual node to be migrated.
具体地,虚拟节点上包括多个业务对象,业务对象为根据预设的划分规则划分的对象 的数据集合;例如:以客户划分对象,每个客户的数据集合为一个业务对象;数据结构信息表示物理节点上的数据的结构,数据结构信息具体包括物理节点与虚拟节点的映射关系,虚拟节点与业务对象的映射关系,业务对象与业务表的映射关系,数据结构信息可由元数据节点进行维护。源物理节点根据数据结构信息获得待迁移的至少一个虚拟节点对应的所有业务对象,源物理节点可以向元数据节点获取待迁移的至少一个虚拟节点的数据结构信息。Specifically, the virtual node includes multiple service objects, and the service object is an object that is divided according to a preset division rule. The data set; for example, the object is divided by the client, and the data set of each client is a business object; the data structure information represents the structure of the data on the physical node, and the data structure information specifically includes the mapping relationship between the physical node and the virtual node, and the virtual node The mapping relationship with the business object, the mapping relationship between the business object and the business table, and the data structure information can be maintained by the metadata node. The source physical node obtains all the service objects corresponding to the at least one virtual node to be migrated according to the data structure information, and the source physical node may acquire the data structure information of the at least one virtual node to be migrated to the metadata node.
参见图4a,在本实施例的一种可能的实施方式中,所述源物理节点获取所述至少一个虚拟节点中每个虚拟节点的数据结构信息,以及根据所述数据结构信息得到所有业务对象包括:Referring to FIG. 4a, in a possible implementation manner of this embodiment, the source physical node acquires data structure information of each virtual node in the at least one virtual node, and obtains all service objects according to the data structure information. include:
S401、获取待迁移的至少一个虚拟节点的虚拟节点标识。S401. Obtain a virtual node identifier of at least one virtual node to be migrated.
具体的,物理节点上的数据可分为四个层次,从上到下分别为虚拟节点、业务对象、业务表和业务记录,一个虚拟节点关联多个业务对象,一个业务对象关联多个业务表,一个业务表存放多个业务记录;业务对象表示根据预先定义规则划分的对象所属的数据集合,例如:根据不同的客户划分对象,每个客户为一个业务对象;根据业务类型划分对象,每种业务对象为一个业务对象;根据不同的订单划分业务对象,每个订单为一个业务对象;业务表用于存储具体的业务记录。元数据节点上可维护数据结构信息,数据结构信息表示物理节点的数据结构,数据结构信息包括数据分片表,业务对象根表和业务对象附属表;数据分片表存放表示虚拟节点与业务对象之间的映射关系的记录,映射关系可以用虚拟节点标识与业务对象的标识进行关联来表示;业务对象根表存放业务对象的基本信息,例如:在业务对象为某个客户的数据集合时,业务对象根表中存放客户的个人信息;业务对象附属表存放表示业务对象与业务表之间的映射关系。Specifically, the data on the physical node can be divided into four levels, from top to bottom, respectively, a virtual node, a business object, a service table, and a business record, one virtual node is associated with multiple business objects, and one business object is associated with multiple business tables. a business table stores a plurality of business records; the business object represents a data set to which the objects are divided according to a predefined rule, for example, the objects are divided according to different customers, and each customer is a business object; the objects are divided according to the service type, each The business object is a business object; the business objects are divided according to different orders, each order is a business object; the business table is used to store specific business records. The data structure information can be maintained on the metadata node, and the data structure information represents the data structure of the physical node. The data structure information includes a data fragmentation table, a business object root table, and a business object subsidiary table; the data fragmentation table storage represents the virtual node and the business object. A record of the mapping relationship between the virtual node identifier and the identifier of the business object; the business object root table stores basic information of the business object, for example, when the business object is a data set of a customer, The business object root table stores the customer's personal information; the business object subsidiary table storage represents the mapping relationship between the business object and the business table.
S402、根据虚拟节点标识检索预设的数据分片表得到对应的所有业务对象的业务对象标识。S402. Retrieve the preset data fragment table according to the virtual node identifier to obtain a service object identifier of all the corresponding service objects.
具体的,源物理节点从元数据节点获取数据分片表,以虚拟节点标识检索数据分片表得到待迁移的至少一个虚拟节点所属的所有业务对象的业务对象标识。Specifically, the source physical node obtains the data fragmentation table from the metadata node, and retrieves the data fragmentation table by using the virtual node identifier to obtain the business object identifier of all the business objects to which the at least one virtual node to be migrated belongs.
S403、根据业务对象标识检索预设的业务对象附属表得到业务表。S403. Retrieve a preset business object subsidiary table according to the business object identifier to obtain a business table.
具体的,业务对象附属表定义了业务对象与业务表之间的映射关系,源物理节点根据业务对象标识检索预设的业务对象附属表得到业务表。Specifically, the business object subsidiary table defines a mapping relationship between the business object and the business table, and the source physical node retrieves the preset business object subsidiary table according to the business object identifier to obtain the business table.
S404、根据业务对象标识在业务表中检索得到业务记录。S404. Retrieve the business record in the business table according to the business object identifier.
示例性的,参见图4b所示,假设待迁移的至少一个虚拟节点为虚拟节点1,源物理节点获取虚拟节点1的虚拟节点标识,根据该虚拟节点标识检索预设的数据分片表得到虚拟节点1关联业务对象11、业务对象12、…、业务对象1m的业务对象标识,然后源物理节点根据业务对象标识检索预设的业务对象附属表得到关联的多个业务表,以业务对象11为例,检索得到业务对象11的业务对象标识关联有业务表111、业务表112、…、业务表11k;接下来源物理节点可根据业务对象的业务对象标识在业务表中检索到对应的业务记录,以业务表111为例,业务表111中存放的业务记录1111、业务记录1112、…、业务记录111h。For example, as shown in FIG. 4b, it is assumed that at least one virtual node to be migrated is a virtual node 1, and the source physical node acquires a virtual node identifier of the virtual node 1, and retrieves a preset data fragment table according to the virtual node identifier to obtain a virtual The node 1 associates the business object identifier of the business object 11, the business object 12, ..., the business object 1m, and then the source physical node retrieves the preset business object subsidiary table according to the business object identifier to obtain a plurality of related business tables, and the business object 11 is For example, the business object identifier of the searched business object 11 is associated with the business table 111, the business table 112, ..., the business table 11k; then the source physical node can retrieve the corresponding business record in the business table according to the business object identifier of the business object. Taking the service table 111 as an example, the business record 1111, the business record 1112, ..., the business record 111h stored in the service table 111.
S204、源物理节点向目标物理节点发送首个业务对象C1。S204. The source physical node sends the first service object C1 to the target physical node.
具体的,源物理节点确定待迁移的至少一个虚拟节点所属的所有业务对象后,从所有业务对象中选取一个业务对象发送给目标物理节点。其中,源物理节点设置一个记录业务对象的迁移状态的记录表,在初始状态下,所有业务对象的迁移状态为未迁移,在某个业务对象成功迁移到目标物理节点时,源物理节点将该业务对象的迁移状态变更为已迁移。 Specifically, after the source physical node determines all the service objects to which the at least one virtual node belongs to be migrated, one of the service objects is selected and sent to the target physical node. The source physical node sets a record table for recording the migration status of the service object. In the initial state, the migration status of all service objects is not migrated. When a service object is successfully migrated to the target physical node, the source physical node will The migration status of the business object is changed to migrated.
S205、源物理节点接收到客户端发送的业务访问请求。S205. The source physical node receives the service access request sent by the client.
具体的,业务访问请求的操作对象为S203中所有业务对象中的一个,业务访问请求的操作类型可以是读操作或写操作。Specifically, the operation object of the service access request is one of all the service objects in S203, and the operation type of the service access request may be a read operation or a write operation.
S206、源物理节点生成业务日志。S206. The source physical node generates a service log.
具体的,业务日志中包括业务访问请求,源物理节点还可以在业务日志中增加时间戳或版本号,便于目标物理节点区分业务访问请求的先后顺序。Specifically, the service log includes a service access request, and the source physical node may further add a timestamp or a version number to the service log, so that the target physical node can distinguish the order of service access requests.
S207、源物理节点向客户端返回业务访问响应。S207. The source physical node returns a service access response to the client.
具体的,源物理节点根据业务访问请求执行相应的操作,向客户端返回业务访问响应,例如:业务访问请求的操作类型为读操作,业务访问响应中携带读取的数据,业务访问请求的操作类型为写操作时,业务访问响应中携带写状态信息,写状态信息用于表示写操作是否执行成功。Specifically, the source physical node performs a corresponding operation according to the service access request, and returns a service access response to the client, for example, the operation type of the service access request is a read operation, the service access response carries the read data, and the service access request is operated. When the type is a write operation, the service access response carries write status information, and the write status information is used to indicate whether the write operation is successful.
S208、源物理节点向目标物理节点发送业务日志。S208. The source physical node sends a service log to the target physical node.
具体的,源物理节点向目标物理节点发送业务日志,目标物理节点对接收到的业务日志进行缓存。需要说明的是,源物理节点可以在每接收到一个业务访问请求生成业务日志,将业务日志发送给目标物理节点,也可以是源物理节点接收到一个业务访问请求生成业务日志,将生成的业务日志进行缓存,在所有业务对象迁移完成后,将缓存的业务日志全部发送给目标物理节点。Specifically, the source physical node sends a service log to the target physical node, and the target physical node caches the received service log. It should be noted that the source physical node may generate a service log every time a service access request is received, and send the service log to the target physical node, or the source physical node receives a service access request to generate a service log, and the generated service is generated. The log is cached. After all the business objects are migrated, all the cached service logs are sent to the target physical node.
S209、源物理节点向目标物理节点发送最后一个业务对象。S209. The source physical node sends the last service object to the target physical node.
具体的,待迁移的至少一个虚拟节点对应的业务对象的数量为n,源物理节点可以对已迁移的业务对象进行计数,每迁移一个业务对象计数值加1,在计数值等于所有业务对象的数量n时,表明所有业务对象迁移成功。Specifically, the number of the service objects corresponding to the at least one virtual node to be migrated is n, and the source physical node may count the migrated service objects, and the value of each service object is incremented by one, and the count value is equal to all the service objects. When the quantity is n, it indicates that all business objects migrate successfully.
S210、虚拟节点的重建和业务重演。S210, virtual node reconstruction and service replay.
具体的,目标物理节点接收源物理节点发送的业务对象,源物理节点在待迁移的所有业务对象发送完毕后,可以先向目标物理节点发送迁移完成消息,迁移完成消息表示源物理节点上待迁移的业务对象全部发送完毕;目标物理节点在确定源物理节点上待迁移的所有业务对象发送完毕后,可以从元数据节点上获取源物理节点的数据结构信息,目标物理节点根据数据结构信息对接收到的所有业务对象进行重组,得到该至少一个虚拟节点。同时,目标物理节点可在源物理节点的指示或元数据节点的指示后根据缓存的业务日志进行业务重演,目标物理节点根据日志文件中携带的时间戳或版本号进行日志重演,使目标物理节点上业务访问请求的执行顺序与源物理节点保持一致。其中在进行业务重演的过程中,如果业务访问请求的操作类型为读操作,可以跳过该业务访问请求。例如:目标物理节点缓存的业务日志包括:业务日志1、业务日志2、业务日志3和业务日志4;业务日志1中记录的业务访问请求为修改用户信息,记录的版本号为1.0;业务日志2中记录的业务访问请求为修改计费类型,记录的版本号为1.1;业务日志3记录的业务访问请求为读取消费记录,记录的版本号为1.2;业务日志4中记录的业务访问请求为修改用户余额,记录的版本号为1.3。假设版本号的记录规则为根据先后顺序递增,版本号大的业务日志比版本号小的业务日志新,目标物理节点在根据上述的4个业务日志进行业务重演时,依照业务日志1、业务日志2、业务日志3和业务日志4的顺序进行业务重演。Specifically, the target physical node receives the service object sent by the source physical node, and after the source physical node sends all the service objects to be migrated, the source physical node may send a migration completion message to the target physical node, and the migration completion message indicates that the source physical node is to be migrated. All the service objects are sent; after the target physical node determines that all the service objects to be migrated on the source physical node are sent, the data structure information of the source physical node can be obtained from the metadata node, and the target physical node receives the data according to the data structure information. All the business objects that arrive are reorganized to obtain the at least one virtual node. At the same time, the target physical node may perform service replay according to the cached service log after the indication of the source physical node or the indication of the metadata node, and the target physical node performs log replay according to the timestamp or version number carried in the log file to make the target physical node The execution order of the upper service access request is consistent with the source physical node. In the process of performing service replay, if the operation type of the service access request is a read operation, the service access request may be skipped. For example, the service log cached by the target physical node includes: service log 1, service log 2, service log 3, and service log 4. The service access request recorded in service log 1 is modified user information, and the version number of the record is 1.0; The service access request recorded in 2 is the modified charging type, and the recorded version number is 1.1; the service access request recorded in the service log 3 is the read consumption record, and the recorded version number is 1.2; the service access request recorded in the service log 4 To modify the user balance, the version number of the record is 1.3. It is assumed that the record number of the version number is incremented according to the sequence, and the service log with a larger version number is newer than the service log with a smaller version number. When the target physical node performs service replay according to the above four service logs, the service log 1 and the service log are used. 2. The service replay is performed in the order of service log 3 and service log 4.
S211、源物理节点向元数据节点发送迁移完成消息。S211. The source physical node sends a migration complete message to the metadata node.
具体的,源物理节点在待迁移的至少一个虚拟节点所属的所有业务对象迁移完成时, 向元数据节点发送迁移完成消息,迁移完成消息表示源物理节点上待迁移的所有业务对象迁移完毕。Specifically, when the source physical node migrates all the service objects to which the at least one virtual node to be migrated belongs, A migration completion message is sent to the metadata node. The migration completion message indicates that all the business objects to be migrated on the source physical node are migrated.
S212、元数据节点向源物理节点下发切换指示消息。S212. The metadata node sends a handover indication message to the source physical node.
其中,切换指示消息用于指示源物理节点执行路由切换。The handover indication message is used to indicate that the source physical node performs route switching.
S213、源物理节点阻塞请求的事务,等待已启动的事务执行完成。S213. The source physical node blocks the requested transaction, and waits for the started transaction to complete.
具体的,源物理节点接收到切换指示消息之后,阻塞客户端请求的事务,事务包括多个业务访问请求,事务具有完整性的特点,在事务包括的多个业务访问请求全部执行成功后,事务才视为执行成功,当事务包括的任意一个或多个业务操作请求没有执行成功时,需要对事务进行回退操作,重新执行事务包括的多个业务访问请求;源物理节点判断存在已启动的事务,且已启动的事务未成功执行时,等待已启动的事务执行完成。Specifically, after receiving the handover indication message, the source physical node blocks the transaction requested by the client, and the transaction includes multiple service access requests, and the transaction has the characteristics of integrity. After all the service access requests included in the transaction are successfully executed, the transaction is completed. It is considered that the execution is successful. When any one or more business operation requests included in the transaction are not successfully executed, the transaction needs to be rolled back, and multiple service access requests included in the transaction are re-executed; the source physical node determines that there is a startup. A transaction, and a transaction that has started is not successfully executed, waiting for the execution of the started transaction to complete.
S214、源物理节点向元数据节点返回切换准备消息。S214. The source physical node returns a handover preparation message to the metadata node.
具体的,源物理节点在已启动的事务执行完成后,向元数据节点返回切换准备消息,切换准备消息表示源物理节点已经完成路由切换的准备。Specifically, after the execution of the started transaction is completed, the source physical node returns a handover preparation message to the metadata node, where the handover preparation message indicates that the source physical node has completed the route switching preparation.
在本申请的一种可能的实施方式中,源物理节点可以在待迁移的至少一个虚拟节点所属的所有业务节点发送完成后,阻塞客户端请求的事务,源物理节点在确定已启动的事务执行完成后,向元数据节点发送切换准备消息,切换准备消息用于表示源物理节点已作好路由切换的准备,以确保事务的完整性。In a possible implementation manner of the present application, the source physical node may block the transaction requested by the client after all the service nodes to which the at least one virtual node to be migrated is sent, and the source physical node determines to perform the executed transaction. After completion, the handover preparation message is sent to the metadata node, and the handover preparation message is used to indicate that the source physical node is ready for route switching to ensure the integrity of the transaction.
其中,源物理节点可以向目标物理节点发送切换准备消息,目标物理节点在接收切换准备消息之后,再根据缓存的业务日志进行业务重演,目标物理节点在业务重演完成后,可以从元数据节点获取源物理节点的副本物理节点,目标物理节点将缓存的业务日志发送个副本物理节点,副本物理节点根据业务日志对至少一个虚拟节点进行业务重演。The source physical node may send a handover preparation message to the target physical node, and after receiving the handover preparation message, the target physical node performs service replay according to the cached service log, and the target physical node may obtain the information from the metadata node after the service replay is completed. A physical node of the source physical node, the target physical node sends the cached service log to the physical node of the replica, and the physical node of the replica performs service replay on at least one virtual node according to the service log.
S215、元数据节点向客户端发送路由切换消息。S215. The metadata node sends a route switching message to the client.
具体的,元数据节点接收到切换准备消息时,确认源物理节点作为路由切换准备,元数据节点获取目标物理节点的标识和待迁移的至少一个虚拟节点的标识,元数据节点向客户端发送路由切换消息,路由切换消息用于指示客户端更新至少一个虚拟节点所在的物理节点,路由切换消息中可携带待迁移的至少一个虚拟节点的标识和目标物理节点的标识。Specifically, when receiving the handover preparation message, the metadata node confirms that the source physical node is prepared as a route switch, and the metadata node acquires the identifier of the target physical node and the identifier of the at least one virtual node to be migrated, and the metadata node sends a route to the client. The switching message is used to indicate that the client updates the physical node where the at least one virtual node is located, and the routing switch message carries the identifier of the at least one virtual node to be migrated and the identifier of the target physical node.
S216、客户端向目标物理节点发送业务访问请求。S216. The client sends a service access request to the target physical node.
具体的,客户端接收路由切换消息,将至少一个虚拟节点与源物理节点的映射关系变更为至少一个虚拟节点与目标物理节点的映射关系,客户端向至少一个虚拟节点所属的业务对象发送业务对象请求时,根据变更后的映射关系向目标物理节点发送业务访问请求。Specifically, the client receives the routing switch message, and changes the mapping relationship between the at least one virtual node and the source physical node to the mapping relationship between the at least one virtual node and the target physical node, and the client sends the service object to the service object to which the at least one virtual node belongs. When requested, the service access request is sent to the target physical node according to the changed mapping relationship.
S217、目标物理节点向客户端返回业务访问响应。S217. The target physical node returns a service access response to the client.
具体的,目标物理节点接收业务访问请求,根据业务访问请求执行相应的操作,向客户端返回业务访问响应。Specifically, the target physical node receives the service access request, performs a corresponding operation according to the service access request, and returns a service access response to the client.
S218、元数据节点向源物理节点发送下线通知消息。S218. The metadata node sends an offline notification message to the source physical node.
具体的,下线通知消息用于对源物理节点中至少一个虚拟节点进行清理,下线通知消息中可携带至少一个虚拟节点的标识。Specifically, the offline notification message is used to clean at least one virtual node in the source physical node, and the offline notification message may carry the identifier of the at least one virtual node.
参见图4c所示,下面就一个具体的实施例一种虚拟节点的数据迁移方法进行说明:Referring to FIG. 4c, a data migration method of a virtual node is described below in a specific embodiment:
在初始条件下,分布式数据库系统包括4个物理节点,分别为物理节点1、物理节点2、物理节点3和物理节点4,每个物理节点包括12个虚拟节点,每个虚拟节点部署有1个副本,下面括号中编号为虚拟节点的表换,相同编号的两个虚拟节点互为主本和副本,也可以称为 主节点和备节点(或主分片或备分片),物理节点与虚拟节点的映射关系如下:Under the initial conditions, the distributed database system includes four physical nodes, which are physical node 1, physical node 2, physical node 3, and physical node 4. Each physical node includes 12 virtual nodes, and each virtual node has 1 deployed. Copy, the number in the brackets below is the table of the virtual node, the two virtual nodes of the same number are the master and the copy, which can also be called The primary node and the standby node (or primary or backup fragment), the mapping relationship between the physical node and the virtual node is as follows:
物理节点1:(1,2,3,4,5,6),(9,12,14,17,19,22)Physical node 1: (1, 2, 3, 4, 5, 6), (9, 12, 14, 17, 19, 22)
物理节点2:(7,8,9,10,11,12),(1,4,15,18,20,23)Physical node 2: (7, 8, 9, 10, 11, 12), (1, 4, 15, 18, 20, 23)
物理节点3:(13,14,15,16,17,18),(2,5,7,10,21,24)Physical node 3: (13,14,15,16,17,18), (2,5,7,10,21,24)
物理节点4:(19,20,21,22,23,24),(3,6,8,11,13,16)Physical node 4: (19, 20, 21, 22, 23, 24), (3, 6, 8, 11, 13, 16)
随着业务发展,当前的4个物理节点负荷过重,计划扩展一个新的物理节点5。元数据节点的数据均衡子系统计算出需要分别迁移物理节点1.虚拟节点1、物理节点2.虚拟节点7、物理节点3.虚拟节点13、物理节点4.虚拟节点19到物理节点5。依次遍历物理节点1.虚拟节点1、物理节点2.虚拟节点7、物理节点3.虚拟节点13、物理节点4.虚拟节点19。物理节点1-4为源物理节点,物理节点5为目标物理节点。As the business develops, the current four physical nodes are overloaded and plans to expand a new physical node5. The data equalization subsystem of the metadata node calculates that it is necessary to separately migrate the physical node 1. virtual node 1, physical node 2. virtual node 7, physical node 3. virtual node 13, physical node 4. virtual node 19 to physical node 5. The physical node 1. virtual node 1, physical node 2. virtual node 7, physical node 3. virtual node 13, physical node 4. virtual node 19 are sequentially traversed. Physical nodes 1-4 are source physical nodes, and physical nodes 5 are target physical nodes.
数据分片表的结构定义为The structure of the data fragmentation table is defined as
{{
Data_node_id int,//物理节点IDData_node_id int, / / physical node ID
Vnode_id int,//虚拟节点IDVnode_id int, / / virtual node ID
startHashkey int,//记录虚拟节点的开始hash值startHashkey int, / / record the starting hash value of the virtual node
endHashkey int,//记录虚拟节点的结束hash值endHashkey int, / / record the end hash value of the virtual node
is_primary bool//是否主本Is_primary bool// whether this is the main
}}
以针对物理节点1的虚拟节点1的迁移为例:物理节点1通过数据分片表中虚拟节点标识Vnode_id=1为索引进行条件检索,获取虚拟节点1下的全部业务对象的标识,业务对象的标识可用Hash值表示,全部业务对象的标识为一个Hash值范围列表,假设全部业务对象的hash值范围列表为(O1,O2,O3,O4,O5);然后物理节点1以每个业务对象的Hash值为条件遍历业务对象根表,获取业务对象根表信息,以及根据预设的业务对象附属表以业务对象的Hash值检索关联的业务表,业务表中存放有多个业务记录,物理节点1在确定待迁移的虚拟节点1所属的业务对象后,将虚拟节点1的业务对象迁移到物理节点5,形成基线复制。迁移过程中,如出现异常,则重新进行迁移,清理物理节点5.虚拟节点1,由物理节点1.虚拟节点1重新进行迁移。在业务对象的迁移期间,客户端可继续访问物理节点1.虚拟节点1,物理节点节点1.虚拟节点1执行业务访问请求,并返回业务访问响应,物理节点1.虚拟节点1将生成的业务日志发送给物理节点5,物理节点5缓存业务日志;物理节点1.虚拟节点1在全部的业务对象迁移完成后,物理节点5根据缓存业务日志的业务重演。物理节点1在确定全部的业务对象发送完毕后,阻塞客户端发起的事务,由于事务完整性的特点,物理节点1等待已启动的事务执行完毕后,向元数据节点发送切换准备消息,元数据节点接收切换准备消息后,向客户端发送路由切换消息,路由切换消息用于指示客户端将虚拟节点1与物理节点1的映射关系更新为虚拟节点1与物理节点5的映射关系。物理节点2的寻节点7、物理节点3的虚拟节点13和物理节点4的虚拟节点19的迁移过程可参照上述的描述,此处不再赘述。图4c中灰色的方块表示已迁移的虚拟节点,在虚拟节点1、7、13和19迁移到物理节点5时,需要在物理节点5上部署副本,部署副本时遵循反亲和性的规则,即主本和副本不能位于相同的物理节点上。Taking the migration of the virtual node 1 for the physical node 1 as an example: the physical node 1 performs conditional retrieval by using the virtual node identifier Vnode_id=1 in the data fragmentation table as an index, and obtains the identifier of all the business objects under the virtual node 1, and the business object The identifier can be represented by a hash value. The identifier of all business objects is a list of hash value ranges. It is assumed that the hash value range of all business objects is (O1, O2, O3, O4, O5); then physical node 1 is for each business object. The Hash value traverses the root table of the business object, obtains the root table information of the business object, and retrieves the associated business table by using the hash value of the business object according to the preset business object subsidiary table, where the business table stores multiple business records and physical nodes. After the service object to which the virtual node 1 to be migrated belongs is determined, the service object of the virtual node 1 is migrated to the physical node 5 to form a baseline replication. During the migration process, if an exception occurs, re-migrate and clean the physical node 5. Virtual node 1 is re-migrated by physical node 1. Virtual node 1. During the migration of the business object, the client can continue to access the physical node 1. Virtual node 1, physical node node 1. Virtual node 1 performs a service access request and returns a service access response, physical node 1. The service that virtual node 1 will generate The log is sent to the physical node 5, and the physical node 5 caches the service log. The physical node 1. After the migration of all the business objects is completed, the physical node 5 replays the service according to the cached service log. After determining that all the service objects are sent, the physical node 1 blocks the transaction initiated by the client. Due to the characteristics of the transaction integrity, the physical node 1 waits for the started transaction to complete, and then sends a handover preparation message to the metadata node. After receiving the handover preparation message, the node sends a routing switch message to the client, where the routing switch message is used to instruct the client to update the mapping relationship between the virtual node 1 and the physical node 1 to the mapping relationship between the virtual node 1 and the physical node 5. For the migration process of the finder node 7 of the physical node 2, the virtual node 13 of the physical node 3, and the virtual node 19 of the physical node 4, reference may be made to the above description, and details are not described herein again. The gray squares in Figure 4c represent migrated virtual nodes. When virtual nodes 1, 7, 13, and 19 are migrated to physical node 5, replicas need to be deployed on physical nodes 5, and the rules for anti-affinity are followed when deploying replicas. That is, the master and the copy cannot be on the same physical node.
在图2所描述的方法中,源物理节点待迁移的虚拟节点的数据结构信息,根据数据结构信息获取待迁移的业务对象,将所有业务对象迁移到目标物理节点,实现了关系型数据 的逻辑迁移。In the method described in FIG. 2, the data structure information of the virtual node to be migrated by the source physical node acquires the business object to be migrated according to the data structure information, migrates all the business objects to the target physical node, and implements relational data. Logical migration.
请参见图3,图3是本发明实施例提供的又一种虚拟节点的数据迁移方法的流程示意图,该方法包括但不限于如下步骤。Referring to FIG. 3, FIG. 3 is a schematic flowchart of still another method for data migration of a virtual node according to an embodiment of the present invention, where the method includes but is not limited to the following steps.
S301、元数据节点检测到满足迁移条件。S301. The metadata node detects that the migration condition is met.
具体地,分布式数据库系统包括多个物理节点,迁移条件包括但不限于新增物理节点、删除物理节点、不满足负载均衡条件或不满足数据均衡条件等。Specifically, the distributed database system includes multiple physical nodes, and the migration conditions include, but are not limited to, adding a physical node, deleting a physical node, not satisfying a load balancing condition, or failing to satisfy a data balancing condition.
S302、元数据节点与客户端之间同步元数据。S302: Synchronize metadata between the metadata node and the client.
其中,元数据节点与客户端之间需要定期的同步元数据,元数据包括但不限于物理节点与虚拟节点的映射关系、虚拟节点的主本和副本的存储位置、数据均衡条件等。The metadata synchronization parameter is required between the metadata node and the client. The metadata includes but is not limited to the mapping relationship between the physical node and the virtual node, the storage location of the virtual node and the copy, and the data balancing condition.
S303、元数据节点下发迁移指示消息。S303. The metadata node sends a migration indication message.
具体地,元数据节点将迁移指示消息下发给源物理节点与目标物理节点,触发源物理节点上业务对象的迁移。同时,元数据节点下发迁移指示消息给源物理节点的各个副本物理节点。Specifically, the metadata node sends the migration indication message to the source physical node and the target physical node, and triggers migration of the service object on the source physical node. At the same time, the metadata node sends a migration indication message to each replica physical node of the source physical node.
S304、源物理节点获取待迁移的至少一个虚拟节点的数据结构信息。S304. The source physical node acquires data structure information of at least one virtual node to be migrated.
具体地,虚拟节点上包括多个业务对象,业务对象为根据预设的划分规则划分的对象的数据集合,例如,以客户划分对象,每个客户的数据集合为一个业务对象;数据结构信息表示物理节点上的数据的结构,数据结构信息具体包括物理节点与虚拟节点的映射关系,虚拟节点与业务对象的映射关系,业务对象与业务表的映射关系,数据结构信息可由元数据节点进行维护。源物理节点根据数据结构信息获得待迁移的至少一个虚拟节点对应的所有业务对象,源物理节点可以向元数据节点获取待迁移的至少一个虚拟节点的数据结构信息。Specifically, the virtual node includes multiple service objects, and the business object is a data set of objects divided according to a preset division rule. For example, the object is divided by a client, and each customer's data set is a business object; the data structure information is represented. The structure of the data on the physical node, the data structure information specifically includes the mapping relationship between the physical node and the virtual node, the mapping relationship between the virtual node and the business object, the mapping relationship between the business object and the service table, and the data structure information can be maintained by the metadata node. The source physical node obtains all the service objects corresponding to the at least one virtual node to be migrated according to the data structure information, and the source physical node may acquire the data structure information of the at least one virtual node to be migrated to the metadata node.
其中,在迁移期间,暂停源物理节点与副本物理节点之间的主从复制。暂停主从复制的原因是:在迁移过程中,仍然支持在线业务并发,同一个虚拟节点迁移前后的业务数据会访问不同的物理节点(源物理节点和目标物理节点),迁移期间,副本数据与主数据保持一致较为困难。Among them, during the migration, the master-slave replication between the source physical node and the replica physical node is suspended. The reason for suspending master-slave replication is that during the migration process, online service concurrency is still supported. The service data before and after the migration of the same virtual node accesses different physical nodes (source physical node and target physical node). During the migration, the replica data and It is more difficult to keep the master data consistent.
S305、源物理节点将待迁移的业务对象进行加锁处理。S305. The source physical node performs locking processing on the service object to be migrated.
具体地,源物理节点从所有业务对象中选取一个待迁移的业务对象,将待迁移的业务对象进行加锁处理,加锁处理后,待迁移的业务对象不可修改,即对待迁移的业务对象的操作只能为读操作,不能为写操作。Specifically, the source physical node selects a business object to be migrated from all the business objects, and locks the business object to be migrated. After the lock processing, the business object to be migrated cannot be modified, that is, the business object to be migrated. The operation can only be a read operation and cannot be a write operation.
S306、源物理节点向目标物理节点发送待迁移的业务对象。S306. The source physical node sends the service object to be migrated to the target physical node.
具体的,源物理节点从待迁移的所有业务对象中选择一个业务对象迁移到目标物理节点。Specifically, the source physical node selects one business object from all the business objects to be migrated to migrate to the target physical node.
S307、源物理节点删除待迁移的业务对象。S307. The source physical node deletes the service object to be migrated.
具体的,源物理节点在待迁移的业务对象发送给目标物理节点之后,删除待迁移的业务对象。Specifically, the source physical node deletes the service object to be migrated after the service object to be migrated is sent to the target physical node.
S308、客户端向源物理节点发送业务访问请求。S308. The client sends a service access request to the source physical node.
具体的,在业务对象的迁移过程中,客户端向源物理节点发送针对待访问的业务对象的业务访问请求,业务访问请求访问的业务对象为所有的业务对象中的一个。Specifically, in the migration process of the business object, the client sends a service access request to the source physical node for the business object to be accessed, and the business object accessed by the service access request is one of all the business objects.
S309、源物理节点判断待访问的业务对象是否已迁移。S309. The source physical node determines whether the service object to be accessed has been migrated.
具体的,源物理节点维护一个业务对象的状态表,状态表中存储用于表示业务对象的 状态的表项,业务对象的状态分为已迁移和未迁移,源物理节点可根据预先存储的状态表查询待访问的业务对象的状态为已迁移还是未迁移,如果待访问的业务对象的状态为未迁移,源物理节点直接响应业务访问请求,向客户端返回业务访问响应;如果待访问的业务对象的状态为已迁移,执行S310。Specifically, the source physical node maintains a state table of a business object, and the state table stores a service object for representing the business object. The state of the service object is classified as migrated and not migrated. The source physical node can query whether the status of the service object to be accessed is migrated or not migrated according to the pre-stored state table. If the source physical node directly responds to the service access request, the service access response is returned to the client. If the status of the service object to be accessed is migrated, S310 is performed.
S310、源物理节点向客户端返回路由变更消息。S310. The source physical node returns a route change message to the client.
具体的,源物理节点在待访问的业务对象已迁移的情况下,向客户端返回路由变更消息,路由变更消息表示待访问的业务对象所在的物理节点发生变更,路由更新消息可携带目标物理节点的标识。Specifically, the source physical node returns a route change message to the client when the to-be-accessed service object has been migrated, and the route change message indicates that the physical node where the service object to be accessed is changed, and the route update message may carry the target physical node. Logo.
S311、客户端再次向目标物理节点发送业务访问请求。S311. The client sends a service access request to the target physical node again.
具体的,客户端接收路由更新消息,根据路由更新消息获得目标物理节点的标识,再次向目标物理节点发送业务访问请求。Specifically, the client receives the routing update message, obtains the identifier of the target physical node according to the routing update message, and sends a service access request to the target physical node again.
S312、客户端接收目标物理节点返回的业务访问响应。S312. The client receives a service access response returned by the target physical node.
具体的,目标物理节点接收客户端发送的针对待访问的业务对象发送的业务访问请求,由于待访问的业务对象已成功迁移到目标物理节点,目标物理节点执行业务访问请求,向客户端返回业务访问响应,客户端接收目标物理节点返回的业务访问响应。Specifically, the target physical node receives the service access request sent by the client for the service object to be accessed, and the target physical node performs the service access request and returns the service to the client because the service object to be accessed has been successfully migrated to the target physical node. In response to the response, the client receives the service access response returned by the target physical node.
S313、源物理节点向元数据节点发送迁移完成消息。S313. The source physical node sends a migration complete message to the metadata node.
具体的,源物理节点确定待迁移的所有业务对象迁移完成,向元数据节点发送迁移完成消息,其中,源物理节点可以对迁移成功的业务对象进行计数,每迁移个业务对象,计数值加1,在计数值等于待迁移的所有业务对象的数量时,确定待迁移的所有业务对象迁移完成。Specifically, the source physical node determines that all the service objects to be migrated are migrated, and sends a migration completion message to the metadata node, where the source physical node can count the successfully transferred business objects, and each time the service object is migrated, the count value is increased by one. When the count value is equal to the number of all business objects to be migrated, it is determined that all the business objects to be migrated are migrated.
S314、元数据节点向客户端发送路由切换消息。S314. The metadata node sends a route switching message to the client.
具体的,路由切换消息表示虚拟节点所在的物理节点发生更新,路由切换消息中可携带至少一个虚拟节点的标识和目标物理节点的标识,客户端接收路由更新消息,根据路由更新消息将至少一个虚拟节点与目标物理节点进行映射。Specifically, the routing switch message indicates that the physical node where the virtual node is located is updated, and the routing switch message may carry the identifier of the at least one virtual node and the identifier of the target physical node, and the client receives the routing update message, and at least one virtual according to the routing update message The node is mapped to the target physical node.
S315、元数据节点向源物理节点发送下线通知消息。S315. The metadata node sends an offline notification message to the source physical node.
具体的,下线通知消息用于通知虚拟节点进行下线,下线通知消息中可携带至少一个虚拟节点的标识,源物理节点接收下线通知消息,可根据消息通知消息删除至少一个虚拟节点。Specifically, the offline notification message is used to notify the virtual node to go offline. The offline notification message may carry the identifier of the at least one virtual node, and the source physical node receives the offline notification message, and the at least one virtual node may be deleted according to the message notification message.
参见图4c,下面就一个具体的实施例一种虚拟节点的数据迁移方法进行说明:Referring to FIG. 4c, a data migration method of a virtual node is described below in a specific embodiment:
在初始条件下,分布式数据库系统包括4个物理节点,分别为物理节点1、物理节点2、物理节点3和物理节点4,每个物理节点包括12个虚拟节点,每个虚拟节点部署有1个副本,下面括号中编号为虚拟节点的表换,相同编号的两个虚拟节点互为主本和副本,,也可以称为主节点和备节点(或主分片或备分片)物理节点与虚拟节点的映射关系如下:Under the initial conditions, the distributed database system includes four physical nodes, which are physical node 1, physical node 2, physical node 3, and physical node 4. Each physical node includes 12 virtual nodes, and each virtual node has 1 deployed. A copy of the virtual node is numbered in the parentheses below. The two virtual nodes of the same number are the master and the copy. They can also be called the primary node and the standby node (or the primary or backup slice) physical node. The mapping relationship with the virtual node is as follows:
物理节点1:(1,2,3,4,5,6),(9,12,14,17,19,22)Physical node 1: (1, 2, 3, 4, 5, 6), (9, 12, 14, 17, 19, 22)
物理节点2:(7,8,9,10,11,12),(1,4,15,18,20,23)Physical node 2: (7, 8, 9, 10, 11, 12), (1, 4, 15, 18, 20, 23)
物理节点3:(13,14,15,16,17,18),(2,5,7,10,21,24)Physical node 3: (13,14,15,16,17,18), (2,5,7,10,21,24)
物理节点4:(19,20,21,22,23,24),(3,6,8,11,13,16)Physical node 4: (19, 20, 21, 22, 23, 24), (3, 6, 8, 11, 13, 16)
随着业务发展,当前的4个物理节点负荷过重,计划扩展一个新的物理节点5。元数据节点的数据均衡子系统计算出需要分别迁移物理节点1.虚拟节点1、物理节点2.虚拟节点7、物理节点3.虚拟节点13、物理节点4.虚拟节点19到物理节点5。依次遍历物理节点1.虚拟 节点1、物理节点2.虚拟节点7、物理节点3.虚拟节点13、物理节点4.虚拟节点19。物理节点1-4为源物理节点,物理节点5为目标物理节点。As the business develops, the current four physical nodes are overloaded and plans to expand a new physical node5. The data equalization subsystem of the metadata node calculates that it is necessary to separately migrate the physical node 1. virtual node 1, physical node 2. virtual node 7, physical node 3. virtual node 13, physical node 4. virtual node 19 to physical node 5. Traverse the physical node in turn. 1. Virtual Node 1, physical node 2. Virtual node 7, physical node 3. Virtual node 13, physical node 4. Virtual node 19. Physical nodes 1-4 are source physical nodes, and physical nodes 5 are target physical nodes.
以物理节点1.虚拟节点1的迁移为例进行说明,虚拟节点1所属的业务对象的获取方法可参照图2的实施例的描述,此处不再赘述。For example, the physical node 1. The migration of the virtual node 1 is taken as an example. For the method for obtaining the service object to which the virtual node 1 belongs, reference may be made to the description of the embodiment of FIG. 2, and details are not described herein again.
迁移过程为:遍历物理节点1.虚拟节点1下的全部业务对象:业务对象1、业务对象2、业务对象3、业务对象4和业务对象5,假设迁移的顺序为业务对象1-5逐个进行迁移,暂停物理节点1.虚拟节点1与副本物理节点之间的主从复制;物理节点1对业务对象1进行加锁,迁移物理节点1.虚拟节点1.业务对象1到物理节点5.虚拟节点1,然后清理物理节点1.虚拟节点1.业务对象1;循环处理,依次将业务对象2、业务对象3、业务对象4和业务对象5搬迁到物理节点5.虚拟节点1。The migration process is: traversing the physical node 1. All the business objects under the virtual node 1: business object 1, business object 2, business object 3, business object 4, and business object 5, assuming that the order of migration is one for each of the business objects 1-5 Migration, suspend physical node 1. Master-slave replication between virtual node 1 and replica physical node; physical node 1 locks business object 1 and migrates physical node 1. virtual node 1. business object 1 to physical node 5. virtual Node 1, then cleans up the physical node 1. Virtual node 1. Business object 1; loop processing, and then relocate business object 2, business object 3, business object 4, and business object 5 to physical node 5. virtual node 1.
在业务对象的迁移期间,客户端发起对物理节点1.虚拟节点1.业务对象1业务访问请求,物理节点1(源物理节点)判断业务对象1已迁移,则返回给客户端路由更新消息;客户端更新路由更新消息重新向物理节点5.虚拟节点1发起业务访问请求。物理节点2的虚拟节点7、物理节点3的虚拟节点13和物理节点4的虚拟节点19的迁移过程可参照上述的描述,此处不再赘述。图4c中灰色的方块表示已迁移的虚拟节点,在虚拟节点1、7、13和19迁移到物理节点5时,需要在物理节点5上部署副本,部署副本时遵循反亲和性的规则,即主本和副本不能位于相同的物理节点上。During the migration of the business object, the client initiates a service access request to the physical node 1. virtual node 1. business object 1, and the physical node 1 (the source physical node) determines that the business object 1 has been migrated, and returns a routing update message to the client; The client update routing update message re-initiates a service access request to the physical node 5. virtual node 1. For the migration process of the virtual node 7 of the physical node 2, the virtual node 13 of the physical node 3, and the virtual node 19 of the physical node 4, reference may be made to the above description, and details are not described herein again. The gray squares in Figure 4c represent migrated virtual nodes. When virtual nodes 1, 7, 13, and 19 are migrated to physical node 5, replicas need to be deployed on physical nodes 5, and the rules for anti-affinity are followed when deploying replicas. That is, the master and the copy cannot be on the same physical node.
在图3所描述的方法中,源物理节点待迁移的虚拟节点的数据结构信息,根据数据结构信息获取待迁移的业务对象,将所有业务对象迁移到目标物理节点,实现了关系型数据的逻辑迁移。In the method described in FIG. 3, the data structure information of the virtual node to be migrated by the source physical node acquires the business object to be migrated according to the data structure information, migrates all the business objects to the target physical node, and implements the logic of the relational data. migrate.
参见图5,为本发明实施例提供的一种物理节点的结构示意图,本发明实施例的物理节点用于执行图2中的虚拟节点的数据迁移方法,所涉及的术语和过程可参照图图2实施例的描述。物理节点5包括:接收模块501、确定模块502、获取模块503和迁移模块504。FIG. 5 is a schematic structural diagram of a physical node according to an embodiment of the present invention. The physical node used in the embodiment of the present invention is used to perform the data migration method of the virtual node in FIG. 2, and the terminology and process involved may refer to the diagram. 2 Description of the embodiment. The physical node 5 includes a receiving module 501, a determining module 502, an obtaining module 503, and a migration module 504.
接收模块,用于接收迁移指示消息;a receiving module, configured to receive a migration indication message;
确定模块,用于根据所述迁移指示消息确定目标物理节点和所述源物理节点上待迁移的至少一个虚拟节点;a determining module, configured to determine, according to the migration indication message, a target physical node and at least one virtual node to be migrated on the source physical node;
获取模块,用于获取所述源物理节点自身的数据结构信息,以及根据所述数据结构信息得到所述至少一个虚拟节点所属的所有业务对象;An acquiring module, configured to acquire data structure information of the source physical node itself, and obtain, according to the data structure information, all service objects to which the at least one virtual node belongs;
迁移模块,用于以业务对象为粒度将所述所有业务对象迁移到所述目标物理节点。And a migration module, configured to migrate the all business objects to the target physical node at a granularity of the business object.
可选的,所述数据结构信息包括数据分片表和数据附属表;Optionally, the data structure information includes a data fragment table and a data attachment table;
所述获取模块用于:The obtaining module is used to:
根据所述数据分片表查询所述至少一个虚拟节点所属的一个或多个业务对象,以及根据所述业务对象附属表查询所述多个业务对象中每个业务对象所属的业务表。Querying, according to the data fragmentation table, one or more business objects to which the at least one virtual node belongs, and querying, according to the business object auxiliary table, a service table to which each of the plurality of business objects belongs.
可选的,还包括:Optionally, it also includes:
第一访问处理模块,用于接收客户端发送业务访问请求;a first access processing module, configured to receive a client to send a service access request;
执行业务访问请求,以及向所述客户端返回业务访问响应;Performing a business access request and returning a business access response to the client;
将所述业务访问请求记录到业务日志中,以及将所述业务日志发送给所述目标物理节点。Recording the service access request into a service log, and transmitting the service log to the target physical node.
可选的,还包括: Optionally, it also includes:
事务处理模块,用于在业务对象迁移完成的情况下,向元数据节点发送迁移完成消息;a transaction processing module, configured to send a migration completion message to the metadata node when the business object migration is completed;
接收所述元数据节点根据所述迁移完成消息返回的切换指示消息;Receiving a handover indication message returned by the metadata node according to the migration completion message;
接收到所述切换指示消息时,阻塞客户端发起的事务;Blocking the transaction initiated by the client when receiving the handover indication message;
在已启动的事务成功执行的情况下,向所述元数据节点返回切换准备消息;其中,所述切换准备消息用于表示所述源物理节点完成路由切换准备。And in the case that the initiated transaction is successfully executed, returning a handover preparation message to the metadata node; wherein the handover preparation message is used to indicate that the source physical node completes route switching preparation.
可选的,所述迁移模块用于:Optionally, the migration module is configured to:
从所述所有业务对象中选择一个待迁移的业务对象,将所述待迁移的业务对象进行加锁处理;Selecting a business object to be migrated from all the business objects, and locking the business object to be migrated;
确认所述待迁移的业务对象成功迁移到所述目标物理节点时,删除所述待迁移的业务对象。When the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
可选的,物理节点还包括:Optionally, the physical node further includes:
第二访问处理模块,用于在业务对象的迁移过程中,接收所述客户端发送的针对待访问的业务对象的业务访问请求;a second access processing module, configured to receive, during a migration process of the business object, a service access request sent by the client for the service object to be accessed;
判断所述待访问的业务对象是否已迁移到所述目标物理节点;Determining whether the to-be-accessed business object has migrated to the target physical node;
若为是,向所述客户端返回路由更新消息;其中,所述路由更新消息用于指示所述客户端更新所述待访问的业务对象所在的物理节点。If yes, returning a routing update message to the client, where the routing update message is used to instruct the client to update the physical node where the to-be-accessed business object is located.
可选的,还包括:Optionally, it also includes:
通知模块,用于在业务对象迁移完成时,向元数据节点发送迁移完成消息;其中,所述迁移完成消息用于表示所述至少一个虚拟节点所属的所有业务对象迁移完成。And a notification module, configured to send a migration completion message to the metadata node when the business object migration is completed; wherein the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
本发明实施例和图2的实施例基于同一构思,其带来的技术效果也相同,具体过程可参照图2的实施例的描述,此处不再赘述。The embodiment of the present invention and the embodiment of FIG. 2 are based on the same concept, and the technical effects thereof are also the same. For the specific process, reference may be made to the description of the embodiment of FIG. 2, and details are not described herein again.
参见图6,为本发明实施例提供的一种物理节点的结构示意图,在本发明实施例中,物理节点6包括处理器601、存储器602和收发器603。收发器603用于与外部设备之间收发数据。物理节点6中的处理器601的数量可以是一个或多个。本发明的一些实施例中,处理器601、存储器602和收发器603可通过总线系统或其他方式连接。物理节点6可以用于执行图2所示的方法。关于本实施例涉及的术语的含义以及举例,可以参考图2对应的实施例。此处不再赘述。FIG. 6 is a schematic structural diagram of a physical node according to an embodiment of the present invention. In the embodiment of the present invention, the physical node 6 includes a processor 601, a memory 602, and a transceiver 603. The transceiver 603 is configured to transmit and receive data with and from an external device. The number of processors 601 in the physical node 6 may be one or more. In some embodiments of the invention, processor 601, memory 602, and transceiver 603 may be connected by a bus system or other means. The physical node 6 can be used to perform the method shown in FIG. 2. For the meaning and examples of the terms involved in the embodiment, reference may be made to the corresponding embodiment of FIG. 2. I will not repeat them here.
其中,存储器602中存储程序代码。处理器601用于调用存储器602中存储的程序代码,用于执行以下操作:The program code is stored in the memory 602. The processor 601 is configured to call the program code stored in the memory 602 for performing the following operations:
接收迁移指示消息;Receiving a migration indication message;
根据所述迁移指示消息确定目标物理节点和所述源物理节点上待迁移的至少一个虚拟节点;Determining, according to the migration indication message, the target physical node and the at least one virtual node to be migrated on the source physical node;
获取所述源物理节点的数据结构信息,以及根据所述数据结构信息得到所述至少一个虚拟节点所属的所有业务对象;Obtaining data structure information of the source physical node, and obtaining, according to the data structure information, all service objects to which the at least one virtual node belongs;
以业务对象为粒度将所述所有业务对象迁移到所述目标物理节点。All of the business objects are migrated to the target physical node at a granularity of business objects.
在一种可能的实施方式中,所述数据结构信息包括数据分片表和数据附属表;In a possible implementation manner, the data structure information includes a data fragment table and a data attachment table;
处理器601执行所述根据所述数据结构信息得到所述待迁移的至少一个虚拟节点所属的所有业务对象包括:The processor 601 performs, according to the data structure information, all the service objects to which the at least one virtual node to be migrated belongs:
根据所述数据分片表查询所述至少一个虚拟节点所属的一个或多个业务对象,以及根 据所述业务对象附属表查询所述多个业务对象中每个业务对象所属的业务表。Querying, according to the data fragmentation table, one or more business objects to which the at least one virtual node belongs, and a root And querying, according to the business object subsidiary table, a service table to which each of the plurality of business objects belongs.
在一种可能的实施方式中,处理器601还用于执行:In a possible implementation, the processor 601 is further configured to:
接收客户端发送业务访问请求;Receiving a client to send a service access request;
执行业务访问请求,以及向所述客户端返回业务访问响应;Performing a business access request and returning a business access response to the client;
将所述业务访问请求记录到业务日志中,以及将所述业务日志发送给所述目标物理节点。Recording the service access request into a service log, and transmitting the service log to the target physical node.
在一种可能的实施方式中,处理器601还用于执行:In a possible implementation, the processor 601 is further configured to:
在业务对象迁移完成的情况下,向元数据节点发送迁移完成消息;Sending a migration completion message to the metadata node when the business object migration is completed;
所述源物理节点接收所述元数据节点根据所述迁移完成消息返回的切换指示消息;Receiving, by the source physical node, a handover indication message returned by the metadata node according to the migration completion message;
接收到所述切换指示消息时,所述源物理节点阻塞客户端发起的事务;Upon receiving the handover indication message, the source physical node blocks a transaction initiated by the client;
在已启动的事务成功执行的情况下,所述源物理节点向所述元数据节点返回切换准备消息;其中,所述切换准备消息用于表示所述源物理节点完成路由切换准备。And the source physical node returns a handover preparation message to the metadata node, where the handover preparation message is used to indicate that the source physical node completes route switching preparation.
在一种可能的实施方式中,处理器601执行所述以业务对象为粒度将所述所有业务对象迁移到所述目标物理节点包括:In a possible implementation manner, the processor 601 performing the migrating the all service objects to the target physical node at a granularity of a service object includes:
从所述所有业务对象中选择一个待迁移的业务对象,将所述待迁移的业务对象进行加锁处理;Selecting a business object to be migrated from all the business objects, and locking the business object to be migrated;
确认所述待迁移的业务对象成功迁移到所述目标物理节点时,删除所述待迁移的业务对象。When the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
在一种可能的实施方式中,处理器601还包括:In a possible implementation, the processor 601 further includes:
在业务对象的迁移过程中,接收所述客户端发送的针对待访问的业务对象的业务访问请求;Receiving a service access request sent by the client for a service object to be accessed during a migration process of the business object;
判断所述待访问的业务对象是否已迁移到所述目标物理节点;Determining whether the to-be-accessed business object has migrated to the target physical node;
若为是,向所述客户端返回路由更新消息;其中,所述路由更新消息用于指示所述客户端更新所述待访问的业务对象所在的物理节点。If yes, returning a routing update message to the client, where the routing update message is used to instruct the client to update the physical node where the to-be-accessed business object is located.
在一种可能的实施方式中,处理器601还用于执行:In a possible implementation, the processor 601 is further configured to:
在业务对象迁移完成时,向元数据节点发送迁移完成消息;其中,所述迁移完成消息用于表示所述至少一个虚拟节点所属的所有业务对象迁移完成。When the migration of the business object is completed, the migration completion message is sent to the metadata node, where the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
参见图7,为本发明实施例提供的一种物理节点的结构示意图,本发明实施例的物理节点用于执行图3中的虚拟节点的数据迁移方法,所涉及的术语和过程可参照图3实施例的描述。物理节点7包括:确定模块701、接收模块702和重建模块703。FIG. 7 is a schematic structural diagram of a physical node according to an embodiment of the present invention. The physical node in the embodiment of the present invention is used to perform the data migration method of the virtual node in FIG. 3, and the terminology and process may refer to FIG. 3 . Description of the embodiments. The physical node 7 includes a determination module 701, a receiving module 702, and a reconstruction module 703.
确定模块701,用于接收迁移指示消息,以及根据所述迁移指示消息确定源物理节点;a determining module 701, configured to receive a migration indication message, and determine a source physical node according to the migration indication message;
接收模块702,用于接收所述源物理节点发送的业务对象;The receiving module 702 is configured to receive a service object sent by the source physical node.
重建模块703,用于在确定所述源物理节点的业务对象迁移完成时,获取接收到的业务对象的数据结构信息,根据所述数据结构信息重建虚拟节点。The reconstruction module 703 is configured to acquire data structure information of the received service object when the migration of the service object of the source physical node is completed, and reconstruct the virtual node according to the data structure information.
可选的,物理节点7还包括:Optionally, the physical node 7 further includes:
业务恢复模块,用于接收到所述源物理节点发送的业务日志,根据所述业务日志进行业务重演;其中,所述业务日志包括业务访问请求。The service recovery module is configured to receive a service log sent by the source physical node, and perform service replay according to the service log. The service log includes a service access request.
可选的,物理节点7还包括:Optionally, the physical node 7 further includes:
数据备份模块,用于确定所述源物理节点上的业务日志发送完成的情况下,确定目标 副本物理节点,将存储的业务日志和该虚拟节点迁移到所述目标副本物理节点上。a data backup module, configured to determine a target when the service log transmission on the source physical node is completed The replica physical node migrates the stored service log and the virtual node to the target replica physical node.
本发明实施例和图3的实施例基于同一构思,其带来的技术效果也相同,具体过程可参照图3的实施例的描述,此处不再赘述。The embodiment of the present invention and the embodiment of FIG. 3 are based on the same concept, and the technical effects thereof are also the same. For the specific process, reference may be made to the description of the embodiment of FIG. 3, and details are not described herein again.
参见图8,为本发明实施例提供的一种物理节点的结构示意图,在本发明实施例中,物理节点8包括处理器801、存储器802和收发器803。收发器803用于与外部设备之间收发数据。物理节点7中的处理器801的数量可以是一个或多个。本发明的一些实施例中,处理器801、存储器802和收发器803可通过总线系统或其他方式连接。物理节点8可以用于执行图3所示的方法。关于本实施例涉及的术语的含义以及举例,可以参考图3对应的实施例。此处不再赘述。FIG. 8 is a schematic structural diagram of a physical node according to an embodiment of the present invention. In the embodiment of the present invention, the physical node 8 includes a processor 801, a memory 802, and a transceiver 803. The transceiver 803 is configured to transmit and receive data with and from an external device. The number of processors 801 in the physical node 7 may be one or more. In some embodiments of the invention, processor 801, memory 802, and transceiver 803 may be coupled by a bus system or other means. The physical node 8 can be used to perform the method shown in FIG. For the meaning and examples of the terms involved in the embodiment, reference may be made to the corresponding embodiment of FIG. 3. I will not repeat them here.
其中,存储器802中存储程序代码。处理器801用于调用存储器802中存储的程序代码,用于执行以下操作:The program code is stored in the memory 802. The processor 801 is configured to call program code stored in the memory 802 for performing the following operations:
接收迁移指示消息,以及根据所述迁移指示消息确定源物理节点;Receiving a migration indication message, and determining a source physical node according to the migration indication message;
接收所述源物理节点发送的业务对象;Receiving a service object sent by the source physical node;
在确定所述源物理节点的业务对象迁移完成时,获取接收到的业务对象的数据结构信息,根据所述数据结构信息重建虚拟节点。After determining that the migration of the service object of the source physical node is completed, acquiring data structure information of the received service object, and reconstructing the virtual node according to the data structure information.
在一种可能的实施方式中,处理器801还用于执行:In a possible implementation, the processor 801 is further configured to:
所述目标物理节点接收到所述源物理节点发送的业务日志,根据所述业务日志进行业务重演;其中,所述业务日志包括业务访问请求。The target physical node receives the service log sent by the source physical node, and performs service replay according to the service log. The service log includes a service access request.
在一种可能的实施方式中,处理器801还用于执行:In a possible implementation, the processor 801 is further configured to:
确定所述源物理节点上的业务日志发送完成的情况下,确定目标副本物理节点,将存储的业务日志和该虚拟节点迁移到所述目标副本物理节点上。When it is determined that the service log transmission on the source physical node is completed, the target replica physical node is determined, and the stored service log and the virtual node are migrated to the target replica physical node.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。A person skilled in the art can understand that all or part of the process of implementing the above embodiment method can be completed by a computer program to instruct related hardware, and the program can be stored in a computer readable storage medium. When executed, the flow of an embodiment of the methods as described above may be included. The foregoing storage medium includes various media that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
以上实施例仅揭露了本发明中较佳实施例,不能以此来限定本发明之权利范围,本领域普通技术人员可以理解实现上述实施例的全部或部分流程,并依本发明权利要求所作的等同变化,仍属于发明所涵盖的范围。 The above embodiments are only illustrative of the preferred embodiments of the present invention, and the scope of the present invention is not limited thereto, and those skilled in the art can understand all or part of the processes for implementing the above embodiments, and according to the claims of the present invention. Equivalent changes are still within the scope of the invention.

Claims (20)

  1. 一种虚拟节点的数据迁移方法,其特征在于,包括:A data migration method for a virtual node, comprising:
    源物理节点接收迁移指示消息;The source physical node receives the migration indication message;
    所述源物理节点根据所述迁移指示消息确定目标物理节点和所述源物理节点上待迁移的至少一个虚拟节点;Determining, by the source physical node, the target physical node and the at least one virtual node to be migrated on the source physical node according to the migration indication message;
    获取所述源物理节点自身的数据结构信息,以及根据所述数据结构信息得到所述至少一个虚拟节点所属的所有业务对象;Obtaining data structure information of the source physical node itself, and obtaining, according to the data structure information, all service objects to which the at least one virtual node belongs;
    所述源物理节点以业务对象为粒度将所述所有业务对象迁移到所述目标物理节点。The source physical node migrates all the business objects to the target physical node at a granularity of the business object.
  2. 如权利要求1所述的方法,其特征在于,所述数据结构信息包括数据分片表和数据附属表;The method of claim 1 wherein said data structure information comprises a data fragmentation table and a data attachment table;
    所述根据所述数据结构信息得到所述待迁移的至少一个虚拟节点所属的所有业务对象包括:And obtaining, according to the data structure information, all the service objects to which the at least one virtual node to be migrated belongs:
    所述源物理节点根据所述数据分片表查询所述至少一个虚拟节点所属的一个或多个业务对象,以及根据所述业务对象附属表查询所述多个业务对象中每个业务对象所属的业务表。Querying, by the source physical node, one or more business objects to which the at least one virtual node belongs according to the data fragmentation table, and querying, according to the business object auxiliary table, each of the plurality of business objects Business table.
  3. 如权利要求1或2所述的方法,其特征在于,还包括:The method of claim 1 or 2, further comprising:
    所述源物理节点接收客户端发送业务访问请求;Receiving, by the source physical node, a client to send a service access request;
    所述源物理节点执行业务访问请求,以及向所述客户端返回业务访问响应;The source physical node performs a service access request, and returns a service access response to the client;
    所述源物理节点将所述业务访问请求记录到业务日志中,以及将所述业务日志发送给所述目标物理节点。The source physical node records the service access request into a service log, and sends the service log to the target physical node.
  4. 如权利要求3所述的方法,其特征在于,还包括:The method of claim 3, further comprising:
    在业务对象迁移完成的情况下,所述源物理节点向元数据节点发送迁移完成消息;In the case that the business object migration is completed, the source physical node sends a migration completion message to the metadata node;
    所述源物理节点接收所述元数据节点返回的切换指示消息;Receiving, by the source physical node, a handover indication message returned by the metadata node;
    接收到所述切换指示消息时,所述源物理节点阻塞客户端发起的事务;Upon receiving the handover indication message, the source physical node blocks a transaction initiated by the client;
    在已启动的事务成功执行的情况下,所述源物理节点向所述元数据节点返回切换准备消息;其中,所述切换准备消息用于表示所述源物理节点完成路由切换准备。And the source physical node returns a handover preparation message to the metadata node, where the handover preparation message is used to indicate that the source physical node completes route switching preparation.
  5. 如权利要求1所述的方法,其特征在于,所述源物理节点以业务对象为粒度将所述所有业务对象迁移到所述目标物理节点包括:The method of claim 1, wherein the migrating the all the business objects to the target physical node by the source physical node at a granularity of the business object comprises:
    所述源物理节点从所述所有业务对象中选择一个待迁移的业务对象,将所述待迁移的业务对象进行加锁处理;The source physical node selects a business object to be migrated from all the service objects, and performs locking processing on the business object to be migrated;
    所述源物理节点确认所述待迁移的业务对象成功迁移到所述目标物理节点时,删除所述待迁移的业务对象。When the source physical node confirms that the service object to be migrated is successfully migrated to the target physical node, the service object to be migrated is deleted.
  6. 如权利要求5所述的方法,其特征在于,还包括:The method of claim 5, further comprising:
    在业务对象的迁移过程中,所述源物理节点接收所述客户端发送的针对待访问的业务对象的业务访问请求;During the migration of the business object, the source physical node receives a service access request sent by the client for the service object to be accessed;
    所述源物理节点判断所述待访问的业务对象是否已迁移到所述目标物理节点;Determining, by the source physical node, whether the to-be-accessed service object has migrated to the target physical node;
    若为是,所述源物理节点向所述客户端返回路由更新消息;其中,所述路由更新消息用于指示所述客户端更新所述待访问的业务对象所在的物理节点。If yes, the source physical node returns a route update message to the client, where the route update message is used to instruct the client to update the physical node where the to-be-accessed service object is located.
  7. 如权利要求6所述的方法,其特征在于,还包括:The method of claim 6 further comprising:
    在业务对象迁移完成时,所述源物理节点向元数据节点发送迁移完成消息;其中,所 述迁移完成消息用于表示所述至少一个虚拟节点所属的所有业务对象迁移完成。When the business object migration is completed, the source physical node sends a migration completion message to the metadata node; The migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
  8. 一种虚拟节点的数据迁移方法,其特征在于,包括:A data migration method for a virtual node, comprising:
    目标物理节点接收迁移指示消息,以及根据所述迁移指示消息确定源物理节点;Receiving, by the target physical node, a migration indication message, and determining a source physical node according to the migration indication message;
    所述目标物理节点接收所述源物理节点发送的业务对象;Receiving, by the target physical node, a service object sent by the source physical node;
    在确定所述源物理节点的业务对象迁移完成时,获取接收到的业务对象的数据结构信息,根据所述数据结构信息重建虚拟节点。After determining that the migration of the service object of the source physical node is completed, acquiring data structure information of the received service object, and reconstructing the virtual node according to the data structure information.
  9. 如权利要求8所述的方法,其特征在于,还包括:The method of claim 8 further comprising:
    所述目标物理节点接收到所述源物理节点发送的业务日志,根据所述业务日志进行业务重演;其中,所述业务日志包括业务访问请求。The target physical node receives the service log sent by the source physical node, and performs service replay according to the service log. The service log includes a service access request.
  10. 如权利要求9所述的方法,其特征在于,还包括:The method of claim 9 further comprising:
    所述目标物理节点确定所述源物理节点上的业务日志发送完成的情况下,确定目标副本物理节点,将存储的业务日志和该虚拟节点迁移到所述目标副本物理节点上。When the target physical node determines that the service log transmission on the source physical node is complete, the target replica physical node is determined, and the stored service log and the virtual node are migrated to the target replica physical node.
  11. 一种物理节点,其特征在于,所述物理节点为源物理节点,所述源物理节点包括:A physical node, wherein the physical node is a source physical node, and the source physical node includes:
    接收模块,用于接收迁移指示消息;a receiving module, configured to receive a migration indication message;
    确定模块,用于根据所述迁移指示消息确定目标物理节点和所述源物理节点上待迁移的至少一个虚拟节点;a determining module, configured to determine, according to the migration indication message, a target physical node and at least one virtual node to be migrated on the source physical node;
    获取模块,用于获取所述源物理节点自身的数据结构信息,以及根据所述数据结构信息得到所述至少一个虚拟节点所属的所有业务对象;An acquiring module, configured to acquire data structure information of the source physical node itself, and obtain, according to the data structure information, all service objects to which the at least one virtual node belongs;
    迁移模块,用于以业务对象为粒度将所述所有业务对象迁移到所述目标物理节点。And a migration module, configured to migrate the all business objects to the target physical node at a granularity of the business object.
  12. 如权利要求11所述的物理节点,其特征在于,所述数据结构信息包括数据分片表和数据附属表;The physical node according to claim 11, wherein the data structure information comprises a data fragmentation table and a data attachment table;
    所述获取模块用于:The obtaining module is used to:
    根据所述数据分片表查询所述至少一个虚拟节点所属的一个或多个业务对象,以及根据所述业务对象附属表查询所述多个业务对象中每个业务对象所属的业务表。Querying, according to the data fragmentation table, one or more business objects to which the at least one virtual node belongs, and querying, according to the business object auxiliary table, a service table to which each of the plurality of business objects belongs.
  13. 如权利要求11或12所述的物理节点,其特征在于,还包括:The physical node according to claim 11 or 12, further comprising:
    第一访问处理模块,用于接收客户端发送业务访问请求;a first access processing module, configured to receive a client to send a service access request;
    执行业务访问请求,以及向所述客户端返回业务访问响应;Performing a business access request and returning a business access response to the client;
    将所述业务访问请求记录到业务日志中,以及将所述业务日志发送给所述目标物理节点。Recording the service access request into a service log, and transmitting the service log to the target physical node.
  14. 如权利要求13所述的物理节点,其特征在于,还包括:The physical node of claim 13, further comprising:
    事务处理模块,用于在业务对象迁移完成的情况下,向元数据节点发送迁移完成消息;a transaction processing module, configured to send a migration completion message to the metadata node when the business object migration is completed;
    接收所述元数据节点根据所述迁移完成消息返回的切换指示消息;Receiving a handover indication message returned by the metadata node according to the migration completion message;
    接收到所述切换指示消息时,阻塞客户端发起的事务;Blocking the transaction initiated by the client when receiving the handover indication message;
    在已启动的事务成功执行的情况下,向所述元数据节点返回切换准备消息;其中,所述切换准备消息用于表示所述源物理节点完成路由切换准备。And in the case that the initiated transaction is successfully executed, returning a handover preparation message to the metadata node; wherein the handover preparation message is used to indicate that the source physical node completes route switching preparation.
  15. 如权利要求11所述的物理节点,其特征在于,所述迁移模块用于:The physical node according to claim 11, wherein the migration module is configured to:
    从所述所有业务对象中选择一个待迁移的业务对象,将所述待迁移的业务对象进行加锁处理;Selecting a business object to be migrated from all the business objects, and locking the business object to be migrated;
    确认所述待迁移的业务对象成功迁移到所述目标物理节点时,删除所述待迁移的业务对象。 When the business object to be migrated is successfully migrated to the target physical node, the business object to be migrated is deleted.
  16. 如权利要求15所述的物理节点,其特征在于,还包括:The physical node of claim 15 further comprising:
    第二访问处理模块,用于在业务对象的迁移过程中,接收所述客户端发送的针对待访问的业务对象的业务访问请求;a second access processing module, configured to receive, during a migration process of the business object, a service access request sent by the client for the service object to be accessed;
    判断所述待访问的业务对象是否已迁移到所述目标物理节点;Determining whether the to-be-accessed business object has migrated to the target physical node;
    若为是,向所述客户端返回路由更新消息;其中,所述路由更新消息用于指示所述客户端更新所述待访问的业务对象所在的物理节点。If yes, returning a routing update message to the client, where the routing update message is used to instruct the client to update the physical node where the to-be-accessed business object is located.
  17. 如权利要求16所述的物理节点,其特征在于,还包括:The physical node according to claim 16, further comprising:
    通知模块,用于在业务对象迁移完成时,向元数据节点发送迁移完成消息;其中,所述迁移完成消息用于表示所述至少一个虚拟节点所属的所有业务对象迁移完成。And a notification module, configured to send a migration completion message to the metadata node when the business object migration is completed; wherein the migration completion message is used to indicate that all the business objects to which the at least one virtual node belongs are migrated.
  18. 一种物理节点,其特征在于,所述物理节点为目标物理节点,所述目标物理节点包括:A physical node, wherein the physical node is a target physical node, and the target physical node includes:
    确定模块,用于接收迁移指示消息,以及根据所述迁移指示消息确定源物理节点;a determining module, configured to receive a migration indication message, and determine a source physical node according to the migration indication message;
    接收模块,用于接收所述源物理节点发送的业务对象;a receiving module, configured to receive a service object sent by the source physical node;
    重建模块,用于在确定所述源物理节点的业务对象迁移完成时,获取接收到的业务对象的数据结构信息,根据所述数据结构信息重建虚拟节点。And a reconstruction module, configured to acquire data structure information of the received service object when the migration of the business object of the source physical node is completed, and reconstruct the virtual node according to the data structure information.
  19. 如权利要求18所述的物理节点,其特征在于,还包括:The physical node of claim 18, further comprising:
    业务恢复模块,用于接收到所述源物理节点发送的业务日志,根据所述业务日志进行业务重演;其中,所述业务日志包括业务访问请求。The service recovery module is configured to receive a service log sent by the source physical node, and perform service replay according to the service log. The service log includes a service access request.
  20. 如权利要求19所述的物理节点,其特征在于,还包括:The physical node of claim 19, further comprising:
    数据备份模块,用于确定所述源物理节点上的业务日志发送完成的情况下,确定目标副本物理节点,将存储的业务日志和该虚拟节点迁移到所述目标副本物理节点上。 And a data backup module, configured to determine that the target replica physical node is complete, and the stored service log and the virtual node are migrated to the target replica physical node.
PCT/CN2017/090613 2016-09-30 2017-06-28 Data migration method for virtual node, and virtual node WO2018059032A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610877920.0 2016-09-30
CN201610877920.0A CN107885758B (en) 2016-09-30 2016-09-30 Data migration method of virtual node and virtual node

Publications (1)

Publication Number Publication Date
WO2018059032A1 true WO2018059032A1 (en) 2018-04-05

Family

ID=61763120

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/090613 WO2018059032A1 (en) 2016-09-30 2017-06-28 Data migration method for virtual node, and virtual node

Country Status (2)

Country Link
CN (1) CN107885758B (en)
WO (1) WO2018059032A1 (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110990483A (en) * 2019-11-26 2020-04-10 上海莉莉丝科技股份有限公司 Data access and control method and system for cache nodes in distributed cache
CN111143324A (en) * 2019-12-20 2020-05-12 浪潮软件股份有限公司 Kudu database data balancing system based on size and implementation method
CN111245924A (en) * 2020-01-08 2020-06-05 北京松果电子有限公司 Load balancing method and device and computer storage medium
CN113010496A (en) * 2021-03-19 2021-06-22 腾讯科技(深圳)有限公司 Data migration method, device, equipment and storage medium
CN113157668A (en) * 2021-04-23 2021-07-23 上海数禾信息科技有限公司 Non-stop data migration method and device
CN113760858A (en) * 2020-06-05 2021-12-07 中国移动通信集团湖北有限公司 Dynamic migration method and device for memory database data, computing equipment and storage equipment
CN115718571A (en) * 2022-11-23 2023-02-28 深圳计算科学研究院 Data management method and device based on multi-dimensional features

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110445822B (en) * 2018-05-03 2021-11-30 中移(苏州)软件技术有限公司 Object storage method and device
CN110471756A (en) * 2018-05-09 2019-11-19 阿里巴巴集团控股有限公司 A kind of data processing method and device
CN109086292B (en) * 2018-06-11 2023-11-28 平安科技(深圳)有限公司 Database switching method and system
CN110069220B (en) * 2019-04-25 2022-02-22 深信服科技股份有限公司 Distributed scheduling method, device, equipment and computer readable storage medium
CN110321225B (en) * 2019-07-08 2021-04-30 腾讯科技(深圳)有限公司 Load balancing method, metadata server and computer readable storage medium
CN110569225A (en) * 2019-08-26 2019-12-13 网宿科技股份有限公司 Data storage method and system
CN111723148B (en) * 2020-04-10 2024-01-26 浙江大华技术股份有限公司 Data storage method and device, storage medium and electronic device
CN111625364B (en) * 2020-05-30 2023-05-16 抖音视界有限公司 Task allocation method, device, electronic equipment and computer readable medium
CN111737197A (en) * 2020-06-30 2020-10-02 上海英方软件股份有限公司 System and method for realizing non-stop migration service system
CN112732423B (en) * 2020-12-30 2023-01-20 平安科技(深圳)有限公司 Process migration method, device, equipment and medium
CN115065630B (en) * 2022-05-10 2024-04-09 深信服科技股份有限公司 Migration method and device of virtual router, electronic equipment and storage medium

Citations (4)

* 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
CN102185774A (en) * 2011-05-10 2011-09-14 中兴通讯股份有限公司 Method, monitor and system for seamless migration of virtual machine
CN102204187A (en) * 2011-04-28 2011-09-28 华为技术有限公司 Method, correlative device and system for virtual network migration
CN105653630A (en) * 2015-12-25 2016-06-08 北京奇虎科技有限公司 Data migration method and apparatus for distributed database

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8429651B2 (en) * 2010-01-20 2013-04-23 International Business Machines Corporation Enablement and acceleration of live and near-live migration of virtual machines and their associated storage across networks
JP5835846B2 (en) * 2012-08-29 2015-12-24 株式会社日立製作所 Network system and virtual node migration method
CN105335214A (en) * 2015-11-12 2016-02-17 国云科技股份有限公司 Virtual machine failure detection and recovery method

Patent Citations (4)

* 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
CN102204187A (en) * 2011-04-28 2011-09-28 华为技术有限公司 Method, correlative device and system for virtual network migration
CN102185774A (en) * 2011-05-10 2011-09-14 中兴通讯股份有限公司 Method, monitor and system for seamless migration of virtual machine
CN105653630A (en) * 2015-12-25 2016-06-08 北京奇虎科技有限公司 Data migration method and apparatus for distributed database

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110990483A (en) * 2019-11-26 2020-04-10 上海莉莉丝科技股份有限公司 Data access and control method and system for cache nodes in distributed cache
CN111143324A (en) * 2019-12-20 2020-05-12 浪潮软件股份有限公司 Kudu database data balancing system based on size and implementation method
CN111143324B (en) * 2019-12-20 2023-05-02 浪潮软件股份有限公司 Kudu database data equalization system based on size and implementation method
CN111245924A (en) * 2020-01-08 2020-06-05 北京松果电子有限公司 Load balancing method and device and computer storage medium
CN113760858A (en) * 2020-06-05 2021-12-07 中国移动通信集团湖北有限公司 Dynamic migration method and device for memory database data, computing equipment and storage equipment
CN113760858B (en) * 2020-06-05 2024-03-19 中国移动通信集团湖北有限公司 Dynamic migration method and device for memory database data, computing equipment and storage equipment
CN113010496A (en) * 2021-03-19 2021-06-22 腾讯科技(深圳)有限公司 Data migration method, device, equipment and storage medium
CN113010496B (en) * 2021-03-19 2024-03-08 腾讯云计算(北京)有限责任公司 Data migration method, device, equipment and storage medium
CN113157668A (en) * 2021-04-23 2021-07-23 上海数禾信息科技有限公司 Non-stop data migration method and device
CN115718571A (en) * 2022-11-23 2023-02-28 深圳计算科学研究院 Data management method and device based on multi-dimensional features
CN115718571B (en) * 2022-11-23 2023-08-22 深圳计算科学研究院 Data management method and device based on multidimensional features

Also Published As

Publication number Publication date
CN107885758B (en) 2021-11-19
CN107885758A (en) 2018-04-06

Similar Documents

Publication Publication Date Title
WO2018059032A1 (en) Data migration method for virtual node, and virtual node
US11520670B2 (en) Method and apparatus for restoring data from snapshots
US8972405B1 (en) Storage resource management information modeling in a cloud processing environment
US10104175B2 (en) Massively scalable object storage system
KR101453425B1 (en) Metadata Server And Metadata Management Method
US7546486B2 (en) Scalable distributed object management in a distributed fixed content storage system
US9367579B1 (en) System and method for maintaining a file change log within a distributed file system
EP2062125B1 (en) System and method for providing high availability data
US9922075B2 (en) Scalable distributed transaction processing system
EP2521336B1 (en) Massively scalable object storage system
JP2021002369A (en) Index update pipeline
JP5722962B2 (en) Optimize storage performance
US9547706B2 (en) Using colocation hints to facilitate accessing a distributed data storage system
US7440977B2 (en) Recovery method using extendible hashing-based cluster logs in shared-nothing spatial database cluster
US11561930B2 (en) Independent evictions from datastore accelerator fleet nodes
US10528262B1 (en) Replication-based federation of scalable data across multiple sites
US9747168B2 (en) Data block based backup
US8930364B1 (en) Intelligent data integration
JP2020514885A (en) Methods, devices, and systems for maintaining metadata and data integrity across data centers
US20150347250A1 (en) Database management system for providing partial re-synchronization and partial re-synchronization method of using the same
JP5686034B2 (en) Cluster system, synchronization control method, server device, and synchronization control program
CN111984696A (en) Novel database and method
US10387384B1 (en) Method and system for semantic metadata compression in a two-tier storage system using copy-on-write
WO2017156855A1 (en) Database systems with re-ordered replicas and methods of accessing and backing up databases
CN116389233A (en) Container cloud management platform active-standby switching system, method and device and computer equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17854486

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17854486

Country of ref document: EP

Kind code of ref document: A1