Multi-Type Database Dynamic Access Method and Device for Cross-Network Region Deployment

By deploying database proxy nodes in the network area, receiving and processing database access requests across network areas, and determining the target database using identification information and weight lists, the problems of complex network permissions and database failures are solved, and centralized management and efficient database access are achieved.

CN114490633BActive Publication Date: 2025-07-18YINBAOXIN TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111553751.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2025-07-18
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

In the prior art, database access across network areas leads to complex network permissions and difficulty in centralized management, and database failure or maintenance operations can lead to interruption of application system services.

Method used

Simplify network permission configuration and management by deploying database proxy nodes in each network area, receiving application database access requests, determining the target database using identification information and database weight lists, and performing operations on local or remote proxy nodes.

Benefits of technology

Centralized management of database access rights across network areas is realized, which reduces the impact of database service interruptions on the application system, improves the reuse rate of database connections, avoids resource waste, and supports dynamic expansion and failure masking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490633B_ABST
    Figure CN114490633B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for dynamically accessing multi-type databases deployed across network regions, relating to the field of information technology, mainly capable of simplifying the configuration of network permissions and facilitating centralized management of network access permissions for databases. The method includes: receiving a database access request sent by an application program or other database proxy nodes, where the database access request carries identification information of a database set corresponding to the application program; determining a target database for responding to the database access request according to the identification information and a database weight list; querying a local database list according to the target database to determine a target proxy node to which the target database belongs; and if the target proxy node is the database proxy node, locally invoking the target database to perform corresponding operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and particularly to a method and device for dynamically accessing multiple types of databases deployed across network regions. Background Art

[0002] When an application system accesses a database, due to technical and data security and high availability requirements, when it needs to be deployed across network regions, it will involve the problem of accessing the database across network regions.

[0003] Currently, usually the application system and the database node are directly connected, and by establishing a point-to-point network between the application system service node and the region where the database node is located, cross-network region access to the database is achieved. However, when there are many application system nodes, each application system needs to be connected to its corresponding database node, thus forming a many-to-many connection method. This connection method will result in a large number of security policies being configured on the network firewall and routing, making the network permissions very complex and not facilitating the management and maintenance of network permissions. The core of the application system lies in the database. When the database fails or major maintenance operations are carried out, the database needs to be shut down or restarted, which will lead to service interruption of the application system. Even if there is a dual-machine or disaster recovery solution, it also requires the cooperation of the application system. Summary of the Invention

[0004] The present invention provides a method and device for dynamically accessing multiple types of databases deployed across network regions, mainly capable of simplifying the configuration of network permissions and reducing the impact of database service interruption on the application system. The application system does not need to know the quantity, type, and network location of the databases, simplifying the architecture design of the application system.

[0005] According to a first aspect of the present invention, there is provided a method for dynamically accessing multiple types of databases deployed across network regions, which is applied to a database proxy node configured with network permissions, and includes:

[0006] Receiving a database access request sent by an application program or another database proxy node, where the database access request carries identification information of a database set corresponding to the application program;

[0007] Determining a target database for responding to the database access request according to the identification information and a database weight list;

[0008] Querying a local database list according to the target database to determine a target proxy node to which the target database belongs;

[0009] If the target proxy node is the database proxy node, then locally invoking the target database to perform corresponding operations.

[0010] According to a second aspect of the present invention, there is provided a multi-type database dynamic access device deployed across network regions, including:

[0011] A receiving unit, configured to receive a database access request across network regions sent by an application or other database proxy nodes, where the database access request carries identification information of a database set corresponding to the application;

[0012] A first determination unit, configured to determine a target database for responding to the database access request according to the identification information and a database weight list;

[0013] A second determination unit, configured to query a local database list according to the target database to determine a target proxy node to which the target database belongs;

[0014] An invocation unit, configured to, if the target proxy node is the database proxy node, locally invoke the target database to perform corresponding operations.

[0015] According to a third aspect of the present invention, there is provided a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the following steps are implemented:

[0016] Receive a database access request across network regions sent by an application or other database proxy nodes, where the database access request carries identification information of a database set corresponding to the application;

[0017] Determine a target database for responding to the database access request according to the identification information and a database weight list;

