Real-time data storage method, device, computer equipment and storage medium

CN111400361BActive Publication Date: 2024-08-27CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010090231.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-13
Publication Date
2024-08-27
Estimated Expiration
2040-02-13

AI Technical Summary

Technical Problem

[0003]基于此,有必要针对上述技术问题,本申请提供一种数据实时存储方法、装置、计算机设备及存储介质,以解决现有技术中将读取到的日志数据直接写入hive中进行保存会出现延迟严重导致的影响日志数据的存储和分析的技术问题

Benefits of technology

[0016] The above-mentioned real-time data storage methods, devices, computer equipment and storage media classify and process the collected log data, and write the classified log data that meets the log filtering conditions into kafka for buffering processing, and buffer the collected log data. The log data read by kafka is segmented and processed to obtain a string sequence, and then the key-value text sequence is matched for the segmented string sequence with unknown meaning, and then the data is stored in structured data in real time through hbase to obtain structured data. . Among them, the data needs to be buffered through hbase before being input into hive for storage to prevent data congestion when processing massive data. There is a delay in writing data to hive to solve the problem that users cannot perform real-time analysis of log data. technical issues.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111400361B
    Figure CN111400361B
Patent Text Reader

Abstract

The present application belongs to the field of data structured processing, and discloses a real-time data storage method, device, computer equipment and storage medium, wherein the method replaces the specified characters searched from the text sequence to be determined with preset cutting characters, and cuts the text sequence to be determined at the preset cutting characters. Method, device, computer equipment and readable storage medium. The method includes classifying the collected log data, writing the classified log data that meets the log screening conditions into Kafka for buffering, and segmenting the log data read from Kafka to obtain a string sequence, and then matching the key value text sequence for the meaningless string sequence after segmentation, and then storing the data in structured data in real time through HBase to obtain structured data. This method solves the technical problem that users cannot perform real-time analysis on log data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a real-time data storage method, device, computer equipment and storage medium. Background Art

[0002] In the prior art, if you want to analyze the user access logs generated by the server, you can use Hive, a data warehouse tool based on Hadoop, to write the log data on the server to a pre-created database table in Hive in real time, and then perform operations such as query analysis on the data in the database table to achieve the function of real-time analysis of the log data. However, when the amount of log data required is relatively large, directly writing the massive data on the server to Hive will cause data congestion due to Hive's own defects, and there will be a delay in writing data to Hive, and the delay is generally relatively long, which affects the storage and analysis of log data. Summary of the invention

[0003] Based on this, it is necessary to address the above technical problems. The present application provides a real-time data storage method, device, computer equipment and storage medium to solve the technical problem in the prior art that the read log data is directly written into hive for storage, which causes serious delays and affects the storage and analysis of log data.

[0004] A real-time data storage method, the method comprising:

[0005] Read the preset configuration file to obtain the log filtering condition, obtain the log data that meets the log filtering condition from the collected log data, and write the obtained log data into Kafka according to the preset configuration file as the data to be converted;

[0006] Read the data to be converted from Kafka at regular intervals, perform cutting and matching processing on the read data to be converted according to preset slicing conditions to obtain a text sequence to be determined, and write the text sequence to be determined into a preset data table on HBase;

[0007] Generate a structural data soft link pointing to the preset database table for hive according to the storage path of the preset data table on the hbase;

[0008] The to-be-determined text sequence obtained according to the structural data soft link is segmented by a regular expression, and the structured data obtained after the segmentation is written into the structured database on the hive.

[0009] A real-time data storage device, the device comprising:

[0010] A data buffer module is used to read a preset configuration file to obtain a log screening condition, obtain log data that meets the log screening condition from the collected log data, and write the obtained log data into Kafka according to the preset configuration file as data to be converted;

[0011] The sequence matching module is used to periodically read the data to be converted from Kafka, perform segmentation and matching processing on the read data to be converted according to preset segmentation conditions to obtain a text sequence to be determined, and write the text sequence to be determined into a preset data table on HBase;

[0012] A link pointing module, used for generating a structural data soft link pointing to the preset database table for Hive according to the storage path of the preset data table on the HBase;

