Database cluster deployment method and related products
By identifying the database operation mode and performing differentiated operations based on the node status, the problems of data reuse and uninterrupted business in database cluster deployment are solved, and efficient and reliable database cluster deployment and failover are achieved.
Patent Information
- Application Number
- CN202510193226.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-06-10
AI Technical Summary
When expanding a stand-alone database or read-write separation cluster into a database cluster, how to ensure data reuse and uninterrupted business is an urgent problem. Traditional data migration and synchronization solutions have problems such as long time, increased IO times, data inconsistency and recovery point target risk.
By obtaining information from each database node, identifying the database operation mode, and performing differentiated operations based on the node data state and database operation state. Backup operations for stand-alone mode nodes and differentiated operations for cluster mode nodes to reduce redundant operations and improve deployment efficiency.
It significantly reduces redundant operations during the deployment process, greatly improves deployment efficiency, saves time and resources, avoids data inconsistency, and realizes rapid failover in the event of a main library failure, improving the reliability of the database cluster.
Smart Images

Figure CN120123320A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and particularly to a method for deploying a database cluster and related products. Background Art
[0002] With the rapid development of enterprise business and the sharp increase in the amount of data, a single-machine database or a read-write separated cluster has gradually become difficult to meet the requirements of high performance and high availability. To address this challenge, a database cluster architecture has emerged. By deploying a database cluster in two data centers at different geographical locations but within the same city, redundant backup and failover of data are achieved, effectively improving the reliability and disaster tolerance of the system.
[0003] However, in the process of expanding an existing single-machine database or a read-write separated cluster into a database cluster, how to ensure data reuse and uninterrupted business has become an urgent problem to be solved. Traditional data migration and synchronization solutions have many limitations.
[0004] For example, when using an online data synchronization tool, although real-time data migration and synchronization can be achieved, this process requires a full scan and transmission of the data in the original database, resulting in a significant increase in the number of I / O (Input / Output) operations and a long time consumption. In addition, if the primary database fails during the data synchronization process and the synchronized data is incorrect or incomplete, data inconsistency or business logic errors may occur when switching to a dual-center cluster, thereby increasing the risk of the recovery point objective.
[0005] Another example is to perform data migration through backup and recovery. Although the operation is relatively simple, the backup and recovery processes require two I / O operations. For scenarios with a large amount of data, the time consumption will be greatly extended, seriously affecting the business operation of the original primary database. In addition, the timeliness and consistency of the backup data are also difficult to guarantee, increasing the uncertainty in the data migration process. Summary of the Invention
[0006] An object of the present invention is to improve the deployment efficiency of a database cluster.
[0007] A further object of the present invention is to avoid data inconsistency problems caused by dual-primary conflicts.
[0008] Another further object of the present invention is to achieve failover when the primary node fails.
[0009] In particular, according to the first aspect of the present invention, there is provided a method for deploying a database cluster, including:
[0010] Obtain the node information of each database, where the node information includes at least the node data status, the database running status, and the database running mode;
[0011] Identify the database running mode of each node;
[0012] If the database running mode is the single - machine mode, perform a backup operation on all nodes;
[0013] If the database running mode is the cluster mode, perform differential operations on each node according to the node data status and the database running status.
[0014] Optionally, the steps of performing differential operations on each node according to the node data status and the database running status include:
[0015] If the node data status of a node shows that it contains data and its database running status is running, maintain the connection between the node and the master node and preferentially synchronize the data.
[0016] Optionally, the steps of performing differential operations on each node according to the node data status and the database running status further include:
[0017] If the node data status of a node shows that it contains data and its database running status is not running, start the database associated with the node;
[0018] Number the newly started database according to the ID value of the current database;
[0019] Establish a streaming replication connection with the master database to synchronize the data;
[0020] Compare the write - ahead log number of this node with that of the master database, and set the synchronization status of this node according to the comparison result;
[0021] Refer to the configuration standard of the master database and re - configure the configuration file of this node.
[0022] Optionally, the steps of performing differential operations on each node according to the node data status and the database running status further include:
[0023] If the data status of a node shows that it does not contain data, start the data synchronization and transmission process with the master database;
[0024] The master database reads all the data files of its own databases to the standby database and replays the write - ahead log,
[0025] Allocate a node ID for this node, establish a streaming replication connection with the master database and receive the incremental updates from the master database.
[0026] Optionally, after the steps of performing differential operations on each node according to the node data status and the database running status, it further includes:
[0027] Calculate the data volume of the newly started node;
[0028] If its data volume is less than the preset threshold, add the node to the synchronous standby database and set the remaining nodes to the asynchronous state;
[0029] According to the obtained node information, configure the running port and related configuration information of the newly started database;
[0030] The database rereads the configuration file to make the newly set parameters take effect;
[0031] Start the entire database cluster.
[0032] Optionally, the node information further includes the database role. After the step of obtaining the node information of each database, it further includes:
[0033] Determine whether the current node meets the deployment conditions, where the requirements for meeting the deployment conditions are: the database role of the current node is the primary database and the database running status is running, and the database roles of other nodes are standby databases and the database running status is running or non-running.
[0034] Optionally, the database cluster deployment method further includes:
[0035] If the primary database fails during the deployment process, select a standby node from its synchronous standby databases;
[0036] Upgrade the standby node to a new primary database.
[0037] Optionally, after the step of upgrading the standby node to a new primary database, it further includes:
[0038] The new primary database continues to perform backups and clones the standby databases through streaming replication;
[0039] Calculate the recovery point objective;
[0040] Add the original primary database node that has recovered from the failure as a standby database back to the cluster.
[0041] According to the second aspect of the present invention, the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the database cluster deployment method described in any one of the above.
[0042] According to the third aspect of the present invention, the present invention provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the database cluster deployment method described in any one of the above.
[0043] The database cluster deployment method of the present invention first obtains the node information of each database, and the node information at least includes the node data status, the database operation status and the database operation mode. Then, the database operation mode of each node is identified. If the database operation mode is a stand-alone mode, a backup operation is performed on all nodes. If the database operation mode is a cluster mode, a differentiated operation is performed on each node according to the node data status and the database operation status. This deployment strategy of differentiated treatment according to the database operation mode significantly reduces redundant operations in the deployment process, greatly improves deployment efficiency, effectively saves time and resources, and makes the entire database cluster deployment work more efficient and smooth.
[0044] Furthermore, the database cluster deployment method of the present invention, after obtaining the node information of each database, will also determine whether the current node meets the deployment conditions, wherein the requirements for meeting the deployment conditions are: the database role of the current node is the master database, and the database operation status is running, and the database roles of other nodes are standby databases, and the database operation status is running or non-running. In this way, the occurrence of dual-master situations can be prevented. When the master database is unique and in the running state, the writing and updating operations of data can be effectively managed, avoiding data inconsistency problems caused by dual-master conflicts.
[0045] Furthermore, in the database cluster deployment method of the present invention, during the deployment process, when a main database fails, a standby node can be selected from its synchronous standby database, and then the standby node can be upgraded to a new main database. This can ensure that data writing and reading operations will not be interrupted for a long time due to the failure of the main database. The new main database inherits the responsibilities of the original main database and continues to manage and maintain data, so that the continuity of the data is guaranteed. Even if the main database fails, the cluster can still operate normally and provide data services to users. This fast fault recovery capability improves the reliability of the database cluster and reduces the downtime caused by failures.
[0046] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0048] Figure 1 is a schematic flow chart of a database cluster deployment method according to an embodiment of the present invention;
[0049] Figure 2 is a schematic flow chart of new node deployment and cluster startup according to an embodiment of the present invention;
[0050] Figure 3 is a schematic flow chart of failover during deployment according to an embodiment of the present invention;
[0051] Figure 4 is a schematic structural diagram of a dual-center cluster in the same city according to an embodiment of the present invention;
[0052] Figure 5 is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0053] Figure 6 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention;
[0054] Figure 7 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0056] The embodiment of the present invention provides a database cluster deployment method, which aims to use the existing data of each node to achieve efficient deployment of a dual-center cluster in the same city. During the data transmission process, the deployment method can reduce the number of IO times during the data synchronization process.
[0057] Especially in complex scenarios with huge amounts of data, innovative deployment strategies can significantly shorten the time required for the entire deployment process. At the same time, it can also effectively reduce the risk of increased recovery time objectives (RTO) and recovery point objectives (RPO).
[0058] Figure 1 is a schematic flow chart of a database cluster deployment method according to an embodiment of the present invention. Figure 1 As shown, the deployment method at least includes the following steps S102 to S108.
[0059] Step S102, obtaining node information of each database, where the node information at least includes node data status, database operation status and database operation mode.
[0060] Step S104: Identify the database operation mode of each node.
[0061] Step S106: If the database operation mode is a stand-alone mode, a backup operation is performed on all nodes.
[0062] Step S108: If the database operation mode is the cluster mode, a differentiated operation is performed on each node according to the node data state and the database operation state.
[0063] It can be understood that the database operation mode has a stand-alone mode and a cluster mode.
[0064] In stand-alone mode, all data is stored on a single node, and data security is relatively fragile. Once a failure occurs, data may be lost. Therefore, by backing up the data of all nodes, you can use the backup data for recovery in the event of an accident, ensuring data integrity and availability and reducing the risk of data loss.
[0065] In cluster mode, data may be distributed on multiple nodes, and different operations need to be performed on each node according to the node data status (including data or not) and the database operation status (running or not running). Since the status and role of each node in cluster mode are different, by performing differentiated operations, each node can play its due role in the cluster, ensuring that the entire cluster can run efficiently and stably.
[0066] This deployment strategy that differentiates according to the database operation mode can significantly reduce redundant operations during the deployment process, greatly improve deployment efficiency, effectively save time and resources, and make the entire database cluster deployment work more efficient and smooth.
[0067] In this embodiment, the node information of each database can be obtained through the database cluster management software, and the node information is clearly divided into two categories: database configuration information and database operation information.
[0068] The database configuration information includes: database compatibility mode (DB Mode), compatible database types; authentication method (Auth Method), encryption algorithm or authentication mechanism for connecting to the database; write-ahead log archive path (Wal Directory), archive storage path for write-ahead logs; node data status, including data or not including data.
[0069] Database operation information: database operation port (DB Port), and related configuration parameters; database operation mode, stand-alone mode or cluster mode; database number (DB ID), a unique and unchanging positive integer number for each database node (generated when the database cluster is deployed); database role (DB Role), primary database or standby database; database status (DB Status), running or not running; Sync Standby, yes or no; database write-ahead log number (WAL Number), query the log number of the latest database written to disk, the log number can represent the latest data of the database.
[0070] In an optional embodiment, after obtaining the node information of each database, it is also possible to determine whether the current node meets the deployment conditions. Subsequent operations are performed only when the deployment conditions are met. Specifically, the requirements for meeting the deployment conditions are: the database role of the current node is the primary database, and the database operation status is running, and the database roles of other nodes are standby databases, and the database operation status is running or non-running.
[0071] In this way, the dual-master situation can be prevented. When the primary database is unique and in operation, data writing and updating operations can be effectively managed to avoid data inconsistency problems caused by dual-master conflicts.
[0072] The following is a detailed description of the steps of performing differentiated operations on each node according to the node data status and the database operation status in this embodiment.
[0073] In one example, when the node data status of a node indicates that it contains data, if its database operation status is running, the connection between the node and the master node is maintained, and data synchronization is prioritized.
[0074] The master node is the core storage and processing center for data, and other nodes need to keep data synchronized with the master node. For nodes that already contain data and are running, data synchronization is prioritized to ensure that their data is consistent with the latest data of the master node. In this way, no matter which node the user reads data from, they can obtain the same and accurate information, avoiding wrong decisions and business problems caused by inconsistent data.
[0075] Maintaining the connection between the node and the master node and synchronizing data first helps improve the performance of the entire database cluster. By synchronizing data in a timely manner, data differences between nodes can be reduced, reducing the additional processing overhead caused by inconsistent data. At the same time, when there are a large number of data requests, each node can provide consistent data responses, improving the system's concurrent processing capabilities and response speed, and ensuring the efficient and stable operation of the database cluster.
[0076] Of course, if the node is already a master node and is running, then its current state is maintained.
[0077] In another example, when the node data status of the node shows that it contains data, if its database operation status is not running, the database associated with the node is started, and then the newly started database is numbered according to the ID value of the current database. Then, a streaming replication connection is established with the main library to synchronize data. The pre-write log number of the node is compared with that of the main library, and the synchronization state of the node is set according to the comparison result; the configuration file of the node is reconfigured with reference to the configuration standard of the main library.
[0078] When the node data status shows that it contains data but the database is not running, start the database associated with it, and perform operations such as numbering and establishing a streaming replication connection according to the process, so that the node can be quickly integrated into the database cluster. Establishing a streaming replication connection with the main database to synchronize data, comparing the pre-write log number and setting the synchronization status can ensure that the data of the node is highly consistent with the main database. Even in the case of frequent data updates, this mechanism can synchronize the changes of the main database to the node in a timely manner. Numbering the newly started database according to the current database ID value facilitates the identification and management of the node. At the same time, reconfiguring the configuration file of the node with reference to the main database configuration standard makes the configuration of the entire database cluster unified and standardized. This not only facilitates the subsequent maintenance and upgrade of the node, but also reduces potential problems caused by configuration differences, and improves the manageability and maintainability of the database cluster.
[0079] In this embodiment, the step of numbering the newly started database according to the ID value of the current database is specifically: numbering in sequence from the maximum value of the current database ID + 1. This numbering method ensures the uniqueness and continuity of the database ID, greatly facilitating the identification and management of nodes.
[0080] The steps of comparing the write-ahead log number of the node with that of the main database and setting the synchronization state of the node according to the comparison result are as follows: querying the write-ahead log number of the node and comparing it with the write-ahead log number of the main database. If the write-ahead log number of the node is greater than the set threshold, it means that the data update of this node is significantly different from that of the main database, which may be due to the fact that the node has previously performed a large number of independent data operations, or has accumulated a large number of local data changes after being disconnected from the main database for a period of time. At this time, its synchronization state is set to asynchronous because real-time synchronization in this case may have a significant impact on the performance of the main database and the entire cluster. Asynchronous synchronization allows the node to gradually synchronize data with the main database in the subsequent period, reducing the burden on the main database and ensuring the final consistency of the data. When the write-ahead log number of the node is less than or equal to the threshold, it indicates that the data difference between the node and the main database is within an acceptable range. At this time, it is set to the synchronization state, and the node can receive incremental updates from the main database in real time to ensure real-time consistency of the data.
[0081] In another example, when the data status of the node shows that it contains no data, the data synchronization transmission process with the primary database is started. The primary database reads the data files of all its databases to the standby database, replays the write-ahead log, assigns a node ID to the node, establishes a streaming replication connection with the primary database, and receives incremental updates from the primary database.
[0082] Because the node has no data initially, it needs to obtain data from the main database. By starting the synchronous transmission process, a data transmission channel between the main database and the node is established to prepare for subsequent data transmission.
[0083] As the core data storage location, the master database has complete database data files. Transferring these data files to a node with empty data (standby database) allows the node to quickly obtain the basic data of the database and ensure the initial consistency of the node with the master database at the data level.
[0084] The write-ahead log records all modification operations of the database. The master database replays the write-ahead log to the standby database, which allows the standby database to perform these operations in the order of data changes in the master database, thereby ensuring that the data in the standby database is consistent with the master database not only in the initial state, but also in the history and logic of data changes. Even if there are new data changes during the data transmission process, the standby database can achieve complete data synchronization by replaying the log.
[0085] In a database cluster, each node needs to have a unique identifier for easy management and identification. Assigning a node ID to a newly populated node facilitates data interaction and status monitoring within the cluster, so that the node has a clear identity in the cluster and can participate in the operation of the cluster normally.
[0086] After establishing a streaming replication connection, the node can receive the subsequent incremental updates of the master database in real time, that is, the data changes in the master database will be transmitted to the node in a timely manner. In this way, after the initial data synchronization is completed, the node can continue to maintain consistency with the master database data, ensuring that the data of each node can be updated in a timely manner during the operation of the entire database cluster, meeting the business's requirements for real-time data.
[0087] Figure 2 FIG. 1 is a schematic flow chart of new node deployment and cluster startup according to an embodiment of the present invention. Figure 2 As shown, after performing differentiated operations on each node according to the node data status and the database operation status, new node deployment and cluster startup at least include the following steps S202 to S210.
[0088] Step S202, calculating the data volume of the newly started node.
[0089] In a database cluster, when a new node is started and added to the cluster, the data volume of the node needs to be calculated first. The purpose of calculating the data volume is to evaluate the data synchronization requirements and capabilities of the new node, and to determine its role and configuration in the cluster.
[0090] Step S204: If the data volume is less than a preset threshold, the node is added to the synchronous standby database, and the remaining nodes are set to an asynchronous state.
[0091] After obtaining the data volume of the new node, it needs to be compared with the preset threshold. This threshold is usually set based on the cluster capacity, performance requirements, and data synchronization requirements. If the data volume of the new node is less than the preset threshold, it means that it has the ability to undertake more data synchronization tasks, so it can be configured as a synchronous standby database. At the same time, in order to optimize cluster performance and resource utilization, other nodes can be set to asynchronous state to reduce unnecessary data synchronization overhead.
[0092] Step S206: configure the newly started database operation port and related configuration information according to the acquired node information.
[0093] After determining the role and configuration of the new node, you need to configure the database's operating port, log file path, memory allocation and other related parameters based on the obtained node information. When configuring the parameters of the new node, you need to ensure that these parameters are compatible with the configuration of other nodes in the cluster and will not cause conflicts. At the same time, you must also retain the original configuration so that you can roll back or adjust it when necessary.
[0094] Step S208: the database re-reads the configuration file to make the newly set parameters effective.
[0095] After configuring the parameters of the new node, you need to let the database reread the configuration file so that the newly set parameters can take effect. This usually involves restarting the database service or executing a specific command to load the new configuration.
[0096] Step S210, start the entire database cluster.
[0097] After completing the configuration and parameter settings of all nodes, you can start the entire database cluster. This usually involves starting components such as cluster management tools and database services and ensuring that they can run normally. Starting the database cluster ensures that all nodes are running as expected and can handle transaction requests from clients. At the same time, it also marks the completion of the entire deployment process.
[0098] In the embodiment of the present invention, for nodes that already have data stored, after completing the verification work, they only need to be simply configured before they can be put into use. This method fully utilizes the existing data of the node, greatly reduces the time required for data transmission of some nodes, and effectively saves precious IO resources and network resources. Especially in scenarios with huge amounts of data, this advantage is more prominent and can significantly improve deployment efficiency.
[0099] For nodes without data, the embodiment of the present invention optimizes the backup logic. In the data backup and cloning process, only one IO operation is required at both the transmission end and the receiving end to complete the data backup and cloning task. This innovative optimization greatly saves IO resources and significantly shortens the data transmission time, thereby effectively reducing the recovery time objective (RTO) and improving the system's recovery speed when facing failures.
[0100] In addition, during the deployment process, even if the main database fails, the embodiment of the present invention can continue the deployment work by virtue of its unique failover mechanism. This feature reduces the risk of data loss when the main database fails, thereby reducing the recovery point objective (RPO) and ensuring data integrity and business continuity.
[0101] Figure 3 is a schematic flow chart of failover during deployment according to an embodiment of the present invention. Figure 3 As shown, the failover includes at least the following steps S302 to S310.
[0102] Step S302: If a failure occurs in the primary database during the deployment process, a standby node is selected from its synchronous standby database.
[0103] During the deployment or operation of a database cluster, the primary database (the database node responsible for processing transactions) may encounter a failure, resulting in service interruption. In order to maintain service continuity, a node is selected from the primary database's synchronous backup database (a backup database that keeps data synchronized with the primary database) as a backup node. When selecting a backup node, factors such as its data synchronization status, performance, and stability are usually considered.
[0104] Step S304: Upgrade the standby node to the new master database.
[0105] After the upgrade, the new master database has the functions and permissions of the original master database. The new master database will begin to process transaction requests from clients to ensure the continuity of database services.
[0106] Step S306: The new primary database continues to perform backup and clones the standby database through streaming replication.
[0107] While assuming the role of the master database, the new master database will continue to perform backup operations to ensure data security. Streaming replication is a common data synchronization mechanism in database clusters. The new master database will synchronize transaction logs to other standby database nodes in real time through streaming replication technology. Using streaming replication technology, new standby database nodes can be created, and these nodes will keep data synchronized with the new master database.
[0108] Step S308: Calculate the recovery point objective.
[0109] During the fault recovery process, a recovery point objective (RPO) needs to be determined, that is, the time point or state to which the data is restored. The determination of the recovery point objective will directly affect the speed and accuracy of data recovery. For example, the recovery point objective = the database write-ahead log sequence number of the original primary database – the database write-ahead log sequence number of the new primary database.
[0110] Step S310: restore the original master database node that has failed and add it back to the cluster as a standby database.
[0111] After the failed original master database node is repaired, it needs to be rejoined to the database cluster. Since the new master database has assumed the role of the master database, the repaired original master database node will be added to the cluster as a standby database node. Before joining the cluster, it is necessary to ensure data synchronization between the repaired original master database node and the new master database. This can be achieved through streaming replication or other data synchronization mechanisms.
[0112] In this embodiment, the new master database inherits the responsibilities of the original master database and continues to manage and maintain data, which can achieve failover and ensure data continuity. Even if the master database fails, the cluster can still operate normally and provide data services to users. This fast fault recovery capability improves the reliability of the database cluster and reduces downtime caused by failures.
[0113] Figure 4 It is a schematic structural diagram of a dual-center cluster in the same city according to an embodiment of the present invention, including a Primary Region (primary region) and a Secondary Region (backup region).
[0114] In the Primary Region, there is an AZ1 zone, which includes a Primary node and two Standby nodes. The primary node and the standby nodes are connected, indicating that data can be synchronized and replicated between them.
[0115] In the Secondary Region, there is an AZ2 area, which includes a SubPrimary (secondary primary node) and two Standby (standby nodes). The subprimary node and the standby node also have a similar connection relationship.
[0116] Both regions have local backups, which are used to save a copy of data locally to increase data security.
[0117] The database nodes with dotted lines represent nodes without data. For example, some Standby nodes in the Secondary Region in the figure may be newly added nodes without data, and data synchronization and configuration operations need to be performed according to the above process.
[0118] After the above detailed step analysis and illustrations, those skilled in the art can fully understand how to use existing data to deploy a dual-center cluster in the same city to ensure high availability and consistency of data. In other words, these steps and explanations clearly show how to use existing data to directly build a database cluster to ensure that data can remain highly available and consistent under any circumstances.
[0119] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes may be made to the above method.
[0120] It should be understood that in some embodiments, each part can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0121] This embodiment also provides a computer program product 10 , a computer readable storage medium 20 , and a computer device 30 . Figure 5 is a schematic diagram of a computer program product 10 according to an embodiment of the present invention,Figure 6 is a schematic diagram of a computer-readable storage medium 20 according to an embodiment of the present invention, Figure 7 is a schematic diagram of a computer device 30 according to an embodiment of the present invention. The computer program product 10 includes a computer program 11, which implements the steps of any of the above-mentioned database cluster deployment methods when executed by a processor 32. The computer-readable storage medium 20 stores the above-mentioned computer program 11, which implements the steps of any of the above-mentioned database cluster deployment methods when executed by the processor 32. The computer device 30 may include a memory 31, a processor 32, and the computer program 11 stored in the memory 31 and running on the processor 32.
[0122] The computer program 11 for performing the operation of the present invention may be an assembly instruction, an instruction set architecture (ISA) instruction, a machine instruction, a machine-related instruction, a microcode, a firmware instruction, a state setting data, a configuration data of an integrated circuit, or a source code or an object code written in any combination of one or more programming languages and process programming languages. The computer program 11 may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network (including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider via the Internet). In some embodiments, in order to perform various aspects of the present invention, an electronic circuit including, for example, a programmable logic circuit, a field programmable gate array (FPGA) or a programmable logic array (PLA) may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.
[0123] In the description of this embodiment, the computer program product 10 is a related product including the computer program 11 .
[0124] For the purposes of the description of this embodiment, the computer-readable storage medium 20 is a tangible device capable of retaining and storing the computer program 11, which may be any device that can contain, store, communicate, propagate or transmit the program 11 for use with or in conjunction with an instruction execution system, device or apparatus. More specific examples (a non-exhaustive list) of the computer-readable storage medium 20 include the following: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, and any suitable combination of the foregoing.
[0125] The computer device 30 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smart phone. In some examples, the computer device 30 may be a cloud computing node. The computer device 30 may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, a program module may include routines, programs, target programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 30 may be implemented in a distributed cloud computing environment where remote processing devices linked via a communication network perform tasks. In a distributed cloud computing environment, program modules may be located on a local or remote computing system storage medium including a storage device.
[0126] The computer device 30 may include a processor 32 adapted to execute stored instructions, and a memory 31 providing temporary storage space for the operation of the instructions during operation. The processor 32 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 31 may include a random access memory (RAM), a read-only memory, a flash memory, or any other suitable storage system.
[0127] The computer device 30 may also include a network adapter / interface and an input / output (I / O) interface. The I / O interface allows data to be input and output with external devices that may be connected to the computer device. The network adapter / interface may provide communication between the computer device and a network, which is typically shown as a communication network.
[0128] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.
Claims
1. A database cluster deployment method, comprising: Obtaining node information of each database, wherein the node information includes at least node data status, database operation status, and database operation mode; Identify the database operation mode of each node; If the database operation mode is stand-alone mode, perform backup operations on all nodes; If the database operation mode is cluster mode, differentiated operations are performed on each node according to the node data status and database operation status.
2. The database cluster deployment method according to claim 1, wherein: The steps of performing differentiated operations on each node according to the node data status and database operation status include: If the node data status of the node shows that it contains data and its database operation status is running, the connection between the node and the master node is maintained and data synchronization is prioritized.
3. The database cluster deployment method according to claim 2, wherein: The steps of performing differentiated operations on each node according to the node data status and database operation status also include: If the node data status of the node shows that it contains data and its database operation status is not running, start the database associated with the node; Number the newly started database according to the ID value of the current database; Establish a streaming replication connection with the primary database to synchronize data; Compare the pre-write log number of the node with that of the main library, and set the synchronization status of the node according to the comparison result; Refer to the configuration standard of the main library and reconfigure the configuration file of the node.
4. The database cluster deployment method according to claim 3, wherein: The steps of performing differentiated operations on each node according to the node data status and database operation status also include: If the data status of the node shows that it does not contain data, the data synchronization transmission process with the main database is started; The master database reads the data files of all its databases to the slave database and replays the write-ahead log. Assign a node ID to the node, establish a streaming replication connection with the master library, and receive incremental updates from the master library.
5. The database cluster deployment method according to claim 4, wherein: After the step of performing differentiated operations on each node according to the node data status and the database operation status, the following steps are also included: Calculate the data volume of the newly started node; If the data volume is less than the preset threshold, the node is added to the synchronous standby database and the remaining nodes are set to asynchronous state; Configure the newly started database operation port and related configuration information based on the obtained node information; The database re-reads the configuration file to make the newly set parameters take effect; Start the entire database cluster.
6. The database cluster deployment method according to claim 1, wherein: The node information also includes the database role. After the step of obtaining the node information of each database, the following steps are further included: Determine whether the current node meets the deployment conditions, where the requirements for meeting the deployment conditions are: the database role of the current node is the primary database and the database operation status is running, and the database roles of other nodes are standby databases and the database operation status is running or not running.
7. The database cluster deployment method according to claim 1, further comprising: If the primary database fails during deployment, a standby node is selected from its synchronized standby database; The standby node is upgraded to the new master database.
8. The database cluster deployment method according to claim 7, wherein: After the step of upgrading the standby node to a new master database, the method further includes: The new primary database continues to perform backup and clones the standby database through streaming replication; Calculate recovery point objectives; Restore the failed master database node and add it back to the cluster as a standby database.
9. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the database cluster deployment method according to any one of claims 1 to 8.
10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the database cluster deployment method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Database cluster inspection control method and system and server
CN120336342A