[0018] Query a local database list according to the target database to determine a target proxy node to which the target database belongs;

[0019] If the target proxy node is the database proxy node, locally invoke the target database to perform corresponding operations.

[0020] According to a fourth aspect of the present invention, there is provided a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, the following steps are implemented:

[0021] Receive a database access request across network regions sent by an application or other database proxy nodes, where the database access request carries identification information of a database set corresponding to the application;

[0022] Determine a target database for responding to the database access request according to the identification information and a database weight list;

[0023] Query the local database list according to the target database to determine the target proxy node to which the target database belongs;

[0024] If the target proxy node is the database proxy node, the target database is called locally to perform corresponding operations.

[0025] The present invention provides a method and device for dynamically accessing multiple types of databases deployed across network areas. Compared with the current method of directly connecting an application system and a database node and opening up a network in a region where the application system and the database node are located, the present invention can receive a database access request sent by an application, wherein the database access request carries identification information of a database set corresponding to the application; and according to the identification information and a database weight list, a target database that responds to the database access request is determined; at the same time, a local database list is queried according to the target database to determine a target proxy node to which the target database belongs; if the target proxy node is the database proxy node, the target database is called locally to perform a corresponding operation, thereby responding to database access requests across network areas by deploying a database proxy node in the network area where the application is located and opening up network permissions between database proxy nodes in each network area. At the same time, by opening up network permissions between each database proxy node, the configuration of network permissions can be simplified, and centralized management of network access permissions for databases is facilitated. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0027] Figure 1 A flow chart of a method for dynamically accessing multiple types of databases deployed across network regions provided by an embodiment of the present invention is shown;

[0028] Figure 2 A flowchart of another method for dynamically accessing multiple types of databases deployed across network regions provided by an embodiment of the present invention is shown;

[0029] Figure 3 A schematic diagram showing the structure of a device for dynamically accessing multiple types of databases deployed across network regions provided by an embodiment of the present invention;

[0030] Figure 4 A schematic diagram showing the structure of another device for dynamically accessing multiple types of databases deployed across network areas provided by an embodiment of the present invention;

[0031] Figure 5The figure shows a schematic physical structure diagram of a computer device provided by an embodiment of the present invention. Detailed implementation manners

[0032] In the following, the present invention will be described in detail with reference to the accompanying drawings and in combination with embodiments. It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other.

[0033] Currently, when there are many application system nodes, each application system needs to be connected to its corresponding database, thus forming a many-to-many connection method. This connection method will configure numerous security policies on the network firewall and routing, making the network permissions very complex and not facilitating centralized management of network permissions.

[0034] To solve the above problems, an embodiment of the present invention provides a multi-type database dynamic access method for cross-network area deployment, as Figure 1 shown, the method includes:

[0035] 101. Receive a database access request across network areas sent by an application program or other database proxy nodes.

[0036] Among them, the database access request carries the identification information of the database set corresponding to the application program. The identification information of the database set may specifically be the encoding of the database set, or the application program may directly specify the identification information of the database to be accessed, that is, the data access request carries the identification information of the database corresponding to the application program. To overcome the defect that the network permissions in the prior art are relatively complex and not facilitating centralized management of databases in different network areas, an embodiment of the present invention sets at least one database proxy node in each network area where the application program is located. By opening the network permissions between the database proxies in each network area, it can respond to database access across network areas, and at the same time can simplify the configuration of network permissions and facilitate centralized management of databases in different network areas. The embodiment of the present invention is mainly applied to the scenario of accessing databases across network areas. The execution subject of the embodiment of the present invention is the database proxy node.

[0037] Specifically, to facilitate the management of databases in different network regions, at least one database proxy node can be set in each network region. For the availability of the system, each network region can provide dual-node redundancy. The two nodes can work simultaneously and allow one of them to fail or go down. Meanwhile, two database management nodes are set for all network regions. An effective network connection needs to be deployed between the database proxy nodes and the database management nodes. The database proxy node is the actual working node that responds to application requests and database operations. The database management node has all the functions of the proxy node, can respond to the operation requests of the application or initiate operations on the database, and can also manage the proxy and database access permissions. Specifically, the database management node has both management functions and proxy functions. The management functions include host information management, database information management, account information management, node detection and management, database access permission management, database route aggregation, etc. The proxy functions include SQL analysis, permission control, database management, database account management, operating system account management, request and data forwarding, SQL execution, resource and status detection, database connection pool maintenance, etc.

