A method, system, device, and medium of accessing a distributed database

CN117216127BActive Publication Date: 2026-09-22BEIJING CHINA POWER INFORMATION TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311184843.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-14
Publication Date
2026-09-22
Estimated Expiration
2043-09-14

AI Technical Summary

Technical Problem

[0003]目前,数字化系统的底层数据库采用集中式数据库,数字化系统的业务系统则是按照微服务架构进行设计和构建的,利用数字化系统并行处理业务时,会出现数字化系统响应效率低下的情况

Benefits of technology

[0063]本申请提供了一种访问分布式数据库的方法,应用于数据库访问组件,第一数据库访问组件和第二数据库访问组件属于数据库访问组件,首先通过第一数据库访问组件接收前端应用发送的访问请求之后,根据访问请求中的数据库标识,查询到第二数据库访问组件,将访问请求发送至第二数据库访问组件,以使第二数据库访问组件根据访问请求访问目标分布式数据库,并获得分布式数据库返回的访问结果,最后通过第一数据库访问组件接收第二数据库访问组件发送的访问结果。在此过程中,通过构建数据库访问组件以及将原先底层数据库的集中式数据库替换为分布式数据库,使得数据库访问组件接收访问请求,以使数据库访问组件根据访问请求访问目标分布式数据库,从而提高数字化系统的响应效率,可以使得数字化系统并行处理业务。并且提升数字化系统的架构灵活性,提高数字化系统可靠性和整体性能,降低数字化系统建设和维护成本。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117216127B_ABST
    Figure CN117216127B_ABST
Patent Text Reader

Abstract

The application discloses a method, system, device and medium for accessing a distributed database. In the method, the first database access component and the second database access component belong to the database access component. After receiving the access request sent by the front-end application through the first database access component, the second database access component is queried according to the database identifier in the access request, the access request is sent to the second database access component, the second database access component accesses the target distributed database and obtains the access result, and finally the access result sent by the second database access component is received. In this process, the access request is distributed to the second database access component through the first database access component, so that the second database access component accesses the target distributed database according to the access request, thereby improving the response efficiency of the digital system and enabling the digital system to process business in parallel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data communication, and in particular to a method, system, device and medium for accessing a distributed database. Background Technology

[0002] With the rapid development of Internet technology, major companies have developed digital systems for massive numbers of customers, such as the power digital marketing service system, to handle large volumes of high-frequency, parallel and discrete business.

[0003] Currently, the underlying database of digital systems adopts a centralized database, while the business systems of digital systems are designed and built according to a microservice architecture. When using digital systems to process business in parallel, the response efficiency of digital systems will be low. Summary of the Invention

[0004] This application provides a method, system, device, and medium for accessing distributed databases. By constructing a database access component, it enables access to distributed databases, thereby improving the response efficiency of digital systems.

[0005] In a first aspect, this application provides a method for accessing a distributed database, the method comprising:

[0006] The first database access component receives an access request sent by the front-end application, the access request including the identifier of the second database access component;

[0007] The second database access component can be retrieved by using the identifier of the second database access component through the first database access component;

[0008] The first database access component sends an access request to the second database access component, so that the second database access component can access the target distributed database according to the access request and obtain the access result returned by the target distributed database. The access result is obtained when the second database access component successfully accesses the target distributed database.

[0009] The first database access component receives the access results sent by the second database access component.

[0010] Optionally, the access request includes an interface service token. Before the second database access component is queried by the first database access component based on the identifier of the second database access component, the method further includes:

[0011] The interface service is authenticated by the first database access component based on the interface service token, which is obtained by the front-end application when applying for interface service permissions.

[0012] By authenticating the interface service token carried in the access request through the first database access component, the access request can be verified, thereby ensuring the security of the received access request.

[0013] Optionally, the access request includes a data access identifier. Before the first database access component queries the second database access component based on the second database access component identifier, the method further includes:

[0014] Database access authentication is performed by the first database access component based on a data access identifier, which is obtained when the front-end application registers with the first database access component.

[0015] By authenticating the data access identifier carried in the access request through the first database access component, the access request can be verified, thereby ensuring that the received access request can perform data access operations.

[0016] Optionally, after retrieving the second database access component, the system also includes:

[0017] The first database access component sends a mutual trust authentication request to the second database access component.

[0018] The first database access component receives a mutual trust authentication response from the second data access component, the mutual trust authentication response including mutual trust authentication pass information, so as to establish a mutual trust relationship between the first database access component and the second database access component.

[0019] The first database access component sends a mutual trust authentication request to the second database access component. With the mutual trust authentication mechanism, when the access request reaches the second database access component, the second database access component will no longer perform database access authentication and interface service authentication.

[0020] Optionally, after sending the access request to the second database access component via the first database access component, the method further includes:

[0021] The first database access component receives the error result returned by the second database access component, which is obtained when the second database access component fails to access the target distributed database.

[0022] Access failures occur when the target distributed database cannot find the corresponding result based on the access request, or when there is an error in the access request parameters that prevent access to the target distributed database.

[0023] Secondly, this application also provides a method for accessing a distributed database, the method comprising:

