Database operation method, device, equipment, medium and program product
By persisting the connection information of database nodes in external storage resources and timely updating it, the permission failure problem caused by changes in database node connection information is solved, and the stability and operation efficiency of distributed databases are improved.
Patent Information
- Application Number
- CN202411641657.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-18
AI Technical Summary
When the connection information of the database node changes, the permissions of the pre-configured database tenant and data warehouse will be invalid, and the database node needs to be restarted to update the permissions, resulting in a reduced stability of the distributed database operation.
By obtaining and persisting the connection information of database nodes in external storage resources, and updating the connection information in the data storage component when the connection information changes, ensuring that data warehouses and database tenants can obtain the latest connection information in a timely manner and update their operation permissions.
The connection information is updated without restarting the database node, which improves the stability and efficiency of database operations and ensures access to the database nodes by data warehouses and database tenants.
Smart Images

Figure CN119149645B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of database and computer, and in particular to a database operation method, device, equipment, medium and program product. Background Art
[0002] A distributed database includes multiple database nodes located in the same or different geographical locations. Therefore, it is impossible to use a unified verification method to obtain data operation permissions for multiple database nodes, and it is impossible to implement joint operations on heterogeneous data. Usually, the operation permissions of multiple database nodes are obtained by utilizing the environment variables of each database node in the form of database tenants and data warehouses, so that the data warehouse including data from multiple database nodes can be operated through database tenants.
[0003] In the process of implementing the present invention, the inventors found that when the connection information of the database node changes, the permissions of the pre-configured database tenants and data warehouses will become invalid. It is necessary to obtain the environment variables after restarting the database node and reconfigure the connection string information to update the permissions, which reduces the stability of the distributed database operation. Summary of the invention
[0004] In view of the above problems, the present invention provides a database operation method, apparatus, device, medium and program product.
[0005] According to a first aspect of the present invention, a database operation method is provided, comprising: in response to a data operation request, determining a target database node from a distributed database, wherein the distributed database comprises a plurality of database nodes, the target database node is at least one of the plurality of database nodes, and the target database node stores data to be operated related to the data operation request; based on the target database node, determining a target data warehouse corresponding to the target database node from a plurality of data warehouses, and determining a target database tenant from a plurality of database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, the connection information is obtained from an external storage resource, and the target database tenant has the ability to process the data to be operated; and operating the data to be operated in the target data warehouse using the database tenant to obtain a target result corresponding to the data operation request.
[0006] According to an embodiment of the present invention, the database operation method also includes: storing the connection information of each of the multiple database nodes obtained from the external storage resource into the data storage component; in response to the instruction for generating the data warehouse, obtaining the connection information of the database node corresponding to the data warehouse from the data storage component; correspondingly, the data warehouse is generated in the following manner: based on the connection information of the database node, determining the source data of the database node; and generating the data warehouse using the source data of the database node.
[0007] According to an embodiment of the present invention, connection information of a database node corresponding to a data warehouse obtained from an external storage resource is stored in a data storage component, including: using a persistent storage component to persistently store the connection information in an external storage resource; and in response to a data call request, storing the connection information read from the external storage resource in the data storage component, wherein the data call request includes a request to operate on data in the database node using the connection information.
[0008] According to an embodiment of the present invention, the database operation method also includes: when the connection information of the database node changes, using a persistent storage component to persistently store the updated connection information in an external storage resource; in response to a target request, reading the updated connection information from the external storage resource, and using the updated connection information to update the connection information of the database node stored in the data storage component, wherein the target request includes a request of the same type as a data operation request or a request of the same type as a data call request; using the updated connection information to update the warehouse connection string information of the data warehouse, wherein the warehouse connection string information is used to determine the operation authority of the data warehouse to the database node; and using the updated connection information to update the tenant connection string information of the database tenant, wherein the tenant connection string information is used to determine the operation authority of the database tenant to the database node.
[0009] According to an embodiment of the present invention, determining a target database node from a distributed database includes: determining the target database node from a plurality of database nodes based on a database node table name in a data operation request.
[0010] According to an embodiment of the present invention, database tenants are configured in the following manner, including: determining configuration resources of multiple database tenants based on database resources of a distributed database; determining tenant connection string information of multiple database tenants using connection information of multiple database nodes of a distributed database; and configuring configuration resources and tenant connection string information for an initial database tenant to obtain a database tenant.
[0011] According to an embodiment of the present invention, each data warehouse corresponds to one or more database nodes, and each database tenant corresponds to one or more database nodes; based on the target database node, a target data warehouse corresponding to the target database node is determined from multiple data warehouses, and a target database tenant is determined from multiple database tenants, including: based on the correspondence between the target database node and the warehouse, the target data warehouse is determined, wherein the warehouse correspondence represents the mapping relationship between the data warehouse and the database node; and based on the correspondence between the target database node and the tenant, the target database tenant is determined, wherein the tenant correspondence represents the mapping relationship between the database tenant and the database node.
[0012] A second aspect of the present invention provides a database operation device, comprising:
[0013] a node determination module, configured to determine a target database node from a distributed database in response to a data operation request, wherein the distributed database includes a plurality of database nodes, the target database node is at least one of the plurality of database nodes, and the target database node stores data to be operated related to the data operation request;
[0014] a target determination module, for determining, based on a target database node, a target data warehouse corresponding to the target database node from a plurality of data warehouses, and determining a target database tenant from a plurality of database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, the connection information is obtained from an external storage resource, and the target database tenant has the ability to process the data to be operated; and
[0015] The data operation module is used to use the database tenant to operate the data to be operated in the target data warehouse to obtain the target result corresponding to the data operation request.
[0016] A third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.
[0017] The fourth aspect of the present invention further provides a computer-readable storage medium on which a computer program or instruction is stored, and the steps of the above method are implemented when the above computer program or instruction is executed by a processor.
[0018] The fifth aspect of the present invention also provides a computer program product, including a computer program or instructions, which implement the steps of the above method when executed by a processor.
[0019] According to an embodiment of the present invention, in response to a data operation request, a target database node corresponding to the data operation request is determined from multiple database nodes of a distributed database, and a target data warehouse is determined from multiple data warehouses, and a target database tenant is determined from multiple database tenants, and the target database tenant is used to operate the data in the target data warehouse. By operating the data in the data warehouse through the database tenant, data operations can be performed without authenticating each database node, thereby improving the efficiency of data operations. The data warehouse and the database tenant are both determined based on the connection information of the database node, and the data security in the distributed database can be ensured by verifying the connection information. In addition, the connection information is obtained from an external storage resource. When the connection information changes, the connection information in the external storage resource can be updated without restarting the database node, thereby ensuring that the data warehouse and the database tenant can obtain the latest connection information in a timely manner, guaranteeing the access rights of the data warehouse and the database tenant to the database node, and improving the stability of database operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings.
[0021] Figure 1 An application scenario diagram of a database operation method, apparatus, device, medium, and program product according to an embodiment of the present invention is shown.
[0022] Figure 2 A flowchart of a database operation method according to an embodiment of the present invention is shown.
[0023] Figure 3 A timing diagram showing the updating of warehouse connection string information by the database operation method according to an embodiment of the present invention is shown.
[0024] Figure 4 The corresponding relationship among the database node, the data warehouse and the database tenant of the database operation method according to the embodiment of the present invention is shown.
[0025] Figure 5 A structural block diagram of a database operating device according to an embodiment of the present invention is shown.
[0026] Figure 6 FIG. 5 is a block diagram of an electronic device suitable for implementing a database operation method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.
[0028] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0029] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0030] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0031] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, invention and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0032] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present invention provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.
[0033] An embodiment of the present invention provides a database operation method, comprising: in response to a data operation request, determining a target database node from a distributed database, wherein the distributed database includes multiple database nodes, the target database node is at least one of the multiple database nodes, and the target database node stores data to be operated related to the data operation request; based on the target database node, determining a target data warehouse corresponding to the target database node from multiple data warehouses, and determining a target database tenant from multiple database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, the connection information is obtained from an external storage resource, and the target database tenant has the ability to process the data to be operated; and using the database tenant to operate on the data to be operated in the target data warehouse to obtain a target result corresponding to the data operation request.
[0034] Figure 1 An application scenario diagram of a database operation method, apparatus, device, medium, and program product according to an embodiment of the present invention is shown.
[0035] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0036] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).
[0037] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0038] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0039] It should be noted that the database operation method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the database operation device provided in the embodiment of the present invention can generally be set in the server 105. The database operation method provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the database operation device provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.
[0040] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0041] The following will be based on Figure 1 The scene described by Figure 2~Figure 4 The database operation method of the embodiment of the invention is described in detail.
[0042] Figure 2 A flowchart of a database operation method according to an embodiment of the present invention is shown.
[0043] like Figure 2 As shown, the database operation method of this embodiment includes operations S210 to S230.
[0044] In operation S210, in response to a data operation request, a target database node is determined from a distributed database, wherein the distributed database includes multiple database nodes, the target database node is at least one of the multiple database nodes, and the target database node stores data to be operated related to the data operation request.
[0045] In operation S220 , based on the target database node, a target data warehouse corresponding to the target database node is determined from a plurality of data warehouses, and a target database tenant is determined from a plurality of database tenants.
[0046] In operation S230, the target database tenant is used to operate the data to be operated in the target data warehouse to obtain a target result corresponding to the data operation request.
[0047] According to an embodiment of the present invention, in response to a user's data operation request, a target database node corresponding to the data operation request is determined from a distributed database, wherein the distributed database may use Kubernetes (k8s), the distributed database includes multiple database nodes, the target database node is at least one of the multiple database nodes, the data operation request is used to request an operation on data in the target database node, and the target database node stores data to be operated related to the data operation request.
[0048] According to an embodiment of the present invention, a distributed database includes multiple data warehouses and multiple database tenants, wherein the multiple data warehouses are determined based on multiple database nodes, and the multiple database tenants are determined based on the multiple database nodes.
[0049] According to an embodiment of the present invention, based on the target database node, a target data warehouse corresponding to the target database node is determined from multiple data warehouses, and a target database tenant is determined from multiple database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, and the target database tenant has the ability to process the data to be operated.
[0050] According to an embodiment of the present invention, the connection information of a database node may include the name of a database table stored in the database node, the username and password of the database node, and other information. The connection information may be obtained from an external storage resource, wherein the external storage resource may include a persistent volume (PersistentVolume, PV) for providing persistent storage. The connection information of the database node may be mounted to the PV to achieve persistent storage. After the persistent storage is achieved, the connection information may be obtained through the PV.
[0051] According to an embodiment of the present invention, there is a one-to-one correspondence between multiple database tenants and multiple data warehouses, and the database tenant can be used to operate the data in the data warehouse corresponding to the database tenant, wherein the target data warehouse and the target database tenant determined based on the target database node are a pair of data warehouse and database tenant corresponding to each other. The target database tenant is used to operate the data to be operated in the target data warehouse to obtain the target result corresponding to the data operation request.
[0052] According to an embodiment of the present invention, in response to a data operation request, a target database node corresponding to the data operation request is determined from multiple database nodes of a distributed database, and a target data warehouse is determined from multiple data warehouses, and a target database tenant is determined from multiple database tenants, and the target database tenant is used to operate the data in the target data warehouse. By operating the data in the data warehouse through the database tenant, data operations can be performed without authenticating each database node, thereby improving the efficiency of data operations. The data warehouse and the database tenant are both determined based on the connection information of the database node, and the data security in the distributed database can be ensured by verifying the connection information. In addition, the connection information is obtained from an external storage resource. When the connection information changes, the connection information in the external storage resource can be updated without restarting the database node, thereby ensuring that the data warehouse and the database tenant can obtain the latest connection information in a timely manner, guaranteeing the access rights of the data warehouse and the database tenant to the database node, and improving the stability of database operations.
[0053] According to an embodiment of the present invention, the database operation method also includes: storing the connection information of each of the multiple database nodes obtained from the external storage resource into the data storage component; in response to the instruction for generating the data warehouse, obtaining the connection information of the database node corresponding to the data warehouse from the data storage component; correspondingly, the data warehouse is generated in the following manner: based on the connection information of the database node, determining the source data of the database node; and generating the data warehouse using the source data of the database node.
[0054] According to an embodiment of the present invention, the connection information of the database node may be obtained by reading a data storage component, wherein the data storage component may include a component backend for storing information of backend services.
[0055] According to an embodiment of the present invention, after respective connection information of multiple database nodes obtained from an external storage resource is stored in a data storage component, in response to an instruction for generating a data warehouse, the data warehouse corresponding to the instruction and the database node corresponding to the data warehouse are determined, and the connection information of the database node corresponding to the data warehouse is obtained through the data storage component.
[0056] According to an embodiment of the present invention, the connection information of the database node may also be obtained by obtaining the environment variables of the container group (Pod) of the database node or reading through the k8s interface.
[0057] According to an embodiment of the present invention, since the database table name of the database node can be determined through the connection information of the database node, and the permission to read and operate data from the database node can be obtained, the source data of the database node can be determined based on the connection information of the database node, and a data warehouse can be generated based on the source data of the database node, so that the data warehouse includes all the data in one or more database nodes corresponding to the data warehouse.
[0058] According to an embodiment of the present invention, after the connection information of each of the multiple database nodes is stored in the data storage component, in response to an instruction for generating a data warehouse, the connection information is obtained from the data storage component, the source data of the database node is determined, and the data warehouse is generated using the source data. The accuracy of the connection information used when generating the data warehouse can be ensured, thereby ensuring that the source data can be successfully obtained and the data warehouse can be generated according to the connection information, thereby improving the efficiency of generating the data warehouse.
[0059] According to an embodiment of the present invention, connection information of a database node corresponding to a data warehouse obtained from an external storage resource is stored in a data storage component, including: using a persistent storage component to persistently store the connection information in an external storage resource; and in response to a data call request, storing the connection information read from the external storage resource in the data storage component, wherein the data call request includes a request to operate on data in the database node using the connection information.
[0060] According to an embodiment of the present invention, a persistent storage component is used to persistently store connection information in an external storage resource, wherein the persistent storage operation may include a creation operation, a mount operation, etc., and the persistent storage component may include an operation component capable of mounting the connection information to an external storage resource.
[0061] According to an embodiment of the present invention, in response to a data call request, connection information is read from an external storage resource and stored in a data storage component, wherein the data call request includes a request for operating data in a database node using the connection information. For example, after creating a new database node, a distributed database administrator can use the connection information of the database node to initiate a login request to the database node or a request for operating data in the database node, so as to send the data call request.
[0062] According to an embodiment of the present invention, the updated connection information is persistently stored in an external storage resource using a persistent storage component, thereby avoiding the situation where the updated connection information is lost when the database node is re-called due to the connection information of the database node not being persistent, thereby improving the stability of data operations. In response to a data call request, the connection information stored in the external storage resource is stored in the data storage component, so that the connection information is read through the data storage component, and the data warehouse and database tenants are created or configured, thereby improving the efficiency of creating the data warehouse and the efficiency of configuring the database tenants.
[0063] According to an embodiment of the present invention, database tenants are configured in the following manner, including: determining configuration resources of multiple database tenants based on database resources of a distributed database; determining tenant connection string information of multiple database tenants using connection information of multiple database nodes of a distributed database; and configuring configuration resources and tenant connection string information for an initial database tenant to obtain a database tenant.
[0064] According to an embodiment of the present invention, based on the database resources of the distributed database, the configuration resources of the respective multiple database tenants are determined, wherein the database resources may include the maximum number of connections allowed for the distributed database, the query cache size, the buffer pool size, etc. The configuration resources are used to support the database tenants' operations on the distributed database, and may include the database resources allocated to the respective multiple database tenants. The connection information of the respective multiple database nodes of the distributed database is used to determine the tenant connection string information of the respective multiple database tenants, wherein the tenant connection string information is used to determine the database tenant's operation authority on the database node.
[0065] According to an embodiment of the present invention, a distributed database includes multiple initial database tenants, wherein the initial database tenant is a database tenant to which configuration resources and connection string information are not allocated, so the initial database tenant can determine the corresponding database manipulation language (Data Manipulation Language, DML) based on the data operation request, but the initial database tenant does not have the operation authority for the database node, and cannot use the database resources to perform data operations. After the initial database tenant is configured using the configuration resources and the tenant connection string information, the initial database tenant can use the database resources and the operation authority for the database node to operate the data to be operated, and obtain a database tenant that can operate the data in the target database node based on the data operation request.
[0066] According to an embodiment of the present invention, the configuration resources of the database tenant are determined based on the database resources of the distributed database, the tenant connection string information of the database tenant is determined based on the connection information, and the initial database tenant is configured using the above information, so that the configured database tenant has the operation authority over the database node and has sufficient database resources to support the database tenant to operate the data of the database node in the data warehouse.
[0067] According to an embodiment of the present invention, the database operation method also includes: when the connection information of the database node changes, using a persistent storage component to persistently store the updated connection information in an external storage resource; in response to a target request, reading the updated connection information from the external storage resource, and using the updated connection information to update the connection information of the database node stored in the data storage component, wherein the target request includes a request of the same type as a data operation request or a request of the same type as a data call request; using the updated connection information to update the warehouse connection string information of the data warehouse, wherein the warehouse connection string information is used to determine the operation authority of the data warehouse to the database node; and using the updated connection information to update the tenant connection string information of the database tenant, wherein the tenant connection string information is used to determine the operation authority of the database tenant to the database node.
[0068] According to an embodiment of the present invention, when the connection information of a database node changes, the connection information stored in the data storage component needs to be updated to ensure that the database tenant and the data warehouse can use the latest connection information. When the connection information of a database node changes, the updated connection information is persistently stored in an external storage resource using a persistent storage component to achieve persistence of the connection information.
[0069] According to an embodiment of the present invention, in response to a target request, updated connection information of persistent storage is read from an external storage resource, and the updated connection information is used to update the connection information before the update in the data storage component, wherein the target request may include requests of the same type as data operation requests. For example, after the connection information of a database node changes, a distributed database administrator may use the connection information of the database node to initiate a login request to the database node or a request to operate the data in the database node to implement the sending of a data target request. The target request may also include requests of the same type as data call requests. For example, an error occurs in the process of using a database tenant to operate data in a data warehouse. By comparison, it is found that the connection information configured in the database tenant is the connection information before the update, which triggers a target request to update the connection information in the data storage component so as to update the database tenant and the data warehouse according to the connection information in the array storage component.
[0070] According to an embodiment of the present invention, after completing the update of the connection information in the data storage component, the warehouse connection string information of the data warehouse and the tenant connection string information of the database tenant are updated using the updated connection information, wherein the warehouse connection string information is used to determine the data warehouse's operating authority over the database node, and the tenant connection string information is used to determine the database tenant's operating authority over the database node. For example, in the case where the warehouse connection string information of the data warehouse matches the updated connection information of the target database node, the data in the target database node can be used to update the data in the data warehouse, and in the case where the tenant connection string information of the database tenant matches the updated connection information of the target database node, the database tenant can be used to operate on the data in the data warehouse corresponding to the target database node.
[0071] According to an embodiment of the present invention, when the connection information of a database node changes, it is necessary to update the connection information stored in the data storage component so that the warehouse connection string information of the data warehouse and the tenant connection string information of the database tenant can be updated according to the data storage component, thereby ensuring that the data warehouse and the database tenant still have the authority to operate the information of the database node after the connection information changes, thereby ensuring the stability of data operations.
[0072] Figure 3 A timing diagram showing the updating of warehouse connection string information by the database operation method according to an embodiment of the present invention is shown.
[0073] like Figure 3 As shown, the updating process includes operations S301 to S306.
[0074] In operation S301, the connection information of the database node is monitored regularly using a timing script, and when the connection information changes, the updated connection information is sent to the external storage resource. In operation S302, the updated connection information is stored in the external storage resource using a persistent storage component. In operation S303, in response to the target request, the updated connection information is read from the external resource and sent to the data storage component. In operation S304, the data storage component updates the connection information of the database node using the updated connection information. In operation S305, the data storage component sends the updated connection information to the data warehouse. In operation S306, the warehouse connection string information is updated using the updated connection information to complete the update of the warehouse connection string of the data warehouse. In operation S307, the data warehouse sends an update completion message to the timing script. After receiving the update completion message, the timing script determines the connection information currently used in the warehouse connection string of the data warehouse, and continues to monitor the connection information of the database node.
[0075] According to an embodiment of the present invention, determining a target database node from a distributed database includes: determining the target database node from a plurality of database nodes based on a database node table name in a data operation request.
[0076] According to an embodiment of the present invention, the data operation request includes the table name of the data table stored in the database node, indicating that the data operation request needs to operate the data in the data table matching the table name. Therefore, the target database node can be determined from multiple database nodes based on the table name.
[0077] According to an embodiment of the present invention, a target database node is determined from multiple database nodes based on a table name in a data operation request, thereby ensuring accuracy in determining the target database node.
[0078] According to an embodiment of the present invention, each data warehouse corresponds to one or more database nodes, and each database tenant corresponds to one or more database nodes; based on the target database node, a target data warehouse corresponding to the target database node is determined from multiple data warehouses, and a target database tenant is determined from multiple database tenants, including: based on the correspondence between the target database node and the warehouse, the target data warehouse is determined, wherein the warehouse correspondence represents the mapping relationship between the data warehouse and the database node; and based on the correspondence between the target database node and the tenant, the target database tenant is determined, wherein the tenant correspondence represents the mapping relationship between the database tenant and the database node.
[0079] Figure 4 The corresponding relationship among the database node, the data warehouse and the database tenant of the database operation method according to the embodiment of the present invention is shown.
[0080] like Figure 4 As shown, the distributed database includes multiple data warehouses 401, multiple database nodes 402, and multiple database tenants 403. Each data warehouse corresponds to one or more database nodes, and each database tenant corresponds to one or more database nodes. For example, data warehouse 1 corresponds to database node 1, database node 2, and database node 3, that is, data warehouse 1 includes data in database node 1, database node 2, and database node 3, and database tenant 1 corresponds to database node 1, database node 2, and database node 3, that is, database tenant 1 can operate on the data in database node 1, database node 2, and database node 3.
[0081] Each data warehouse corresponds to a database tenant, and the corresponding data warehouse and database tenant have the same one or more database nodes. For example, data warehouse 1 corresponds to database tenant 1, and they both correspond to database nodes 1, 2, and 3. Therefore, users can use database tenant 1 to operate on the data in data warehouse 1, and implement operations on the data in database nodes 1, 2, and 3.
[0082] According to an embodiment of the present invention, based on the correspondence between the target database node and the warehouse, a target data warehouse including the target database node is determined from multiple data warehouses, wherein the warehouse correspondence represents the mapping relationship between the data warehouse and the database node. Based on the correspondence between the target database node and the tenant, a target database tenant that can operate the target database node is determined from multiple database tenants, wherein the tenant correspondence represents the mapping relationship between the database tenant and the database node.
[0083] According to an embodiment of the present invention, when creating a data warehouse and configuring a database tenant, the mapping relationship between the data warehouse and the database node and the mapping relationship between the database tenant and the database node are determined according to the connection information used. It is ensured that after determining the target database node, the target data warehouse and the target database tenant can be determined according to the above mapping relationship, thereby improving the efficiency of data operations.
[0084] Based on the above database operation method, the present invention also provides a database operation device. Figure 5 The device is described in detail.
[0085] Figure 5 A structural block diagram of a database operating device according to an embodiment of the present invention is shown.
[0086] like Figure 5 As shown, the database operation device 500 of this embodiment includes a node determination module 510 , a target determination module 520 and a data operation module 530 .
[0087] The node determination module 510 is used to determine a target database node from a distributed database in response to a data operation request, wherein the distributed database includes multiple database nodes, the target database node is at least one of the multiple database nodes, and the target database node stores data to be operated related to the data operation request. In one embodiment, the node determination module 510 can be used to perform the operation S210 described above, which will not be repeated here.
[0088] The target determination module 520 is used to determine the target data warehouse corresponding to the target database node from multiple data warehouses based on the target database node, and determine the target database tenant from multiple database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, the connection information is obtained from an external storage resource, and the target database tenant has the ability to process the data to be operated. In one embodiment, the target determination module 520 can be used to perform the operation S220 described above, which will not be repeated here.
[0089] The data operation module 530 is used to operate the data to be operated in the target data warehouse using the database tenant to obtain the target result corresponding to the data operation request. In one embodiment, the data operation module 530 can be used to perform the operation S230 described above, which will not be repeated here.
[0090] According to an embodiment of the present invention, the database operation device 500 further includes an information storage module, an information reading module, a data determination module and a warehouse generation module.
[0091] The information storage module is used to store the connection information of each of the multiple database nodes obtained from the external storage resource into the data storage component.
[0092] The information reading module is used to obtain connection information of a database node corresponding to the data warehouse from the data storage component in response to an instruction for generating the data warehouse.
[0093] The data determination module is used to determine the source data of the database node based on the connection information of the database node.
[0094] The warehouse generation module is used to generate a data warehouse using the source data of the database node.
[0095] According to an embodiment of the present invention, the information storage module includes a first storage unit and a second storage unit.
[0096] The first storage unit is used to persistently store the connection information in an external storage resource using a persistent storage component.
[0097] The second storage unit is used to store the connection information read from the external storage resource in the data storage component in response to a data call request, wherein the data call request includes a request to operate the data in the database node using the connection information.
[0098] According to an embodiment of the present invention, the database operation device 500 further includes a first data updating module, a second data updating module, a first connection updating module and a second connection updating module.
[0099] The first data updating module is used to use the persistent storage component to persistently store the updated connection information in an external storage resource when the connection information of the database node changes.
[0100] The second data update module is used to respond to a target request, read updated connection information from an external storage resource, and use the updated connection information to update the connection information of the database node stored in the data storage component, wherein the target request includes a request of the same type as a data operation request or a request of the same type as a data call request.
[0101] The first connection update module is used to update the warehouse connection string information of the data warehouse using the updated connection information, wherein the warehouse connection string information is used to determine the operation authority of the data warehouse to the database node.
[0102] The second connection update module is used to update the tenant connection string information of the database tenant using the updated connection information, wherein the tenant connection string information is used to determine the operation authority of the database tenant to the database node.
[0103] According to an embodiment of the present invention, the node determination module 510 includes a node determination unit.
[0104] The node determination unit is used to determine a target database node from multiple database nodes based on the database node table name in the data operation request.
[0105] According to an embodiment of the present invention, the database operation device 500 further includes a resource determination module, a connection determination module and a tenant configuration module.
[0106] The resource determination module is used to determine the configuration resources of each of multiple database tenants based on the database resources of the distributed database.
[0107] The connection determination module is used to determine the tenant connection string information of each of the multiple database tenants by using the connection information of each of the multiple database nodes of the distributed database.
[0108] The tenant configuration module is used to configure resources and tenant connection string information for the initial database tenant to obtain the database tenant.
[0109] According to an embodiment of the present invention, the target determination module 520 includes a target warehouse determination unit and a target tenant determination unit.
[0110] The target warehouse determination unit is used to determine the target data warehouse based on the target database node and the warehouse correspondence relationship, wherein the warehouse correspondence relationship represents the mapping relationship between the data warehouse and the database node.
[0111] The target tenant determination unit is used to determine the target database tenant based on the target database node and the tenant correspondence relationship, wherein the tenant correspondence relationship represents the mapping relationship between the database tenant and the database node.
[0112] According to an embodiment of the present invention, any multiple modules of the node determination module 510, the target determination module and the data operation module 530 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the node determination module 510, the target determination module and the data operation module 530 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the node determination module 510, the target determination module and the data operation module 530 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0113] Figure 6 A block diagram of an electronic device suitable for implementing a database operation method according to an embodiment of the present invention is shown.
[0114] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.
[0115] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.
[0116] According to an embodiment of the present invention, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.
[0117] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.
[0118] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: 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 portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.
[0119] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present invention.
[0120] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 601. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0121] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0122] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present invention are performed. According to the embodiment of the present invention, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0123] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0124] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0125] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present invention may be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention may be combined and / or combined in various ways. All of these combinations and / or combinations fall within the scope of the present invention.
[0126] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.
Claims
1. A database operation method, characterized in that: The method comprises: In response to a data operation request, determining a target database node from a distributed database, wherein the distributed database includes a plurality of database nodes, the target database node is at least one of the plurality of database nodes, and the target database node stores data to be operated related to the data operation request; Based on the target database node, determining a target data warehouse corresponding to the target database node from a plurality of data warehouses, and determining a target database tenant from a plurality of database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, the connection information is obtained from an external storage resource, and the target database tenant has the ability to process the data to be operated; Using the target database tenant to operate the data to be operated in the target data warehouse to obtain a target result corresponding to the data operation request; When the connection information of the database node changes, the updated connection information is persistently stored in an external storage resource using a persistent storage component; In response to a target request, the updated connection information is read from the external storage resource, and the connection information of the database node stored in the data storage component is updated using the updated connection information, wherein the data storage component stores the connection information of each of the plurality of database nodes obtained from the external storage resource, the target request includes a request of the same type as the data operation request or a request of the same type as the data call request, and the data call request includes a request to operate the data in the database node using the connection information; Using the updated connection information to update the warehouse connection string information of the data warehouse, wherein the warehouse connection string information is used to determine the operation authority of the data warehouse to the database node; The tenant connection string information of the database tenant is updated using the updated connection information, wherein the tenant connection string information is used to determine the operation authority of the database tenant on the database node.
2. The method according to claim 1, characterized in that The method further comprises: Storing connection information of each of the plurality of database nodes obtained from the external storage resource in the data storage component; In response to an instruction for generating a data warehouse, acquiring connection information of a database node corresponding to the data warehouse from the data storage component; Correspondingly, the data warehouse is generated in the following manner: Determining source data of the database node based on the connection information of the database node; The data warehouse is generated using the source data of the database node.
3. The method according to claim 2, characterized in that The storing the connection information of each of the plurality of database nodes obtained from the external storage resource into the data storage component includes: Using the persistent storage component to persistently store the connection information in the external storage resource; In response to a data call request, the connection information read from the external storage resource is stored in the data storage component.
4. The method according to claim 1, characterized in that The step of determining a target database node from a distributed database includes: The target database node is determined from the plurality of database nodes based on the database node table name in the data operation request.
5. The method according to claim 1, characterized in that The database tenant is configured by: Determining configuration resources of each of the plurality of database tenants based on database resources of the distributed database; Determine tenant connection string information of each of the plurality of database tenants using respective connection information of the plurality of database nodes of the distributed database; The configuration resource and the tenant connection string information are configured for the initial database tenant to obtain the database tenant.
6. The method according to claim 1, characterized in that Each of the data warehouses corresponds to one or more of the database nodes, and each of the database tenants corresponds to one or more of the database nodes; The step of determining a target data warehouse corresponding to the target database node from a plurality of data warehouses based on the target database node, and determining a target database tenant from a plurality of database tenants, includes: Determine the target data warehouse based on the target database node and warehouse correspondence relationship, wherein the warehouse correspondence relationship represents the mapping relationship between the data warehouse and the database node; The target database tenant is determined based on the target database node and tenant correspondence relationship, wherein the tenant correspondence relationship represents a mapping relationship between the database tenant and the database node.
7. A database operation device, characterized in that: The device comprises: a node determination module, configured to determine a target database node from a distributed database in response to a data operation request, wherein the distributed database includes a plurality of database nodes, the target database node is at least one of the plurality of database nodes, and the target database node stores data to be operated related to the data operation request; a target determination module, configured to determine, based on the target database node, a target data warehouse corresponding to the target database node from a plurality of data warehouses, and determine a target database tenant from a plurality of database tenants, wherein the target data warehouse stores data obtained from the target database node using connection information, the connection information being obtained from an external storage resource, and the target database tenant having the ability to process the data to be operated; A data operation module, used to operate the data to be operated in the target data warehouse by using the target database tenant to obtain a target result corresponding to the data operation request; A first data updating module, configured to use a persistent storage component to persistently store the updated connection information in an external storage resource when the connection information of the database node changes; a second data update module, configured to read the updated connection information from the external storage resource in response to a target request, and update the connection information of the database node stored in the data storage component by using the updated connection information, wherein the data storage component stores respective connection information of a plurality of database nodes obtained from the external storage resource, the target request includes a request of the same type as the data operation request or a request of the same type as the data call request, and the data call request includes a request to operate the data in the database node by using the connection information; A first connection update module, configured to update the warehouse connection string information of the data warehouse using the updated connection information, wherein the warehouse connection string information is used to determine the operation authority of the data warehouse to the database node; The second connection update module is used to update the tenant connection string information of the database tenant using the updated connection information, wherein the tenant connection string information is used to determine the operation authority of the database tenant on the database node.
8. An electronic device comprising: one or more processors; a memory for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Big data storage optimization analysis system for cloud platform
CN114546415A
Tenant authority management method, system and device of SaaS platform and medium
CN118484796A