[0038] In a specific application scenario, when the application system and the database it accesses are in different network regions, the application may access the database across network regions. After receiving a database access request, if the database to be accessed is under the local database proxy node, the local database proxy node completes the corresponding database operation and returns the result; if the database to be accessed is not under the local database proxy node, the database access request can be forwarded to the remote database proxy node. If the local database proxy node and the remote database proxy node can be directly connected, the database proxy node directly forwards the database access request to the remote database proxy node; if the local database proxy node and the remote database proxy node cannot be directly connected, the database access request can be forwarded to the remote database proxy node through the database management node. It should be noted that the database access request received by the database proxy node may also be forwarded by other database proxy nodes.

[0039] 102. Determine the target database for responding to the database access request according to the identification information and the database weight list.

[0040] For the embodiments of the present invention, after receiving a database access request, the local database proxy node first performs SQL parsing on the database operation statement carried in the database access request, and determines whether the current access requires operations such as adding, deleting, querying, and modifying the database according to the parsing result; if operations such as adding, deleting, querying, and modifying the database are required, the database access request is authenticated to determine whether the user has access rights to the database, data operation rights, etc. If the authentication fails, an error is directly reported to the application program; if the authentication is successful, the target database for responding to the current database access request is selected. The target database can be determined according to the identification information of the database set and the weight values of each database in the database weight list. For the specific determination process of the target database, step 102 specifically includes: querying the database weight list according to the identification information to determine the weight values corresponding to each database in the database set; screening out the maximum weight value from the weight values corresponding to each database in the database set, and determining the database corresponding to the maximum weight value as the target database, where the database weight list records the weight values corresponding to each database in different database sets.

[0041] For example, the identification information of the database set is 1100. Querying the database weight list according to this identification information, it is determined that the database set 1100 includes database A, database B, and database C. The weight values corresponding to database A, database B, and database C for the current operation type (add, delete, modify, query) are 0.6, 0.3, and 0.1 respectively. Since the weight value corresponding to database A is the largest, database A is used as the target database for this operation.

[0042] Further, the database weight list contains the mapping relationships between different database sets and different databases, as well as the weight values corresponding to different databases. These initial information such as mapping relationships and weight values can be manually configured on the system page. During the operation of the system, the node detection and management module of the database management node will regularly collect the status of the databases under each database proxy node, the status of the database servers, and the resource usage. The database management node will dynamically adjust the weight values of each database according to the above-collected information, and regularly send the database weight list to each database proxy node. Based on this, before determining the target database for responding to the database access request according to the identification information and the database weight list, the method further includes: The database proxy node receives the database weight list sent by the database management node. The management node is used to regularly collect the status information of each database belonging to different database proxy nodes and the resource usage information of each database server, dynamically adjust the weight values of each database belonging to different database proxy nodes according to the status information and the resource usage information, and construct a database weight list according to the weight values of each database belonging to different database proxy nodes.

[0043] In a specific application scenario, if the application program directly specifies the identification information of the database to be accessed, the target database can be directly locked.

[0044] 103. Query the local database list according to the target database to determine the target proxy node to which the target database belongs.

[0045] Among them, the local database list contains each database belonging to the local database proxy node. For the embodiments of the present invention, after determining the target database for responding to the current database access request, the local database list will be queried according to the target database identifier to determine whether the target database belongs to the local database proxy node. If the target database belongs to the local database proxy node, the target database will be called locally to execute the corresponding operation; if the target database does not belong to the local database proxy node but is under the remote database proxy node, the database access request can be forwarded to the remote database proxy node for processing by the remote database proxy node. Thus, the target proxy node to which the target database belongs can be determined.

[0046] 104. If the target proxy node is the database proxy node, call the target database locally to execute the corresponding operation.