[0013] The structuring module is used to perform a segmentation process on the to-be-determined text sequence obtained according to the soft link of the structural data through a regular expression, and write the structured data obtained after the segmentation process into the structured database on the hive.

[0014] A computer device comprises a memory and a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method of the schematic diagram of the real-time data storage device are implemented.

[0015] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned schematic diagram method of a real-time data storage device.

[0016] The above-mentioned real-time data storage method, device, computer equipment and storage medium classify the collected log data, write the classified log data that meets the log screening conditions into Kafka for buffering, and split the log data read from Kafka to obtain a string sequence, then match the key value text sequence for the meaningless string sequence after the split, and then store the data in structured data in real time through HBase to obtain structured data. Among them, before inputting the data into Hive for storage, it is necessary to buffer the data through HBase to prevent data congestion when processing massive data, and delay the data written to Hive, so as to solve the technical problem that users cannot perform real-time analysis on log data. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0018] Figure 1 A schematic diagram of an application environment for a real-time data storage method;

[0019] Figure 2 It is a flowchart of a real-time data storage method;

[0020] Figure 3 for Figure 2 Schematic diagram of the process of step 204;

[0021] Figure 4 for Figure 3 Schematic diagram of the process of step 302;

[0022] Figure 5 for Figure 3 Another schematic diagram of the process of step 306;

[0023] Figure 6 for Figure 2 Schematic diagram of the process of step 202;

[0024] Figure 7 It is a schematic diagram of a real-time data storage device;

[0025] Figure 8 FIG. 1 is a schematic diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0027] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0028] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0029] The real-time data storage method provided by the embodiment of the present invention can be applied to Figure 1 In the application environment shown, the application environment may include a terminal 102, a network 106, and a server 104. The network 106 is used to provide a communication link medium between the terminal 102 and the server 104. The network 106 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0030] The user can use the terminal 102 to interact with the server 104 through the network 106 to receive or send messages, etc. Various communication client applications can be installed on the terminal 102, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0031] Terminal 102 can be various electronic devices with a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Group Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Group Audio Layer 4) players, laptop computers and desktop computers, etc.

[0032] The server 104 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal 102 .

[0033] It should be noted that the real-time data storage method provided in the embodiment of the present application is generally executed by the server / terminal, and accordingly, the real-time data storage device is generally arranged in the server / terminal device.

[0034] It should be understood that Figure 1 The number of terminals, networks and servers in the embodiment is only for illustration. Any number of terminals, networks and servers may be provided according to the implementation requirements.

[0035] The terminal 102 communicates with the server 104 through the network. The server 104 collects log data from the terminal 102, writes the log data into kafka for buffer storage after filtering, and saves the structured data in the database on hive after cutting and matching the data and cutting and denoising by regular expressions. The terminal 102 and the server 104 are connected through a network, which can be a wired network or a wireless network. The terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, and portable wearable devices. The terminal 102 can also be a server storing log data, and the server 104 can be implemented with an independent server or a server cluster composed of multiple servers.

[0036] In one embodiment, Figure 2 As shown, a real-time data storage method is provided, which is applied to Figure 1 The server in the example is used as an example to illustrate, including the following steps:

[0037] Step 202, read the preset configuration file to obtain the log screening condition, obtain the log data that meets the log screening condition from the collected log data, and write the obtained log data into Kafka according to the preset configuration file as the data to be converted.

[0038] The data source of general log data is the server, or the backend corresponding to the terminal. The information of user access to the system stored on the server is usually generated by web containers such as nginx (Nginx (engine x) is a high-performance HTTP and reverse proxy web server, and also provides IMAP / POP3 / SMTP services), tomcat (Tomcat server is a free open source web application server), webLogic (Java application server for development, integration, deployment and management of large-scale distributed web applications, network applications and database applications), etc., which can be:

[0039] field information such as system_name, source, agent, status, method, byte, connecttime, type, appname, request URL, clientip, serverip, acctime, etc.

[0040] However, the data mentioned above is not limited to log data. As long as the data meets the preset screening conditions, it can be processed by this proposal. The log data here is just for the convenience of explaining a specific application scenario. For example, the format or type of log data agreed upon by the developer.

