Database cluster expansion method, device, computer equipment and storage medium
Through the automated cross-host expansion method, the problem of complex and time-consuming operations during database cluster expansion is solved, and efficient database cluster expansion is achieved.
Patent Information
- Application Number
- CN202110416588.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-19
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2041-04-19
AI Technical Summary
During the expansion of existing database clusters, physical host resources need to be manually found, which is complex and time-consuming, resulting in low expansion efficiency.
By generating cross-host expansion instructions, determining the target physical host from the physical resource pool, adding and expanding database nodes, and establishing synchronization relationships, the migration and switching of database nodes can be automatically achieved.
It simplifies the database cluster expansion operation, shortens the expansion time, improves the expansion efficiency, and ensures the stability and integrity of the data cluster.
Smart Images

Figure CN115221156B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a database cluster expansion method, apparatus, computer equipment, and storage medium. Background Art
[0002] A database cluster utilizes two or more database servers to form a single, virtual database logical image, providing transparent data services to clients. With increasing application system volume and data access, the database cluster needs to be expanded. However, the physical host hosting the current MySQL database cannot accommodate this expansion, making expansion impossible.
[0003] Currently, database cluster expansion requires operations and maintenance personnel to manually search for physical host resources. Manual expansion is complex and time-consuming. Summary of the Invention
[0004] Based on this, it is necessary to provide a database cluster expansion method, device, computer equipment and storage medium that can improve the efficiency of data cluster expansion in order to address the above technical problems.
[0005] A method for expanding a database cluster, the method comprising:
[0006] In response to the trigger information that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated;
[0007] According to the cross-host capacity expansion instruction, determining a target physical host from a physical resource pool and generating pre-occupancy information for cross-host capacity expansion;
[0008] Adding an expansion database node of the target physical host according to the pre-occupancy information, and establishing a synchronization relationship between the expansion database node and the migration data node of the current physical host;
[0009] In response to the database node switching instruction, detecting attribute data of the newly added first database instance of the expanded database node;
[0010] When the attribute data of the first database instance is preset data, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0011] In one embodiment, before generating the cross-host expansion instruction in response to the trigger information indicating that the target physical resources required for the incremental service data are greater than the remaining physical resources of the current physical host, the method further includes:
[0012] Receive a database cluster expansion request sent by a business terminal, where the expansion request carries physical resources required for incremental business data;
[0013] Responding to the capacity expansion request, obtaining the remaining physical resources of the current physical host;
[0014] The trigger information of the capacity expansion mode is generated according to the remaining physical resources and the physical resources required by the service incremental data.
[0015] In one embodiment, generating the trigger information of the capacity expansion method according to the remaining physical resources and the physical resources required by the incremental service data includes:
[0016] When the target physical resources required by the incremental service data are greater than the remaining physical resources of the current physical host, trigger information for cross-host expansion is generated.
[0017] In one embodiment, determining a target physical host from a physical resource pool and generating pre-occupancy information for cross-host capacity expansion according to the cross-host capacity expansion instruction includes:
[0018] According to the cross-host expansion instruction, the remaining physical resources of each physical host in the physical resource pool and a preset threshold value of physical resources for ensuring normal operation of each physical host are obtained;
[0019] A physical host whose physical resources are greater than the target physical resources and less than or equal to a preset threshold of the physical resources is determined as the target physical host, and network address and domain name information for cross-host expansion is generated.
[0020] In one embodiment, when the attribute data of the first database instance is preset data, switching the primary database from the second database instance of the migration database node to the newly added first database instance of the expansion database node includes:
[0021] When the permissions, account numbers, and memory parameters of the first database instance are the corresponding preset data and the version information is compatible with the first database instance and the second database instance, the main database is switched from the second database instance of the migration database node to the newly added first database instance of the expanded database node.
[0022] In one embodiment, the method further comprises:
[0023] The domain name of the expanded database node and the domain name of the migrated database node are switched, and a backup node of the first database instance is determined.
[0024] In one embodiment, the method further comprises:
[0025] When it is detected that the first database instance is providing a normal external data service function, the migration database node is deleted.
[0026] A database cluster expansion device, comprising:
[0027] A response module is used to respond to trigger information indicating that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, and generate cross-host expansion instructions for the database cluster;
[0028] a determination module, configured to determine a target physical host from a physical resource pool according to the cross-host capacity expansion instruction and generate pre-occupancy information for the cross-host capacity expansion;
[0029] A creation module, configured to add an expansion database node of the target physical host according to the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration data node of the current physical host;
[0030] A detection module, configured to respond to a database node switching instruction and detect attribute data of a newly added database instance of the expanded database node;
[0031] The switching module is configured to switch the primary database from the database instance of the expanded database node to the newly added database instance of the expanded database node when the attribute data of the newly added database instance is preset data.
[0032] A computer device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0033] In response to the trigger information that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated;
[0034] According to the cross-host capacity expansion instruction, determining a target physical host from a physical resource pool and generating pre-occupancy information for cross-host capacity expansion;
[0035] Adding an expansion database node of the target physical host according to the pre-occupancy information, and establishing a synchronization relationship between the expansion database node and the migration data node of the current physical host;
[0036] In response to the database node switching instruction, detecting attribute data of the newly added first database instance of the expanded database node;
[0037] When the attribute data of the first database instance is preset data, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0038] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0039] In response to the trigger information that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated;
[0040] According to the cross-host capacity expansion instruction, determining a target physical host from a physical resource pool and generating pre-occupancy information for cross-host capacity expansion;
[0041] Adding an expansion database node of the target physical host according to the pre-occupancy information, and establishing a synchronization relationship between the expansion database node and the migration data node of the current physical host;
[0042] In response to the database node switching instruction, detecting attribute data of the newly added first database instance of the expanded database node;
[0043] When the attribute data of the first database instance is preset data, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0044] The above-mentioned database cluster expansion method, device, computer equipment and storage medium, when the remaining physical resources of the current physical host cannot meet the current expansion needs, determine the target physical host from the physical resource pool and generate pre-occupation information for cross-host expansion according to the generated cross-host expansion instruction of the database cluster, to ensure that cross-host expansion can be achieved; according to the pre-occupation information, a new expansion database node of the target physical host is added, and a synchronization relationship between the expansion database node and the migration data node of the current physical host is established; that is, the full data on the migration database node is synchronized to the expansion database node; according to the database node switching instruction, when it is detected that the attribute data of the first database instance newly added to the expansion database node is preset data, the database node is switched and the determination of the main database is realized, that is, the data cluster expansion is achieved by adding the expansion database node and switching the data node, which simplifies the operation of database cluster expansion, shortens the expansion time, and improves the efficiency of database cluster expansion. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 This is an application environment diagram of a database cluster expansion method in one embodiment;
[0046] Figure 2 A schematic diagram of a process for expanding a database cluster according to an embodiment;
[0047] Figure 3A schematic flow chart of a method for expanding a database cluster according to another embodiment;
[0048] Figure 4 A schematic diagram of an application framework for scaling a database cluster in one embodiment;
[0049] Figure 5 This is a structural block diagram of a database cluster expansion device in one embodiment;
[0050] Figure 6 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0052] The database cluster expansion method provided in this application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The terminal 102 responds to the trigger information that the target physical resources required for the incremental data of the business are greater than the remaining physical resources of the current physical host, and generates a cross-host expansion instruction for the database cluster; according to the cross-host expansion instruction, the target physical host is determined from the physical resource pool of the server 104 and pre-occupancy information for cross-host expansion is generated; according to the pre-occupancy information, an expansion database node of the target physical host is added, and a synchronization relationship between the expansion database node and the migration data node of the current physical host is established; in response to the database node switching instruction, the attribute data of the newly added first database instance of the expansion database node is detected; when the attribute data of the first database instance is preset data, the main database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones and tablets, and the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0053] In one embodiment, Figure 2 As shown, a database cluster expansion method is provided, which is applied to Figure 1 The following steps are explained for the terminal in the figure:
[0054] Step 202 : In response to trigger information indicating that the target physical resources required by the incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated.
[0055] Incremental business data refers to business data generated during human-machine interaction. For example, incremental business data can include logistics address information, logistics express quantity, logistics vehicle information, etc. Physical resources refer to resources such as the CPU, hard disk capacity, and memory capacity of the physical host.
[0056] Specifically, when the cloud database user console receives a database cluster expansion request sent by the business terminal (that is, the physical host resources where the current MySQL database is located cannot meet the expansion of the MySQL database), the cloud database user console responds to the expansion request and obtains the remaining physical resources of the current physical host; wherein, the expansion request carries the physical resources required for the incremental business data; based on the remaining physical resources and the physical resources required for the incremental business data, the trigger information of the expansion method is generated, and the remaining physical resources and the physical resources required for the incremental business data are compared, that is, when the target physical resources required for the incremental business data are greater than the remaining physical resources of the current physical host, the trigger information for cross-host expansion is generated.
[0057] Optionally, when the target physical resources required for the incremental business data are less than or equal to the remaining physical resources of the current physical host, a trigger message for local host expansion is generated. In response to the trigger message that the target physical resources required for the incremental business data are less than the remaining physical resources of the current physical host, a local host expansion instruction for the database cluster is generated to complete the local expansion of the database cluster.
[0058] Step 204 : According to the cross-host capacity expansion instruction, a target physical host is determined from the physical resource pool and pre-occupancy information for the cross-host capacity expansion is generated.
[0059] The pre-occupancy information includes the subnet mask information and available IP addresses of the VPC (Private Cloud) in the network segment where the current physical host is located.
[0060] Specifically, the cloud database user console responds to the cross-host expansion instruction, determines the target physical host for expansion from the physical resource pool, generates subnet mask information and IP address information for the cross-host, and obtains the corresponding target domain name.
[0061] Step 206: Add an expansion database node to the target physical host according to the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration data node of the current physical host.
[0062] Specifically, when the cloud database user console responds to a cross-host expansion instruction, determines the target physical host for expansion from the physical resource pool, and generates information such as subnet mask information and IP address for cross-host, expansion order task information is generated; based on the expansion order task information, the subnet mask information, IP address and domain name for cross-host are obtained by calling the network group interface, the subnet mask information, IP address and domain name are bound to the target physical host, a new expansion database node of the target physical host is added, and a Docker instance and a first database instance (such as a Mysql instance) are created on the expansion data node.
[0063] Establish a synchronization relationship between the migration data node of the current physical host and the expansion data node of the target physical host. By calling the backup group interface, synchronize the full data on the migration database node to the first database instance of the expansion database node. That is, the second database instance of the migration database node becomes the master database, and the first database instance of the expansion database node becomes the slave database. Optionally, by calling the backup group interface, synchronize the backup data on the original backup database node to the first database instance of the expansion database node, avoiding data loss and ensuring data integrity.
[0064] After establishing the synchronization relationship between the migration database node and the expansion database node, by calling the cloud monitoring orchestration and adding the configured cloud monitoring script file and Docker monitoring script file, the cloud monitoring script file and Docker monitoring script are run to monitor the Docker instance and the first database instance in the expansion database node in real time, and the monitoring information of the Docker instance and the first database instance is visualized.
[0065] Step 208 : In response to the database node switching instruction, the attribute data of the newly added first database instance of the expanded database node is detected.
[0066] The attribute data includes account information and permission information pre-assigned to the database embodiment, database memory parameters, and the version number of the database embodiment, etc. The attribute data is obtained by parsing the database embodiment using a parsing tool (e.g., Cloud Parsing).
[0067] Specifically, the cloud database user console receives the database node switching instruction sent by the business terminal, responds to the received data node switching instruction, and performs a full-line inspection of the primary and standby databases, that is, obtains the account information and permission information, database memory parameters, and version number of the database embodiment and other attribute data of the first database embodiment of the expanded database node and the version number of the second database embodiment of the migrated database node, detects whether the account information and permission information of the first database embodiment are switchable accounts and permissions, and whether the parameter values of the database memory parameters are within the preset value range (database memory parameters include the memory consumed by the database server operation, parsing, query and internal management and the memory used by the buffer pool), detects whether the version number of the first database embodiment is the same as the version number of the second database embodiment, that is, whether the first database embodiment and the second database embodiment are compatible. If the version number of the first database embodiment is different from the version number of the second database embodiment, the second database embodiment is incompatible with the first database instance, resulting in data writing failure.
[0068] In step 210 , when the attribute data of the first database instance is the preset data, the primary database is switched from the second database instance of the migrated database node to the first database instance newly added to the expanded database node.
[0069] Specifically, when it is detected that the account information and permission information of the first database embodiment are switchable accounts and permissions, and the parameter value of the database memory parameter is within the preset value range and the version number of the first database embodiment is the same as the version number of the second database embodiment, the expanded database node and the migration database node are switched, that is, the main database is switched from the second database instance of the migration database node to the newly added first database instance of the expanded database node, and the incremental data of the first database embodiment is synchronized to the second data embodiment.
[0070] In the above-mentioned database cluster expansion method, when the remaining physical resources of the current physical host cannot meet the current expansion demand, according to the generated cross-host expansion instruction of the database cluster, the target physical host is determined from the physical resource pool and pre-occupation information for cross-host expansion is generated to ensure that cross-host expansion can be achieved; according to the pre-occupation information, an expansion database node of the target physical host is added, and a synchronization relationship between the expansion database node and the migration data node of the current physical host is established; that is, the full data on the migration database node is synchronized to the expansion database node; according to the database node switching instruction, when it is detected that the attribute data of the first database instance newly added to the expansion database node is the preset data, the database node is switched and the main database is updated, that is, the data cluster expansion is achieved by adding the expansion database node and switching the data node, which simplifies the operation of database cluster expansion, shortens the expansion time, and improves the efficiency of database cluster expansion.
[0071] In another embodiment, Figure 3 As shown, a database cluster expansion method is provided, which is applied to Figure 1 This article uses the Cloud Database User Console in the terminal as an example to explain the following steps:
[0072] Step 302: Receive a database cluster expansion request sent by a business terminal. The expansion request carries physical resources required for business incremental data.
[0073] Step 304: respond to the capacity expansion request and obtain the remaining physical resources of the current physical host.
[0074] Step 306 , determining whether the remaining physical resources of the current physical host meet the requirements for local host expansion; if so, executing step 308 ; otherwise, executing step 310 .
[0075] Step 308 : In response to the trigger information that the target physical resources required by the incremental business data are less than the remaining physical resources of the current physical host, a local host expansion instruction of the database cluster is generated to complete the local expansion of the database cluster.
[0076] Specifically, when the target physical resources required for the incremental business data are less than the remaining physical resources of the current physical host, that is, the current physical host meets the local host expansion, a trigger information for the local host expansion is generated, and in response to the trigger information for the local host expansion, a local host expansion instruction for the database cluster is generated. Based on the local host expansion instruction, the database cluster expansion is completed on the local physical host. The local database cluster expansion method is implemented using the existing expansion method, which will not be elaborated here.
[0077] Step 310 : In response to the trigger information indicating that the target physical resources required by the incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated.
[0078] Specifically, when the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, that is, the current physical host does not meet the local host expansion, a cross-host expansion trigger information is generated, and in response to the cross-host expansion trigger information, a cross-host expansion instruction for the database cluster is generated.
[0079] Step 312: According to the cross-host capacity expansion instruction, a target physical host is determined from the physical resource pool and pre-occupancy information for the cross-host capacity expansion is generated.
[0080] Specifically, according to the cross-host expansion instruction, the remaining physical resources of each physical host in the physical resource pool and the preset threshold of physical resources to ensure the normal operation of each physical host are obtained; the physical host whose physical resources are greater than the target physical resources and less than or equal to the preset threshold of physical resources is determined as the target physical host, and the network address and domain name information for cross-host expansion is generated; that is, the subnet mask information and IP address and other information for cross-host are generated to obtain the corresponding target domain name.
[0081] Step 314: Add an expansion database node to the target physical host according to the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration data node of the current physical host.
[0082] Step 316 : In response to the database node switching instruction, the attribute data of the newly added first database instance of the expanded database node is detected.
[0083] In step 318 , when the attribute data of the first database instance is the preset data, the primary database is switched from the second database instance of the migrated database node to the first database instance newly added to the expanded database node.
[0084] Specifically, when the permissions, accounts, and memory parameters of the first database instance are the corresponding preset data and the version information is compatible with the first database instance and the second database instance, the main database is switched from the second database instance of the migration database node to the first database instance newly added to the expanded database node.
[0085] Step 320: Switch the domain name of the expanded database node and the domain name of the migrated database node, and determine the backup node of the first database instance.
[0086] Specifically, when it is detected that the account information and permission information of the first database embodiment are switchable accounts and permissions, and the parameter values of the database memory parameters are within the preset value range and the version number of the first database embodiment is the same as the version number of the second database embodiment, the expanded database node and the migrated database node are switched, and after the main database is switched from the second database instance of the migrated database node to the newly added first database instance of the expanded database node, the domain name of the expanded database node and the domain name of the migrated database node are switched, that is, the old second database node domain name is switched to the newly added first database node domain name, and the first database node domain name is switched to the second database node domain name; by calling the backup group interface, the backup node is updated from the migration database node of the second database embodiment to the expanded database node of the first database embodiment, and the information of the successful database node switching is fed back to the server.
[0087] Step 322: When it is detected that the first database instance is providing normal data services to the outside world, the migration database node is deleted.
[0088] Specifically, after receiving the information feedback of successful switching, the server generates a business verification instruction and sends the business verification instruction to the business terminal. The business terminal performs business verification on the first database instance. When the business verification passes, the server generates a database node offline instruction. The cloud database management console in the terminal responds to the database node offline instruction. When it is detected that the first database instance can provide external data services normally, the cloud monitoring script file and the Docker monitoring script file, as well as the monitoring information of the Docker instance and the first database instance are deleted, and the Docker instance and the second database instance in the migration database node are deleted to complete the deletion of the migration database node, that is, the database node is offline.
[0089] The following is an application scenario for database cluster expansion, such as Figure 4 As shown, it includes a first terminal, a second terminal and a server, wherein the first terminal is a business terminal, the second terminal is integrated with a cloud database user control platform and a cloud database management control platform, and the server is integrated with an ITIL platform (Information Technology Infrastructure Library).
[0090] The first terminal sends a capacity expansion request for the database cluster to the second terminal. The capacity expansion request carries capacity expansion order information, which includes the physical resources required for the incremental business data, namely the required CPU, hard disk and memory, etc.; the cloud database user control platform of the second terminal responds to the capacity expansion request, obtains the remaining physical resources of the current physical host, compares whether the remaining physical resources of the current physical host support the local host capacity expansion, and generates a trigger information for cross-host capacity expansion when the target physical resources required for the incremental business data are greater than the remaining physical resources of the current physical host; in response to the trigger information for cross-host capacity expansion, a cross-host capacity expansion instruction for the database cluster is generated, and the cloud database user console determines the target physical host from the physical resource pool according to the cross-host capacity expansion instruction and generates pre-occupancy information for cross-host capacity expansion, and sends the generated cross-host capacity expansion instruction to the cloud database management and control platform, which creates an ITIL work order and sends the ITIL work order to the ITIL platform, and the ITIL work order includes the time point for switching the database node for data cluster capacity expansion, the database node creation task and the database node deletion tasks, etc., execute ITIL work orders; when the server receives the ITIL work order confirmation information fed back by the first terminal, it adds an expanded database node to the target physical host according to the pre-occupied information, and establishes a synchronization relationship between the expanded database node and the migration data node of the current physical host. When responding to the database node switching instruction, it detects the attribute data of the newly added first database instance of the expanded database node; if it is detected that the attribute data of the first database instance is the preset data, the main database is switched from the second database instance of the migration database node to the first database instance newly added to the expanded database node, the domain name of the expanded database node and the domain name of the migration database node are switched, and the backup node of the first database instance is determined, that is, the switching is successful; the switching success information is sent to the server, the server generates a business verification instruction, and sends the business verification instruction to the first terminal. The first database instance is business verified through the first terminal. When the business verification passes, the server generates a database node offline instruction, the cloud database management console responds to the database node offline instruction, deletes the migration database node, and the offline node is completed.
[0091] In the above-mentioned database cluster expansion method, when an expansion request sent by a business terminal is received, the expansion method suitable for the database cluster expansion is determined by pre-judging whether the current physical host meets the local host expansion. When the current physical host does not meet the local host expansion, the target physical host is determined from the physical resource pool according to the generated cross-host expansion instruction and pre-occupation information for cross-host expansion is generated. According to the pre-occupation information, an expansion database node of the target physical host is added, and a synchronization relationship between the expansion database node and the migration data node of the current physical host is established; the switching of database nodes, the switching of backup nodes and the offline of migration database nodes are completed by responding to database node switching instructions; by automatically searching for the target physical host, operations such as adding database instances and switching data nodes are automatically realized, which simplifies the operation of database cluster expansion, shortens the expansion time, improves the stability of the physical host and avoids data overflow in the database.
[0092] It should be understood that although Figure 2-3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 2-3 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0093] In one embodiment, Figure 5 As shown, a database cluster expansion device is provided, including: a response module 502, a determination module 504, a creation module 506, a detection module 508 and a switching module 510, wherein:
[0094] The response module 502 is configured to generate a cross-host expansion instruction for the database cluster in response to the trigger information indicating that the target physical resources required for the incremental business data are greater than the remaining physical resources of the current physical host.
[0095] The determination module 504 is configured to determine a target physical host from the physical resource pool according to the cross-host capacity expansion instruction and generate pre-occupancy information for the cross-host capacity expansion.
[0096] The creation module 506 is used to add an expansion database node of the target physical host according to the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration data node of the current physical host.
[0097] The detection module 508 is configured to respond to the database node switching instruction and detect the attribute data of the newly added database instance of the expanded database node.
[0098] The switching module 510 is configured to switch the primary database from the database instance of the expanded database node to the newly added database instance of the expanded database node when the attribute data of the newly added database instance is preset data.
[0099] In the above-mentioned data cluster expansion device, when the remaining physical resources of the current physical host cannot meet the current expansion needs, the target physical host is determined from the physical resource pool according to the generated cross-host expansion instruction of the database cluster and pre-occupation information for cross-host expansion is generated to ensure that cross-host expansion can be achieved; according to the pre-occupation information, an expansion database node of the target physical host is added, and a synchronization relationship between the expansion database node and the migration data node of the current physical host is established; that is, the full data on the migration database node is synchronized to the expansion database node; according to the database node switching instruction, when it is detected that the attribute data of the first database instance newly added to the expansion database node is the preset data, the database node is switched and the main database is determined, that is, the data cluster expansion is achieved by adding the expansion database node and switching the data node, which simplifies the operation of database cluster expansion, shortens the expansion time, and improves the efficiency of database cluster expansion.
[0100] In another embodiment, a database cluster expansion device is provided. In addition to a response module 502, a determination module 504, a creation module 506, a detection module 508, and a switching module 510, the device further includes a receiving module, an acquisition module, a generation module, and a deletion module, wherein:
[0101] The receiving module is used to receive a database cluster expansion request sent by a business terminal. The expansion request carries the physical resources required for the business incremental data.
[0102] In one embodiment, the response module 502 is further configured to respond to the capacity expansion request, obtain the remaining physical resources of the current physical host, and generate trigger information for the capacity expansion method according to the remaining physical resources and the physical resources required by the incremental service data.
[0103] The response module 502 includes a generation submodule. In one embodiment, the generation module is used to generate trigger information for cross-host expansion when the target physical resources required for the incremental business data are greater than the remaining physical resources of the current physical host; when the target physical resources required for the incremental business data are less than or equal to the remaining physical resources of the current physical host, the generation module is used to generate trigger information for local host expansion.
[0104] The acquisition module is used to obtain the remaining physical resources of each physical host in the physical resource pool and the preset threshold value of the physical resources for ensuring the normal operation of each physical host according to the cross-host expansion instruction.
[0105] In one embodiment, the generation module is further configured to determine a physical host whose physical resources are greater than the target physical resources and less than or equal to a preset threshold of the physical resources as the target physical host, and to generate network address and domain name information for cross-host expansion.
[0106] In one embodiment, the switching module 510 is also used to switch the main database from the second database instance of the migration database node to the first database instance newly added to the expanded database node when the permissions, accounts, and memory parameters of the first database instance are the corresponding preset data and the version information is compatible with the first database instance and the second database instance.
[0107] In one embodiment, the switching module 510 is further configured to switch the domain name of the expanded database node and the domain name of the migrated database node, and determine a backup node of the first database instance.
[0108] The deletion module is used to delete the migration database node when it is detected that the first database instance is performing a normal external data service function.
[0109] In one embodiment, the terminal receives a database cluster expansion request sent by a business terminal, the expansion request carries the physical resources required for the business incremental data, responds to the expansion request, and obtains the remaining physical resources of the current physical host; determines whether the remaining physical resources of the current physical host meet the local host expansion, and if the current physical host meets the local host expansion, generates trigger information for the local host expansion, responds to the trigger information for the local host expansion, generates a local host expansion instruction for the database cluster, and completes the database cluster expansion on the local physical host based on the local host expansion instruction.
[0110] The current physical host does not meet the local host expansion, and generates a cross-host expansion trigger information. In response to the cross-host expansion trigger information, a cross-host expansion instruction for the database cluster is generated. According to the cross-host expansion instruction, the target physical host is determined from the physical resource pool and pre-occupancy information for cross-host expansion is generated. According to the pre-occupancy information, an expansion database node of the target physical host is added, and a synchronization relationship between the expansion database node and the migration data node of the current physical host is established; in response to the database node switching instruction, the attribute data of the first database instance newly added to the expansion database node is detected; when the attribute data of the first database instance is the preset data, the master database is switched from the migration data node to the new one. The second database instance of the library node is switched to the first database instance newly added to the expanded database node; the domain name of the expanded database node and the domain name of the migrated database node are switched, and the backup node of the first database instance is determined. When it is detected that the first database instance is functioning normally in providing external data services, the migrated database node is deleted. That is, by pre-judging whether the current physical host meets the capacity expansion of the local host and determining the expansion method suitable for the database cluster expansion, operations such as adding new database instances and switching data nodes are automatically implemented, which simplifies the operation of database cluster expansion, shortens the expansion time, improves the stability of the physical host, and thus avoids data overflow in the database.
[0111] The specific definitions of the database cluster expansion device can be found in the definitions of the database cluster expansion method above and will not be repeated here. Each module in the aforementioned database cluster expansion device can be implemented in whole or in part through software, hardware, or a combination thereof. Each of these modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0112] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a method for expanding the capacity of a database cluster is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the computer device housing, or an external keyboard, touchpad or mouse.
[0113] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0114] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0115] In response to the trigger information that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated;
[0116] According to the cross-host capacity expansion instruction, a target physical host is determined from the physical resource pool and pre-occupancy information for the cross-host capacity expansion is generated;
[0117] Add an expansion database node to the target physical host based on the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration data node of the current physical host;
[0118] In response to the database node switching instruction, detecting attribute data of the first database instance newly added to the expanded database node;
[0119] When the attribute data of the first database instance is the preset data, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0120] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0121] Receive a database cluster expansion request from a business terminal. The expansion request carries the physical resources required for incremental business data.
[0122] Respond to capacity expansion requests and obtain the remaining physical resources of the current physical host;
[0123] Generate trigger information for capacity expansion based on the remaining physical resources and the physical resources required for incremental business data.
[0124] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0125] When the target physical resources required by the incremental business data are greater than the remaining physical resources of the current physical host, trigger information for cross-host expansion is generated.
[0126] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0127] According to the cross-host expansion instruction, the remaining physical resources of each physical host in the physical resource pool and the preset threshold of the physical resources required to ensure the normal operation of each physical host are obtained;
[0128] A physical host whose physical resources are greater than the target physical resources and less than or equal to a preset threshold of the physical resources is determined as the target physical host, and network address and domain name information for cross-host expansion is generated.
[0129] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0130] When the permissions, accounts, and memory parameters of the first database instance are the corresponding preset data and the version information is compatible with the first database instance and the second database instance, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0131] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0132] The domain name of the expanded database node and the domain name of the migrated database node are switched, and the backup node of the first database instance is determined.
[0133] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0134] When it is detected that the first database instance is providing normal external data services, the migration database node is deleted.
[0135] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0136] In response to the trigger information that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated;
[0137] According to the cross-host capacity expansion instruction, a target physical host is determined from the physical resource pool and pre-occupancy information for the cross-host capacity expansion is generated;
[0138] Add an expansion database node to the target physical host based on the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration data node of the current physical host;
[0139] In response to the database node switching instruction, detecting attribute data of the first database instance newly added to the expanded database node;
[0140] When the attribute data of the first database instance is the preset data, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0141] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0142] Receive a database cluster expansion request from a business terminal. The expansion request carries the physical resources required for incremental business data.
[0143] Respond to capacity expansion requests and obtain the remaining physical resources of the current physical host;
[0144] Generate trigger information for capacity expansion based on the remaining physical resources and the physical resources required for incremental business data.
[0145] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0146] When the target physical resources required by the incremental business data are greater than the remaining physical resources of the current physical host, trigger information for cross-host expansion is generated.
[0147] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0148] According to the cross-host expansion instruction, the remaining physical resources of each physical host in the physical resource pool and the preset threshold of the physical resources required to ensure the normal operation of each physical host are obtained;
[0149] A physical host whose physical resources are greater than the target physical resources and less than or equal to a preset threshold of the physical resources is determined as the target physical host, and network address and domain name information for cross-host expansion is generated.
[0150] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0151] When the permissions, accounts, and memory parameters of the first database instance are the corresponding preset data and the version information is compatible with the first database instance and the second database instance, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node.
[0152] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0153] The domain name of the expanded database node and the domain name of the migrated database node are switched, and the backup node of the first database instance is determined.
[0154] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0155] When it is detected that the first database instance is providing normal external data services, the migration database node is deleted.
[0156] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0157] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0158] The above embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A database cluster expansion method, characterized in that: The method comprises: In response to the trigger information that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, a cross-host expansion instruction for the database cluster is generated; According to the cross-host capacity expansion instruction, determining a target physical host from a physical resource pool and generating pre-occupancy information for cross-host capacity expansion; Adding an expansion database node of the target physical host according to the pre-occupancy information, and establishing a synchronization relationship between the expansion database node and the migration database node of the current physical host; In response to the database node switching instruction, detecting attribute data of the newly added first database instance of the expanded database node; When the attribute data of the first database instance is the preset data, the primary database is switched from the second database instance of the migration database node to the first database instance newly added to the expansion database node; The step of determining a target physical host from a physical resource pool and generating pre-occupancy information for cross-host capacity expansion according to the cross-host capacity expansion instruction includes: According to the cross-host expansion instruction, the remaining physical resources of each physical host in the physical resource pool and a preset threshold value of physical resources for ensuring normal operation of each physical host are obtained; Determine a physical host whose physical resources are greater than the target physical resources and less than or equal to a preset threshold of the physical resources as the target physical host, and generate network address and domain name information for cross-host expansion; When the attribute data of the first database instance is preset data, switching the primary database from the second database instance of the migration database node to the newly added first database instance of the expansion database node includes: When the permissions, account numbers, and memory parameters of the first database instance are the corresponding preset data and the version information is compatible with the first database instance and the second database instance, the main database is switched from the second database instance of the migration database node to the newly added first database instance of the expanded database node.
2. The method according to claim 1, characterized in that Before generating the cross-host expansion instruction in response to the trigger information indicating that the target physical resources required for the incremental service data are greater than the remaining physical resources of the current physical host, the method further includes: Receive a database cluster expansion request sent by a business terminal, where the expansion request carries physical resources required for incremental business data; Responding to the capacity expansion request, obtaining the remaining physical resources of the current physical host; The trigger information of the capacity expansion mode is generated according to the remaining physical resources and the physical resources required by the service incremental data.
3. The method according to claim 2, characterized in that The generating the trigger information of the capacity expansion mode according to the remaining physical resources and the physical resources required by the service incremental data includes: When the target physical resources required by the incremental service data are greater than the remaining physical resources of the current physical host, trigger information for cross-host expansion is generated.
4. The method according to claim 1, wherein The method further comprises: The domain name of the expanded database node and the domain name of the migrated database node are switched, and a backup node of the first database instance is determined.
5. The method according to claim 4, characterized in that The method further comprises: When it is detected that the first database instance is providing a normal external data service function, the migration database node is deleted.
6. A database cluster expansion device, characterized in that: The device comprises: A response module is used to respond to trigger information indicating that the target physical resources required for incremental business data are greater than the remaining physical resources of the current physical host, and generate cross-host expansion instructions for the database cluster; a determination module, configured to determine a target physical host from a physical resource pool according to the cross-host capacity expansion instruction and generate pre-occupancy information for the cross-host capacity expansion; A creation module is used to add an expansion database node of the target physical host according to the pre-occupancy information, and establish a synchronization relationship between the expansion database node and the migration database node of the current physical host; a detection module, configured to respond to a database node switching instruction and detect attribute data of a newly added first database instance of the expanded database node; a switching module, configured to switch the primary database from the second database instance of the migration database node to the first database instance newly added to the expansion database node when the attribute data of the first database instance is preset data; The determination module is specifically configured to obtain, according to the cross-host expansion instruction, the remaining physical resources of each physical host in the physical resource pool and a preset threshold of physical resources required to ensure normal operation of each physical host; determine a physical host whose physical resources are greater than the target physical resources and less than or equal to the preset threshold of physical resources as the target physical host, and generate network address and domain name information for cross-host expansion; The switching module is specifically used to switch the main database from the second database instance of the migration database node to the newly added first database instance of the expanded database node when the permissions, account numbers, and memory parameters of the first database instance are corresponding preset data and the version information is compatible with the first database instance and the second database instance.
7. The device according to claim 6, characterized in that The device further comprises: A receiving module, configured to receive a database cluster expansion request sent by a business terminal, wherein the expansion request carries the physical resources required for the incremental business data; The response module is further configured to respond to the capacity expansion request, obtain the remaining physical resources of the current physical host, and generate trigger information for the capacity expansion method according to the remaining physical resources and the physical resources required by the service incremental data.
8. The device according to claim 7, characterized in that The response module also includes: The generating submodule is used to generate trigger information for cross-host expansion when the target physical resources required by the incremental business data are greater than the remaining physical resources of the current physical host.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Capacity expansion method, device and system for database cluster and database cluster system
CN107357896A
Cluster expansion method and system, electronic equipment and storage medium
CN112306373A