[0047] For the embodiments of the present invention, when the target database belongs to the local database proxy node, step 104 specifically includes: determining whether there is a target database connection pool corresponding to the target database in the local database connection pool set; if there is a target database connection pool corresponding to the target database in the local database connection pool set, then calling a database connection from the target database connection pool so that the target database performs corresponding operations; if there is no target database connection pool corresponding to the target database in the local database connection pool set, then establishing the target database connection pool and adding the target database connection pool to the local database connection pool set; calling a database connection from the established target database connection pool so that the target database performs corresponding operations.

[0048] Specifically, if the target proxy node is the local database proxy node, that is, the target database belongs to the local database proxy node, then query the local database connection pool set to determine whether there is a target database connection pool corresponding to the target database in the local database connection pool set. If it exists, directly apply for a connection to the target database and execute the corresponding SQL operation statement, and feedback the execution result; if it does not exist, establish a target database connection pool, add it to the local database connection pool set, then apply for a connection to the target database to execute the corresponding SQL operation statement, and feedback the execution result. It should be noted that in the prior art, in the case of a single database bearing multiple intermediate connections, each middleware or application maintains an independent database connection pool. For performance and availability considerations, each database connection pool reserves a part of idle database connections. When the number of database connection pools of the middleware reaches a certain level, the database server is required to maintain a large number of idle connections, which will cause waste of server resources. However, the embodiments of the present invention concentrate the database access requirements in fewer database connection pools as much as possible. Therefore, compared with the prior art, the embodiments of the present invention can improve the reuse rate of database connections and avoid wasting the resources of the database server.

[0049] In a specific application scenario, if the target database does not belong to the database proxy node, then query the database proxy mapping table to determine the remote database proxy node to which the target database belongs, and forward the database access request to the remote database proxy node through the database management node. The database proxy mapping table records the mapping relationships between different database proxy nodes and different databases. By querying the database proxy mapping table, the remote database proxy node to which the target database belongs can be determined, and then the database access can be directly forwarded or forwarded to the remote database proxy node through the database management node.

[0050] Furthermore, after receiving a database access request, the remote database proxy node first queries a preset valid proxy list to detect whether the forwarding source is a legitimate request. If it is an illegal request, the request is recorded in a log, and the database access request is discarded without any response. If it is a legitimate request, the database connection pool set under the remote database proxy node is queried to determine whether there is a target database connection pool in the database connection pool set. If there is a target database connection pool, a database connection is applied for in the connection pool of the target database, a corresponding SQL operation statement is executed, and the execution result is returned to the requester. If there is no connection pool for the target database, it is necessary to first create a database connection pool corresponding to the target database, and add the database connection pool to the database connection pool set under the remote database proxy node, and then apply for a database connection in the database connection pool, execute the corresponding SQL statement, and return the execution result to the requester.

[0051] A method for dynamically accessing multiple types of databases deployed across network areas provided by an embodiment of the present invention can receive a database access request across network areas sent by an application program, the database access request carrying identification information of a database set corresponding to the application program; and determine a target database to respond to the database access request based on the identification information and a database weight list; at the same time, query a local database list based on the target database to determine a target proxy node to which the target database belongs; if the target proxy node is the database proxy node, call the target database locally to perform a corresponding operation, thereby responding to database access requests across network areas by deploying a database proxy node in the network area where the application program is located and opening network permissions between database proxy nodes in each network area; at the same time, by opening network permissions between each database proxy node, the configuration of network permissions can be simplified, and centralized management of network access permissions for databases is facilitated.

[0052] Further, in order to better illustrate the management process of a database across network regions, as a refinement and extension of the above embodiment, the embodiment of the present invention provides another method for dynamically accessing multiple types of databases deployed across network regions, such as Figure 2 As shown, the method includes:

[0053] 201. Obtain a database proxy mapping table regularly sent by a database management node.

[0054] Among them, the database proxy mapping table records the mapping relationships between different database proxy nodes and different databases. For the embodiments of the present invention, the database management node will send all the database addresses and service ports registered in the basic information to each database proxy node in the form of a list. Then, the database proxy node performs network exploration according to the basic list sent by the database management node, forms a local database list based on the network exploration results, and each database proxy node sends its local database list to the database management node. The database management node forms a database proxy mapping table based on the local database lists uploaded by each database proxy node and distributes it to each database proxy node.

