WO2021197432A1 - 一种数据库集群的路由方法和装置 - Google Patents
一种数据库集群的路由方法和装置 Download PDFInfo
- Publication number
- WO2021197432A1 WO2021197432A1 PCT/CN2021/084963 CN2021084963W WO2021197432A1 WO 2021197432 A1 WO2021197432 A1 WO 2021197432A1 CN 2021084963 W CN2021084963 W CN 2021084963W WO 2021197432 A1 WO2021197432 A1 WO 2021197432A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- target
- database cluster
- database
- role
- identifier
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/62—Protecting access to data via a platform, e.g. using keys or access control rules
- G06F21/6218—Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2221/00—Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F2221/21—Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F2221/2141—Access rights, e.g. capability lists, access control lists, access tables, access matrices
Definitions
- the present disclosure relates to the field of computer technology, and in particular to a routing method and device for a database cluster.
- Data sub-database storage is a practical and effective way to solve database pressure, such as isomorphic sub-databases, that is, database clusters.
- database pressure such as isomorphic sub-databases, that is, database clusters.
- the data routing problem needs to be solved after the database is divided.
- the first method excessive waste of server resources, doubled the maintenance cost; when the system is online, the workload will be doubled, and the more applications will increase the configuration information, which is prone to errors;
- the second method due to each Access requests carry the sub-database master key as an input parameter, so it is more intrusive to business operations.
- the embodiments of the present disclosure provide a routing method and device for a database cluster to solve the technical problems of wasting server resources, high maintenance costs, or intrusive to business operations.
- a routing method for a database cluster including:
- the database access request carrying a target business system identifier and a target user identifier
- the database access request is routed to the target database cluster.
- the access authority information includes the correspondence between each database cluster and each role, and the correspondence between each business system and each user and each role;
- matching the configuration information of the corresponding target database cluster includes:
- the configuration information includes: database address, port number, name, connection timeout time, read and write timeout time, reconnection strategy, read-only, whether to enable load balancing, and whether to support at least one of batch operations.
- the number of the target role is at least one, and the target role has a one-to-one correspondence with the target database cluster.
- the database access request before receiving the database access request, it further includes:
- the database access request before receiving the database access request, it further includes:
- each database cluster and each role is obtained from the authority system, and stored in the cache.
- matching the corresponding target role according to the target service system identifier and the target user identifier includes:
- the corresponding relationship between the target service system identifier and the target user identifier and the target role is stored in a cache.
- a routing device for a database cluster including:
- a receiving module configured to receive a database access request, the database access request carrying a target business system identifier and a target user identifier;
- the matching module is configured to match the configuration information of the corresponding target database cluster according to the target business system identifier, the target user identifier, and the access authority information configured in the authority system;
- the routing module is configured to route the database access request to the target database cluster according to the configuration information of the target database cluster.
- the access authority information includes the correspondence between each database cluster and each role, and the correspondence between each business system and each user and each role;
- the matching module is also used for:
- the configuration information includes: database address, port number, name, connection timeout time, read and write timeout time, reconnection strategy, read-only, whether to enable load balancing, and whether to support at least one of batch operations.
- the number of the target role is at least one, and the target role has a one-to-one correspondence with the target database cluster.
- a configuration module for:
- a configuration module for:
- each database cluster and each role is obtained from the authority system, and stored in the cache.
- the matching module is further used for:
- the corresponding relationship between the target service system identifier and the target user identifier and the target role is stored in a cache.
- an electronic device including:
- One or more processors are One or more processors;
- Storage device for storing one or more programs
- the one or more processors When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the foregoing embodiments.
- a computer-readable medium having a computer program stored thereon, and the program is executed by a processor to implement the method described in any of the foregoing embodiments.
- An embodiment in the above disclosure has the following advantages or beneficial effects: because the configuration information of the corresponding target database cluster is matched according to the target business system identification, target user identification, and access authority information configured in the authorization system, the database access request.
- the technical means of routing to the target database cluster overcomes the technical problems of wasting server resources, high maintenance costs, or intrusive to business operations in the prior art.
- the embodiment of the present disclosure realizes the decoupling of the application system and the database cluster in the routing strategy, and manages the user's database access authority by configuring the access authority information in the authority system in the application system, thereby realizing database routing.
- the embodiments of the present disclosure can fully decouple the application system from the database cluster, and there is no need for each business operation to have a sub-database master key, and it is also unnecessary for each data cluster to deploy an application system separately.
- Fig. 1 is a schematic diagram of the main flow of a routing method for a database cluster according to an embodiment of the present disclosure
- FIG. 2 is a schematic diagram of the main flow of a routing method for a database cluster according to a reference embodiment of the present disclosure
- FIG. 3 is a schematic diagram of a system framework for implementing the routing method of an embodiment of the present disclosure
- FIG. 4 is a schematic diagram of the main process of a routing method for a database cluster according to another reference embodiment of the present disclosure
- FIG. 5 is a schematic diagram of main modules of a routing device of a database cluster according to an embodiment of the present disclosure
- Fig. 6 is an exemplary system architecture diagram to which the embodiments of the present disclosure can be applied;
- Fig. 7 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present disclosure.
- Fig. 1 is a schematic diagram of the main flow of a routing method for a database cluster according to an embodiment of the present disclosure.
- the routing method of the database cluster may include:
- Step 101 Receive a database access request, where the database access request carries a target service system identifier and a target user identifier.
- a general application system can only access specific functions after logging in and obtaining permissions.
- the login generally goes through a single sign-on verification. After the verification is passed, the user's functional permissions (for example, which specific functions can be used) are obtained from the permission system.
- step 101 may include: receiving a database access request; performing login verification on the target user according to the target service system identification and target user identification carried in the database access request; if the login is passed, obtaining the The function authority corresponding to the target user is executed and step 102 is executed; if the login fails, the process ends.
- the authority system in the embodiment of the present disclosure is a part of the application system, and the functional authority of each user to access the application system is stored.
- Step 102 According to the target service system identifier, the target user identifier, and the access authority information configured in the authority system, match the configuration information of the corresponding target database cluster.
- the configuration information of the target database cluster can be matched through the access authority information pre-configured in the authority system.
- the configuration information includes: database address, port number, name, connection timeout time, read and write timeout time, reconnection strategy, read-only, whether to enable load balancing, and whether to support at least one of batch operations.
- the configuration information may include the following information:
- connectTimeout 3000;//Timeout time when establishing socket connection with database server
- socketTimeout 15000;//socket operation (read and write) timeout time
- the access authority information includes the correspondence between each database cluster and each role, and the correspondence between each business system and each user and each role.
- step 102 may include: matching the corresponding target role according to the target business system identifier and the target user identifier; matching the corresponding target database cluster identifier according to the target role; according to the target database cluster identifier Match the configuration information of the target database cluster.
- the target role is first matched according to the correspondence between the business system identification and the user identification and the role; then according to the correspondence between the role and the database cluster identification, the identification of the target database cluster is matched; and finally according to the database cluster The corresponding relationship between the identifier and the configuration information of the database cluster is matched, and the configuration information of the target database cluster is matched.
- the number of the target role is at least one, and the target role has a one-to-one correspondence with the target database cluster.
- the correspondence relationship between the service system ID and the user ID and the role can be one-to-one or one-to-many. Therefore, the target service system ID and the target user ID can match at least For a target role, since there is a one-to-one correspondence between the role and the database cluster, at least one corresponding target database cluster can be matched according to the at least one target role.
- the method further includes: determining the database cluster corresponding to each user according to the region where each user is located; configuring the correspondence between each database cluster and each role, and storing it in the authority system; configuring Correspondence between each business system and each user and each role, and store it in the authority system.
- the embodiment of the present disclosure configures the authority information of the user to access the database (including the correspondence between each database cluster and each role, as well as the correspondence between each business system and each user and each role) to the authority system, then through the authority
- the system can manage user access to the database, so that the database access request can be easily routed to the correct database cluster.
- a database cluster is a database cluster.
- this disclosure Due to the large amount of configuration information of the database cluster (mainly including database address, port number, name, connection timeout time, read and write timeout time, reconnection strategy, read-only, whether to enable load balancing, whether to support batch operation, etc.), this disclosure
- this disclosure by configuring the corresponding relationship between the database cluster identifier and the configuration information of the database cluster, it is convenient to configure the corresponding relationship between the database cluster and the role in the authority system.
- each database cluster can be accessed by many users, the access permissions of the database cluster can be assigned to roles, and the correspondence between each database cluster and each role can be configured in the permission system, for example:
- the general way of sub-database can be based on region + country, for example: assuming that the country is divided into southern (area1) and northern (area2), plus three foreign (area3) database clusters, which correspond to database cluster 1, database cluster 2, and database cluster 3 respectively, so the staff in the south only need to operate the business data in the south, so generally only the access authority of database cluster 1 is required That’s all; the same in the north only need access to database cluster 2; foreign users only need access to database cluster 3; only a few users, such as system administrators, need access to all database clusters, and this type of user
- the data is rarely modified, usually to view the data, so for this type of user, after logging in, the user needs to further select the database cluster on the interface of the application and the inventor's confirmation.
- RoleA users in the south are assigned RoleA
- users in the north are assigned RoleB
- foreign users are assigned RoleC
- administrator colleagues have three roles (RoleA, RoleB, and RoleC).
- each business system and each user and each role can be stored in the authority system in a key-value manner.
- key business system ID+user ID
- value RoleA.
- the method further includes: acquiring the corresponding relationship between each database cluster and each role from the authority system, and storing it in the cache. Since the corresponding relationship between each database cluster and each role occupies less storage space, the corresponding relationship between each database cluster and each role can be obtained from the authorization system before step 101 and stored in the cache, then When the same request comes next time, the correspondence between each database cluster and each role can be directly obtained from the cache.
- step 102 may include: traversing the correspondence between each business system and each user and each role in the authority system, so as to match the corresponding target role according to the target business system identifier and the target user identifier;
- the corresponding relationship between the target service system identifier and the target user identifier and the target role is stored in a cache.
- the embodiment of the present disclosure configures the corresponding relationship between each business system and each user and each role to the authority system, and when the request comes, the matching target role is queried, and the target business system identifier and the target user identifier and target are obtained from the authority system
- the corresponding relationship of the roles is stored in the cache, so that when the same request comes next time, the target role can be directly queried from the cache to reduce the access pressure of the permission system.
- Step 103 Route the database access request to the target database cluster according to the configuration information of the target database cluster.
- the data access layer routes the database access request to the target database cluster (that is, the target sub-database) according to the configuration information of the target database cluster matched in step 102, so that the user can access the database and manipulate the data.
- the target database cluster that is, the target sub-database
- the embodiments of the present disclosure match the configuration information of the corresponding target database cluster according to the target business system identification, target user identification, and access authority information configured in the authorization system, thereby combining the database
- the technical means of routing the access request to the target database cluster solves the technical problems of wasting server resources, high maintenance costs, or intrusive to business operations in the prior art.
- the embodiment of the present disclosure realizes the decoupling of the application system and the database cluster in the routing strategy, and manages the user's database access authority by configuring the access authority information in the authority system in the application system, thereby realizing database routing.
- the embodiments of the present disclosure can fully decouple the application system from the database cluster, and there is no need for each business operation to have a sub-database master key, and it is also unnecessary for each data cluster to deploy an application system separately.
- Fig. 2 is a schematic diagram of a main flow of a routing method for a database cluster according to a reference embodiment of the present disclosure.
- the routing method of the database cluster may include:
- Step 201 Determine the database cluster corresponding to each user according to the area where each user is located.
- the database is split according to the region where each user is located, so that different users can access the corresponding database cluster. For example: configure southern users to access database cluster 1, northern users to access database cluster 2, and so on. Developers can configure according to actual needs.
- Step 202 Configure the access authority information into the authority system.
- the access authority information includes the corresponding relationship between each database cluster and each role, and the corresponding relationship between each business system and each user and each role.
- a one-to-one correspondence between each database cluster and each role can be configured in the authority system. That is, a role corresponds to a database cluster.
- RoleA owns ⁇ db.partition1 ⁇
- RoleB owns ⁇ db.partition2 ⁇
- RoleC owns ⁇ db.partition3 ⁇ .
- the database cluster corresponding to each user is determined in step 101, the corresponding role can be configured in combination with the business system.
- Step 203 Obtain the corresponding relationship between each database cluster and each role from the authority system, and store it in a cache.
- Step 204 Receive a database access request, where the database access request carries the target service system identifier and the target user identifier.
- Step 205 Traverse the correspondence between each business system and each user and each role in the authority system, so as to match the corresponding target role according to the target business system identifier and the target user identifier.
- Step 206 Store the target service system identifier and the corresponding relationship between the target user identifier and the target role in a cache.
- Step 207 Traverse the correspondence between each database cluster and each role in the cache, and match the identifier of the corresponding target database cluster according to the target role.
- Step 208 Match the configuration information of the target database cluster according to the identifier of the target database cluster.
- the configuration information includes: database address, port number, name, connection timeout time, read and write timeout time, reconnection strategy, read-only, load balancing enabled, and batch operation supported.
- Step 209 Route the database access request to the target database cluster according to the configuration information of the target database cluster.
- FIG. 3 is a schematic diagram of an application system framework for implementing the routing method of an embodiment of the present disclosure.
- the application system includes multiple database clusters, applications, permission platforms, login platforms, and caches.
- the applications include a web layer, a service layer, and a data access layer.
- FIG. 4 is a schematic diagram of the main flow of a routing method for a database cluster according to another reference embodiment of the present disclosure.
- the routing method of the database cluster may include:
- step 401 the web layer receives the database access request, and parses to obtain the target business system identifier and the target user identifier.
- step 402 verification information is configured in the login platform, and the web layer obtains the verification information from the login platform, and performs login verification on the target user according to the target service system identifier and the target user identifier.
- step 403 if the login is passed, the web layer obtains the functional permission corresponding to the target user from the permission platform; if the login fails, it exits the system.
- a general application system can only access specific functions after logging in and obtaining permissions.
- the login generally goes through a single sign-on verification. After the verification is passed, the user's functional permissions (for example, which specific functions can be used) are obtained from the permission platform.
- step 404 the service layer determines whether there is a target role corresponding to the target business system identifier and the target user identifier in the cache; if not, step 405 is executed; if yes, step 406 is executed.
- Step 405 The service layer traverses the correspondence between each business system and each user and each role in the authority platform, so as to match the corresponding target role according to the target business system identifier and the target user identifier;
- the service system identifier and the corresponding relationship between the target user identifier and the target role are stored in a cache.
- Step 406 The service layer matches the identifier of the corresponding target database cluster according to the target role.
- Step 407 The service layer matches the configuration information of the target database cluster according to the identifier of the target database cluster.
- the corresponding relationship between the database cluster identifier and the configuration information of the database cluster does not need to be modified frequently. Therefore, when the cluster is deployed, the corresponding relationship between the database cluster identifier and configuration information can be stored in the service layer for convenience Service layer acquisition.
- Step 408 The data access layer routes the database access request to the target database cluster according to the configuration information of the target database cluster.
- the service layer After matching the target database cluster, the service layer transmits the request to the database access layer, and the data access layer routes the database access request to the target database cluster according to the configuration information of the target database cluster.
- FIG. 5 is a schematic diagram of the main modules of the routing device of a database cluster according to an embodiment of the present disclosure.
- the routing device 500 of the database cluster includes a receiving module 501, a matching module 502, and a routing module 503;
- the module 501 is configured to receive a database access request, the database access request carries a target service system identifier and a target user identifier;
- the matching module 502 is configured to access access according to the target service system identifier, the target user identifier, and the authorization system
- the authority information matches the configuration information of the corresponding target database cluster;
- the routing module 503 is configured to route the database access request to the target database cluster according to the configuration information of the target database cluster.
- the access authority information includes the correspondence between each database cluster and each role, and the correspondence between each business system and each user and each role;
- the matching module 502 is also used for:
- the configuration information includes: database address, port number, name, connection timeout time, read and write timeout time, reconnection strategy, read-only, whether to enable load balancing, and whether to support at least one of batch operations.
- the number of the target role is at least one, and the target role has a one-to-one correspondence with the target database cluster.
- a configuration module for:
- a configuration module for:
- each database cluster and each role is obtained from the authority system, and stored in the cache.
- the matching module 502 is further configured to:
- the corresponding relationship between the target service system identifier and the target user identifier and the target role is stored in a cache.
- the embodiments of the present disclosure match the configuration information of the corresponding target database cluster according to the target business system identification, target user identification, and access authority information configured in the authorization system, thereby combining the database
- the technical means of routing the access request to the target database cluster solves the technical problems of wasting server resources, high maintenance costs, or intrusive to business operations in the prior art.
- the embodiment of the present disclosure realizes the decoupling of the application system and the database cluster in the routing strategy, and manages the user's database access authority by configuring the access authority information in the authority system in the application system, thereby realizing database routing.
- the embodiments of the present disclosure can fully decouple the application system from the database cluster, and there is no need for each business operation to have a sub-database master key, and it is also unnecessary for each data cluster to deploy an application system separately.
- FIG. 6 shows an exemplary system architecture 600 of a routing method for a database cluster or a routing device for a database cluster to which embodiments of the present disclosure can be applied.
- the system architecture 600 may include terminal devices 601, 602, and 603, a network 604, and a server 605.
- the network 604 is used to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605.
- the network 604 may include various connection types, such as wired, wireless communication links, or fiber optic cables, and so on.
- the user can use the terminal devices 601, 602, and 603 to interact with the server 605 via the network 604 to receive or send messages and so on.
- Various communication client applications such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and social platform software, can be installed on the terminal devices 601, 602, and 603 (only examples).
- the terminal devices 601, 602, and 603 may be various electronic devices that have a display screen and support web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and so on.
- the server 605 may be a server that provides various services, such as a background management server (just an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603.
- the background management server can analyze and process the received item information query request and other data, and feed back the processing results (such as target push information, item information-only examples) to the terminal device.
- routing method of the database cluster provided by the embodiment of the present disclosure is generally executed by the server 605, and correspondingly, the routing device of the database cluster is generally set in the server 605.
- terminal devices, networks, and servers in FIG. 6 are merely illustrative. There can be any number of terminal devices, networks, and servers according to implementation needs.
- FIG. 7 shows a schematic structural diagram of a computer system 700 suitable for implementing a terminal device of an embodiment of the present disclosure.
- the terminal device shown in FIG. 7 is only an example, and should not bring any limitation to the function and scope of use of the embodiments of the present disclosure.
- the computer system 700 includes a central processing unit (CPU) 701, which can be based on a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703 And perform various appropriate actions and processing.
- ROM read-only memory
- RAM random access memory
- various programs and data required for the operation of the system 700 are also stored.
- the CPU 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704.
- An input/output (I/O) interface 705 is also connected to the bus 704.
- the following components are connected to the I/O interface 705: an input part 706 including a keyboard, a mouse, etc.; an output part 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and speakers, etc.; a storage part 708 including a hard disk, etc. ; And a communication section 709 including a network interface card such as a LAN card, a modem, and the like. The communication section 709 performs communication processing via a network such as the Internet.
- the drive 710 is also connected to the I/O interface 705 as needed.
- a removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that the computer program read therefrom is installed into the storage section 708 as needed.
- an embodiment of the present disclosure includes a computer program, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart.
- the computer program may be downloaded and installed from the network through the communication part 709, and/or installed from the removable medium 711.
- CPU central processing unit
- the computer-readable medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two.
- the computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or a combination of any of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable removable Programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
- a computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.
- a computer-readable signal medium may include a data signal propagated in a baseband or as a part of a carrier wave, and a computer-readable program code is carried therein. This propagated data signal can take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing.
- the computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit the program for use by or in combination with the instruction execution system, apparatus, or device .
- the program code contained on the computer-readable medium can be transmitted by any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
- each block in the flowchart or block diagram may represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more for realizing the specified logic function.
- Executable instructions may also occur in a different order from the order marked in the drawings. For example, two blocks shown one after another can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved.
- each block in the block diagram or flowchart, and the combination of blocks in the block diagram or flowchart can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by It is realized by a combination of dedicated hardware and computer instructions.
- the modules involved in the embodiments described in the present disclosure can be implemented in software or hardware.
- the described modules can also be set in the processor.
- a processor includes a receiving module, a matching module, and a routing module, where the names of these modules do not constitute the module itself under certain circumstances. The limit.
- the present disclosure also provides a computer-readable medium.
- the computer-readable medium may be included in the device described in the foregoing embodiment; or it may exist alone without being assembled into the device.
- the above-mentioned computer-readable medium carries one or more programs.
- the device implements the following method: receiving a database access request, the database access request carrying the target service system identifier and the target User ID; according to the target business system ID, the target user ID and the access authority information configured in the authority system, match the configuration information of the corresponding target database cluster; according to the configuration information of the target database cluster, the The database access request is routed to the target database cluster.
- the embodiment of the present disclosure because the configuration information of the corresponding target database cluster is matched according to the target business system identification, the target user identification and the access authority information configured in the authority system, the database access request is routed to the target database cluster Therefore, it overcomes the technical problems of wasting server resources, high maintenance costs, or intrusive to business operations in the prior art.
- the embodiment of the present disclosure realizes the decoupling of the application system and the database cluster in the routing strategy, and manages the user's database access authority by configuring the access authority information in the authority system in the application system, thereby realizing database routing.
- the embodiments of the present disclosure can fully decouple the application system from the database cluster, and there is no need for each business operation to have a sub-database master key, and it is also unnecessary for each data cluster to deploy an application system separately.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Computing Systems (AREA)
- Health & Medical Sciences (AREA)
- Bioethics (AREA)
- General Health & Medical Sciences (AREA)
- Computer Hardware Design (AREA)
- Computer Security & Cryptography (AREA)
- Software Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
公开了一种数据库集群的路由方法和装置,涉及计算机技术领域。该方法的一具体实施方式包括:接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。该实施方式能够解决浪费服务器资源、维护成本高或者对业务操作侵入性大的技术问题。
Description
相关申请的交叉引用
本申请要求享有2020年4月2日提交的申请号为202010255023.2的中国发明专利申请的优先权,其全部内容通过引用并入本文。
本公开涉及计算机技术领域,尤其涉及一种数据库集群的路由方法和装置。
数据分库存储是解决数据库压力切实有效的方法,比如同构分库,也就是数据库集群。然而分库后需要解决数据路由的问题,目前常用的方式有以下两种:
1)每套数据库集群上各自单独部署应用系统,在访问系统时,会经过一个入口应用将访问请求路由到某个集群的应用上;2)只部署一套应用系统,访问系统时,强制要求访问请求携带分库主键作为入参,在服务层或数据操作层根据分库主键确定对应的数据库集群。
在实现本公开过程中,发明人发现现有技术中至少存在如下问题:
第一种方式:过多的浪费服务器资源,成倍地增加维护成本;系统上线时,会成倍地增加工作量,应用多则配置信息就多,容易出错;第二种方式:由于每个访问请求都携带分库主键作为入参,所以对业务操作的侵入性较大。
发明内容
有鉴于此,本公开实施例提供一种数据库集群的路由方法和装置,以解决浪费服务器资源、维护成本高或者对业务操作侵入性大的技术问题。
为实现上述目的,根据本公开实施例的一个方面,提供了一种数据库集群的路由方法,包括:
接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;
根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;
根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
可选地,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系;
根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息,包括:
根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;
根据所述目标角色匹配对应的目标数据库集群的标识;
根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
可选地,所述配置信息包括:数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡,是否支持批量操作中的至少一种。
可选地,所述目标角色的数量为至少一个,所述目标角色与所述目标数据库集群一一对应。
可选地,接收数据库访问请求之前,还包括:
根据各个用户所在区域,确定所述各个用户对应的数据库集群;
配置各个数据库集群与各个角色之间的对应关系,并将其存入权限系统;
配置各个业务系统和各个用户与各个角色之间的对应关系,并将 其存入权限系统。
可选地,接收数据库访问请求之前,还包括:
从所述权限系统获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存。
可选地,根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色,包括:
遍历所述权限系统中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;
将所述目标业务系统标识和所述目标用户标识与所述目标角色的对应关系存入缓存。
另外,根据本公开实施例的另一个方面,提供了一种数据库集群的路由装置,包括:
接收模块,用于接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;
匹配模块,用于根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;
路由模块,用于根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
可选地,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系;
所述匹配模块还用于:
根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;
根据所述目标角色匹配对应的目标数据库集群的标识;
根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
可选地,所述配置信息包括:数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡,是否支持批量操作中的至少一种。
可选地,所述目标角色的数量为至少一个,所述目标角色与所述目标数据库集群一一对应。
可选地,还包括配置模块,用于:
接收数据库访问请求之前,根据各个用户所在区域,确定所述各个用户对应的数据库集群;
配置各个数据库集群与各个角色之间的对应关系,并将其存入权限系统;
配置各个业务系统和各个用户与各个角色之间的对应关系,并将其存入权限系统。
可选地,还包括配置模块,用于:
从所述权限系统获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存。
可选地,所述匹配模块还用于:
遍历所述权限系统中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;
将所述目标业务系统标识和所述目标用户标识与所述目标角色的对应关系存入缓存。
根据本公开实施例的另一个方面,还提供了一种电子设备,包括:
一个或多个处理器;
存储装置,用于存储一个或多个程序,
当所述一个或多个程序被所述一个或多个处理器执行时,所述一个或多个处理器实现上述任一实施例所述的方法。
根据本公开实施例的另一个方面,还提供了一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现上述任一实施例所述的方法。
上述公开中的一个实施例具有如下优点或有益效果:因为采用根据目标业务系统标识、目标用户标识和配置在权限系统中的访问权限信息匹配对应的目标数据库集群的配置信息,从而将数据库访问请求路由至目标数据库集群的技术手段,所以克服了现有技术中浪费服务器资源、维护成本高或者对业务操作侵入性大的技术问题。本公开实施例在路由策略上实现了应用系统和数据库集群的解耦,通过在应用系统中的权限系统配置访问权限信息的方式管理用户的数据库访问权限,从而实现数据库路由。本公开实施例可以使应用系统与数据库集群充分解耦,不需要每个业务操作都带有分库主键,也不需要每个数据集群单独部署应用系统。
上述的非惯用的可选方式所具有的进一步效果将在下文中结合具体实施方式加以说明。
附图用于更好地理解本公开,不构成对本公开的不当限定。其中:
图1是根据本公开实施例的数据库集群的路由方法的主要流程的示意图;
图2是根据本公开一个可参考实施例的数据库集群的路由方法的主要流程的示意图;
图3是实现本公开实施例的路由方法的系统框架示意图;
图4是根据本公开另一个可参考实施例的数据库集群的路由方法的主要流程的示意图;
图5是根据本公开实施例的数据库集群的路由装置的主要模块的示意图;
图6是本公开实施例可以应用于其中的示例性系统架构图;
图7是适于用来实现本公开实施例的终端设备或服务器的计算机系统的结构示意图。
以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。
图1是根据本公开实施例的数据库集群的路由方法的主要流程的示意图。作为本公开的一个实施例,如图1所示,所述数据库集群的路由方法可以包括:
步骤101,接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识。
一般的应用系统都要经过登录、获取权限之后,才能访问具体功能。登录一般经过的是单点登录校验,校验通过后,从权限系统获取用户的功能权限(比如可以使用哪些具体功能)。可选地,步骤101可以包括:接收数据库访问请求;根据所述数据库访问请求中携带的目标业务系统标识和目标用户标识,对所述目标用户进行登录校验;若登录通过,则获取所述目标用户对应的功能权限并执行步骤102;若登录失败,则结束。需要指出的是,本公开实施例中的权限系统为应用系统中的一部分,存储有各个用户访问应用系统的功能权限。
步骤102,根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息。
通过步骤101得到目标业务系统标识和目标用户标识后,可以通过预先配置在权限系统中的访问权限信息匹配出目标数据库集群的配置信息。可选地,所述配置信息包括:数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡,是否支持批量操作中的至少一种。例如,配置信息可以包括如下信息:
jdbc:mysql://192.168.0.1:3358/db1?//MYSQL数据库地址:端口/数据库名称
useUnicode=true;//是否使用Unicode字符集
characterEncoding=utf8;//使用utf8编码
connectTimeout=3000;//和数据库服务器建立socket连接时的超时时间
socketTimeout=15000;//socket操作(读写)超时时间
rewriteBatchedStatements=true;//是否打开批量执行
autoReconnectForPools=true;//是否使用针对数据库连接池的重连策略
failOverReadOnly=false;//自动重连成功后,连接是否设置为只读
roundRobinLoadBalance=true;//开启负载均衡策略
allowMultiQueries=true;//支持多条SQL批量操作
可选地,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系。可选地,步骤102可以包括:根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;根据所述目标角色匹配对应的目标数据库集群的标识;根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。在本公开的实施例中,首先根据业务系统标识和用户标识与角色的对应关系,匹配出目标角色;然后根据角色 与数据库集群标识的对应关系,匹配出目标数据库集群的标识;最后根据数据库集群标识与数据库集群的配置信息的对应关系,匹配出目标数据库集群的配置信息。
可选地,所述目标角色的数量为至少一个,所述目标角色与所述目标数据库集群一一对应。在本公开的实施例中,业务系统标识和用户标识与角色的对应关系可以是一对一的,也可以是一对多的,因此通过目标业务系统标识和所述目标用户标识可以匹配出至少一个目标角色,由于角色与数据库集群为一一对应的关系,那么最终可以根据至少一个目标角色分别匹配出对应的至少一个目标数据库集群。
可选地,在步骤101之前,还包括:根据各个用户所在区域,确定所述各个用户对应的数据库集群;配置各个数据库集群与各个角色之间的对应关系,并将其存入权限系统;配置各个业务系统和各个用户与各个角色之间的对应关系,并将其存入权限系统。本公开实施例将用户访问数据库的权限信息(包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系)配置到权限系统,那么通过权限系统就可以管理用户访问数据库,从而方便地将数据库访问请求路由到正确的数据库集群。
具体方法如下:
分库后,一个应用系统连接多个数据库集群(一个分库即为一个数据库集群),在集群配置文件中的配置方式示例:
db.partition1=数据库集群1的配置信息
db.partition2=数据库集群2的配置信息
db.partition3=数据库集群3的配置信息
……
由于数据库集群的配置信息较多(主要包含数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡,是否支持批量操作等),本公开实施例通过配置数据库集群标识与数据库集群的配置信息之间的对应关系,方便在权限系统中配置数据库集群与角色之间的对应关系。
由于每个数据库集群可以被很多用户访问,因此可以将数据库集 群的访问权限分配到角色上,并将各个数据库集群与各个角色之间的对应关系配置到权限系统中,例如:
RoleA拥有{db.partition1}
RoleB拥有{db.partition2}
RoleC拥有{db.partition3}
需要说明的是,假如一个业务系统的业务范围是全世界,而中国对业务站到80%,则一般的分库方式可以按照区域+国家,例如:假设国内分为南部(area1)、北部(area2),再加个国外(area3)三个数据库集群,分别对应数据库集群1、数据库集群2、数据库集群3,那么在南部工作人员只要操作南部业务数据,所以一般只需数据库集群1的访问权限即可;同样北部的只需要数据库集群2的访问权限;国外的用户只需要数据库集群3的访问权限;只有极少数用户比如系统管理员才需要全部的数据库集群的访问权限,而这类的用户极少修改数据,一般是查看数据,所以针对这类用户在登陆后,用户需要在应用与发明人确认过界面上进一步选择数据库集群。
所以,南部用户分配RoleA;北部用户分配RoleB;国外用户分配RoleC;管理员同事拥有三个角色(RoleA、RoleB和RoleC)。
可选地,各个业务系统和各个用户与各个角色之间的对应关系可以采用key-value方式存储在权限系统中。例如:key=业务系统ID+用户ID,value=RoleA。
可选地,在步骤101之前,还包括:从所述权限系统获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存。由于各个数据库集群与各个角色之间的对应关系占用的存储空间较少,因此可以在步骤101之前从权限系统中获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存,那么当下次相同的请求到来时,可以直接从缓存中获取各个数据库集群与各个角色之间的对应关系。
可选地,步骤102可以包括:遍历所述权限系统中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;将所述目标业务系统标识和所述目标用户标识与所述目标角色的对应关系存入缓存。本公 开实施例将各个业务系统和各个用户与各个角色之间的对应关系配置到权限系统,当请求到来时查询出匹配的目标角色,并从权限系统获取目标业务系统标识和目标用户标识与目标角色的对应关系,将其存储到缓存中,方便下次相同的请求到来时,可以直接从缓存中查询出目标角色,以减轻权限系统的访问压力。
步骤103,根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
数据访问层根据步骤102中匹配出的目标数据库集群的配置信息,将数据库访问请求路由到目标数据库集群(即目标分库),以使用户可以访问数据库、操作数据。
根据上面所述的各种实施例,可以看出本公开实施例通过根据目标业务系统标识、目标用户标识和配置在权限系统中的访问权限信息匹配对应的目标数据库集群的配置信息,从而将数据库访问请求路由至目标数据库集群的技术手段,解决了现有技术中浪费服务器资源、维护成本高或者对业务操作侵入性大的技术问题。本公开实施例在路由策略上实现了应用系统和数据库集群的解耦,通过在应用系统中的权限系统配置访问权限信息的方式管理用户的数据库访问权限,从而实现数据库路由。本公开实施例可以使应用系统与数据库集群充分解耦,不需要每个业务操作都带有分库主键,也不需要每个数据集群单独部署应用系统。
图2是根据本公开一个可参考实施例的数据库集群的路由方法的主要流程的示意图。作为本公开的又一个实施例,如图2所示,所述数据库集群的路由方法可以包括:
步骤201,根据各个用户所在区域,确定所述各个用户对应的数据库集群。
在该步骤中,根据各个用户所在区域,对数据库进行分库操作,使得不同的用户能够访问对应的数据库集群。比如:配置南部用户访 问数据库集群1、北部用户访问数据库集群2,等。开发人员可以根据实际需要进行配置。
步骤202,将访问权限信息配置到权限系统中。
其中,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系。
由于步骤201中确定了各个用户与各个数据库集群之间的对应关系,因此可以在权限系统中配置各个数据库集群与各个角色之间的一一的对应关系。即一个角色对应一个数据库集群。例如:RoleA拥有{db.partition1};RoleB拥有{db.partition2};RoleC拥有{db.partition3}。
然后采用key-value方式将各个业务系统和各个用户与各个角色之间的对应关系也存储在权限系统中,例如:key=业务系统ID+用户ID,value=RoleA;key=业务系统ID+用户ID,value=RoleA、RoleB。
需要指出的是,由于在步骤101确定了各个用户对应的数据库集群,因此结合业务系统就可以配置出对应的角色。
步骤203,从所述权限系统获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存。
步骤204,接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识。
步骤205,遍历所述权限系统中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色。
步骤206,将所述目标业务系统标识和所述目标用户标识与所述目标角色的对应关系存入缓存。
步骤207,在缓存中遍历各个数据库集群与各个角色之间的对应关系,根据所述目标角色匹配对应的目标数据库集群的标识。
步骤208,根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
可选地,所述配置信息包括:数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡, 是否支持批量操作中的至少一种。
步骤209,根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
另外,在本公开一个可参考实施例中数据库集群的路由方法的具体实施内容,在上面所述数据库集群的路由方法中已经详细说明了,故在此重复内容不再说明。
图3是实现本公开实施例的路由方法的应用系统框架示意图。该应用系统包括多个数据库集群、应用、权限平台、登录平台和缓存,其中,应用包括web层、服务层和数据访问层。图4是根据本公开另一个可参考实施例的数据库集群的路由方法的主要流程的示意图。作为本公开的又一个实施例,如图4所示,所述数据库集群的路由方法可以包括:
步骤401,web层接收数据库访问请求,解析得到目标业务系统标识和目标用户标识。
步骤402,登录平台中配置有校验信息,web层从登录平台获取校验信息,根据目标业务系统标识和目标用户标识,对所述目标用户进行登录校验。
步骤403,若登录通过,则web层从权限平台获取所述目标用户对应的功能权限;若登录失败,则退出系统。
一般的应用系统都要经过登录、获取权限之后,才能访问具体功能。登录一般经过的是单点登录校验,校验通过后,从权限平台获取用户的功能权限(比如可以使用哪些具体功能)。
步骤404,服务层判断缓存中是否有目标业务系统标识和目标用户标识对应的目标角色;若否,则执行步骤405;若是,则执行步骤406。
用户登录校验通过后,服务层从缓存获取目标业务系统标识和目标用户标识对应的目标角色,例如:key=系统ID+用户ID,value=RoleA。
步骤405,服务层遍历所述权限平台中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;将所述目标业务系统标识和所述目 标用户标识与所述目标角色的对应关系存入缓存。
如果缓存中没有目标业务系统标识和目标用户标识与目标角色的对应关系,则在权限平台遍历各个业务系统和各个用户与各个角色之间的对应关系,从而匹配出目标角色,并将对应关系存入缓存,例如:key=系统ID+用户ID,value=RoleA。
步骤406,服务层根据所述目标角色匹配对应的目标数据库集群的标识。
步骤407,服务层根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
一般来说,数据库集群的标识与数据库集群的配置信息之间的对应关系不需要经常修改,因此当集群部署完成后,可以将数据库集群的标识与配置信息的对应关系存储在服务层,以方便服务层获取。
步骤408,数据访问层根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
服务层匹配出目标数据库集群后,将请求传入数据库访问层,数据访问层根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
另外,在本公开一个可参考实施例中数据库集群的路由方法的具体实施内容,在上面所述数据库集群的路由方法中已经详细说明了,故在此重复内容不再说明。
图5是根据本公开实施例的数据库集群的路由装置的主要模块的示意图,如图5所示,所述数据库集群的路由装置500包括接收模块501、匹配模块502和路由模块503;其中,接收模块501用于接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;匹配模块502用于根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;路由模块503用于根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
可选地,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系;
所述匹配模块502还用于:
根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;
根据所述目标角色匹配对应的目标数据库集群的标识;
根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
可选地,所述配置信息包括:数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡,是否支持批量操作中的至少一种。
可选地,所述目标角色的数量为至少一个,所述目标角色与所述目标数据库集群一一对应。
可选地,还包括配置模块,用于:
接收数据库访问请求之前,根据各个用户所在区域,确定所述各个用户对应的数据库集群;
配置各个数据库集群与各个角色之间的对应关系,并将其存入权限系统;
配置各个业务系统和各个用户与各个角色之间的对应关系,并将其存入权限系统。
可选地,还包括配置模块,用于:
从所述权限系统获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存。
可选地,所述匹配模块502还用于:
遍历所述权限系统中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;
将所述目标业务系统标识和所述目标用户标识与所述目标角色的对应关系存入缓存。
根据上面所述的各种实施例,可以看出本公开实施例通过根据目标业务系统标识、目标用户标识和配置在权限系统中的访问权限信息匹配对应的目标数据库集群的配置信息,从而将数据库访问请求路由至目标数据库集群的技术手段,解决了现有技术中浪费服务器资源、维护成本高或者对业务操作侵入性大的技术问题。本公开实施例在路由策略上实现了应用系统和数据库集群的解耦,通过在应用系统中的权限系统配置访问权限信息的方式管理用户的数据库访问权限,从而实现数据库路由。本公开实施例可以使应用系统与数据库集群充分解耦,不需要每个业务操作都带有分库主键,也不需要每个数据集群单独部署应用系统。
需要说明的是,在本公开所述数据库集群的路由装置的具体实施内容,在上面所述数据库集群的路由方法中已经详细说明了,故在此重复内容不再说明。
图6示出了可以应用本公开实施例的数据库集群的路由方法或数据库集群的路由装置的示例性系统架构600。
如图6所示,系统架构600可以包括终端设备601、602、603,网络604和服务器605。网络604用以在终端设备601、602、603和服务器605之间提供通信链路的介质。网络604可以包括各种连接类型,例如有线、无线通信链路或者光纤电缆等等。
用户可以使用终端设备601、602、603通过网络604与服务器605交互,以接收或发送消息等。终端设备601、602、603上可以安装有各种通讯客户端应用,例如购物类应用、网页浏览器应用、搜索类应用、即时通信工具、邮箱客户端、社交平台软件等(仅为示例)。
终端设备601、602、603可以是具有显示屏并且支持网页浏览的各种电子设备,包括但不限于智能手机、平板电脑、膝上型便携计算机和台式计算机等等。
服务器605可以是提供各种服务的服务器,例如对用户利用终端设备601、602、603所浏览的购物类网站提供支持的后台管理服务器(仅为示例)。后台管理服务器可以对接收到的物品信息查询请求等数据进行分析等处理,并将处理结果(例如目标推送信息、物品信息——仅为示例)反馈给终端设备。
需要说明的是,本公开实施例所提供的数据库集群的路由方法一般由服务器605执行,相应地,所述数据库集群的路由装置一般设置在服务器605中。
应该理解,图6中的终端设备、网络和服务器的数目仅仅是示意性的。根据实现需要,可以具有任意数目的终端设备、网络和服务器。
下面参考图7,其示出了适于用来实现本公开实施例的终端设备的计算机系统700的结构示意图。图7示出的终端设备仅仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图7所示,计算机系统700包括中央处理单元(CPU)701,其可以根据存储在只读存储器(ROM)702中的程序或者从存储部分708加载到随机访问存储器(RAM)703中的程序而执行各种适当的动作和处理。在RAM 703中,还存储有系统700操作所需的各种程序和数据。CPU 701、ROM 702以及RAM703通过总线704彼此相连。输入/输出(I/O)接口705也连接至总线704。
以下部件连接至I/O接口705:包括键盘、鼠标等的输入部分706;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分707;包括硬盘等的存储部分708;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分709。通信部分709经由诸如因特网的网络执行通信处理。驱动器710也根据需要连接至I/O接口705。可拆卸介质711,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据 需要安装在驱动器710上,以便于从其上读出的计算机程序根据需要被安装入存储部分708。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序,其包括承载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分709从网络上被下载和安装,和/或从可拆卸介质711被安装。在该计算机程序被中央处理单元(CPU)701执行时,执行本公开的系统中限定的上述功能。
需要说明的是,本公开所示的计算机可读介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本公开中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本公开中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读介质,该计算机可读介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。
附图中的流程图和框图,图示了按照本公开各种实施例的系统、方法和计算机程序的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
描述于本公开实施例中所涉及到的模块可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块也可以设置在处理器中,例如,可以描述为:一种处理器包括接收模块、匹配模块和路由模块,其中,这些模块的名称在某种情况下并不构成对该模块本身的限定。
作为另一方面,本公开还提供了一种计算机可读介质,该计算机可读介质可以是上述实施例中描述的设备中所包含的;也可以是单独存在,而未装配入该设备中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被一个该设备执行时,该设备实现如下方法:接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
根据本公开实施例的技术方案,因为采用根据目标业务系统标识、目标用户标识和配置在权限系统中的访问权限信息匹配对应的目标数 据库集群的配置信息,从而将数据库访问请求路由至目标数据库集群的技术手段,所以克服了现有技术中浪费服务器资源、维护成本高或者对业务操作侵入性大的技术问题。本公开实施例在路由策略上实现了应用系统和数据库集群的解耦,通过在应用系统中的权限系统配置访问权限信息的方式管理用户的数据库访问权限,从而实现数据库路由。本公开实施例可以使应用系统与数据库集群充分解耦,不需要每个业务操作都带有分库主键,也不需要每个数据集群单独部署应用系统。
上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。
Claims (11)
- 一种数据库集群的路由方法,其包括:接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
- 根据权利要求1所述的方法,其中,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各个用户与各个角色之间的对应关系;根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息,包括:根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;根据所述目标角色匹配对应的目标数据库集群的标识;根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
- 根据权利要求2所述的方法,其中,所述配置信息包括:数据库地址、端口号、名称,连接超时时间,读写超时时间,重连策略,是否只读,是否开启负载均衡,是否支持批量操作中的至少一种。
- 根据权利要求2所述的方法,其中,所述目标角色的数量为至少一个,所述目标角色与所述目标数据库集群一一对应。
- 根据权利要求2所述的方法,其中,接收数据库访问请求之前,还包括:根据各个用户所在区域,确定所述各个用户对应的数据库集群;配置各个数据库集群与各个角色之间的对应关系,并将其存入权限系统;配置各个业务系统和各个用户与各个角色之间的对应关系,并将其存入权限系统。
- 根据权利要求2所述的方法,其中,接收数据库访问请求之前,还包括:从所述权限系统获取各个数据库集群与各个角色之间的对应关系,并将其存入缓存。
- 根据权利要求6所述的方法,其中,根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色,包括:遍历所述权限系统中各个业务系统和各个用户与各个角色之间的对应关系,从而根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;将所述目标业务系统标识和所述目标用户标识与所述目标角色的对应关系存入缓存。
- 一种数据库集群的路由装置,其包括:接收模块,用于接收数据库访问请求,所述数据库访问请求携带目标业务系统标识和目标用户标识;匹配模块,用于根据所述目标业务系统标识、所述目标用户标识和配置在权限系统中的访问权限信息,匹配对应的目标数据库集群的配置信息;路由模块,用于根据所述目标数据库集群的配置信息,将所述数据库访问请求路由至所述目标数据库集群。
- 根据权利要求8所述的装置,其中,所述访问权限信息包括各个数据库集群与各个角色之间的对应关系,以及,各个业务系统和各 个用户与各个角色之间的对应关系;所述匹配模块还用于:根据所述目标业务系统标识和所述目标用户标识匹配对应的目标角色;根据所述目标角色匹配对应的目标数据库集群的标识;根据所述目标数据库集群的标识匹配所述目标数据库集群的配置信息。
- 一种电子设备,其包括:一个或多个处理器;存储装置,用于存储一个或多个程序,当所述一个或多个程序被所述一个或多个处理器执行时,所述一个或多个处理器实现如权利要求1-7中任一所述的方法。
- 一种计算机可读介质,其上存储有计算机程序,所述程序被处理器执行时实现如权利要求1-7中任一所述的方法。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010255023.2A CN113495921B (zh) | 2020-04-02 | 2020-04-02 | 一种数据库集群的路由方法和装置 |
CN202010255023.2 | 2020-04-02 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021197432A1 true WO2021197432A1 (zh) | 2021-10-07 |
Family
ID=77928531
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2021/084963 WO2021197432A1 (zh) | 2020-04-02 | 2021-04-01 | 一种数据库集群的路由方法和装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN113495921B (zh) |
WO (1) | WO2021197432A1 (zh) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111104465A (zh) * | 2019-12-13 | 2020-05-05 | 北京金迅瑞博网络技术有限公司 | Cdn业务数据展示方法、装置和电子设备 |
CN113992680A (zh) * | 2021-11-10 | 2022-01-28 | 中国工商银行股份有限公司 | 应用于分布式多活系统的调度方法、装置、设备及介质 |
CN114357001A (zh) * | 2022-01-12 | 2022-04-15 | 平安科技(深圳)有限公司 | 多集群的数据查询方法、装置、监控平台及存储介质 |
CN114389894A (zh) * | 2022-01-28 | 2022-04-22 | 青岛海尔科技有限公司 | 权限控制方法、设备、存储介质及计算机程序产品 |
CN114745281A (zh) * | 2022-04-11 | 2022-07-12 | 京东科技信息技术有限公司 | 一种数据处理的方法和装置 |
CN115080940A (zh) * | 2022-07-04 | 2022-09-20 | 中国联合网络通信集团有限公司 | 基于层次状态机用户访问权限的处理方法及装置 |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114051029B (zh) * | 2021-11-10 | 2023-07-18 | 北京百度网讯科技有限公司 | 授权方法、授权装置、电子设备和存储介质 |
CN114095419B (zh) * | 2021-11-12 | 2023-11-28 | 软通动力信息技术(集团)股份有限公司 | 一种集群路由方法、装置、系统及存储介质 |
CN114417395B (zh) * | 2021-12-08 | 2022-08-19 | 慧之安信息技术股份有限公司 | 操作系统安全路由处理方法和系统 |
CN114697322B (zh) * | 2022-02-17 | 2024-03-22 | 上海生慧樘科技有限公司 | 一种基于云端业务处理的数据筛选方法 |
CN114519033A (zh) * | 2022-02-21 | 2022-05-20 | 深圳市和讯华谷信息技术有限公司 | 一种数据写入方法及其相关设备 |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106202540A (zh) * | 2016-07-26 | 2016-12-07 | 浪潮通用软件有限公司 | 一种大型应用系统的数据库可横向扩展方法 |
CN106789989A (zh) * | 2016-12-09 | 2017-05-31 | 武汉斗鱼网络科技有限公司 | 一种用户权限验证方法及装置 |
US20180096045A1 (en) * | 2010-12-23 | 2018-04-05 | Mongodb, Inc. | Large distributed database clustering systems and methods |
US20180324161A1 (en) * | 2017-05-08 | 2018-11-08 | Microsoft Technology Licensing, Llc | Domain authentication |
US10216508B1 (en) * | 2018-01-05 | 2019-02-26 | Bank Of America Corporation | System and method for configurable services platform |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100381964C (zh) * | 2003-12-26 | 2008-04-16 | 华为技术有限公司 | 一种用户权限管理方法 |
CN100351865C (zh) * | 2004-01-13 | 2007-11-28 | 威盛电子股份有限公司 | 用户权限设定系统和设定方法 |
CN101034990B (zh) * | 2007-02-14 | 2010-06-23 | 华为技术有限公司 | 权限管理方法及装置 |
CN102611699A (zh) * | 2012-02-22 | 2012-07-25 | 浪潮(北京)电子信息产业有限公司 | 一种云操作系统中访问控制的方法和系统 |
CN104915353B (zh) * | 2014-03-13 | 2018-03-23 | 中国电信股份有限公司 | 分布式数据库下全局主键生成方法和系统 |
CN104994086B (zh) * | 2015-06-26 | 2018-09-04 | 北京京东尚科信息技术有限公司 | 一种数据库集群权限的控制方法及装置 |
CN105426396A (zh) * | 2015-10-28 | 2016-03-23 | 深圳市万姓宗祠网络科技股份有限公司 | 一种基于路由算法的数据库分片方法、系统和中间件系统 |
CN105956029B (zh) * | 2016-04-25 | 2019-06-07 | 吉林大学 | 混合存储架构下的数据访问方法 |
CN106095977A (zh) * | 2016-06-20 | 2016-11-09 | 环球大数据科技有限公司 | 一种数据库的分布式处理方法及系统 |
CN107766378A (zh) * | 2016-08-22 | 2018-03-06 | 南京中兴新软件有限责任公司 | 请求信息的发送方法及装置、分布式数据库系统 |
CN106407011B (zh) * | 2016-09-20 | 2019-05-10 | 焦点科技股份有限公司 | 一种基于路由表的搜索系统集群服务管理的方法及系统 |
CN110138862B (zh) * | 2019-05-16 | 2022-03-04 | 北京字节跳动网络技术有限公司 | 基于应用服务的业务处理方法、装置、网关设备及介质 |
-
2020
- 2020-04-02 CN CN202010255023.2A patent/CN113495921B/zh active Active
-
2021
- 2021-04-01 WO PCT/CN2021/084963 patent/WO2021197432A1/zh active Application Filing
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180096045A1 (en) * | 2010-12-23 | 2018-04-05 | Mongodb, Inc. | Large distributed database clustering systems and methods |
CN106202540A (zh) * | 2016-07-26 | 2016-12-07 | 浪潮通用软件有限公司 | 一种大型应用系统的数据库可横向扩展方法 |
CN106789989A (zh) * | 2016-12-09 | 2017-05-31 | 武汉斗鱼网络科技有限公司 | 一种用户权限验证方法及装置 |
US20180324161A1 (en) * | 2017-05-08 | 2018-11-08 | Microsoft Technology Licensing, Llc | Domain authentication |
US10216508B1 (en) * | 2018-01-05 | 2019-02-26 | Bank Of America Corporation | System and method for configurable services platform |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111104465A (zh) * | 2019-12-13 | 2020-05-05 | 北京金迅瑞博网络技术有限公司 | Cdn业务数据展示方法、装置和电子设备 |
CN113992680A (zh) * | 2021-11-10 | 2022-01-28 | 中国工商银行股份有限公司 | 应用于分布式多活系统的调度方法、装置、设备及介质 |
CN113992680B (zh) * | 2021-11-10 | 2024-02-02 | 中国工商银行股份有限公司 | 应用于分布式多活系统的调度方法、装置、设备及介质 |
CN114357001A (zh) * | 2022-01-12 | 2022-04-15 | 平安科技(深圳)有限公司 | 多集群的数据查询方法、装置、监控平台及存储介质 |
CN114389894A (zh) * | 2022-01-28 | 2022-04-22 | 青岛海尔科技有限公司 | 权限控制方法、设备、存储介质及计算机程序产品 |
CN114389894B (zh) * | 2022-01-28 | 2023-12-19 | 青岛海尔科技有限公司 | 权限控制方法、设备、存储介质及计算机程序产品 |
CN114745281A (zh) * | 2022-04-11 | 2022-07-12 | 京东科技信息技术有限公司 | 一种数据处理的方法和装置 |
CN114745281B (zh) * | 2022-04-11 | 2023-12-05 | 京东科技信息技术有限公司 | 一种数据处理的方法和装置 |
CN115080940A (zh) * | 2022-07-04 | 2022-09-20 | 中国联合网络通信集团有限公司 | 基于层次状态机用户访问权限的处理方法及装置 |
Also Published As
Publication number | Publication date |
---|---|
CN113495921A (zh) | 2021-10-12 |
CN113495921B (zh) | 2023-09-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021197432A1 (zh) | 一种数据库集群的路由方法和装置 | |
US10536545B2 (en) | Cloud database connection multiplexing | |
JP2018088293A (ja) | 単一テナント及び複数テナント環境を提供するデータベースシステム | |
US12067426B2 (en) | Techniques for consistent multi-tenant behavior in microservices based applications | |
CN110019211A (zh) | 关联索引的方法、装置和系统 | |
US10656972B2 (en) | Managing idempotent operations while interacting with a system of record | |
WO2022121221A1 (zh) | 基于令牌的应用程序访问方法、装置、计算机设备和介质 | |
US8745088B2 (en) | System and method of performing risk analysis using a portal | |
US8645550B2 (en) | Database virtualization | |
US11388164B2 (en) | Distributed application programming interface whitelisting | |
US20150095973A1 (en) | Cloud database lockdown | |
US11310316B2 (en) | Methods, devices and computer program products for storing and accessing data | |
WO2017161956A1 (zh) | 一种数据库扩展系统、设备和用于扩展数据库的方法 | |
US20200327140A1 (en) | Systems and methods for access to multi-tenant heterogeneous databases | |
WO2024124789A1 (zh) | 文件处理方法、装置、服务器及介质 | |
WO2023056946A1 (zh) | 一种数据缓存方法、装置和电子设备 | |
CN113760948A (zh) | 一种数据查询的方法及装置 | |
US11570182B1 (en) | Compute-less authorization | |
WO2024045646A1 (zh) | 管理集群访问权限的方法、装置和系统 | |
US20170364293A1 (en) | Method and apparatus for data processing | |
CN112825094B (zh) | 一种数据权限校验方法和装置 | |
US11196762B2 (en) | Vulnerability scanner based on network profile | |
CN109558433B (zh) | 一种请求访问hdfs的方法和装置 | |
CN109656519B (zh) | 一种业务数据自动化接入方法和装置 | |
US20150213124A1 (en) | Continuously blocking query result data for a remote query |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 21781924 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 270123) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 21781924 Country of ref document: EP Kind code of ref document: A1 |