[0041] The preset configuration file includes information about the collection path of the log data on the data source, the type or format of the log data that the server needs to obtain, etc. It is a configuration file pre-written on the server. When collecting and filtering the log data, as long as the information in the preset configuration file is read, the log data can be processed according to the collection path and filtering information in the preset configuration file. In this embodiment, the server can be regarded as a web container. The format and type of the log data generated by the web container are various. Before analysis, it is necessary to read the preset configuration file to obtain the log filtering conditions. After the log data is collected from the web container, the log data is filtered according to the preset filtering conditions. Among them, the collection path stores the storage path of the log data on the web container. The server can collect the log data from the web container according to the collection path as the data to be filtered; the data to be filtered is the log data that has not yet been classified, and can be log data of various formats and types mixed together, which is relatively messy and inconvenient for subsequent processing and analysis.

[0042] Optionally, specifically, the format of a line of log information obtained in this embodiment may be:

[0043] weblogic_acc appName, agent Nanning 0.012 17:53:54-GET 675 200 / life / selfhire.getAccountInfo 202.103.238.166

[0044] Another log information format can be:

[0045] DRV_LOG_ERROR("[0x%08x]-[DWSdk.errorcode=0x%08x]Init DwSDKfilded", DRV_INIT_FAILED, initRet).

[0046] As can be seen from the above, the log data obtained by filtering according to the log filtering conditions is a seemingly meaningless and messy string. It is obviously difficult to analyze countless such log data.

[0047] Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all the action stream data of consumers in the website.

[0048] Step 204, periodically read the data to be converted from Kafka, perform cutting and matching processing on the read data to be converted according to preset slicing conditions to obtain a text sequence to be determined, and write the text sequence to be determined into a preset data table on HBase.

[0049] Optionally, you can pull the data to be converted from the specified path on Kafka every 5 seconds or 25 seconds, and cut and match the data to be converted according to the preset slicing conditions. The specific duration of the timing depends on the amount of data. For example, if the amount of data is large, you can pull it every 5 seconds for display. If the log data is generated slowly, you can pull the data to be converted every 25 seconds. There will be no delay here.

[0050] Furthermore, the spark operator can be used to perform cutting and matching operations on the read data to be converted, and the data to be converted can be divided into small strings, each of which has its own meaning, and the strings obtained after cutting are used as string sequences, and then the string sequences are interpreted and matched to obtain the text sequence to be determined. Then the text sequence to be determined is written into the preset database table on hbase. The main abstraction provided by Spark is the Resilient Distributed Dataset (RDD), which is a collection of elements partitioned across cluster nodes and can be operated in parallel. Spark operators are divided into conversion operators and Action operators. Action operators will form a job, converting an RDD into another RDD, or converting file system data into an RDD.

[0051] The preset slicing condition is the standard for slicing the data to be converted. It depends on the specific format or type of the data to be converted. Because the data to be converted can be log data customized by the developer, and the format and type are also predefined, after the logs to be converted are screened out, the data to be converted can be directly sliced ​​and matched according to the preset slicing condition.

[0052] Optionally, when the data to be converted is 'weblogic_acc appName, agent Nanning 0.012 17:53:54 -GET 675 200 / life / selfhire.getAccountInfo 202.103.238.166', patterns can also be found in the data to be converted, and it can be found that the data to be converted includes multiple strings, and the strings are separated by space characters ' / t'. Then, the data to be converted can be cut with the space character as the cutting point, and the attribute values ​​can be matched for the strings obtained after cutting to obtain the text sequence to be determined.

[0053] Then write the text sequence to be determined into hbase. The Hbase data storage format can be value = {"appType":"weblogic_acc","appName":"","xForwardedFor":"","agent":"", "city":"Nanning","accTime":"0.012","connectTime":"17:53:54","source":"", "method":"GET","connectByte":"675","status":"200","requestURL": " / life / selfhire.getAccountInfo","clientIp":"202.103.238.166"......};

[0054] It can be seen that the data is stored in hbase in the form of a dictionary. Each text sequence to be determined is a dictionary, corresponding to the attributes and attribute values.

[0055] Step 206: Generate a structural data soft link pointing to the preset database table for Hive according to the storage path of the preset data table on HBase.