[0055] It should be noted that each database in the embodiments of the present invention is built-in with database jdbc drivers of various domestic and foreign database manufacturers, can manage all databases that support jdbc connections, and can solve the problem that traditional databases such as Oracle, Db2, and postgre cannot be dynamically horizontally scaled.

[0056] 202. If it is determined according to the database proxy mapping table that there is a newly added database in the database set corresponding to the database proxy node, a database connection pool corresponding to the newly added database is established.

[0057] In a specific application scenario, when a new database needs to be added before the business peak arrives, only through the database replication technology, a new set of databases is cloned, and the newly added database is mapped to the corresponding database set. Then, the database management node synchronizes the newly added mapping relationship in the database proxy mapping table to each database proxy node. After each database proxy node obtains the latest mapping relationship, it can create a database connection pool for the newly added database and bear the request response. Thus, according to the increase in the actual business volume, the business carrying capacity can be increased by dynamically adding databases without the need for the application program to stop for capacity expansion.

[0058] 203. If it is determined according to the database proxy mapping table that there is a database to be removed in the database set corresponding to the database proxy node, the database weight list is updated, and the database connection pool corresponding to the removed database is destroyed.

[0059] In a specific application scenario, when it is necessary to shrink the database after the business peak has passed, the redundant databases can be removed from the corresponding database set. Further, the database management node will regularly send the mapping relationship of the database set in the database proxy mapping table to each database proxy node. After the database proxy node determines that the mapping relationship has been cancelled, it will update the database weight list and destroy the corresponding database connection pool. When the time is right, the server resources can be recycled at the physical level. Thus, by dynamically updating the mapping relationship between the database set and the databases, the application program can be shielded from the perception of the addition and reduction of databases. When it is confirmed that there is no data change in the database to be recycled, it can be directly powered off. The present invention will handle this database as a database failure scenario and will no longer send requests to this database.

[0060] In a specific application scenario, when a service interruption occurs in the database, the database proxy node can actively shield the faulty database and switch to an available database. There are two ways to obtain the abnormal state of the database. One implementation method is that the database proxy node actively discovers it, that is, it actively discovers that the database service is unavailable during the node detection cycle. Another implementation method is to discover that the database connection fails when responding to the service or to discover that the database service is unavailable when creating a new database connection pool.

[0061] Specifically, for the first implementation method, when the database proxy node performs server resource detection and database operation detection, if it discovers a server failure or a database failure, it will immediately update the database weight list and the local data source list, set the database status in the database weight list and the local data source list to unavailable, and at the same time delete the database connection pool from the local database connection pool set. Further, it will report the database service failure to the database management node. After the database management node obtains the database service failure report, it will update the database proxy mapping table, set the status of the database in the database proxy mapping table to unavailable, and synchronize it to all database proxy nodes. When the database proxy node detects that the database service is normal, it will then set the database status to normal.

[0062] Further, for the second implementation, when the database proxy node creates a new database connection pool in response to a database access request, if it detects that the database service is abnormal, the database proxy node immediately updates the database weight list and the local data source list, sets the database status in the database weight list and the local data source list to unavailable, and at the same time deletes the database connection pool from the local database connection pool set. Further, it reports the database service failure to the database management node. After receiving the database server failure report, the database management node immediately updates the preset data source proxy mapping table, sets the status of the database in the preset data source proxy mapping table to unavailable, and synchronizes it to all database proxy nodes. When the database proxy node detects that the database service is normal, it sets the database status to normal. Based on this, the method includes: when a service interruption occurs in the target database, the database proxy node marks the target database in the database weight list and the local database list as unavailable respectively, and deletes the target database connection pool corresponding to the target database from the local database connection pool set; reports the fault information of the target database to the database management node, so that the database management node marks the target database in the database proxy mapping table as unavailable based on the fault information and synchronizes it to different database proxy nodes. Thus, the database proxy node can dynamically destroy and rebuild the database connection pool. When a fault occurs in the database and the server, there is no need to restart the application program or middleware, and the purpose of resetting the database connection pool can be achieved.