[0024] The second database access component receives access requests sent by the first database access component.

[0025] The second database access component retrieves the access results from the target distributed database based on the query statement in the access request.

[0026] The access result is sent to the first database access component through the second database access component.

[0027] The second database access component allows queries to be made to the target distributed database based on access requests, thereby obtaining the access results. This component enables parallel processing of access requests, improving the speed at which access requests are processed.

[0028] Optionally, the second database access component retrieves the access result from the target distributed database based on the query statement in the access request, including:

[0029] The primary key identifier and partition index data are obtained through the second database access component based on the access request and the full-text search service, wherein the full-text search service is a plug-in of the second database access component;

[0030] The second database access component retrieves the access results from the target distributed database based on the primary key identifier, partition index data, and the query statement in the access request.

[0031] Based on the full-text search service plugin of the second database access component, the primary key identifier and partition index data of the data location required by the access request in the target distributed database can be obtained. This allows the second database access component to quickly obtain access results from the target distributed database based on the primary key identifier, partition index data, and query statement.

[0032] Thirdly, this application provides a first database access component, which includes:

[0033] A receiving unit is configured to receive an access request sent by a front-end application, wherein the access request includes a second database access component identifier;

[0034] The query unit is used to query the second database access component based on the second database access component identifier;

[0035] The sending unit is used to send the access request to the second database access component, so that the second database access component can access the target distributed database according to the access request and obtain the access result returned by the target distributed database. The access result is obtained when the second database access component successfully accesses the target distributed database.

[0036] The receiving unit is also used to receive the access results sent by the second database access component.

[0037] Optionally, the device further includes:

[0038] The authentication unit is used to authenticate the interface service based on the interface service token, which is obtained by the front-end application when applying for interface service permissions.

[0039] Optionally, the device further includes:

[0040] The authentication unit is used to authenticate database access based on a data access identifier, which is obtained when the front-end application registers with the first database access component.

[0041] Optionally, the transmitting unit is also used for:

[0042] Send a mutual trust authentication request to the second database access component;

[0043] The receiving unit is also configured to receive a mutual trust authentication response returned by the second data access component, the mutual trust authentication response including mutual trust authentication pass information, so as to establish a mutual trust relationship between the first database access component and the second database access component.

[0044] Optionally, the receiving unit is also used for:

[0045] Receive the error result returned by the second database access component, which is obtained when the second database access component fails to access the target distributed database.

[0046] Fourthly, this application provides a second database access component, which includes:

[0047] The receiving unit is used to receive access requests sent by the first database access component;

[0048] The query unit is used to retrieve access results from the target distributed database based on the query statement in the access request.

[0049] The sending unit is used to send the access result to the first database access component.

[0050] Optionally, the query unit includes:

[0051] The sub-unit is used to obtain the primary key identifier and partition index data based on the access request and the full-text search service, wherein the full-text search service is a plug-in of the second database access component;

[0052] The query subunit is used to retrieve access results from the target distributed database based on the primary key identifier, partition index data, and the query statement in the access request.

[0053] Fifthly, an access to a distributed database system, the system comprising: a front-end application capable of accessing a first database access component, the first database access component, a second database access component, and a target distributed database accessible by the second database access component;

[0054] A front-end application that can access the first database access component is used to call microservices according to business needs and send access requests to the database access component through the microservices.

[0055] The first database access component is used to execute the method provided in the first aspect above in response to the access request;

[0056] The second database access component is used to execute the method provided in the second aspect above in response to the access request;

[0057] The second database access component can access the target distributed database, obtain the access result based on the access request, and return the access result to the second database access component.

[0058] Sixthly, this application provides an electronic device including a memory and a processor:

[0059] Memory is used to store computer programs;

[0060] The processor is used to execute the methods provided in the first or second aspect above, according to a computer program.

[0061] In a seventh aspect, this application provides a computer-readable storage medium for storing a computer program for performing the methods provided in the first or second aspect above.

[0062] Therefore, this application has the following beneficial effects:

[0063] This application provides a method for accessing a distributed database, applied to a database access component. A first database access component and a second database access component are used. First, the first database access component receives an access request from a front-end application. Then, based on the database identifier in the access request, it queries and locates the second database access component, sending the access request to the second database access component. The second database access component then accesses the target distributed database according to the access request and obtains the access result returned by the distributed database. Finally, the first database access component receives the access result sent by the second database access component. In this process, by constructing database access components and replacing the original centralized database with a distributed database, the database access components receive access requests and access the target distributed database accordingly, thereby improving the response efficiency of the digital system and enabling parallel processing of business processes. Furthermore, it enhances the architectural flexibility, reliability, and overall performance of the digital system, while reducing its construction and maintenance costs.

[0064] During the process of obtaining access results, the primary key identifier and partition index data of the data location required by the access request in the target distributed database can be obtained by the full-text search service plugin of the second database access component. This allows the second database access component to quickly obtain access results from the target distributed database based on the primary key identifier, partition index data, and query statement, thereby improving the query speed.