[0056] A link is a method of establishing a connection between a shared file and several directory entries of the user accessing it. A soft link is also called a symbolic link. This file contains the path name of another file. It can be any file or directory, and can link files in different file systems. It is similar to a shortcut under Windows. It saves the absolute path of the file it represents. It is another type of file that has an independent block on the hard disk and replaces its own path when accessed.

[0057] Hbase is not suitable for complex SQL query, so the data should be written to hive for subsequent query and analysis. However, due to the limitations of hive, it is not possible to pull data directly from hbase to hive, so a soft link needs to be established to create conditions for writing data into hive.

[0058] Step 208: The text sequence to be determined obtained according to the soft link of the structured data is segmented by a regular expression, and the structured data obtained after the segmentation is written into a structured database on Hive.

[0059] Specifically, the processing of the text sequence to be determined may be to remove ideographic symbols in the text sequence to be determined and only take numerical values ​​or character strings with representative meanings.

[0060] Furthermore, the specified characters searched from the to-be-determined text sequence are replaced with preset cutting characters, and the to-be-determined text sequence is cut at the preset cutting characters.

[0061] Specifically, after obtaining the to-be-determined text sequence from the structural soft link, the to-be-determined text sequence is processed by means of json_tuple(), and the specific processing steps are as follows:

[0062] Get the text sequence to be determined, remove meaningless characters such as brackets, curly brackets or double quotes in the text sequence to be determined, and replace them with specified symbols, such as replacing "},{" with double vertical bars "|,|"; split the data at the double vertical bars into multiple small strings, output them, obtain structured data, and write them into the structured database on hive to complete the storage operation of structured data. This application writes structured data into the internal database of hive, which will improve the performance of data storage by more than 10 times compared with traditional methods, and provides structured system-generated user access logs to the hive database in real time, which can further analyze the structured logs and tap the value of the logs.

[0063] In the above data real-time storage method, the collected log data is classified and processed, and the classified log data that meets the log screening conditions is written into Kafka for buffering, and the log data read from Kafka is segmented to obtain a string sequence, and then the key value text sequence is matched for the segmented string sequence with unknown meaning, and then the data is stored in structured data in real time through Hbase to obtain structured data. Among them, before the data is input into Hive for storage, it is necessary to buffer the data through Hbase to prevent data congestion when processing massive data, and delay in writing data to Hive, so as to solve the technical problem that users cannot perform real-time analysis on log data.

[0064] In one embodiment, Figure 3 As shown, step 204 includes:

[0065] Step 302: Determine the slicing points of the data to be converted according to preset slicing conditions.

[0066] The slicing point is extracted from the preset slicing condition according to the data to be converted. For example, every two strings in the data to be converted are distinguished by "\t" to prevent string adhesion. In this case, "\t" can be used as the slicing point of the data to be converted, and the "\t" slicing point can be extracted from the preset slicing condition. All positions of the slicing point in the data to be converted are located, and the data to be converted is cut according to the located data to obtain a sequence of strings one by one.

[0067] Further, the character string that appears most frequently in the data to be converted is used as the slicing point. Optionally, the character string that appears most frequently in the data to be converted can be used as the slicing point, which depends on the type of the data to be converted. Generally, the character string that appears most frequently is the slicing point included in the preset slicing condition.

[0068] Step 304: locate the position coordinates of the slicing point in the data to be converted, and cut the data to be converted into a string sequence according to the position coordinates.

[0069] Splitting the transformed data according to the slicing points generally does not cause damage to the required data, such as cutting a single string into two strings.

[0070] Step 306: Obtain a key-value text sequence corresponding to the string sequence according to a preset matching condition and associate the key-value text sequence with the string sequence to obtain the text to be determined.

[0071] Generally, the key-value text sequence is pre-written into the preset configuration file by the developer, and the preset matching condition is included in the preset matching condition. The key-value text sequence is obtained according to the preset matching condition, and the identifier of the key-value text sequence is obtained, and the string sequence corresponding to the identifier is associated with the key-value text sequence to obtain the text sequence to be determined.

[0072] This embodiment performs a cutting and matching operation on the data to be converted to match a key-value text sequence for a string sequence obtained from a string of meaningless and irregular data, so that a string sequence whose meaning was originally unknown has corresponding attributes, a text sequence to be determined is obtained, and the meaning of each string in the log data is clarified.

