The monitoring method and device of database access
Technical field
The application is related to field of computer technology, more particularly to a kind of database access monitoring method and dress
Put.
Background technology
At present, the process of most of business processing can all be related to the access operation to database, such as:
Read operation or write operation.Once database access malfunctions, normal business processing will be influenceed.Therefore,
How database access is monitored, turned into quickly to position and handle in service exception
Urgent problem to be solved.
The content of the invention
In view of this, the application provides the monitoring method and device of a kind of database access.
Specifically, the application is achieved by the following technical solution:
A kind of monitoring method of database access, methods described includes:
Receive the access request for database;
Judge whether to preserve the corresponding business information of the access request;
When preserving the corresponding business information of the access request, based on the business information, the visit
Ask that the access result of request and the access request exports the monitoring daily record of this database access.
Optionally, methods described also includes:
Generate the business information of each business scenario;
Preserve the corresponding relation of each business scenario and its business information;
It is described to judge whether to preserve the corresponding business information of the access request, including:
Judge whether to preserve the business information of the business scenario belonging to the access request.
Optionally, the business information of each business scenario of generation, including:
For each business scenario, the SQL data file related to the business scenario is obtained, will be described
SQL data files and default database split rule as input data input template engine, obtain institute
State the business information of business scenario.
Optionally, the visit based on the business information, the access request and the access request
The monitoring daily record that result exports this database access is asked, including:
The database is parsed from the business information and splits rule;
Object library information is determined according to the required parameter that the database splits regular and described access request;
By the business scenario belonging to the business information, the object library information, the required parameter and
The result that accesses is exported as the monitoring daily record of this database access.
Optionally, methods described also includes:
When being configured with database middleware, the object library information and the required parameter are sent to institute
Database middleware is stated, so that the database middleware carries out database access, and passes through the data
Storehouse middleware receives the access result.
A kind of supervising device of database access, described device includes:
Request reception unit, receives the access request for database;
Information judging unit, judges whether to preserve the corresponding business information of the access request;
Daily record output unit, when preserving the corresponding business information of the access request, based on the industry
The access result of business information, the access request and the access request exports this database access
Monitor daily record.
Optionally, described device also includes:
Information generating unit, generates the business information of each business scenario;
Information holding unit, preserves each business scenario and the corresponding relation of its business information;
Described information judging unit, judges whether to preserve the industry of the business scenario belonging to the access request
Business information.
Optionally, described information generation unit, for each business scenario, is obtained and the business scenario
Related SQL data files, the SQL data files and default database are split rule as
Input data input template engine, obtains the business information of the business scenario.
Optionally, the daily record output unit, the database is parsed from the business information and is split
Rule, object library information is determined according to the required parameter that the database splits regular and described access request,
And by the business scenario belonging to the business information, the object library information, the required parameter and institute
State the monitoring daily record output for accessing result as this database access.
Optionally, described device also includes:
Database access unit, when being configured with database middleware, by the object library information and described
Required parameter is sent to the database middleware, so that the database middleware carries out database access,
And the access result is received by the database middleware.
The application can be combined and visited when being monitored to database access it can be seen from above description
Business information, required parameter and the access result output monitoring daily record of the business scenario belonging to request are asked,
So as to associate business scenario and database access, it can be realized soon by monitoring daily record in service exception
Speed positioning and processing, lift Consumer's Experience.
Brief description of the drawings
Fig. 1 is a kind of flow of the monitoring method of database access shown in the exemplary embodiment of the application one
Figure.
Fig. 2 is a kind of supervising device for database access shown in the exemplary embodiment of the application one
One structural representation.
Fig. 3 is a kind of structure of the supervising device of database access shown in the exemplary embodiment of the application one
Schematic diagram.
Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following
When description is related to accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous
Key element.Embodiment described in following exemplary embodiment does not represent the institute consistent with the application
There is embodiment.On the contrary, they are only one be described in detail in such as appended claims, the application
The example of the consistent apparatus and method of a little aspects.
It is the purpose only merely for description specific embodiment in term used in this application, and is not intended to be limiting
The application." one kind ", " institute of singulative used in the application and appended claims
State " and "the" be also intended to including most forms, unless context clearly shows that other implications.Should also
Work as understanding, term "and/or" used herein refers to and associated lists item comprising one or more
Purpose any or all may combine.
It will be appreciated that though may describe various using term first, second, third, etc. in the application
Information, but these information should not necessarily be limited by these terms.These terms only be used for by same type of information that
This is distinguished.For example, in the case where not departing from the application scope, the first information can also be referred to as
Two information, similarly, the second information can also be referred to as the first information.Depending on linguistic context, as in this institute
Use word " if " can be construed to " and ... when " or " when ... when " or " response
In it is determined that ".
In correlation technique, when being monitored to database access, it will usually for data lab setting independence
Monitoring system.However, in such implementation, database access monitoring divides completely with upper-layer service
From, once database access malfunctions, it is impossible to realize the quick positioning and processing to abnormal traffic.
In view of the above-mentioned problems, the application provides a kind of monitoring scheme of database access, can be by database
Access monitoring is combined with business scenario, so as in service exception, can be realized pair by monitoring daily record
The quick positioning and processing of abnormal traffic.
Fig. 1 is a kind of flow of the monitoring method of database access shown in the exemplary embodiment of the application one
Figure.
Fig. 1 is refer to, the monitoring method of the database access can be applied in the terminal, the terminal
Can include smart mobile phone, tablet personal computer, PDA (Personal Digital Assistant, palm PC),
The smart machines such as PC.The monitoring method of the database access can be understood as what is loaded in the terminal
The processing logic that application program (Application, APP) is performed, includes following steps:
Step 101, the access request for database is received.
In the present embodiment, the access request includes carrying out read operation or write operation for database
Miscellaneous service is asked, such as:Inquiry into balance request, transfer request, payment request etc..It is described to access
Request is generally triggered by user, such as:User can trigger the access by default function button please
Ask, user can also trigger the access request by way of phonetic entry, the application does not make spy to this
Different limitation.
Step 102, judge whether to preserve the corresponding business information of the access request.
In the present embodiment, the business information is corresponding with business scenario, can include:Correspondence business
SQL (Structured Query Language, SQL) data file, data of scene
Storehouse splits rule etc..Wherein, the SQL data files can be understood as the annotation letter of correspondence business scenario
Breath, can include:The files such as SQL statement.The database, which splits rule, can include point of database
Storehouse, point table rule etc., rule is split according to the required parameter of the access request and the database, can
To determine this object library information accessed.The business work(that the business scenario is generally supported by application program
It can determine that, by taking Alipay wallet as an example, the business scenario can include:Transfer accounts scene, pay scene
Deng.
Optionally, in one example of the application, the business information of each business scenario can be previously generated,
And preserve the corresponding relation of each business scenario and its business information, such as:Application program can be after mounting
Generate the business information of each business scenario and preserve etc..
In the present embodiment,, can when generating the business information of the business scenario for certain business scenario
First to obtain the SQL data file and database fractionation rule related to the business scenario, and pass through mould
Plate engine generates the business information of the business scenario.Specifically, developer can pre-set and be used for
Generate the template of business information, when generating the business information, can by the SQL data files and
Database splits rule as input data input template engine, template engine and then can be based on described pre-
If template generation described in business scenario business information.Certainly, in actual applications, it would however also be possible to employ
Other modes generate the business information of each business scenario, and the application is not particularly limited to this.
Based on abovementioned steps 101, after the access request is received, it can be determined that locally whether preserve
There is the corresponding business information of the access request, such as:Judge whether to preserve belonging to the access request
Business scenario business information., can when locally preserving the corresponding business information of the access request
To perform step 103, when not preserving the corresponding business information of the access request locally, it can be based on
The database access monitoring scheme provided in correlation technique is accessed local data base and is monitored, the application
This is no longer going to repeat them.
Step 103, when preserving the corresponding business information of the access request, based on business letter
The access result of breath, the access request and the access request exports the monitoring of this database access
Daily record.
In the present embodiment, based on abovementioned steps 102, when it is determined that to preserve the access request corresponding
, can the visit based on the business information, the access request and the access request during business information
Ask the monitoring daily record that result exports this database access.
Optionally, in one example of the application, application program, can after the access request is received
To carry out database access based on the access request, and after the access result of this access is received,
Export the monitoring daily record of this database access.In the present embodiment, asked it is determined that preserving the access
When seeking corresponding business information, database can be first parsed from the business information and splits rule, so
The required parameter carried in regular and described access request is split according to the database afterwards and determines that this is accessed
Object library information, the object library information generally includes:This target database accessed, target point
The information such as table, are then based on the object library information and carry out database access, and receive access result.
Receive after the access result, can be (that is, described to visit by the application scenarios belonging to the business information
Ask the business scenario belonging to request), the object library information, the request ginseng carried in the access request
The several and described result that accesses is exported as the monitoring daily record of this database access.
As an example it is assumed that the access request is transfer request, for Alipay wallet, connecing
After the transfer request for receiving user's input, if it is determined that preserve the corresponding business information of scene of transferring accounts, then
Database can be parsed from the business information and splits rule, and rule is split according to the database
Object library information is determined with the required parameter carried in the transfer request, such as:According to initiation account of transferring accounts
Number, the required parameter such as target account and the database split rule and determine to initiate account and target account institute
Database information.It is determined that after the database information, can be based on carrying in the transfer request
The required parameter such as transfer amounts and the database information carry out database access, such as:Based on institute
State transfer amounts and update described remaining sum for initiating account and target account etc., and return is visited after access terminates
Ask result.Alipay wallet can be after the access result be received, the scene that will transfer accounts, initiation account
(include with the required parameter carried in the database information where target account, the transfer request:
Initiate account, target account, transfer amounts etc.) and the access result be used as this database access
Monitoring daily record output.When the access result is accesses failure, related personnel can be according to output
The database information of this access is quickly oriented in monitoring daily record, to be handled.
Optionally,, can when application program is configured with database middleware in one example of the application
To carry out database access by the database middleware, and receive by the database middleware to visit
Ask result.Such as:, can be first from institute when it is determined that preserving the access request corresponding business information
State and database fractionation rule is parsed in business information, then split according to the database regular and described
The required parameter carried in access request determines this object library information accessed, then by the object library
The required parameter carried in information and the access request is sent in the database middleware, database
Between part database access can be carried out according to the object library information and the access request, without true again
Set the goal storehouse information.Certainly, in practical implementations, can also be by database middleware according to the data
Storehouse splits the required parameter carried in regular and described access request and determines this object library information accessed,
The application is not particularly limited to this.
It should be noted that in practical implementations, according to correlation technique, DAO (Data can be based on
Access Object, database access object) interface carries out database access, and the application is another herein
One repeats.
The application can be combined and visited when being monitored to database access it can be seen from above description
Business information, required parameter and the access result output monitoring daily record of the business scenario belonging to request are asked,
So as to associate business scenario and database access, it can be realized soon by monitoring daily record in service exception
Speed positioning and processing, lift Consumer's Experience.
Embodiment with the monitoring method that aforementioned data storehouse is accessed is corresponding, and present invention also provides database
The embodiment of the supervising device of access.
The embodiment of the supervising device of the application database access can be applied in terminal.Device embodiment
It can be realized, can also be realized by way of hardware or software and hardware combining by software.It is real with software
Exemplified by existing, as the device on a logical meaning, being will be non-volatile by the processor of terminal where it
Property memory in corresponding computer program instructions read in internal memory what operation was formed.From hardware view
Speech, as shown in Fig. 2 a kind of hardware configuration of the supervising device place terminal for the application database access
Figure, in addition to the processor shown in Fig. 2, internal memory, network interface and nonvolatile memory,
Terminal in embodiment where device can also include other hardware generally according to the actual functional capability of the terminal,
This is repeated no more.
Fig. 3 is a kind of structure of the supervising device of database access shown in the exemplary embodiment of the application one
Schematic diagram.
Fig. 3 is refer to, the supervising device 200 of the database access can be applied shown in earlier figures 2
Terminal in, include:Request reception unit 201, information judging unit 202, daily record output unit
203rd, information generating unit 204, information holding unit 205 and database access unit 206.
Wherein, the request reception unit 201, receives the access request for database;
Described information judging unit 202, judges whether to preserve the corresponding business information of the access request;
The daily record output unit 203, when preserving the corresponding business information of the access request, base
This data is exported in the access result of the business information, the access request and the access request
The monitoring daily record that storehouse is accessed.
Described information generation unit 204, generates the business information of each business scenario;
Described information storage unit 205, preserves each business scenario and the corresponding relation of its business information;
Optionally, described information judging unit 202, judges whether to preserve belonging to the access request
The business information of business scenario.
Optionally, described information generation unit 204, for each business scenario, is obtained and the business
The related SQL data files of scene, rule is split by the SQL data files and default database
As input data input template engine, the business information of the business scenario is obtained.
Optionally, the daily record output unit 203, parses the database from the business information
Rule is split, object library is determined according to the required parameter that the database splits regular and described access request
Information, and by the business scenario belonging to the business information, the object library information, the required parameter
And the result that accesses is exported as the monitoring daily record of this database access.
The database access unit 206, when being configured with database middleware, the object library is believed
Breath and the required parameter are sent to the database middleware, so that the database middleware enters line number
Accessed according to storehouse, and the access result is received by the database middleware.
The function of unit and the implementation process of effect specifically refer to correspondence in the above method in said apparatus
The implementation process of step, will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is joined
See the part explanation of embodiment of the method.Device embodiment described above be only it is schematical,
The wherein described unit illustrated as separating component can be or may not be it is physically separate, make
It can be for the part that unit is shown or may not be physical location, you can with positioned at a place,
Or can also be distributed on multiple NEs.Can select according to the actual needs part therein or
Person's whole modules realize the purpose of application scheme.Those of ordinary skill in the art are not paying creativeness
In the case of work, you can to understand and implement.
The preferred embodiment of the application is the foregoing is only, it is all at this not to limit the application
Within the spirit and principle of application, any modification, equivalent substitution and improvements done etc. should be included in
Within the scope of the application protection.