[0065] In addition, the constructed database access component can authenticate access requests, thereby ensuring the security and validity of received access requests and preventing unauthorized users from making access requests. Furthermore, database access components in different digital systems can establish mutual trust relationships, so that when the first database access component sends an access request to the second database access component, the second database access component no longer needs to perform authentication operations, thus reducing redundant authentication operations and improving the efficiency of data access. The database access component uses a two-level mutual trust protocol to provide two-level, interconnected proxying for service database access. Attached Figure Description

[0066] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings.

[0067] Figure 1 This is a schematic diagram of the structure of an existing digital system in the embodiments of this application;

[0068] Figure 2 This is a schematic diagram of the structure of a novel digital system according to an embodiment of this application;

[0069] Figure 3 This is an example diagram of the database map and distributed database selection on the headquarters side in this application embodiment;

[0070] Figure 4 This is an example diagram of the database map and distributed database selection on the subsidiary side in this application embodiment;

[0071] Figure 5 This is a flowchart illustrating a method for accessing a distributed database according to an embodiment of this application;

[0072] Figure 6 This is a flowchart illustrating one embodiment of a method for accessing a distributed database according to this application.

[0073] Figure 7 This is a schematic diagram of the structure of a first database access component in an embodiment of this application;

[0074] Figure 8 This is a schematic diagram of the structure of a second database access component in an embodiment of this application;

[0075] Figure 9 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0076] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0077] In the embodiments of this application, the word "first" in the name of "first database access component" is only used for name identification and does not represent the first in order. The same rule applies to "second," "third," etc.

[0078] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0079] Currently, enterprises commonly use digital systems designed for massive customer bases, such as digital marketing service systems for the power industry, to handle large volumes of high-frequency, parallel, and discrete business transactions. Figure 1 As shown, current digital systems use a single centralized database such as Oracle as the underlying database, while the upper-layer business systems are designed and built according to a microservice architecture, consisting of front-end microservices, business center / business microservices, and data microservices. However, in actual application of digital systems, it is found that using a centralized database as the underlying database causes a large number of concurrent requests from the front-end application to be transmitted to the database. Due to the characteristics of a centralized database, these requests are processed sequentially. This results in a significant mismatch between the centralized database architecture and the distributed architecture expected by the microservice architecture adopted by the upper-layer business applications, greatly affecting the system's response efficiency.

[0080] like Figure 2 As shown, this application provides a novel digital system, which mainly includes: a front-end application, a database access component, and multiple distributed databases;

[0081] The front-end application is used to call microservices according to business needs and send access requests to the database access component through the microservices; the microservices are composed of front-end microservices, business microservices, data microservices, etc.

[0082] The database access component is used to access distributed databases based on access requests. It can access multiple distributed databases and specifically provides access service interfaces to the outside world, enabling the persistence of domain object data and the querying of application services. It also supports caching operations on business domain object data. Furthermore, the database access component includes various customizable plugins, giving it scalability and extensibility.

[0083] Multiple distributed databases are used to obtain access results based on access requests and return the access results to the database access component.

[0084] In addition, the database access component executes customized plugins either serially or by bypass. In the serial processing mode, the database access component can use the chain of responsibility pattern to implement various customized plugin functions. The chain of responsibility pattern sends requests in sequence and processes the next request only after receiving the processing result, thus resolving the sequential execution relationship in a group of services. In the by bypass processing mode, the database access component triggers corresponding customized plugins according to the configuration, and multiple customized plugins can be triggered simultaneously based on the plugin configuration.

[0085] The novel digital system provided in this application builds a new database access component on the basis of the original digital system, and replaces the original centralized database with a distributed database, thereby improving the architectural flexibility of the digital system, enhancing system reliability and overall performance, and reducing the construction and maintenance costs of the digital system.

[0086] It should be noted that, considering enterprise data application scenarios, taking a power grid company as an example, the headquarters represents the parent company, and the provincial and municipal power companies are subsidiaries. This new digital system can serve as a data system for either the headquarters or the subsidiaries.

[0087] In this embodiment, by constructing a database access component and replacing the underlying database with a distributed database, the novel digital system provided by this embodiment can send access requests to a target distributed database for processing via the database access component, enabling the underlying database in the digital system to be a multi-type distributed database. Specifically, the method may include: a first database access component receiving an access request sent by a front-end application; querying the second database access component based on the second database access component identifier in the access request; forwarding the access request to the second database access component via the first access component; enabling the second database access component to access the target distributed database according to the access request; obtaining the access result returned by the target distributed database; and finally, receiving the access result sent by the second database access component via the first database access component.

[0088] As can be seen, the method provided in this application, based on the first database access component, can forward access requests to the second database access component to be accessed, so that the second database access component can access the target distributed database according to the access request, thereby obtaining the access result. In this process, the access routing capability of the database access component is used to forward the access request to the database access component to be accessed, and then the data processing capability of the database access component is used to access the target distributed database and obtain the access result, thereby improving the response efficiency of the digital system and enabling the digital system to process business in parallel.

[0089] To facilitate understanding of the specific implementation of the method for accessing a distributed database provided in this application embodiment, the following description will be provided in conjunction with the accompanying drawings.