[0073] In one embodiment, Figure 4 As shown, step 302 includes:

[0074] Step 402: The occurrence frequency of each character string in the same row of data to be converted is used as a frequency array, and the variance of the frequency array is calculated.

[0075] Traverse the data to be converted and obtain each string in the data to be converted, and list the frequency of each string appearing in the same row of data to be converted as an array. If there are 20 rows of data to be converted, the number of frequencies of the same string appearing in these 20 rows of data to be converted is used as an array as frequency data, and the variance of the frequency data is calculated.

[0076] Step 404: If the variance of the frequency group is less than a specific value, the character string is used as a slicing point.

[0077] If the variance satisfies a certain threshold, the string can be considered as a separator, and the separator can be used as a slicing point. Of course, this is only one way to obtain slicing points. Generally, after determining the slicing point according to the preset slicing conditions, the slicing point can be verified according to this method to increase the accuracy of the data to be converted.

[0078] This embodiment determines the segmentation point by calculating the frequency of occurrence of the character string in the data to be converted, so that the determined segmentation point is more accurate, thereby increasing the accuracy of segmenting the data to be converted.

[0079] In one embodiment, Figure 5 As shown, step 306 includes:

[0080] Step 502: Obtain a key-value text sequence of a character string sequence and an identifier of the key-value text sequence.

[0081] Each string sequence has a corresponding key-value text sequence, but the string sequence needs to be matched with the key-value text sequence, so the application can determine which string sequence corresponds to which key-value text sequence by obtaining the identifiers of the string sequence and the key-value text sequence.

[0082] When generating a string sequence, the database generates a row mark for each string sequence, which can be used as an identifier of the string sequence. Then, the identifier of the part-time text sequence that is consistent with the identifier is obtained for association.

[0083] Step 504: assign the string sequence corresponding to the identifier to the key-value text sequence.

[0084] Specifically, after obtaining a string sequence and a key-value text sequence that are consistent with the identifier, the string sequence can be assigned to the key-value text sequence as the text to be determined.

[0085] This embodiment performs a cutting and matching operation on the data to be converted, matches the key value text sequence to the string sequence obtained from a string of meaningless and irregular data, so that the string sequence whose meaning is originally unknown has the corresponding attribute, and obtains the text sequence to be determined. And matching and associating by judging the consistency of the identifier is very convenient and fast, which improves the calculation and matching efficiency.

[0086] In one embodiment, Figure 6 As shown, step 202 includes:

[0087] Step 602: Obtain format keywords from the collected log data, and classify the log data according to the format keywords to obtain classified log data.

[0088] The format keyword can be a keyword indicating the level of log data, for example, debug log data: all detailed information, used for debugging; info: some key jumps, logs that prove the normal operation of the software; warning: indicating that some accidents have occurred and the software cannot handle them, but it can still run normally; error: due to some serious problems, the software cannot perform some functions normally, but it can still run; critical / fatal: very serious errors, the software can no longer run. Some are log information formats set by developers themselves. For example, the above mentioned: weblogic_acc appName, agent Nanning 0.012 17:53:54-GET 675 200 / life / selfhire.getAccountInfo202.103.238.166, such log data needs to be structured, otherwise it is just a meaningless string, and analysts cannot get usable information based on such a string of irregular strings.

[0089] Therefore, the meaningless and irregular log data mentioned above can be classified according to the level of the main daily data, or according to the unique distinguishing keywords in different types of logs. It can be determined according to the specific situation and is not limited here.

[0090] Step 604, log data that meets the log screening condition is obtained from the classified log data as the data to be written, and the data to be written is written into Kafka according to the collection path of the data to be written. For example, if the log data that meets the daily screening condition includes a special keyword, the log data can be regarded as the data to be written that meets the log screening condition, and the data to be written is written into Kafka for buffer storage.

[0091] Through this embodiment, by first classifying the collected log data according to level, format, type or special keywords before filtering the log data, and then filtering it, it is possible to avoid unnecessary server memory usage caused by repeated filtering operations when filtering the log data, thereby improving the efficiency of log data filtering.