[0063] In a specific application scenario, the database management node can uniformly manage and update the accounts and passwords of the managed databases according to security requirements. Specifically, when the user updates the operating system account password, the account information management module in the database management node first uses a random password string to modify the password of the account in the basic information database, and saves the original password to the historical password database. At the same time, it queries the database proxy node where the account host is located according to the basic information database and sends an account password modification instruction to it. After receiving the operating system account password modification instruction, the database proxy node connects to the server through ssh and modifies the account password. After the database proxy node completes the password modification, it feeds back the modification result to the database management node and checks whether there is a database connection pool using this account in the primary and standby nodes. If there is a database connection pool using this account, it destroys and rebuilds it. When the account password modification fails, the database management node sends an information indicating the modification failure to the database management node. After receiving this information, the database management node restores the account password in the basic information database to the state before the modification.

[0064] Further, when the user updates the password of the database account, the account information management module in the database management node first uses a random password string to modify the password of the account in the basic information database and saves the original password to the historical password database. At the same time, it queries the database proxy node corresponding to the database to which the account belongs according to the basic information database and sends an account password modification instruction to it. After receiving the modification instruction for the database account password, the database proxy node will connect to the corresponding database and modify the account password. After the database proxy node completes the password modification, it will feedback the modification result to the database management node and retrieve whether there is a database connection pool using this account in the primary and standby nodes. If there is a database connection pool using this account, it will be destroyed and rebuilt; if not, it will be skipped. When the password modification fails, the database management node will restore the account password in the basic information database to the state before the modification. Based on this, the method further includes: in response to the password modification instruction of the database account, connecting to the corresponding database, modifying the account password of the corresponding database, and feedbacking the modification result to the database management node; detecting whether there is a database connection pool using the account in the corresponding primary and standby nodes, and if there is a database connection pool using the account, destroying it. Thus, the database proxy node can dynamically destroy and rebuild the database connection pool, and when the database account password is modified, it is not necessary to restart the application or middleware to achieve the purpose of resetting the database connection pool.

[0065] In the embodiment of the present invention, the internal accounts of each database are uniformly managed by the database proxy node without opening them to users. The database proxy node can centrally manage information such as all database connection pools, databases, servers, and account passwords, and can ensure that the application system will not be affected when the information changes.

[0066] Further, as Figure 1 a specific implementation of Figure 3 shown, the embodiment of the present invention provides a multi-type database dynamic access device deployed across network regions. As

[0067] shown in

[0068] Figure [FIGURE NUMBER], the device includes: a receiving unit 31, a first determination unit 32, a second determination unit 33, and a calling unit 34.

[0069] It should be noted that the "[FIGURE NUMBER]" in the translation of item needs to be replaced with the actual figure number in the original text. Also, the " ", "

[0065] " etc. in the translation are kept as they are according to the requirement of preserving 7 - digit tags exactly.The second determination unit 33 may be configured to query the local database list according to the target database, and determine the target proxy node to which the target database belongs.

[0070] The calling unit 34 may be configured to, if the target proxy node is the database proxy node, locally call the target database to perform corresponding operations.

[0071] In a specific application scenario, in order to determine the target database for responding to a database access request, the first determination unit 32, as Figure 4 shown, includes a determination module 321 and a screening module 322.

[0072] The determination module 321 may be configured to query the database weight list according to the identification information, and determine the weight value corresponding to each database in the database set, where the database weight list records the weight values corresponding to each database in different database sets.

[0073] The screening module 322 may be configured to screen out the maximum weight value from the weight values corresponding to each database in the database set, and determine the database corresponding to the maximum weight value as the target database.

[0074] In a specific application scenario, in order to call the target database to perform corresponding operations, the calling unit 34 includes a determination module 341, a calling module 342, and a establishing module 343.

[0075] The determination module 341 may be configured to determine whether a target database connection pool corresponding to the target database exists in the local database connection pool set.

[0076] The calling module 342 may be configured to, if the target database connection pool exists in the local database connection pool set, call a database connection from the target database connection pool so that the target database performs corresponding operations.

[0077] The establishing module 343 may be configured to, if the target database connection pool does not exist in the local database connection pool set, establish the target database connection pool and add the target database connection pool to the local database connection pool set.

[0078] The calling module 342 may also be configured to call a database connection from the established target database connection pool so that the data target database performs corresponding operations.

[0079] Meanwhile, if the target database does not belong to the local database proxy node, the apparatus further includes a forwarding unit 35.