[0090] It should be noted that the entity implementing this method for accessing a distributed database can be a database access component provided in the embodiments of this application. This database access component can be carried in an electronic device or a functional module of an electronic device. The electronic device in the embodiments of this application can be any device capable of implementing the method for accessing a distributed database in the embodiments of this application, such as an Internet of Things (IoT) device.

[0091] Figure 5 This is a flowchart illustrating a method for accessing a distributed database, as provided in an embodiment of this application. This method can be applied to a database access component, which may be, for example, a... Figure 7 A first database access component 700 and shown are shown. Figure 8 The second database access component 800 is described above.

[0092] It should be noted that the embodiments in this application construct a database access component. Taking a power grid company as an example, and considering the enterprise data application scenario, the headquarters represents the parent company, and the provincial and municipal power companies are subsidiaries. Furthermore, based on the actual situation of power marketing, business data is generally stored separately in the digital system on the headquarters side and the digital system on the subsidiary side, according to physical location. This business data can generally be categorized into basic files, business processing procedures, and business processing results. For example, the database in the digital system on the headquarters side stores business processing result data, while the database in the digital system on the subsidiary side stores business processing process data. Basic file data is synchronized from the digital system on the subsidiary side to the digital system on the headquarters side for centralized storage.

[0093] The database can be divided into primary and secondary databases. The primary database is the physical database, a distributed database instance, and different distributed database products can be selected based on data scale and access characteristics. The secondary database is the logical database, divided according to data distribution, and is independent of the data scale at the headquarters or subsidiary level. A primary database consists of one or more secondary databases (logical databases), determined by optimized combination and allocation based on the data classification, storage scale, and access characteristics of the secondary databases in the region. Using logical databases can shield the physical details of the distributed database.

[0094] The headquarters and subsidiary databases can choose the same distributed database option based on their needs, or they can choose different distributed database options. Table 1 shows an example of distributed database selection, where the most suitable distributed database is chosen based on dimensions such as data classification, storage scale, and access characteristics. The data volume scale n is generally chosen to be in the tens of millions.

[0095] Table 1. Examples of Distributed Database Selection

[0096]

[0097]

[0098] When selecting a database for the headquarters side, specific examples include... Figure 3 The database map and distributed database selection example shown on the headquarters side select distributed database 1 and distributed database 3. Among them, the engineering, market, metering, asset, and operation data in distributed database 1 are selected as the power marketing business service data, and the operation management data in distributed database 3 are selected as the supporting platform data.

[0099] Similarly, when selecting a database for a subsidiary, specific options can be chosen based on, for example, the database type. Figure 4 The database map and distributed database selection example shown for the subsidiary side selects Distributed Database 1, Distributed Database 2, and Distributed Database 3. Specifically, data from Distributed Database 1 (including business expansion, engineering, marketing, contracts, metering, assets, and operations) and Distributed Database 2 (including accounting and payment data) are selected as power marketing service data. IoT data from Distributed Database 3 is selected as customer IoT application data, and operations management data is selected as support platform data. Distributed Database 2 includes not only accounting and payment data stored in the payment and accounting database but also billing data stored in the billing database.

[0100] It should be noted that the embodiments of this application construct a database access component. Based on enterprise data application scenarios and according to physical location, business data is generally stored in a distributed database on the headquarters side and a distributed database on the subsidiary side. Business data can generally be divided into types such as basic files, business processing procedures, and business processing results. For example, the database in the digital system on the headquarters side stores business processing result data, the database in the digital system on the subsidiary side stores business processing process data, and basic file data is synchronized from the digital system on the subsidiary side to the digital system on the headquarters side for centralized storage.

[0101] The database access component manages multiple distributed databases, and specific management methods may include the following:

[0102] (1) To manage distributed database instances, including adding, updating, deleting, restarting, and restoring database instances, you can obtain detailed information and current status of the database instances.

[0103] (2) Managing distributed databases, including adding database IDs, updating databases, deleting database IDs, etc., will obtain detailed database information and current status.

[0104] (3) The distributed database is partitioned. The vertical partitioning principle is adopted. The data is reasonably partitioned according to the business service type to facilitate the management of massive data.

[0105] (4) Partition the distributed database and adopt the principle of horizontal partitioning of data. For example, the data can be reasonably partitioned according to the city, which is convenient for managing massive amounts of data. Partitioning can also be carried out according to range, list, hash, and mixed methods.

[0106] Because the databases at headquarters and those at subsidiaries store different data, enterprise data management can include multiple headquarters-side database access components and multiple subsidiary-side database access components. To ensure that front-end applications can obtain the corresponding access results, the database access components must have database access routing capabilities, allowing them to route and forward access requests.

[0107] In addition, to ensure that the database access component can handle access requests normally, the database access component also has access support capabilities, specifically including: (1) controlling access requests to the distributed database according to rate limiting rules, including controlling requests that exceed the time limit. (2) when the service interface fails, the access requests to the front-end application return quickly to reduce resource usage and prevent being overwhelmed by traffic. (3) automatically scaling up and down the deployed resources based on the scheduling throughput and resource usage. (4) isolating services of different businesses from each other to reduce the mutual influence of business services and improve the stability of service operation. (5) asynchronously recording the business service call log to provide basic data for value-added operations. (6) monitoring the database access service call status.

