A database access method, device, equipment and storage medium
Through the virtual database and unified portal automatic routing solution, the problem of database cluster management and access complexity is solved, and high availability and efficient access of multi-node databases are achieved.
Patent Information
- Application Number
- CN202210182423.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-02-25
AI Technical Summary
After business expansion, database cluster management and access become complex and cumbersome, especially in multi-node environments, making it difficult to guarantee service stability and high availability.
Obtain the database registration request through the reserved registration interface, create a virtual database and filter the target database from the database cluster according to the preset filtering rules to achieve unified entrance automatic routing and traffic control to ensure high availability and efficiency.
It provides a solution for quickly completing high-availability configuration, unified management and control of multi-node databases, avoiding the impact of single node failure on the overall service, and improving database access efficiency.
Smart Images

Figure CN114564530B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database management, and in particular to a database access method, device, equipment and storage medium. Background Art
[0002] At present, with the development of Internet technology, databases are the core cornerstone of all services and the storage of key data. Their importance is self-evident. However, databases are fragile and difficult to maintain. For example, sudden power outages, human error, large request traffic, and other factors may cause data loss and service downtime, thus affecting the normal operation of services. As the most popular open source database in the community, MySQL is the choice of most companies. In order to ensure high availability and stable operation of services, multiple database instances are generally deployed in actual use, and the master-slave cluster is established using the MySQL built-in binlog logging system. However, as the needs of the project, the database cluster often expands horizontally with the development of the business, thus forming a huge data network. In actual scenarios, the node management and access to so many databases is often a difficult and cumbersome task. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a database access method, device, equipment and medium, which can improve the efficiency of database access. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses a database access method, comprising:
[0005] Acquire multiple database registration requests through a reserved registration interface, and perform corresponding database registration according to the database registration requests to obtain a registered database cluster;
[0006] Creating a corresponding virtual database for the database cluster;
[0007] A data access request is obtained through the virtual database, and a target access database is screened out from the database cluster according to a preset screening rule, so as to execute the data access request using the target access database.
[0008] Optionally, acquiring multiple database registration requests through a reserved registration interface, and performing corresponding database registrations according to the database registration requests to obtain a registered database cluster, includes:
[0009] Obtaining registration requests corresponding to multiple databases in sequence through a reserved registration interface, and verifying connectivity of each database in sequence according to the registration request; the reserved registration interface is an application programming interface;
[0010] The database with normal connectivity is persistently stored to obtain a registered database, so as to obtain the database cluster.
[0011] Optionally, the creating a corresponding virtual database for the database cluster includes:
[0012] Obtain database screening conditions through the reserved data resource interface;
[0013] Filtering a target database from the database cluster according to the database screening condition; the target database includes at least one master node database;
[0014] A corresponding virtual database is created for the target database.
[0015] Optionally, the filtering out a target access database from the database cluster according to a preset filtering rule, so as to execute the data access request by using the target access database, includes:
[0016] Filtering a target access database from the database cluster according to the current throughput of each database in the database cluster and the preset filtering rule;
[0017] The target access database is accessed using a preset routing strategy according to the data access request, and a corresponding data query result is generated.
[0018] Optionally, the creating a corresponding virtual database for the database cluster includes:
[0019] A data connection pool is constructed based on the database connection corresponding to each of the databases;
[0020] Create a corresponding virtual database for the database cluster, and disclose the virtual IP and access password corresponding to the virtual database;
[0021] Correspondingly, accessing the target access database using a preset routing strategy according to the data access request includes:
[0022] A connection route corresponding to the target access database is obtained from the data connection pool, and the target access database is accessed according to the connection route.
[0023] Optionally, after performing corresponding database registration according to the database registration request to obtain a registered database cluster, the method further includes:
[0024] Configuring corresponding routing attributes for each of the databases, and obtaining the preset routing strategy based on all the routing attributes;
[0025] Configure traffic control rules, which include database access frequency control and database access traffic control.
[0026] Optionally, after creating a corresponding virtual database for the database cluster, the method further includes:
[0027] Monitor each database in the database cluster through a heartbeat mechanism to obtain the operating status of the database cluster;
[0028] Determine whether the database cluster has a fault according to a preset fault detection rule and the operating status;
[0029] If it is determined that the database cluster has a fault, a corresponding alarm prompt is generated.
[0030] In a second aspect, the present application discloses a database access device, comprising:
[0031] A registration request acquisition module, used to acquire multiple database registration requests through a reserved registration interface, and perform corresponding database registration according to the database registration requests to obtain a registered database cluster;
[0032] A virtual database creation module, used to create a corresponding virtual database for the database cluster;
[0033] The data access module is used to obtain a data access request through the virtual database, and filter out a target access database from the database cluster according to a preset screening rule, so as to execute the data access request using the target access database.
[0034] In a third aspect, the present application discloses an electronic device, comprising:
[0035] Memory, used to store computer programs;
[0036] The processor is used to execute the computer program to implement the aforementioned database access method.
[0037] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program implements the aforementioned database access method when executed by a processor.
[0038] In the present application, multiple database registration requests are obtained through a reserved registration interface, and corresponding database registration is performed according to the database registration request to obtain a registered database cluster; a corresponding virtual database is created for the database cluster; a data access request is obtained through the virtual database, and a target access database is screened from the database cluster according to a preset screening rule, so as to use the target access database to execute the data access request. It can be seen that by creating a corresponding virtual database for the database cluster, receiving data access requests using the virtual database, and then executing the data access request in the corresponding target access database, the user is allowed to quickly complete the high-availability configuration of the registration data service through the provided reserved registration interface. After the configuration is completed, the data access service is provided to the user through the exposed virtual database as a unified entrance. In view of the difficulties and dilemmas of user services when accessing multi-node services after the establishment of multi-database master-slave, a unified entrance automatic routing solution is proposed to realize a master-slave high-availability database registration routing solution, which can uniformly manage and control multiple nodes of the database, and the failure of a certain node will not affect the use of the entire service, thereby improving the efficiency of database access. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0040] Figure 1 A flow chart of a database access method provided for this application;
[0041] Figure 2 A schematic diagram of a database access method in the prior art provided by this application;
[0042] Figure 3 A schematic diagram of a database access method provided for this application;
[0043] Figure 4 A specific database access method flow chart provided for this application;
[0044] Figure 5 A specific database access system architecture diagram provided for this application;
[0045] Figure 6 A specific database access timing diagram provided for this application;
[0046] Figure 7 A schematic diagram of the structure of a database access device provided in this application;
[0047] Figure 8 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION
[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] In the prior art, database clusters often expand horizontally with the development of business, thus forming a huge data network. In actual scenarios, the node management and access to so many databases are often difficult and cumbersome. In order to overcome the above-mentioned technical distinguishing features, this application proposes a database access method, which solves the difficult dilemma of user services when accessing multi-node services after the establishment of multiple database masters and slaves through a unified entry automatic routing solution, realizes a master-slave highly available database registration routing solution, can uniformly manage and control multiple nodes of the database, and the failure of a node will not affect the use of the entire service, thereby improving the efficiency of database access.
[0050] The present application embodiment discloses a database access method, see Figure 1 As shown, the method may include the following steps:
[0051] Step S11: obtaining multiple database registration requests through a reserved registration interface, and performing corresponding database registration according to the database registration requests to obtain a registered database cluster.
[0052] In this embodiment, firstly, a user's registration request for multiple existing databases is obtained through a reserved registration interface, and then corresponding database registration is performed according to the database registration request to obtain a database cluster including multiple registered databases, and the above database may be MySQL. The above reserved registration interface may be an open API (Application Programming Interface) interface or a user graphical interface, etc.
[0053] In this embodiment, the acquisition of multiple database registration requests through the reserved registration interface, and the corresponding database registration according to the database registration requests to obtain the registered database cluster may include: sequentially acquiring the registration requests corresponding to the multiple databases through the reserved registration interface, and sequentially verifying the connectivity of each database according to the registration request; the reserved registration interface is an application programming interface; and persistently storing the database with normal connectivity to obtain the registered database to obtain the database cluster. That is, the connectivity of the database requested for registration is first verified, and then the registration is performed after the verification is passed, and the registration may be persistently registered in the storage.
[0054] Step S12: Create a corresponding virtual database for the database cluster.
[0055] In this embodiment, after the database registration is completed, a corresponding virtual database is created for the above database cluster, and the virtual database can be used as a unified entrance to receive data access requests.
[0056] In this embodiment, the creation of a corresponding virtual database for the database cluster may include: obtaining a database screening condition through a reserved data resource interface; screening a target database from the database cluster according to the database screening condition; the target database includes at least one master node database; and creating a corresponding virtual database for the target database. That is, some database resources in the database cluster may be selected according to demand to create a corresponding virtual database, that is, only some database resources may be opened to allow access.
[0057] In this embodiment, after creating the corresponding virtual database for the database cluster, it may also include: monitoring each database in the database cluster through the heartbeat mechanism to obtain the operating status of the database cluster; judging whether the database cluster has a fault according to the preset fault detection rules and the operating status; if it is determined that the database cluster has a fault, a corresponding alarm prompt is generated. That is, the heartbeat mechanism will check the availability of each database node. As long as the virtual database meets the minimum specification requirements, that is, at least one master node database survives, user services will not be paralyzed due to the failure of individual database nodes. Therefore, with the help of the platform's heartbeat mechanism, even if some service nodes fail, the availability of the overall service can still be guaranteed, providing valuable buffer time for users to repair the database.
[0058] Step S13: obtaining a data access request through the virtual database, and screening out a target access database from the database cluster according to a preset screening rule, so as to execute the data access request using the target access database.
[0059] In this embodiment, the virtual database is used to obtain a data access request sent by a user, and a target access database is screened out from the database cluster according to a preset screening rule, so as to execute the data access request using the target access database.
[0060] In this embodiment, the target access database is filtered out from the database cluster according to the preset filtering rules so as to execute the data access request using the target access database, which may include: filtering out the target access database from the database cluster according to the current throughput of each database in the database cluster and the preset filtering rules; accessing the target access database according to the data access request using the preset routing strategy, and generating corresponding data query results. That is to say, in this embodiment, with the help of the preset routing strategy, all request commands can be distributed to idle databases as much as possible to ensure high utilization of the user's database. That is, through the established routing strategy, the platform distributes external request commands to each node as evenly as possible to prevent some nodes from being idle while other nodes are in high throughput, so that the user's database resources can be maximized. For example Figure 2 As shown, in the prior art, a direct connection is used for data access. When a problem occurs in a subordinate database, the use of the corresponding service will be affected. In this embodiment, for example Figure 3 As shown, after the virtual database is used to undertake the access, a suitable database is allocated for data access. As long as there is a main database operating normally, normal access to the service can be guaranteed.
[0061] In this embodiment, the creation of a corresponding virtual database for the database cluster may include: constructing a data connection pool based on the database connection corresponding to each of the databases; creating a corresponding virtual database for the database cluster, and publicly disclosing the virtual IP and access password corresponding to the virtual database; correspondingly, accessing the target access database using a preset routing strategy according to the data access request may include: obtaining the connection route corresponding to the target access database from the data connection pool, and accessing the target access database according to the connection route. That is, by providing a database registration function, a unified virtual database and a corresponding database pool are created based on the registered database, and users can directly access all database resources through the unified entrance of the virtual database. In other words, after the user registers the service to the platform, the user does not need to configure different database connections on each service, and can access the database through a unified entrance. For example Figure 4 As shown, after the user obtains the virtual database connection, all requests are sent to the virtual database. The virtual database will try to obtain an available database connection from its corresponding connection pool, route to the real database through the connection, execute the request statement and return the corresponding result.
[0062] In this embodiment, after performing the corresponding database registration according to the database registration request to obtain the registered database cluster, it can also include: configuring corresponding routing attributes for each of the databases, and obtaining the preset routing policy based on all the routing attributes; configuring traffic control rules, and the traffic control rules include database access frequency control and database access traffic control.
[0063] further, Figure 5 A database access system architecture diagram is disclosed, including the core (Core), service (Server) and OpenAPI. Among them, the Core is the foundation of the platform and provides basic support for the Server, including storage, which is used to provide storage capabilities for all metadata databases; metadata database management, which is used to manage all user configuration metadata databases; virtual database, which is used to implement a unified model between the database connection exposed to the outside and the real database; traffic control, which is used to control the database access frequency and traffic control according to the configuration; routing strategy, which is used to define different database load routing strategies. Among them, the Server is further implemented based on the basic functions provided by the Core to build the core services of the service, including the connection pool, which is used to recommend the database connection pool based on the database metadata registered by the user; heartbeat detection, which is used to judge the database availability based on the connection pool; data routing, which is used to process external data requests and distribute data requests according to the routing strategy; OpenAPI / GUI is used to integrate the Server capabilities and provide an external interface API.
[0064] The user's use of the database access system mainly consists of three processes: service registration, service configuration, and service use. The details are as follows: Figure 6 The figure shows a specific database access sequence diagram. It can be seen that the user registers the existing databases in the platform of this embodiment in sequence through the API. During the registration process, the platform will verify the connectivity of each database in sequence. If the connectivity is correct, the database metadata information will be persisted to the storage for use in subsequent processes. After the database registration is completed, the user can integrate the existing database resources to create a virtual database. The virtual database consists of multiple database nodes, and the minimum specification requires at least one master node database. After all nodes pass the master-slave verification, the virtual database is created, and the platform will assign a virtual IP and a random access password. The platform will create a corresponding data connection pool for this virtual database and wait for the request command.
[0065] As can be seen from the above, in this embodiment, multiple database registration requests are obtained through the reserved registration interface, and corresponding database registration is performed according to the database registration request to obtain a registered database cluster; a corresponding virtual database is created for the database cluster; a data access request is obtained through the virtual database, and a target access database is screened from the database cluster according to a preset screening rule, so as to use the target access database to execute the data access request. It can be seen that by creating a corresponding virtual database for the database cluster, receiving data access requests using the virtual database, and then executing the data access request in the corresponding target access database, the user is allowed to quickly complete the high-availability configuration of the registration data service through the provided reserved registration interface. After the configuration is completed, the data access service is provided to the user through the exposed virtual database as a unified entrance. The solution of automatic routing through the unified entrance solves the difficulties and dilemmas of user services when accessing multi-node services after the establishment of multi-database master-slave, and realizes the master-slave high-availability database registration routing solution, which can uniformly manage and control multiple nodes of the database, and the failure of a certain node will not affect the use of the entire service, thereby improving the efficiency of database access.
[0066] Correspondingly, the present application also discloses a database access device, see Figure 7 As shown, the device comprises:
[0067] A registration request acquisition module 11 is used to acquire multiple database registration requests through a reserved registration interface, and perform corresponding database registration according to the database registration requests to obtain a registered database cluster;
[0068] A virtual database creation module 12, used to create a corresponding virtual database for the database cluster;
[0069] The data access module 13 is used to obtain a data access request through the virtual database, and filter out a target access database from the database cluster according to a preset filtering rule, so as to execute the data access request using the target access database.
[0070] As can be seen from the above, multiple database registration requests are obtained through the reserved registration interface, and corresponding database registrations are performed according to the database registration requests to obtain a registered database cluster; a corresponding virtual database is created for the database cluster; a data access request is obtained through the virtual database, and a target access database is screened from the database cluster according to a preset screening rule, so as to use the target access database to execute the data access request. It can be seen that by creating a corresponding virtual database for the database cluster, and using the virtual database to receive data access requests, and then allocating the corresponding target access database to execute the data access request, the user is allowed to quickly complete the high-availability configuration of the registration data service through the provided reserved registration interface. After the configuration is completed, the exposed virtual database is used as a unified entrance to provide data access services to users. The solution of automatic routing through the unified entrance solves the difficulties and dilemmas of user services when accessing multi-node services after the establishment of multi-database master-slave, and realizes a master-slave high-availability database registration routing solution, which can uniformly manage and control multiple nodes of the database, and the failure of a node will not affect the use of the entire service, thereby improving the efficiency of database access.
[0071] In some specific embodiments, the registration request acquisition module 11 may specifically include:
[0072] A connectivity verification unit, used to sequentially obtain registration requests corresponding to multiple databases through a reserved registration interface, and sequentially verify the connectivity of each database according to the registration request; the reserved registration interface is an application programming interface;
[0073] The registration unit is used to persistently store the database with normal connectivity to obtain a registered database, so as to obtain the database cluster.
[0074] In some specific embodiments, the virtual database creation module 12 may specifically include:
[0075] A database screening condition acquisition unit, used to acquire database screening conditions through a reserved data resource interface;
[0076] A screening unit, configured to screen out a target database from the database cluster according to the database screening condition; the target database includes at least one master node database;
[0077] The virtual database creation unit is used to create a corresponding virtual database for the target database.
[0078] In some specific embodiments, the data access module 13 may specifically include:
[0079] a target access database determining unit, configured to screen out a target access database from the database cluster according to the current throughput of each database in the database cluster and the preset screening rule;
[0080] The access unit is used to access the target access database using a preset routing strategy according to the data access request and generate a corresponding data query result.
[0081] In some specific embodiments, the virtual database creation module 12 may specifically include:
[0082] A connection pool construction unit, used to construct a data connection pool based on the database connection corresponding to each of the databases;
[0083] A virtual database creation unit, used to create a corresponding virtual database for the database cluster, and disclose the virtual IP and access password corresponding to the virtual database;
[0084] Accordingly, the access unit includes:
[0085] The connection route acquisition unit is used to acquire the connection route corresponding to the target access database from the data connection pool, and access the target access database according to the connection route.
[0086] In some specific embodiments, the database access device may specifically include:
[0087] A routing attribute configuration unit, configured to configure corresponding routing attributes for each of the databases, and obtain the preset routing strategy based on all the routing attributes;
[0088] The traffic control rule configuration unit is used to configure traffic control rules, wherein the traffic control rules include database access frequency control and database access traffic control.
[0089] In some specific embodiments, the database access device may specifically include:
[0090] A monitoring unit, used to monitor each database in the database cluster through a heartbeat mechanism to obtain the operating status of the database cluster;
[0091] A fault judgment unit, used to judge whether the database cluster has a fault according to a preset fault detection rule and the operating status;
[0092] The alarm unit is used to generate a corresponding alarm prompt if it is determined that the database cluster has a fault.
[0093] Furthermore, the present application also discloses an electronic device, see Figure 8As shown, the contents in the drawings should not be considered as any limitation on the scope of use of the present application.
[0094] Figure 8 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the database access method disclosed in any of the aforementioned embodiments.
[0095] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0096] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222, and data 223 including a training set, etc. The storage method can be temporary storage or permanent storage.
[0097] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to including computer programs that can be used to complete the database access method executed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include computer programs that can be used to complete other specific tasks.
[0098] Furthermore, an embodiment of the present application also discloses a computer storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the database access method disclosed in any of the aforementioned embodiments are implemented.
[0099] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0100] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0101] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0102] The above is a detailed introduction to a database access method, device, equipment and medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A database access method, characterized in that: include: Acquire multiple database registration requests through a reserved registration interface, and perform corresponding database registration according to the database registration requests to obtain a registered database cluster; Creating a corresponding virtual database for the database cluster; Acquire a data access request through the virtual database, and select a target access database from the database cluster according to a preset screening rule, so as to execute the data access request using the target access database; The step of creating a corresponding virtual database for the database cluster includes: Obtain database screening conditions through the reserved data resource interface; Filtering a target database from the database cluster according to the database screening condition; the target database includes at least one master node database; Creating a corresponding virtual database for the target database; The step of creating a corresponding virtual database for the database cluster includes: A data connection pool is constructed based on the database connection corresponding to each of the databases; A corresponding virtual database is created for the database cluster, and the virtual IP and access password corresponding to the virtual database are made public.
2. The database access method according to claim 1, characterized in that: The step of obtaining multiple database registration requests through a reserved registration interface and performing corresponding database registration according to the database registration requests to obtain a registered database cluster includes: Obtaining registration requests corresponding to multiple databases in sequence through a reserved registration interface, and verifying connectivity of each database in sequence according to the registration request; the reserved registration interface is an application programming interface; The database with normal connectivity is persistently stored to obtain a registered database, so as to obtain the database cluster.
3. The database access method according to claim 1, characterized in that: The step of selecting a target access database from the database cluster according to a preset screening rule, so as to use the target access database to execute the data access request, includes: Filtering a target access database from the database cluster according to the current throughput of each database in the database cluster and the preset filtering rule; The target access database is accessed using a preset routing strategy according to the data access request, and a corresponding data query result is generated.
4. The database access method according to claim 3, characterized in that: The step of accessing the target access database by using a preset routing strategy according to the data access request includes: A connection route corresponding to the target access database is obtained from the data connection pool, and the target access database is accessed according to the connection route.
5. The database access method according to claim 3, characterized in that: After performing corresponding database registration according to the database registration request to obtain a registered database cluster, the method further includes: Configuring corresponding routing attributes for each of the databases, and obtaining the preset routing strategy based on all the routing attributes; Configure traffic control rules, which include database access frequency control and database access traffic control.
6. The database access method according to any one of claims 1 to 5, characterized in that: After creating a corresponding virtual database for the database cluster, the method further includes: Monitor each database in the database cluster through a heartbeat mechanism to obtain the operating status of the database cluster; Determine whether the database cluster has a fault according to a preset fault detection rule and the operating status; If it is determined that the database cluster has a fault, a corresponding alarm prompt is generated.
7. A database access device, characterized in that: include: A registration request acquisition module, used to acquire multiple database registration requests through a reserved registration interface, and perform corresponding database registration according to the database registration requests to obtain a registered database cluster; A virtual database creation module, used to create a corresponding virtual database for the database cluster; A data access module, used to obtain a data access request through the virtual database, and filter out a target access database from the database cluster according to a preset screening rule, so as to execute the data access request using the target access database; The virtual database creation module is further used to obtain database screening conditions through the reserved data resource interface; filter out a target database from the database cluster according to the database screening conditions; the target database includes at least one master node database; and create a corresponding virtual database for the target database; The virtual database creation module is further used to construct a data connection pool based on the database connection corresponding to each of the databases; create a corresponding virtual database for the database cluster, and disclose the virtual IP and access password corresponding to the virtual database.
8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the database access method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein when the computer programs are executed by a processor, the database access method according to any one of claims 1 to 6 is implemented.