[0080] The forwarding unit 35 can be used to query the database proxy mapping table if the target proxy node is not the database proxy node, determine the remote database proxy node to which the target database belongs, and forward the database access request to the remote database proxy node through the database management node.

[0081] In a specific application scenario, the receiving unit 31 can also be used to receive the database weight list issued by the database management node. The management node is used to regularly collect the status information of each database and the resource usage information of each database server belonging to different database proxy nodes, dynamically adjust the weight values of each database belonging to different database proxy nodes according to the status information and the resource usage information, and construct a database weight list according to the weight values of each database belonging to different database proxy nodes.

[0082] In a specific application scenario, the device further includes: a marking unit 36 and a reporting unit 37.

[0083] The marking unit 36 can be used to mark the target database in the database weight list and the local database list as unavailable respectively when the target database has a service interruption, and delete the target database connection pool corresponding to the target database from the local database connection pool set.

[0084] The reporting unit 37 can be used to report the fault information of the target database to the database management node, so that the database management node marks the target database in the database proxy mapping table as unavailable based on the fault information and synchronizes it to different database proxy nodes.

[0085] In a specific application scenario, the device further includes a modification unit 38. The modification unit 38 can be used to connect to the corresponding database in response to a password modification instruction for a database account, modify the account password of the corresponding database, and feedback the modification result to the database management node; detect whether there is a database connection pool using the account in the corresponding primary and standby nodes, and if there is a database connection pool using the account, destroy it.

[0086] Further, the device further includes: an obtaining unit 39. The obtaining unit 39 can be used to obtain the database proxy mapping table regularly issued by the database management node.

[0087] The determining unit 32 can also be used to establish a database connection pool corresponding to the newly added database if it is determined according to the database proxy mapping table that there is a newly added database in the database set corresponding to the database proxy node.

[0088] The determining unit 32 may also be configured to update the database weight list and destroy the database connection pool corresponding to the removed database if it is determined from the database proxy mapping table that there is a removed database in the database set corresponding to the database proxy node.

[0089] It should be noted that for other corresponding descriptions of the various functional modules involved in the multi-type database dynamic access device deployed across network regions provided in the embodiments of the present invention, reference may be made to Figure 1 the corresponding description of the method shown, which will not be elaborated herein.

[0090] Based on the method as described above Figure 1 shown, correspondingly, the embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the following steps are implemented: receiving a database access request across network regions sent by an application program or other database proxy nodes, where the database access request carries identification information of the database set corresponding to the application program; determining a target database for responding to the database access request according to the identification information and the database weight list; querying a local database list according to the target database to determine a target proxy node to which the target database belongs; if the target proxy node is the database proxy node, locally invoking the target database to perform corresponding operations.

[0091] Based on the method as described above Figure 1 shown and the embodiments of the device as described above Figure 3 shown, the embodiments of the present invention further provide an entity structure diagram of a computer device, as shown in Figure 5 shown. The computer device includes: a processor 41, a memory 42, and a computer program stored on the memory 42 and executable on the processor 41, where the memory 42 and the processor 41 are both arranged on a bus 43. When the processor 41 executes the program, the following steps are implemented: receiving a database access request across network regions sent by an application program or other database proxy nodes, where the database access request carries identification information of the database set corresponding to the application program; determining a target database for responding to the database access request according to the identification information and the database weight list; querying a local database list according to the target database to determine a target proxy node to which the target database belongs; if the target proxy node is the database proxy node, locally invoking the target database to perform corresponding operations.

[0092] Through the technical solution of the present invention, it is possible to receive a database access request sent by an application, where the database access request carries identification information of a database set corresponding to the application; and determine a target database for responding to the database access request according to the identification information and a database weight list. At the same time, query a local database list according to the target database to determine a target proxy node to which the target database belongs; if the target proxy node is the database proxy node, then call the target database locally to execute corresponding operations. Thus, by deploying database proxy nodes in the network area where the application is located and opening network permissions between the database proxy nodes in each network area, it is possible to respond to database access requests across network areas. At the same time, by opening network permissions between each database proxy node, it is possible to simplify the configuration of network permissions and facilitate centralized management of the network access permissions of the database.

[0093] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. Optionally, they can be implemented by program codes executable by the computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module to implement. In this way, the present invention is not limited to any specific combination of hardware and software.