[0108] It should be noted that in the embodiments of this application, the first database access component can be a database access component on the headquarters side, and the second database access component can be a database access component on the subsidiary side. However, in different scenarios or at different times, the first database access component can be a database access component on the subsidiary side, and the second database access component can be a database access component on the headquarters side.

[0109] like Figure 5 As shown, this method is applied to a database access component, and the method includes the following steps S501 to S505:

[0110] S501: Receive an access request sent by the front-end application through the first database access component, wherein the access request includes the identifier of the second database access component;

[0111] To obtain the access result returned by the distributed database, the system first receives the access request sent by the front-end application based on the first database access component. Then, based on the second database access component identifier in the access request, it queries the second database access component, forwards the access request to the second database access component, and enables the second database access component to access the target distributed database according to the access request and obtain the access result returned by the target distributed database. Finally, the access result sent by the second database access component is received by the first database access component. Therefore, in this embodiment, by receiving the access request sent by the front-end application through the first database access component in step S501, a prerequisite is provided for querying the second database access component.

[0112] Combination Figure 2 The novel digital system shown, as an example, may include the following steps in step S501: First, the front-end application calls a front-end microservice based on a business service. Then, the front-end microservice calls various central business microservices. The business microservices then call data microservices, and some query microservices can bypass the business microservices and directly call the data microservices. Finally, the data microservices call the database access service provided by the database access component. The first database access component can receive access requests sent by the front-end application, access the target distributed database according to the requests, and ultimately obtain the access results.

[0113] Upon receiving an access request, authentication can be performed. Specifically, this includes: authenticating the interface service based on the interface service token in the access request, and authenticating database access based on the data access identifier in the access request. The data access identifier is obtained by the front-end application during registration with the first database access component. It should be noted that obtaining the data access identifier can be achieved, for example, by registering the front-end application with the database access component through the database access component configuration center. Upon successful registration, the database access component configuration center issues a unique data access identifier to the front-end application. Similarly, obtaining the service interface token can be achieved, for example, by the front-end application applying for service and interface permissions after registering with the database access component. Once the service and interface registration is approved, the front-end application receives the interface service token.

[0114] During this process, the data access identifier and interface service token in the access request are used to authenticate the interface service and the database access, thereby ensuring that the database access component has the ability to authenticate the database access and preventing unauthorized users from making access request operations.

[0115] S502: The second database access component is retrieved by the first database access component based on the identifier of the second database access component.

[0116] As an example, in order to obtain the target distributed database based on the access request, it is necessary to establish a database access component identifier for the database access component, and similarly, establish a distributed database identifier for the distributed databases managed by the database access component. Furthermore, a mapping relationship is established between the database access component identifier, the distributed database identifier, and the domain name and port of the database access component, and this mapping relationship is saved in an environment configuration table. This environment configuration table is also stored in each database access component, such as the first database access component and the second database access component. Therefore, S502 may include: querying the domain name and port of the second database access component from the environment configuration table of the first database access component based on the second database access component identifier and the distributed database identifier in the database identifier.

[0117] In addition, after the second database access component is located, the process can also include: sending a mutual trust authentication request to the second database access component; and receiving mutual trust authentication success information from the second database access component, thereby establishing mutual trust between the first and second database access components. Because the first and second database access components establish mutual trust, thanks to the mutual trust authentication mechanism, when an access request reaches the second database access component, the second database access component no longer performs database access authentication and interface service authentication. Correspondingly, when the first database access component receives an access request from the second database access component, the first database access component also no longer performs database access authentication and interface service authentication, directly accessing the target distributed database according to the access request, thereby reducing redundant authentication operations and improving data access efficiency. Therefore, the database access component uses a two-level mutual trust protocol to provide two-level database access and two-level connectivity proxy for the service.

[0118] S503: Send the access request to the second database access component through the first database access component.

[0119] As an example, since the access request needs to access the target distributed database, S503 may include: the first database access component forwarding the access request to the second database access component that manages the target distributed database, so that the second database access component can then access the target distributed database according to the access request and obtain the access result returned by the target distributed database. During this process, the first database component can forward the data access service request to the corresponding service interface according to routing rules, and has the capability to support both public routing rules and custom routing.

[0120] S504: The second database access component accesses the target distributed database according to the access request and obtains the access result returned by the target distributed database. The access result is obtained when the second database access component successfully accesses the target distributed database.

[0121] In this process, the second database access component accesses the target distributed database according to the access request and obtains the access results returned by the target distributed database. S504 may include: obtaining the primary key identifier and partition index data through the second database access component based on the access request and the full-text search service. The full-text search service is a plugin of the second database access component. Based on the plugin of the full-text search service of the second database access component, the primary key identifier and partition index data of the data location required by the access request in the target distributed database can be obtained, so that the second database access component can quickly obtain the access results from the target distributed database based on the primary key identifier, partition index data and query statement.

[0122] In addition to the above, after the first database access component forwards the access request to the second database access component, it may also include: receiving an error result returned by the second database access component, which indicates that the second database access component failed to access the target distributed database. Access failure occurs when the target distributed database cannot find the corresponding result based on the access request, or when there is an incorrect parameter in the access request, preventing access to the target distributed database. Therefore, the second database access component may send an error result to the first database access component.

