CN108572993A - Db divides library hash methods, electronic equipment, storage medium and the device to data access - Google Patents
Db divides library hash methods, electronic equipment, storage medium and the device to data access Download PDFInfo
- Publication number
- CN108572993A CN108572993A CN201710149691.5A CN201710149691A CN108572993A CN 108572993 A CN108572993 A CN 108572993A CN 201710149691 A CN201710149691 A CN 201710149691A CN 108572993 A CN108572993 A CN 108572993A
- Authority
- CN
- China
- Prior art keywords
- virtual
- hash
- physics
- library
- access
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention provides a kind of databases to divide library hash methods, electronic equipment, storage medium and to the device of data access, can ensure better database access performance and promote service quality.The database point library hash methods include:Hash is carried out to virtual db and divides library;Virtual db through hash points of library is mapped to actual physics db in a manner of many-to-one.
Description
Technical field
The present invention relates to field of computer technology more particularly to a kind of database to divide library hash method, apparatus, electronic equipment
And storage medium.
Background technology
In the Internet, applications, it is often necessary to the user of magnanimity, the data access of high concurrent, separate unit database be supported to be difficult to
Carrying divides library by data distribution to more libraries, is most common method by multiple servers carrying by hash.
It is proposed to this end that direct hash.Direct hash is that data are divided on different libraries by hash, chooses conduct
The field of hash accesses need to take the field every time, by its corresponding value, calculates the value after the effect of hash functions to judge
Current accessed fall database on, then directly access the database and return the result.However, directly hash is in addition to that can produce
Except the problem of raw rehash, dilatation and failover cost are very high and it considers the difference of machine
The opposite sex, therefore it cannot configure classifying rationally data and flowing of access by machine.
Consistent hashing is proposed for the issuable rehash problems of direct hash.Consistent hashing not only logarithm
According to hash is carried out, hash also is done to database, specific practice is one hash ring of construction, will be put on ring after database hash
Some position, then to finding the database of next position after data hash on ring, that is, the access of the data is put into this
On a corresponding database.However, the problem of consistent hashing be the unbalanced of disaster tolerance and it is also the same have ignored machine it
Between otherness.
Invention content
In view of this, the present invention proposes that a kind of database divides library hash methods, electronic equipment and storage medium and one kind
Device for executing data access in the case where carrying out point library to database according to database point library hash methods, to make
Hash or consistent hashing method divide library more practical, specifically, it is contemplated that the problem of actual machine otherness, press
Machine configuration height to remap, it is ensured that the equilibrium of data and flowing of access, and at the same time also solving database through direct
The excessively high problem of hash dilatation switching surfaces and disaster tolerance lack of uniformity with consistent hashing.
To achieve the above object, according to an aspect of the invention, there is provided a kind of database divides library hash methods.
A kind of database point library hash methods of the embodiment of the present invention include:To virtual db (db:Database databases)
It carries out hash and divides library;Virtual db through hash points of library is mapped to actual physics db in a manner of many-to-one.
Optionally, the hash points of library can be realized by direct hash or consistent hashing.
To achieve the above object, according to another aspect of the present invention, it provides a kind of in the method for executing the present invention
Divide in the case of library database the device for executing data access.
Described device includes:Using hash modules, virtual db management modules, virtual db mapping blocks, physics db data sources
Management module and db access agent modules, wherein
The application hash modules are used to navigate to virtual db by hash points of library;
The virtual db management modules are used for after the db access requests for receiving user according to virtual db information described in
Virtual db mapping blocks request physics db data sources connect and for receiving the execution returned by the db access agents module
As a result and client is returned to;
The virtual db mapping blocks are for judging whether corresponding physics db data sources connection;
The physics db data source management modules are used for there are the corresponding physics db data sources connection
It is returned to the virtual db management modules;
The db access agents module is used to receive the corresponding physics db numbers that the virtual db management modules provide
It connects and executes according to source and ask and return to implementing result to the virtual db management modules.
Optionally, hash points of library can be realized by direct hash or consistent hashing.
Optionally, virtual db mapping blocks are additionally operable to the more new mappings when adding virtual db or physics db, the mapping by
System manager configures.
Optionally, the db access agents module is component of increasing income, such as mybatis.
To achieve the above object, in accordance with a further aspect of the present invention, a kind of electronic equipment is provided.
The present invention a kind of electronic equipment include:At least one processor;And at least one processor communication
The memory of connection;Wherein, the memory is stored with the instruction that can be executed by one processor, and described instruction is described
At least one processor executes, so that at least one processor is able to carry out database point library hash provided by the present invention
Method.
To achieve the above object, in accordance with a further aspect of the present invention, a kind of non-transient computer readable storage medium is provided
Matter.
A kind of non-transient computer readable storage medium of the present invention, the non-transient computer readable storage medium storage
Computer instruction, the computer instruction is for making the computer execute the database point library provided by the present invention side hash
Method.
Above-mentioned technical solution is illustrated hereinafter in conjunction with specific implementation mode.
Description of the drawings
Attached drawing does not constitute inappropriate limitation of the present invention for more fully understanding the present invention.Wherein:
Fig. 1 is the key step schematic diagram of database point library hash methods according to the present invention;
Fig. 2 is for executing data access in the case where carrying out point library to database according to method shown in Fig. 1
The schematic diagram of device;
Fig. 3 is the main flow schematic diagram that data access is carried out with device shown in Figure 2;
Fig. 4 is the hardware architecture diagram of electronic equipment according to the ... of the embodiment of the present invention.
Specific implementation mode
It explains to the exemplary embodiment of the present invention below in conjunction with attached drawing, including the various of the embodiment of the present invention
Details should think them only exemplary to help understanding.Therefore, those of ordinary skill in the art should recognize
It arrives, various changes and modifications can be made to the embodiments described herein, without departing from scope and spirit of the present invention.Together
The description to known function and structure is omitted for clarity and conciseness in sample in following description.
As shown in Figure 1, a kind of database point library hash methods of the embodiment of the present invention mainly include the following steps:
Step S1:Hash is carried out to virtual db in existing hash methods and divides library;
Step S2:Virtual db through hash points of library is mapped to actual physics db in a manner of many-to-one.
This for example direct hash of general hash methods and consistent hashing to database point library has carried out improved
Method introduces the concept of virtual data base, so that general hash methods is acted on virtual data base first, later again to data
Library carries out one layer of mapping from virtual data base to physical database, only changes mapping when making dilatation in this way and does not have to change
Hash functions itself, because without rehash.Specifically, the many-one that is mapped as from virtual db to physics db, limit feelings
It is one-to-one under condition.I.e. physics db is fewer at the beginning, but in applying hash divide be still divide it is more virtual
Db, multiple virtual db are then mapped to a physics db, when business increase physical resource be difficult to support when, just increase
Add physics db, this when that virtual db is remapped to new physics db.There is no need to as traditional straight in the application in this way
It meets hash and needs rehash like that.And in failure excision, it, can be by the corresponding virtual data of failure for direct hash
Library is mapped on other physical machines, to also not need rehash.In addition, for consistent hashing, after failure is extractd
The data and flow of all trouble blocks can all get to the problem of adjacent next node can be with by above-mentioned one layer of mapping
Virtual data base corresponding to Mishap Database is mapped to the preferable server of configuration, or is mapped to by secondary hash more
A database.Existing hash schemes do not have such one layer of mapping, therefore it is reciprocity to treat all databases all, thus neglect
Otherness is omitted.Mapping again in by the method for the invention can will hit more block and be mapped to preferably in hash
On physical resource, to ensure better database access performance and promote service quality.Match in addition, above-mentioned mapping is administrator
It sets, can be by resource impact more reasonable according to the otherness of machine, physics db almost just maps some virtual db less,
Better machine just maps some virtual db more
As shown in Fig. 2, a kind of device 10 of execution data access of the embodiment of the present invention include using hash modules 101,
Virtual db management modules 102, virtual db mapping blocks 103, physics db data sources management module 104 and db access agent modules
105。
As shown in figure 3, the flow for carrying out data access with above-mentioned apparatus can be clear that.
User initiates data access, and virtual db is navigated to by hash such as direct hash or consistent hashings;
User is accessed by virtual db management modules requested database;
After virtual db management modules receive the db access requests of user, according to corresponding virtual db information to virtual db
Mapping block asks the connection of physics db data sources;
After virtual db mapping blocks receive virtual db to the request of physical data, searches and correspond in virtual db mappings
Physics db information, do not return to null then, as exist if according to corresponding information to physics db data source management modules request
Physics db connections;
After physics db data source management modules receive the request connected to physical data source, into corresponding connection pool
Physics db connections are distributed, connection is assigned to and then returns, attempt to create if without corresponding physics db connections, if unsuccessful
Return to null;
Virtual db mapping blocks return to the physical data source connection that physics db data source management modules are asked virtual
Db management modules;
The data source connection information got and db accessing request informations are submitted to db and access generation by virtual db management modules
Manage module;
When-db access agent modules receive access request, according to the connection of the data source of acquisition and access information, with agency
Mode real physics db is accessed is executed and returned, db access agents module can use ready-made component of increasing income,
Such as mybatis;
The implementing result of db access agent modules is returned to user by virtual db management modules.
Can know in more detail from flow illustrated in fig. 3 the effect of the modules of the apparatus according to the invention with
And the correlation between modules, wherein
The application hash modules 101 are used to navigate to virtual data base by hash points of library;
The virtual db management modules 102 after receiving customer data base access request according to virtual data base for believing
It ceases the virtual db mapping blocks 103 and asks the connection of physical database data source and for receiving by the db access agents
The implementing result of the return of module 105 simultaneously returns to client;
The virtual db mapping blocks 103 are for judging whether corresponding physical database data source connection, wherein
User null values or throw exception are returned to judging to be not present in the case that corresponding physical database data source connects;
The physics db data sources management module 104 is used for there are the corresponding physical database data source connections
In the case of be returned to the virtual db management modules 102;
The db access agents module 105 is used to receive the corresponding object that the virtual db management modules 102 provide
The connection of reason database data source and execution ask and return to implementing result to the virtual db management modules 102.
Optionally, the hash points of library is realized by direct hash or consistent hashing.
Optionally, the virtual db mapping blocks 103 are additionally operable to update when adding virtual data base or physical database
Mapping, the mapping are configured by system manager.
Optionally, the db access agents module 105 is component of increasing income, such as mybatis.
According to an embodiment of the invention, the present invention also provides a kind of electronic equipment and a kind of readable storage medium storing program for executing.
The electronic equipment of the embodiment of the present invention includes:At least one processor;And it is logical at least one processor
Believe the memory of connection;Wherein, the memory is stored with the instruction that can be executed by one processor, and described instruction is by institute
It states at least one processor to execute, so that at least one processor executes one kind provided by the present invention and is based on user behavior
The Method of Commodity Recommendation of sequential mining.
The non-transient computer readable storage medium of the embodiment of the present invention, the non-transient computer readable storage medium are deposited
Computer instruction is stored up, the computer instruction is provided by the present invention based on user behavior sequence for making the computer execute
The Method of Commodity Recommendation of excavation.
Fig. 4 is performed for the hardware configuration of the electronic equipment of database point library hash methods according to the ... of the embodiment of the present invention
Schematic diagram.As shown in figure 4, the electronic equipment includes:One or more processors 42 and memory 41, at one in Fig. 4
For reason device 42.Wherein, memory 41 is non-transient computer readable storage medium provided by the present invention.
The electronic equipment can also include:Input unit 43 and output device 44.
Processor 42, memory 41, input unit 43 can be connected with output device 44 by bus or other modes,
In Fig. 4 for being connected by bus.
Memory 41 is used as a kind of non-transient computer readable storage medium, can be used for storing non-transient software program, non-
Transient computer executable program, the finger of step S1 and S2 as given expression to database point library hash methods in the embodiment of the present invention
It enables.Processor 42 is stored in non-transient software program, instruction etc. in memory 41 by operation, to execute the number of the present invention
Divide library hash methods according to library.
Input unit 43 can receive the access information of input.Output device 44 may include that display screen etc. shows equipment.
The said goods can perform the method that the embodiment of the present invention is provided.The technology of detailed description is not thin in the present embodiment
Section, reference can be made to the method that the embodiment of the present invention is provided.
Above-mentioned specific implementation mode, does not constitute limiting the scope of the invention.Those skilled in the art should be bright
It is white, design requirement and other factors are depended on, various modifications, combination, sub-portfolio and replacement can occur.It is any
Modifications, equivalent substitutions and improvements made by within the spirit and principles in the present invention etc., should be included in the scope of the present invention
Within.
Claims (10)
1. a kind of database divides library hash methods, which is characterized in that it includes:
Hash is carried out to virtual db and divides library;
Virtual db through hash points of library is mapped to actual physics db in a manner of many-to-one.
2. according to the method described in claim 1, it is characterized in that, the hash divides library can be by direct hash or consistency
Hash is realized.
3. according to the method described in claim 1, it is characterized in that, the mapping is by administrator configurations.
4. a kind of device to data access, which is characterized in that described device includes:Mould is managed using hash modules, virtual db
Block, virtual db mapping blocks, physics db data sources management module and db access agent modules, wherein
The application hash modules are used to navigate to virtual db by hash points of library;
The virtual db management modules be used for after the db access requests for receiving user according to virtual db information to it is described virtually
Db mapping blocks ask the connection of physics db data sources and for receiving the implementing result returned by the db access agents module
And return to client;
The virtual db mapping blocks are for judging whether corresponding physics db data sources connection, wherein are judging not
User null values or throw exception are returned in the case of being connected there are corresponding physics db data sources;
The physics db data source management modules are used for it there are the corresponding physics db data sources connection
Return to the virtual db management modules;
The db access agents module is used to receive the corresponding physics db data sources that the virtual db management modules provide
Connection and execution ask and return to implementing result to the virtual db management modules.
5. device according to claim 4, which is characterized in that the hash divides library by direct hash or consistent hashing
To realize.
6. device according to claim 4, which is characterized in that the virtual db mapping blocks are additionally operable to adding virtual db
Or more new mappings when physics db, the mapping are configured by system manager.
7. device according to claim 4, which is characterized in that the db access agents module is component of increasing income.
8. device according to claim 7, which is characterized in that the component of increasing income is mybatis.
9. a kind of electronic equipment, which is characterized in that including:
At least one processor;And
The memory being connect at least one processor communication;Wherein,
The memory is stored with the instruction that can be executed by one processor, and described instruction is by least one processor
It executes, so that at least one processor is able to carry out the method described in any one of claim 1-3.
10. a kind of non-transient computer readable storage medium, which is characterized in that the non-transient computer readable storage medium is deposited
Store up computer instruction, the method that the computer instruction is used to that the computer perform claim to be made to require described in any one of 1-3.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710149691.5A CN108572993B (en) | 2017-03-14 | 2017-03-14 | db sub-library hash method, electronic device, storage medium, and apparatus for accessing data |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710149691.5A CN108572993B (en) | 2017-03-14 | 2017-03-14 | db sub-library hash method, electronic device, storage medium, and apparatus for accessing data |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108572993A true CN108572993A (en) | 2018-09-25 |
CN108572993B CN108572993B (en) | 2021-05-25 |
Family
ID=63578522
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710149691.5A Active CN108572993B (en) | 2017-03-14 | 2017-03-14 | db sub-library hash method, electronic device, storage medium, and apparatus for accessing data |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108572993B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111046430A (en) * | 2019-12-12 | 2020-04-21 | 南京医渡云医学技术有限公司 | Data processing method and device, storage medium and electronic equipment |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102137014A (en) * | 2011-03-11 | 2011-07-27 | 华为技术有限公司 | Resource management method, system and resource manager |
CN102333029A (en) * | 2011-06-23 | 2012-01-25 | 北京新媒传信科技有限公司 | Routing method in server cluster system |
CN102521330A (en) * | 2011-12-07 | 2012-06-27 | 华中科技大学 | Mirror distributed storage method under desktop virtual environment |
-
2017
- 2017-03-14 CN CN201710149691.5A patent/CN108572993B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102137014A (en) * | 2011-03-11 | 2011-07-27 | 华为技术有限公司 | Resource management method, system and resource manager |
CN102333029A (en) * | 2011-06-23 | 2012-01-25 | 北京新媒传信科技有限公司 | Routing method in server cluster system |
CN102521330A (en) * | 2011-12-07 | 2012-06-27 | 华中科技大学 | Mirror distributed storage method under desktop virtual environment |
Non-Patent Citations (1)
Title |
---|
暗痛: "一致性哈希算", 《博客园》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111046430A (en) * | 2019-12-12 | 2020-04-21 | 南京医渡云医学技术有限公司 | Data processing method and device, storage medium and electronic equipment |
Also Published As
Publication number | Publication date |
---|---|
CN108572993B (en) | 2021-05-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8200705B2 (en) | Method and apparatus for applying database partitioning in a multi-tenancy scenario | |
US10545776B1 (en) | Throughput and latency optimized volume initialization | |
US9053162B2 (en) | Multi-tenant hosted application system | |
CA2891339C (en) | Distributed caching cluster management | |
US20180293257A1 (en) | Method for accessing distributed database and distributed data service apparatus | |
US20150236974A1 (en) | Computer system and load balancing method | |
US20200301748A1 (en) | Apparatuses and methods for smart load balancing in a distributed computing system | |
WO2012039053A1 (en) | Method of managing computer system operations, computer system and computer-readable medium storing program | |
US11397622B2 (en) | Managed computing resource placement as a service for dedicated hosts | |
US20200117589A1 (en) | Techniques and devices for cloud memory sizing | |
US11614932B2 (en) | Method and system for machine learning framework and model versioning in a machine learning serving infrastructure | |
US20140089260A1 (en) | Workload transitioning in an in-memory data grid | |
US11442781B2 (en) | Master image for deploying workloads in a heterogeneous computing environment | |
US11625179B2 (en) | Cache indexing using data addresses based on data fingerprints | |
CN108572993A (en) | Db divides library hash methods, electronic equipment, storage medium and the device to data access | |
US9641453B2 (en) | Method for prioritizing throughput for network shares | |
US11042665B2 (en) | Data connectors in large scale processing clusters | |
US10911371B1 (en) | Policy-based allocation of provider network resources | |
US10318509B2 (en) | Populating text indexes | |
US10097431B1 (en) | Routing to tenant services utilizing a service directory | |
CN111221857B (en) | Method and apparatus for reading data records from a distributed system | |
US10310889B1 (en) | Data statistics service | |
US8484249B1 (en) | Graph transformations to correct violations of service level objectives in a data center | |
US11656957B1 (en) | Managing nodes of a DBMS | |
US20220261389A1 (en) | Distributing rows of a table in a distributed database system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |