Summary of the invention
The main purpose of the application is to propose a kind of log information processing method, is able to solve and is handling in the prior artThe problems of when log information, user experience when use is improved.
To achieve the above object, the embodiment of the present application provides a kind of log information processing method, is applied to server and pacifiesFull enhancing system SSR server, comprising:
The SSR server is connect with the MySQL database that one has created, and is sent the log information of generation to describedIn the MySQL database table created in MySQL database, so that log server is monitored and obtains log information.
Optionally, the log has different ranks, and the MySQL database table is according to the level creation;
It sends the log information of generation in the MySQL database table created in the MySQL database, comprising:
According to the rank of the log, send the log in the MySQL database table corresponding to the rank.
Optionally, the rank of the log is divided according to Log Types.
The embodiment of the present application also provides a kind of log information processing methods, are applied to log server, comprising:
The log server connects MySQL database and monitors the MySQL database table in the MySQL database,Wherein, the log information that server security enhancing system SSR server is sent is stored in the MySQL database table;
There is newly-increased log information in the MySQL database table if listened to, from the MySQL database tableIt is middle to obtain the log information, and be saved in and be locally stored.
Optionally, the log server is configured with rank;
The log server monitors the MySQL database table in the MySQL database, comprising:
The log server listens only to correspond to the MySQL database table of this log server rank.
Optionally, the rank of the log server is divided according to Log Types.
The embodiment of the present application also provides a kind of server securities to enhance system SSR server, comprising:
Initialization module is set as connecting with the MySQL database that one has created;
Log sending module, is set as sending the log information of generation to and has created in the MySQL databaseIn MySQL database table, so that log server is monitored and obtains log information.
Optionally, the log has different ranks, and the MySQL database table is according to the level creation;
The log sending module is specifically configured to: according to the rank of the log, being sent the log to and is corresponded toIn the MySQL database table of the rank.
The embodiment of the present application also provides a kind of log servers, comprising:
Log information monitors module, is set as connection MySQL database and monitors the MySQL in the MySQL databaseDatabase table;Wherein, the log that server security enhancing system SSR server is sent is stored in the MySQL database tableInformation;
Log information processing module is set as listening to the MySQL database table when log information monitoring moduleWhen the log information that middle presence increases newly, then the log information is obtained from the MySQL database table, and is saved in local depositStorage.
Optionally, the log server is configured with rank;
The log information is monitored module and is specifically configured to: listening only to correspond to the MySQL data of this log server rankLibrary table.
The embodiment of the present application also provides a kind of log information processing systems, comprising: above-mentioned server security enhances systemSSR server and log server.
The technical solution that the application proposes includes: that SSR server is connect with the MySQL database that one has created, and will be generatedLog information be sent in the MySQL database table created in the MySQL database;
Log server connection MySQL database simultaneously monitors the MySQL database table in the MySQL database, ifIt listens to and there is newly-increased log information in the MySQL database table, then obtain the day from the MySQL database tableWill information, and be saved in and be locally stored.
The application forwards middleware as log using MySQL, and the log of different stage is deployed in difference in a distributed mannerLog server on, to provide a kind of simple, reliable, efficient log distributed deployment system, solve existing skillThe problem of generated Insufficient disk space, will also solve entire day after Single Point of Faliure when log progress single machine deployment in artThe problem of aspiration system is hung, improves the reliability of system, and then the user experience is improved.
Specific embodiment
The application is described in detail below with reference to attached drawing and in conjunction with the embodiments.It should be noted that not conflictingIn the case of, the features in the embodiments and the embodiments of the present application can be combined with each other.
The embodiment of the present application forwards middleware as log to realize that the classification distributed type of log is disposed based on MySQL.ItsIn, MySQL is a kind of Relational DBMS (RDBMS) of open source code, uses most common data base administrationLanguage-structured query language (SQL) carries out data base administration.So-called relevant database is built upon relational model baseDatabase on plinth handles the data in database, a relationship type number by means of the mathematical concepts such as algebra of sets and methodIt is made of according to library one or several tables, by saving the data in different tables, rather than all data is placed on oneIn a big warehouse, to increase speed and improve flexibility.The characteristics of Relational DBMS are as follows:
1. data occur in table form
2. every various record names of behavior
3. being often classified as data field corresponding to record name
4. many row and columns form a list
5. several lists forms database
For log information caused by SSR server, following Log Types can be divided into: Debug, Info, Warn,Error and Fatal, by grade, volume sequence is arranged from low to high, are as follows: Debug < Info < Warn < Error < Fatal.Wherein,Debug rank is minimum, can optionally be used in any feelings for being conducive to understand system running state in more detail in debuggingCondition;Info belongs to important output information, for feedback system current state to end user;Warn, Error and FatalThis three should detect an abnormal state of affairs when system is run;Warn belongs to the output information of alert type,It can repair, system can continue to run down;Error belongs to the output information of mistake, can not determine whether system can normal workWork goes down;Fatal belongs to the output information of serious error, and this mistake can not repair, and if system continues to runConsequence is serious if going down.
Fig. 1 show the log information processing method flow chart of the embodiment of the present application 1, comprising the following steps:
Step 101:SSR server is connect with the MySQL database that one has created;
SSR server can generate a large amount of log at runtime, and being in the prior art will be in generated expression logThe log information of appearance is saved in journal file, and the journal file is directly stored on a server.In this application,Log information is not saved in journal file, and is saved in MySQL database.It is saved by generated log informationBefore into MySQL database, elder generation is needed to be attached with the MySQL database that one has created, if it find that not having also when connectionThere is creation MySQL database, then create a MySQL database, when creating MySQL database, MySQL can be used to be providedRealize as issued orders:
Mysql > CREATE DATABASE database-name.
After the MySQL database needed for having created, it is attached in the following way, step are as follows:
1) driving that SSR server load MySQL is provided, such as: mysql-jdbc-driver.jar;
2) IP address, port port, database-name, user name, password, the database table title of MySQL are set;
3) the connect interface for calling MySQL driving, then can connect with the Database of MySQL.
Step 102: sending the log information of generation in the MySQL database table created in the MySQL databaseIn, so that log server is monitored and obtains log information;
It is made of based on MySQL database several specific lists, therefore, the log information of generation is being sent itBefore, if creation corresponds to the MySQL database table of the MySQL database not yet, further creation is needed to correspond toThe MySQL database table of the MySQL database.When creating MySQL database table, it can be used and ordered as follows provided by MySQLIt enables to realize:
Mysql > CREATE TABLE table name (
1 data type of column name,
2 data type of column name,
.......
)。
Herein it should be understood that as described above, log have different ranks, wherein the rank of log can with but notBe limited to divide according to Log Types, wherein the Log Types include at least following one kind: Debug, Info, Warn, Error andFatal.In this application, the log of different stage is saved in different MySQL database tables, that is, a kind of MySQL dataLibrary table corresponds to the other log of level-one, by taking the log information processing to these three types of Debug, Info, Error as an example: by dayWill is divided into first level log, second level log, third level log, wherein and first level log is Debug type,Second level log is Info type, and third level log is Error type, then, creating corresponding MySQL database tableWhen, it needs to create three MySQL database tables, is respectively as follows: the corresponding first level log i.e. first level of Debug type of creationMySQL database table, creates the second level MySQL database table of corresponding second level log, that is, Info type, and creation corresponds toThird level log, that is, Error type third level MySQL database table.Certainly, those skilled in the art can be according to settingMeter needs, and selection creates one such or two kinds of ranks MySQL database table, also can choose creation more than three kinds of ranksMySQL database table.
When producing new log information in SSR server, then SSR server can be according to the rank of current log, by thisLog information, which is sent, to be saved in corresponding in the other MySQL database table of the journal stage.Also to Debug, Info, ErrorFor the log information processing of these three types, in above-mentioned steps 101, corresponding first level log has been created i.e.The second level MySQL number of the first level MySQL database table of Debug type, corresponding second level log, that is, Info typeAccording to Ku Biao and the third level MySQL database table of corresponding third level log, that is, Error type.If at this moment producing oneThe log of Error type, then, SSR server then sends the i.e. Error type of corresponding third level log for the logIn third level MySQL database table.Wherein, when sending MySQL database table for log, MySQL can be used to be providedRealize as issued orders:
Mysql > insert into table name (field 1, field 2) Values (value 1, value 2).
It should be noted that above-mentioned steps 101 and 102 apply in SSR server.
Step 103: log server connection MySQL database simultaneously monitors the MySQL database in the MySQL databaseTable;
Wherein, server security enhancing system SSR server hair as described above is stored in the MySQL database tableSend to log information;
In this application, log server refers to the server for storing log information.Log server in order toThe log information in above-mentioned MySQL database is enough obtained, needs to connect the MySQL database that SSR server is created, this fieldTechnical staff it should be appreciated that can be attached in several ways, the step of one of connection type are as follows:
1) driving that log server load MySQL is provided, such as: mysql-jdbc-driver.jar;
2) IP address, port port, database-name, user name, password, the database table title of MySQL are set;
3) the connect interface for calling MySQL driving, then can connect with the Database of MySQL.
After connecting upper MySQL database, log server can by call MySQL other interfaces (such as: judge numberAccording to table size either with or without variation interface) can know at any time either with or without newly-increased log information in database table, it is rightMySQL database table is monitored.
Herein it should be understood that as described above, log server is configured with rank, i.e., different log services utensilsThere is different ranks, different ranks corresponds to different server performances.In this application, log server listens only to correspond to thisThe MySQL database table of log server rank, also with the log information processing to these three types of Debug, Info, ErrorFor: log server is divided into first level log server, second level log server, third level log servicesDevice, wherein first level log server monitors storage first level log, that is, Debug type first level MySQL databaseTable, second level log server monitor second level log, that is, Info type second level MySQL database table, the third levelOther log server monitors third level log, that is, Error type third level MySQL database table.
Step 104: there is newly-increased log information in the MySQL database table if listened to, from the MySQLThe log information is obtained in database table, and is saved in and is locally stored.
As described above, if there is newly-increased log information in database table, so that it may the get provided by MYSQL drivingInterface obtains newly-increased log information, and the disk space of newly-increased log information serializing to log server is completed logThe storage of information.Also by taking above situation as an example: if at this moment third level log server listens to third level MySQL dataIt has increased the log of an Error type in the table of library newly, then the log information has been obtained by the get interface that MYSQL driving provides, andThe disk space of the newly-increased serializing of this Error log information to third level log server is completed into depositing for log informationStorage.Equally, if at this moment second level log server listens in second level MySQL database table and increased an Info newlyThe log of type then obtains the log information, and this Info log that will be increased newly by the get interface that MySQL driving providesInformation sequenceization completes the storage of log information to the disk space of second level log server.
It should be noted that above-mentioned steps 103 and 104 apply in log server.
Aim in MySQL database table being first in first out what needs to be explained here is that whole process is Sino-Japan, guarantee in this wayThe succession that log stores on the server is not in out-of-order possibility.In this way, even if wherein a log server goes outExisting failure, entire log processing system also still can be not in the problem of service hangs with entire run, ensure that entireThe high reliability of log processing system.
Compared to traditional mode, the advantage of the application are as follows:
1.MySQL can quickly handle up to ten million concurrent requests, and can carry out reliable persistent storage to data,Even if the unexpected power down delay machine of MySQL, data (can also redo log) mechanism by redo log and carry out restoring that data is avoided to loseLose, avoid middleware in the classification distributed type deployment system of generic log leads to the problem of memory spilling and loss of data.
It is deployed on different server 2. log is distributed, greatly improves the memory space of log, memory spaceIt is that traditional single machine log storage cannot compare.
3. can be stored log on a different server according to different log ranks, the distribution of such server is justIt is linked up with log rank, the log of this low level of Debug can be assigned to the server of low performance, and Error is this advancedOther log can be assigned to high performance server, in this way can be effective and reasonable utilize server, realize the conjunction of serverReason distribution.
4. improving the reliability of system, the single machine log system disaster tolerance poor performance of traditional approach, server is askedTopic, the paralysis of entire log system, entire log system is still in the case where there is single machine failure for the log system of classification distributed typeSo can effectively it run.
Fig. 2 is the SSR server architecture figure of the embodiment of the present application 2, as shown in Fig. 2, the server security enhances system SSRServer includes:
Initialization module is set as connecting with the MySQL database that one has created;
Log sending module, is set as sending the log information of generation to and has created in the MySQL databaseIn MySQL database table, so that log server is monitored and obtains log information.
Wherein, log has different ranks, and the MySQL database table is according to the level creation.
Further, the log sending module is specifically configured to: according to the rank of the log, the log being sentTo in corresponding to the MySQL database table of the rank.
Fig. 3 is the log server structure chart of the embodiment of the present application 3, as shown in figure 3, the log server includes:
Log information monitors module, is set as connection MySQL database and monitors the MySQL in the MySQL databaseDatabase table;Wherein, the log that server security enhancing system SSR server is sent is stored in the MySQL database tableInformation;
Log information processing module is set as listening to the MySQL database table when log information monitoring moduleWhen the log information that middle presence increases newly, then the log information is obtained from the MySQL database table, and is saved in local depositStorage.
Wherein, the log server is configured with rank.
Further, the log information is monitored module and is specifically configured to: listening only to correspond to this log server rankMySQL database table.
Fig. 4 is the log information processing system structure chart of the embodiment of the present application 4, as shown in figure 4, the log information processing systemSystem includes above-mentioned described server security enhancing system SSR server and log server.
This point it is emphasized that described scheme, realized the day of different stage through the foregoing embodiment in the applicationWill is deployed in a distributed manner on different log servers, to provide a kind of simple, reliable, efficient log distribution portionAdministration's system, generated Insufficient disk space, also solves when solving the problems, such as log progress single machine deployment in the prior artThe problem of entire log system is hung after Single Point of Faliure, improves the reliability of system, and then the user experience is improved.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-rowHis property includes, so that the process, method, article or the device that include a series of elements not only include those elements, andAnd further include other elements that are not explicitly listed, or further include for this process, method, article or device institute it is intrinsicElement.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to doThere is also other identical elements in the process, method of element, article or device.
Above-mentioned the embodiment of the present application serial number is for illustration only, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment sideMethod can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many casesThe former is more preferably embodiment.Based on this understanding, the technical solution of the application substantially in other words does the prior artThe part contributed out can be embodied in the form of software products, which is stored in a storage mediumIn (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal (can be mobile phone, computer, serviceDevice, air conditioner or network equipment etc.) execute method described in each embodiment of the application.
The above is only preferred embodiment of the present application, are not intended to limit the scope of the patents of the application, all to utilize this ShenPlease equivalent structure or equivalent flow shift made by specification and accompanying drawing content, be applied directly or indirectly in other relevant skillsArt field similarly includes in the scope of patent protection of the application.