[0123] S505: Send the access result of the first database access component to the second database access component.

[0124] As an example, after executing S505, it may also include: after receiving the access result sent by the second database access component, the first database access component sends the access result to the front-end application, thereby completing the entire access process.

[0125] As can be seen, in this embodiment, the first database access component receives the access request sent by the front-end application. Based on the database identifier in the access request, it queries the second database access component and sends the access request to it. The second database access component then accesses the target distributed database according to the access request and obtains the access result returned by the distributed database. Finally, the first database access component receives the access result sent by the second database access component. In this process, by constructing database access components and assigning access requests to the corresponding database access components, the database access components can access the corresponding distributed databases according to the access requests, thereby improving the response efficiency of the digital system and enabling the digital system to process business in parallel.

[0126] To satisfy the routing capabilities of the database access component, this application embodiment also provides an access to a distributed database system, which includes: a front-end application that can access the first database access component, the first database access component, the second database access component, and a target distributed database that the second database access component can access;

[0127] A front-end application that can access the first database access component is used to call microservices according to business needs and send access requests to the first database access component through the microservices.

[0128] The first database access component is used to execute the method of obtaining access results by the first database access component in the above embodiments according to the access request;

[0129] The second database access component is used to execute the method of accessing the target distributed database by the second database access component in the above embodiment according to the access request;

[0130] The second database access component can access the target distributed database, obtain the access result based on the access request, and return the access result to the second database access component.

[0131] According to an embodiment of this application, a method for accessing a distributed database system is provided. A front-end application that can access a first database access component sends an access request to the first database access component. The first database access component then forwards the access request to a second database access component. Based on the access request, the second database access component can obtain the access result through the target distributed database that it can access. The second database access component sends the obtained access result back to the first database access component, so that the first database access component returns the access result to the front-end application that can access the first database access component, thus completing the request to access the distributed database.

[0132] To make the methods provided in the embodiments of this application clearer and easier to understand, the following is combined with... Figure 6 The method is illustrated with an example. In this embodiment, the first database access component is a headquarters-side database access component, and the second database access component is a subsidiary-side database access component.

[0133] like Figure 6 As shown, this embodiment may include:

[0134] S601: The front-end application sends an access request to the headquarters-side database access component. The access request includes a second database access component identifier, a data access identifier, and an interface service token.

[0135] As an example, S601 may include: The front-end application generates an access request based on its business requirements and sends the request to the headquarters-side database access component. Since the front-end application has previously registered with the database access component and obtained a data access identifier, and has also applied for service and interface permissions and obtained an interface service token, the front-end application carries the registered data access identifier, the interface service token, and the second database access component identifier in the access request header.

[0136] S602: The headquarters-side database access component performs authentication based on the data access identifier and the interface service token.

[0137] As an example, S602 may include: the headquarters-side database access component needs to perform interface service authentication based on the interface service token and data access authentication based on the data access identifier to determine whether the access request can access the database.

[0138] S603: If the authentication of the headquarters-side database access component is successful, the subsidiary-side database access component can be found based on the identifier of the second database access component.

[0139] As an example, S603 may include: if authentication is successful, the headquarters-side database access component queries the environment configuration for the domain name and port of the target subsidiary-side database access component based on the subsidiary-side database access component identifier and the target distributed database identifier.

[0140] S604: The headquarters-side database access component sends the access request to the subsidiary-side database access component.

[0141] As an example, S604 further includes: the headquarters-side database access component sending a mutual trust authentication request to the subsidiary-side database access component, and then the headquarters-side database access component receiving a mutual trust authentication response returned by the subsidiary-side data access component, the response including the mutual trust authentication pass information, so as to establish a mutual trust relationship between the headquarters-side database access component and the subsidiary-side database access component.

[0142] Because the headquarters-side database access component and the subsidiary-side database access component establish a mutual trust relationship, the subsidiary-side database access component no longer performs database access authentication and interface service authentication when the access request reaches the subsidiary-side database access component, thanks to the mutual trust authentication mechanism.

[0143] S605: The subsidiary-side database access component sends the access request to the target distributed database.

[0144] As an example, S605 may include: the subsidiary database access component can obtain the primary key identifier and partition index data in the target distributed database through access requests and full-text search storage auxiliary queries, and then send the primary key identifier, partition index data and query statement in the access request to the target distributed database.

[0145] S606: The target distributed database obtains the access result based on the access request.

[0146] As an example, S606 may include the target distributed database retrieving access results based on the query statement in the access request.

[0147] S607: The target distributed database sends the access result to the subsidiary's database access component.

[0148] S608: The subsidiary-side database access component sends the access result to the headquarters-side database access component.

[0149] S609: The headquarters-side database access component sends access results to the front-end application.

[0150] As an example, based on the routing path of the access request, the access result obtained from the target distributed database is also routed back to the front-end application according to the routing path, thereby completing the access request.