[0092] It should be understood that although Figure 2-Figure 6 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-Figure 6 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages do not necessarily have to be executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages does not have to be sequentially, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0093] In one embodiment, Figure 7 As shown, a real-time data storage device is provided, which corresponds one-to-one to the real-time data storage method in the above embodiment. The real-time data storage device includes:

[0094] The data buffer module 702 is used to read the preset configuration file to obtain the log filtering conditions, obtain the log data that meets the log filtering conditions from the collected log data, and write the obtained log data into Kafka according to the preset configuration file as the data to be converted.

[0095] The sequence matching module 704 is used to periodically read the data to be converted from Kafka, perform segmentation and matching processing on the read data to be converted according to preset segmentation conditions to obtain the text sequence to be determined, and write the text sequence to be determined into a preset data table on HBase.

[0096] The link pointing module 706 is used to generate a structural data soft link pointing to the preset database table for hive according to the storage path of the preset data table on hbase.

[0097] The structuring module 708 is used to perform segmentation processing on the to-be-determined text sequence obtained according to the soft link of the structured data through a regular expression, and write the structured data obtained after the segmentation processing into the structured database on the hive.

[0098] Furthermore, the sequence matching module 704 includes:

[0099] A slicing point determination submodule is used to determine the slicing points of the data to be converted according to preset slicing conditions;

[0100] The data cutting submodule is used to locate the position coordinates of the slicing point in the data to be converted, and cut the data to be converted into a string sequence according to the position coordinates.

[0101] The sequence association submodule is used to obtain the key-value text sequence corresponding to the string sequence according to the preset matching condition and associate it to obtain the text to be determined.

[0102] Furthermore, the slicing point determination submodule includes:

[0103] The frequency calculation unit is used to take the occurrence frequency of each string in the same row of data to be converted as a frequency array and calculate the variance of the frequency array.

[0104] The first slicing confirmation unit is used to use the character string as a slicing point if the variance of the frequency group is less than a specific value.

[0105] Furthermore, the slicing point determination submodule further includes:

[0106] The second slicing confirmation unit is used to use the character string that appears most frequently in the data to be converted as a slicing point.

[0107] Furthermore, the sequence association submodule includes:

[0108] The identification acquisition unit is used to acquire a key-value text sequence of a character string sequence and an identifier of the key-value text sequence.

[0109] The attribute assignment unit is used to assign the string sequence corresponding to the identifier to the key-value text sequence.

[0110] Furthermore, the structural module 708 includes:

[0111] The data classification submodule is used to obtain format keywords from the collected log data, and classify the log data according to the format keywords to obtain classified log data.

[0112] The data screening submodule is used to obtain the log data that meets the log screening conditions from the classified log data as the data to be written, and write the data to be written into Kafka according to the collection path of the data to be written.

[0113] Furthermore, the structuring module 708 further includes:

[0114] The cutting processing submodule is used to replace the specified characters searched from the text sequence to be determined with preset cutting characters, and to cut the text sequence to be determined at the preset cutting characters.

[0115] The above-mentioned real-time data storage device classifies the collected log data, writes the classified log data that meets the log screening conditions into Kafka for buffering, and splits the log data read from Kafka to obtain a string sequence, then matches the key value text sequence for the meaningless string sequence after the splitting, and then stores the data in structured data in real time through HBase to obtain structured data. Among them, before the data is input into Hive for storage, it is necessary to buffer the data through HBase to prevent data congestion when processing massive data, and delay the data written into Hive, so as to solve the technical problem that users cannot perform real-time analysis on log data.

[0116] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store user order data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a real-time data storage method is implemented.

[0117] Among them, technicians in this technical field can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0118] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0119] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the real-time data storage method in the above embodiment are implemented, such as Figure 2 Steps 202 to 208 shown in the figure, or when the processor executes the computer program, the functions of each module / unit of the real-time data storage device in the above embodiment are realized, for example Figure 7 The functions of modules 702 to 708 are shown in Figure 7. To avoid repetition, they are not described here again.

