Summary of the invention
The present invention proposes a kind of method of utilizing multitype database to carry out system, device and equipment, has solved in prior art and cannot utilize multitype database to carry out the problem of data processing.
Technical scheme of the present invention is achieved in that
The invention discloses a kind of method of utilizing multitype database to carry out system, comprising:
S1. receive the data message of transmission, described information comprises Data Source ground;
S2. the described Data Source ground of judgement is from foreground or backstage; If foreground, enters step S3, if backstage enters step S4;
S3. judge that whether terminal is online, if so, enter step S5, if not, enter step S6;
S4. described data are stored in activeMQ database;
S5. the transmission data lower than preset value are stored in mysql database, the transmission data higher than preset value are stored in mongoDB;
S6. described data are stored in redis database.
Of the present invention, utilize in the method that multitype database carries out system, described preset value comprises at least 1,000 ten thousand data.
Of the present invention, utilize in the method that multitype database carries out system, described foreground comprises the locating terminal with GPRS and GPS communication.
The invention discloses a kind of device that utilizes multitype database to carry out system, for realizing above-mentioned method, comprising:
Data message receiving element, for receiving the data message of transmission, described information comprises Data Source ground;
Data Source ground judging unit is from foreground or backstage for judging described Data Source;
The online judging unit of terminal, whether online for judging terminal;
The first storage unit, for being stored in activeMQ database by described data;
The second storage unit, for being stored in mysql database by the transmission data lower than preset value;
The 3rd storage unit, is stored in mongoDB database for transmission data higher than preset value just;
The 4th storage unit, for being stored in redis database by described data.
Of the present invention, utilize in the device that multitype database carries out system, described preset value comprises at least 1,000 ten thousand data.
Of the present invention, utilize in the device that multitype database carries out system, described foreground comprises the locating terminal with GPRS and GPS communication.
The invention discloses a kind of system of utilizing multitype database to carry out system, comprise at least one client, a plurality of databases that are connected with described client, the controller being connected with described this storehouse of a plurality of data, described controller comprises above-mentioned device.
Of the present invention, utilize in the system that multitype database carries out system, described a plurality of databases, specifically comprise: activeMQ database, mysql database, mongoDB database, redis database.
Of the present invention, utilize in the system that multitype database carries out system, described client is the locating terminal with GPRS and GPS communication.
Implement a kind of method, device and system of utilizing multitype database to carry out system of the present invention, the useful technique effect having is: utilize multitype database to carry out the performance that system can improve system:
1. in the situation that data volume is smaller, can use mysql database save data, Performance Ratio is higher;
2. if mass data, adopts MongoDB save data, can divide storehouse submeter design, improve search efficiency;
3.activeMQ is real-time listening state of a process under the prerequisite not influencing the course;
4. the data that platform sends to terminal after terminal closedown can adopt redis to preserve, can perdurable datas, and when starting up of terminal is again by data distributing.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Embodiment based in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
Refer to Fig. 1, embodiments of the invention, a kind of method of utilizing multitype database to carry out system, comprising:
S1. receive the data message of transmission, described information comprises Data Source ground;
S2. the described Data Source ground of judgement is from foreground or backstage; If foreground, enters step S3, if backstage enters step S4;
S3. judge that whether terminal is online, if so, enter step S5, if not, enter step S6;
S4. described data are stored in activeMQ database;
S5. the transmission data lower than preset value are stored in mysql database, the transmission data higher than preset value are stored in mongoDB;
S6. described data are stored in redis database.
The technical program essence is that relevant database and non-relational database are combined, to can select suitable Database Systems according to actual conditions.
When data volume is smaller and data are more stable, just can select the such inquiry velocity of mysql database also than very fast and a plurality of client computer, can connect a database simultaneously.
When non-relational database that need to minute storehouse submeter just can be selected mongoDB database, mongogDB can storage object type data pattern freely support dynamic queries, can automatically process fragment to support the extendability of cloud computing level, it is more extensive that mongodb supports that multilingual uses.
High scalability MongoDB is applicable to the database being comprised of tens of or hundreds of station servers very much, and Performance Ratio is higher, and Redis has played good supplementary function to relevant database.
ActiveMQ is that apache product is that a powerful messaging bus of increasing income of ability is supported JMS standard, support multiple transportation protocol also can write by multilingual, activeMQ can be embedded in spring system easily, supports Ajax to guarantee high performance cluster from designing simultaneously.
Refer to Fig. 2, embodiments of the invention, utilize multitype database to carry out a device for system, comprising: data message receiving element 10, Data Source ground judging unit 20, the online judging unit 30 of terminal, the first storage unit 40, the second storage unit 50, the 3rd storage unit 60, the 4th storage unit 70.
Data message receiving element 10, for receiving the data message of transmission, described information comprises Data Source ground;
Data Source ground judging unit 20 is from foreground or backstage for judging described Data Source;
The online judging unit 30 of terminal, whether online for judging terminal;
The first storage unit 40, for being stored in activeMQ database by described data;
The second storage unit 50, for being stored in mysql database by the transmission data lower than preset value;
The 3rd storage unit 60, is stored in mongoDB database for transmission data higher than preset value just;
The 4th storage unit 70, for being stored in redis database by described data.
Wherein, preset value comprises at least 1,000 ten thousand data, and foreground comprises the locating terminal with GPRS and GPS communication.
Refer to Fig. 3, a kind of system of utilizing multitype database to carry out system, comprise at least one client 100, a plurality of databases 200 that are connected with client 100, with the controller 300 that a plurality of databases 200 are connected, controller 300 comprises that the above-mentioned multitype database that utilizes carries out the device of system.
Wherein, a plurality of databases, specifically comprise: activeMQ database, mysql database, mongoDB database, redis database.
Client is the locating terminal with GPRS and GPS communication.
According to the description of above system design scheme, mainly comprise following step:
(1) from client add or the operation of revising the small data quantities such as deletion all by direct control MySQL;
(2) locating terminal uploads by GPRS that a large amount of data are kept at mongoDB and according to certain rule minute storehouse submeter, when data inserting or newly-built table save data are seen in the source of data upload judgement data;
(3) when some process is being moved, we need to obtain these states of a process and some data we just can select activeMQ so, and it is that the execution that can not influence the course can phase mutual interference;
(4), when client arranges locating terminal, if locating terminal portion will the form with key_value be kept at data in redis database online so, when terminal is online, resend.
The system work process that utilizes multitype database to carry out system of the technical program is: client 100 arrives a plurality of databases 200 by comprising the mode interaction data of GPRS and GPS communication, the device 1 that utilizes multitype database to carry out system in controller 300 is that foreground or backstage determine according to the data of uploading, and the database that mutual data importing is different is preserved.Specifically, native system is to utilize multitype database should consider that different occasions adopts different strategies to reach the object that improves system performance.
A. the operation of the small data quantity on platform is directly kept at mysql database.
B. locating terminal constantly can cause a large amount of data so just to consider to be kept in mongoDB in uploading data, but the source that will judge data is to realize the preservation of minute storehouse submeter, to have reached data clear.
C. on backstage, need to obtain in real time state of a process and use activeMQ, can non-interferingly obtain state of a process and data, carry out real-time listening the message packing receiving is sent, it is relatively independent that activeMQ monitors process in real time.
When D. locating terminal being arranged from platform or by short-message instruction, judge whether terminal is online, if it is not online, so just the information of transmission is kept in redis database, when terminal is again online, so again by data from new transmission, to reach tube terminal not, be what state data that response platform sends in time.
Implement a kind of method, device and system of utilizing multitype database to carry out system of the present invention, the useful technique effect having is: utilize multitype database to carry out the performance that system can improve system:
1. in the situation that data volume is smaller, can use mysql database save data, Performance Ratio is higher;
2. if mass data, adopts MongoDB save data, can divide storehouse submeter design, improve search efficiency;
3.activeMQ is real-time listening state of a process under the prerequisite not influencing the course;
4. the data that platform sends to terminal after terminal closedown can adopt redis to preserve, can perdurable datas, and when starting up of terminal is again by data distributing.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.