[0151] This embodiment provides a method for accessing a distributed database. By constructing a database access component and distributing access requests to the corresponding database access component, the database access component can access the target distributed database according to the access request, thereby improving the response efficiency of the digital system that processes business and enabling the digital system to process business in parallel.

[0152] See Figure 7 This application provides a first database access component 700, which includes:

[0153] The receiving unit 701 is used to receive an access request sent by the front-end application, wherein the access request includes a second database access component identifier;

[0154] The query unit 702 is used to query the second database access component based on the second database access component identifier;

[0155] Sending unit 703 is used to send an access request to a second database access component, so that the second database access component can access the target distributed database according to the access request and obtain the access result returned by the target distributed database. The access result is obtained when the second database access component successfully accesses the target distributed database.

[0156] The receiving unit 701 is also used to receive the access result sent by the second database access component.

[0157] Optionally, the device further includes:

[0158] The authentication unit is used to authenticate the interface service based on the interface service token, which is obtained by the front-end application when applying for interface service permissions.

[0159] Optionally, the authentication unit is further configured to:

[0160] Database access authentication is performed based on a data access identifier, which is obtained when the front-end application registers with the first database access component.

[0161] Optionally, the transmitting unit 703 is also used for:

[0162] Send a mutual trust authentication request to the second database access component;

[0163] The receiving unit 701 is further configured to receive a mutual trust authentication response returned by the second data access component, the mutual trust authentication response including mutual trust authentication pass information, so as to establish a mutual trust relationship between the first database access component and the second database access component.

[0164] Optionally, the receiving unit 701 is further configured to:

[0165] Receive the error result returned by the second database access component, which is obtained when the second database access component fails to access the target distributed database.

[0166] It should be noted that the specific implementation method and achieved effect of the first database access component 700 can be found in the above. Figure 5 or Figure 6 The relevant descriptions in the provided methods will not be repeated here.

[0167] See Figure 8 This application provides a second database access component 800, which includes:

[0168] The receiving unit 801 is used to receive the access request sent by the first database access component;

[0169] The query unit 802 is used to retrieve the access result from the target distributed database based on the query statement in the access request.

[0170] The sending unit 803 is used to send the access result to the first database access component.

[0171] Optionally, query unit 802 includes:

[0172] The sub-unit is used to obtain the primary key identifier and partition index data based on the access request and the full-text search service, wherein the full-text search service is a plug-in of the second database access component;

[0173] The query subunit is used to retrieve access results from the target distributed database based on the primary key identifier, partition index data, and the query statement in the access request.

[0174] It should be noted that the specific implementation and effects of the second database access component 800 can be found in the above description. Figure 5 or Figure 6 The relevant descriptions in the provided methods will not be repeated here.

[0175] This application also provides an electronic device 900, such as... Figure 9 As shown, the device 900 includes a memory 901 and a processor 902:

[0176] Memory 901 is used to store computer programs;

[0177] Processor 902 is used to execute the above according to the computer program. Figure 5 or Figure 6 The methods provided.

[0178] In addition, this application also provides a computer-readable storage medium for storing a computer program, the computer program being executed. Figure 5 or Figure 6 The methods provided.

[0179] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the methods of the above embodiments can be implemented by means of software plus a general-purpose hardware platform. Based on this understanding, the technical solution of this application can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as a read-only memory (ROM) / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, a server, or a network communication device such as a router) to execute the methods described in various embodiments or some parts of the embodiments of this application.

[0180] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, the device embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. The device embodiments described above are merely illustrative. Modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the objectives of this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0181] The above description is merely an exemplary implementation of this application and is not intended to limit the scope of protection of this application.

Claims

1. A method for accessing a distributed database, characterized in that, A hierarchical business system with a headquarters side and at least one subsidiary side, wherein the headquarters side stores business processing result data and the subsidiary side stores business processing process data, the method comprising: The first database access component receives access requests sent by the front-end application through microservices, and the access request includes the identifier of the second database access component; wherein, the first database access component is deployed on the headquarters side and the second database access component is deployed on the subsidiary side, or the first database access component is deployed on the subsidiary side and the second database access component is deployed on the headquarters side. The first database access component queries the second database access component based on the identifier of the second database access component; the querying of the second database access component based on the identifier of the first database access component includes: querying the domain name and port of the second database access component from the environment configuration table of the first database access component based on the identifier of the second database access component and the identifier of the distributed database in the database identifier. After the second database access component is retrieved, the process also includes: The first database access component sends a mutual trust authentication request to the second database access component; The first database access component receives mutual trust authentication information returned by the second database access component, thereby establishing a mutual trust relationship between the first database access component and the second database access component. The first database access component sends the access request to the second database access component, so that the second database access component can access the target distributed database according to the access request and obtain the access result returned by the target distributed database. The access result is obtained when the second database access component successfully accesses the target distributed database. The first database component forwards the access request to the corresponding service interface according to the routing rules and has the ability to support public routing rules and custom routing. The first database access component receives the access result sent by the second database access component.

2. The method according to claim 1, characterized in that, The access request includes an interface service token. Before the method retrieves the second database access component based on the identifier of the second database access component using the first database access component, it further includes: The interface service is authenticated by the first database access component based on the interface service token, which is obtained by the front-end application when applying for interface service permissions.