[0094] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A dynamic access method for multi-type databases deployed across network regions, characterized in that, Applied to a database proxy node configured with network permissions, including: Receiving a database access request across network regions sent by an application or other database proxy nodes, where the database access request carries identification information of a database set corresponding to the application; Determining a target database for responding to the database access request according to the identification information and a database weight list; Querying a local database list according to the target database to determine a target proxy node to which the target database belongs; If the target proxy node is the database proxy node, locally invoking the target database to perform corresponding operations; The method further includes: In response to a password modification instruction for a database account, connecting to the corresponding database, modifying the account password of the corresponding database, and feeding back the modification result to a database management node; Detecting whether there is a database connection pool using the account in the corresponding primary and standby nodes, and if there is a database connection pool using the account, destroying it.

2. The method according to claim 1, wherein The determining a target database for responding to the database access request according to the identification information and a database weight list includes: Querying the database weight list according to the identification information to determine weight values corresponding to each database in the database set, where the database weight list records weight values corresponding to each database in different database sets; Screening out the maximum weight value from the weight values corresponding to each database in the database set, and determining the database corresponding to the maximum weight value as the target database.

3. The method according to claim 1, wherein The locally invoking the target database to perform corresponding operations includes: Determining whether there is a target database connection pool corresponding to the target database in a local database connection pool set; If there is a target database connection pool in the local database connection pool set, invoking a database connection from the target database connection pool so that the target database performs corresponding operations; If there is no target database connection pool in the local database connection pool set, establishing the target database connection pool and adding the target database connection pool to the local database connection pool set; Invoking a database connection from the established target database connection pool so that the data target database performs corresponding operations; After determining the target proxy node to which the target database belongs by querying the local database list according to the target database, the method further includes: If the target proxy node is not the database proxy node, querying a database proxy mapping table to determine a remote database proxy node to which the target database belongs, and forwarding the database access request to the remote database proxy node through a database management node.

4. The method according to claim 1, wherein Before determining a target database for responding to the database access request according to the identification information and a database weight list, the method further includes: Receive the database weight list sent by the database management node. The management node is used to regularly collect the status information of each database belonging to different database proxy nodes and the resource usage information of each database server, dynamically adjust the weight values of each database belonging to the different database proxy nodes according to the status information and the resource usage information, and construct a database weight list according to the weight values of each database belonging to the different database proxy nodes.

5. The method according to claim 1, wherein The method further includes: When a service interruption occurs in the target database, mark the target database in both the database weight list and the local database list as unavailable, and delete the target database connection pool corresponding to the target database from the local database connection pool set; Report the fault information of the target database to the database management node, so that the database management node marks the target database in the database proxy mapping table as unavailable based on the fault information and synchronizes it to different database proxy nodes.

6. The method according to claim 1, wherein The method further includes: Obtain the database proxy mapping table regularly sent by the database management node; If it is determined according to the database proxy mapping table that there is a newly added database in the database set corresponding to the database proxy node, establish a database connection pool corresponding to the newly added database; If it is determined according to the database proxy mapping table that there is a removed database in the database set corresponding to the database proxy node, update the database weight list and destroy the database connection pool corresponding to the removed database.

7. A multi-type database dynamic access device deployed across network regions, characterized in that, Includes: A receiving unit, configured to receive a database access request across network regions sent by an application program or other database proxy nodes, where the database access request carries identification information of a database set corresponding to the application program; A first determination unit, configured to determine a target database for responding to the database access request according to the identification information and the database weight list; A second determination unit, configured to query the local database list according to the target database to determine a target proxy node to which the target database belongs; A calling unit, configured to, if the target proxy node is the database proxy node, locally call the target database to perform corresponding operations; A modification unit, configured to, in response to a password modification instruction for a database account, connect to the corresponding database, modify the account password of the corresponding database, and feedback the modification result to the database management node; detect whether there is a database connection pool using the account in the corresponding primary and standby nodes, and if there is a database connection pool using the account, destroy it.

8. A computer device, comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Access method and device supporting cross-network-segment scheduling and electronic equipment

    CN110347505A

  • Data access control method and device and computer readable storage medium

    CN113010911A