[0120] In one embodiment, a computer-readable storage medium is provided on which a computer program is stored. When the computer program is executed by a processor, the steps of the real-time data storage method in the above embodiment are implemented, such as Figure 2 Steps 202 to 208 shown in the figure, or when the processor executes the computer program, the functions of each module / unit of the real-time data storage device in the above embodiment are realized, for example Figure 7 The functions of modules 702 to 708 are shown in Figure 7. To avoid repetition, they are not described here again.

[0121] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0122] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0123] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0124] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for those of ordinary skill in the art, without departing from the concept of the present application, several modifications, improvements or equivalent replacements of some technical features can be made, and these modifications or replacements do not make the essence of the same technical solution depart from the spirit and scope of the technical solution of each embodiment of the present invention, and all belong to the protection scope of the present application. Therefore, the protection scope of the patent of this application shall be subject to the attached claims.

Claims

1. A real-time data storage method, characterized in that: include: Read the preset configuration file to obtain the log filtering condition, obtain the log data that meets the log filtering condition from the collected log data, and write the obtained log data into Kafka according to the preset configuration file as the data to be converted; Read the data to be converted from Kafka at regular intervals, perform cutting and matching processing on the data to be converted according to preset slicing conditions to obtain a text sequence to be determined, and write the text sequence to be determined into a preset data table on HBase; Generate a structural data soft link pointing to a preset database table for hive according to the storage path of the preset data table on the hbase; Performing a segmentation process on the to-be-determined text sequence obtained according to the structural data soft link by using a regular expression, and writing the structural data obtained after the segmentation process into the structural database on the hive; The step of performing a cutting and matching process on the read data to be converted according to a preset slicing condition to obtain a text sequence to be determined includes: Determining the slicing points of the data to be converted according to the preset slicing conditions; Locating the position coordinates of the slicing point in the data to be converted, and cutting the data to be converted into a string sequence according to the position coordinates; According to the preset matching condition, a key-value text sequence corresponding to the string sequence is obtained and associated to obtain the text to be determined; The step of obtaining and associating a key-value text sequence corresponding to the string sequence according to a preset matching condition includes: Obtain a key-value text sequence of the string sequence and an identifier of the key-value text sequence; Assigning the string sequence corresponding to the identifier to the key-value text sequence; The cutting process of the to-be-determined text sequence obtained according to the structural data soft link by using a regular expression includes: The specified characters searched from the to-be-determined text sequence are replaced with preset cutting characters, and the to-be-determined text sequence is cut at the preset cutting characters.

2. The method according to claim 1, characterized in that The step of determining the slicing points of the data to be converted according to the preset slicing conditions includes: The occurrence frequency of each character string in the same row of the data to be converted is taken as a frequency array, and the variance of the frequency array is calculated; If the variance of the frequency group is less than a specific value, the character string is used as the slicing point.

3. The method according to claim 1, characterized in that The step of determining the slicing points of the data to be converted according to the preset slicing conditions includes: The character string that appears most frequently in the data to be converted is used as the slicing point.

4. The method according to claim 1, characterized in that: The step of acquiring log data that meets the log screening condition from the collected log data, and writing the acquired log data into Kafka according to the preset configuration file, includes: Acquiring format keywords from the collected log data, and classifying the log data according to the format keywords to obtain classified log data; Log data that meets the log screening condition is obtained from the classified log data as the data to be written, and the data to be written is written into Kafka according to the collection path of the data to be written.

5. A real-time data storage device, characterized in that: The steps of implementing the method according to any one of claims 1 to 4 when the real-time data storage device is executed include: A data buffer module is used to read a preset configuration file to obtain a log screening condition, obtain log data that meets the log screening condition from the collected log data, and write the obtained log data into Kafka according to the preset configuration file as data to be converted; The sequence matching module is used to periodically read the data to be converted from Kafka, perform segmentation and matching processing on the read data to be converted according to preset segmentation conditions to obtain a text sequence to be determined, and write the text sequence to be determined into a preset data table on HBase; A link pointing module, used for generating a structural data soft link pointing to the preset database table for Hive according to the storage path of the preset data table on the HBase; The structuring module is used to perform a segmentation process on the to-be-determined text sequence obtained according to the soft link of the structural data through a regular expression, and write the structured data obtained after the segmentation process into the structured database on the hive.

6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.