3. The method according to claim 1, characterized in that, The access request includes a data access identifier. Before the method retrieves the second database access component based on the second database access component identifier using the first database access component, it further includes: The first database access component performs database access authentication based on the data access identifier, which is obtained when the front-end application registers with the first database access component.

4. The method according to claim 1, characterized in that, After sending the access request to the second database access component through the first database access component, the method further includes: The first database access component receives the error result returned by the second database access component, the error result being obtained when the second database access component fails to access the target distributed database.

5. A method for accessing a distributed database, characterized in that, A hierarchical business system with a headquarters side and at least one subsidiary side, wherein the headquarters side stores business processing result data and the subsidiary side stores business processing process data, the method comprising: The second database access component receives the access request sent by the first database access component; wherein the first database access component is deployed on the headquarters side and the second database access component is deployed on the subsidiary side, or the first database access component is deployed on the subsidiary side and the second database access component is deployed on the headquarters side. The second database access component retrieves access results from the target distributed database based on the query statement in the access request; retrieving access results from the target distributed database based on the query statement in the access request by the second database access component includes: obtaining a primary key identifier and partition index data by the second database access component based on the access request and a full-text search service, wherein the full-text search service is a plugin of the second database access component; and retrieving access results from the target distributed database by the second database access component based on the primary key identifier, the partition index data, and the query statement in the access request. The access result is sent to the first database access component through the second database access component.

6. A first database access component, characterized in that, A hierarchical business system with a headquarters side and at least one subsidiary side, wherein the headquarters side stores business processing result data and the subsidiary side stores business processing process data, the first database access component includes: A receiving unit is configured to receive an access request sent by a front-end application through a microservice, the access request including a second database access component identifier; wherein, the first database access component is deployed on the headquarters side and the second database access component is deployed on the subsidiary side, or the first database access component is deployed on the subsidiary side and the second database access component is deployed on the headquarters side. The query unit is used to query the second database access component based on the identifier of the second database access component; The query unit is specifically used to query the domain name and port of the second database access component from the environment configuration table of the first database access component based on the second database access component identifier and the distributed database identifier in the database identifier; The sending unit is configured to send the access request to the second database access component, so that the second database access component can access the target distributed database according to the access request and obtain the access result returned by the target distributed database. The access result is obtained when the second database access component successfully accesses the target distributed database. The first database component forwards the access request to the corresponding service interface according to the routing rules and has the ability to support public routing rules and custom routing. The sending unit is further configured to send a mutual trust authentication request to the second database access component; The receiving unit is further configured to receive mutual trust authentication pass information returned by the second database access component, so as to establish a mutual trust relationship between the first database access component and the second database access component; The receiving unit is also used to receive the access result sent by the second database access component.

7. The first database access component according to claim 6, characterized in that, The access request includes an interface service token, and the first database access component further includes: The authentication unit is used to authenticate the interface service through the first database access component based on the interface service token, which is obtained by the front-end application when applying for interface service permissions.

8. The first database access component according to claim 6, characterized in that, The access request includes a data access identifier, and the first database access component further includes: The authentication unit is used to perform database access authentication through the first database access component based on the data access identifier, wherein the data access identifier is obtained when the front-end application registers with the first database access component.

9. The first database access component according to claim 6, characterized in that: The receiving unit is further configured to receive an error result returned by the second database access component, the error result being obtained when the second database access component fails to access the target distributed database.

10. A second database access component, characterized in that, A hierarchical business system with a headquarters side and at least one subsidiary side, wherein the headquarters side stores business processing result data and the subsidiary side stores business processing process data, the second database access component includes: The receiving unit is used to receive access requests sent by the first database access component; The query unit is used to retrieve the access result from the target distributed database based on the query statement in the access request; The query unit includes: The sub-unit is used to obtain the primary key identifier and partition index data according to the access request and the full-text search service, wherein the full-text search service is a plug-in of the second database access component; The query subunit is used to retrieve access results from the target distributed database based on the primary key identifier, the partition index data, and the query statement in the access request. The sending unit is used to send the access result to the first database access component; Wherein, the first database access component is deployed on the headquarters side and the second database access component is deployed on the subsidiary side, or the first database access component is deployed on the subsidiary side and the second database access component is deployed on the headquarters side.

11. A method for accessing a distributed database system, characterized in that, The system includes: a front-end application that can access the first database access component, the first database access component, the second database access component, and a target distributed database that the second database access component can access; The front-end application that can access the first database access component is used to call microservices according to business needs and send access requests to the first database access component through the microservices. The first database access component is configured to execute the method according to any one of claims 1 to 4 based on the access request; The second database access component is configured to execute the method of claim 5 according to the access request; The second database access component can access a target distributed database, which is used to obtain an access result based on the access request and return the access result to the second database access component.

12. An electronic device, characterized in that, The device includes a memory and a processor, the processor being configured to execute a program stored in the memory, performing the method as described in any one of claims 1-5.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program for performing the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Database access permission control method and device and electronic equipment

    CN111756752A

  • Data access system and method and electronic equipment

    CN116126944A