CN112905707A - Method and device for synchronizing relational database and search engine and computer storage medium - Google Patents
Method and device for synchronizing relational database and search engine and computer storage medium Download PDFInfo
- Publication number
- CN112905707A CN112905707A CN202110347559.1A CN202110347559A CN112905707A CN 112905707 A CN112905707 A CN 112905707A CN 202110347559 A CN202110347559 A CN 202110347559A CN 112905707 A CN112905707 A CN 112905707A
- Authority
- CN
- China
- Prior art keywords
- log file
- relational database
- search engine
- data
- database
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F16/275—Synchronous replication
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/34—Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
- G06F11/3466—Performance evaluation by tracing or monitoring
- G06F11/3476—Data logging
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a method and a device for synchronizing a relational database and a search engine and a computer storage medium. The method comprises the following steps: establishing a first link, and sending a slave server data request to a master server where a relational database is located so as to enable the master server to push a log file, wherein the log file is generated by modifying the relational database through the master server; acquiring a log file pushed by the main server by using the first link; establishing a second link, and sending a database connection request to the relational database to acquire a plurality of field names associated with the log file; determining the field name of the latest version according to the acquired field names; analyzing the log file by using the field name of the latest version to obtain an analysis result; and pushing the analysis result to a search engine.
Description
Technical Field
The present invention relates to the field of data, and in particular, to a method and apparatus for synchronizing a relational database with a search engine, and a computer storage medium.
Background
At present, a relational database is a mainstream storage mode of an online system, but the relational database cannot support indexes, particularly multi-field random combination indexes and full indexes. Search engines are therefore often introduced to do searches, which raises the problem of synchronizing the relational database with the search engine. One solution to this problem is a double write mode, i.e., data is stored in both the relational database and the search engine. The method ensures that the writing relation database and the writing search engine in the code are atomicity, and once a success and a failure occur, data inconsistency is caused. The other scheme is a database CDC (Change Data Capture) mechanism, which implements index consistency by retry and the like, and mainly achieves a non-intrusive manner through middleware. However, the problem of database log file analysis can be solved by the method, and the problem of search engine synchronization is not solved.
Disclosure of Invention
The invention aims to provide a method, a device and a computer storage medium for synchronizing a relational database and a search engine, which can solve the problem of synchronization of the relational database and the search engine.
In order to solve the above technical problem, the present invention provides a method for synchronizing a relational database and a search engine, which is executed at a listening component, and the method comprises the following steps: establishing a first link, and sending a slave server data request to a master server where a relational database is located so as to enable the master server to push a log file, wherein the log file is generated by modifying the relational database through the master server; acquiring a log file pushed by the main server by using the first link; establishing a second link, and sending a database connection request to the relational database to acquire a plurality of field names associated with the log file; determining the field name of the latest version according to the acquired field names; analyzing the log file by using the field name of the latest version to obtain an analysis result; and pushing the analysis result to a search engine.
In an embodiment of the present invention, the step of parsing the log file using the latest version field name includes: and establishing a mapping relation between the field name of the latest version and corresponding data in the log file.
In an embodiment of the present invention, the method further includes recording a position when the log file is parsed, where the position indicates a starting position of a next parsing.
In an embodiment of the invention, the method further includes saving the field names and the sites as metadata.
In an embodiment of the present invention, the method further includes: providing configuration options of a plurality of storage positions, wherein each storage position comprises a memory and a database; and saving the metadata to a corresponding saving position according to the selection of the configuration option.
In an embodiment of the present invention, the step of pushing the parsing result to a search engine includes: pushing the analysis result to a message middleware; monitoring data sent by the message middleware; and forwarding the data to the search engine.
In an embodiment of the present invention, the method further includes: and querying the relational database in full, and integrally synchronizing the data of the target table in the relational database into the corresponding index of the search engine.
In an embodiment of the present invention, the method further includes analyzing the log file obtained offline, and performing a reverse check on the latest data in the log file from the relational database according to an analysis result.
The invention also provides a device for synchronizing the relational database and the search engine, which comprises a monitoring component configured to: establishing a first link, and sending a slave server data request to a master server where a relational database is located so as to enable the master server to push a log file, wherein the log file is generated by modifying the relational database through the master server; acquiring a log file pushed by the main server by using the first link; establishing a second link, and sending a database connection request to the relational database to acquire a plurality of field names associated with the log file; determining the field name of the latest version according to the acquired field names; analyzing the log file by using the field name of the latest version to obtain an analysis result; and pushing the analysis result to a search engine.
In an embodiment of the present invention, the apparatus further includes a message middleware, wherein the listening component is further configured to push the parsing result to a search engine in the following manner: pushing the analysis result to a message middleware; monitoring data sent by the message middleware; and forwarding the data to the search engine.
In an embodiment of the present invention, the listening component is further configured to: and querying the relational database in full, and integrally synchronizing the data of the target table in the relational database into the corresponding index of the search engine.
In an embodiment of the present invention, the listening component is further configured to: and analyzing the log file acquired offline, and reversely checking the latest data in the log file from the relational database according to the analysis result.
The invention also provides a device for synchronizing the relational database and the search engine, which comprises: a memory for storing instructions executable by the processor; and a processor for executing the instructions to implement the method as described above.
The invention also proposes a computer storage medium having stored computer program code which, when executed by a processor, implements the method as described above.
Compared with the prior art, the method and the device can send the data request to the main server where the relational database is located in a slave server mode through the monitoring component, so that the incremental log file is obtained. And the field name corresponding to the log file is obtained through the monitoring component, so that the analysis of the incremental log file is realized. And sending the analysis result to a search engine, thereby realizing the synchronization of the relational database and the search engine.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the principle of the invention. In the drawings:
fig. 1 is a block diagram of a system architecture according to an embodiment of the present application.
FIG. 2 is a flow chart of a method for synchronizing a relational database with a search engine according to an embodiment of the present application.
FIG. 3 is a flow chart of a method for synchronizing a relational database with a search engine according to another embodiment of the present application.
FIG. 4 is a hardware implementation environment of a synchronization apparatus for a relational database and a search engine according to an embodiment of the present application.
Detailed Description
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings used in the description of the embodiments will be briefly introduced below. It is obvious that the drawings in the following description are only examples or embodiments of the application, from which the application can also be applied to other similar scenarios without inventive effort for a person skilled in the art. Unless otherwise apparent from the context, or otherwise indicated, like reference numbers in the figures refer to the same structure or operation.
As used in this application and the appended claims, the terms "a," "an," "the," and/or "the" are not intended to be inclusive in the singular, but rather are intended to be inclusive in the plural unless the context clearly dictates otherwise. In general, the terms "comprises" and "comprising" merely indicate that steps and elements are included which are explicitly identified, that the steps and elements do not form an exclusive list, and that a method or apparatus may include other steps or elements.
The relative arrangement of the components and steps, the numerical expressions, and numerical values set forth in these embodiments do not limit the scope of the present application unless specifically stated otherwise. Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description. Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate. In all examples shown and discussed herein, any particular value should be construed as merely illustrative, and not limiting. Thus, other examples of the exemplary embodiments may have different values. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
It should be noted that the terms "first", "second", and the like are used to define the components, and are only used for convenience of distinguishing the corresponding components, and the terms have no special meanings unless otherwise stated, and therefore, the scope of protection of the present application is not to be construed as being limited. Further, although the terms used in the present application are selected from publicly known and used terms, some of the terms mentioned in the specification of the present application may be selected by the applicant at his or her discretion, the detailed meanings of which are described in relevant parts of the description herein. Further, it is required that the present application is understood not only by the actual terms used but also by the meaning of each term lying within.
It will be understood that when an element is referred to as being "on," "connected to," "coupled to" or "contacting" another element, it can be directly on, connected or coupled to, or contacting the other element or intervening elements may be present. In contrast, when an element is referred to as being "directly on," "directly connected to," "directly coupled to" or "directly contacting" another element, there are no intervening elements present. Similarly, when a first component is said to be "in electrical contact with" or "electrically coupled to" a second component, there is an electrical path between the first component and the second component that allows current to flow. The electrical path may include capacitors, coupled inductors, and/or other components that allow current to flow even without direct contact between the conductive components.
Fig. 1 is a block diagram of a system architecture according to an embodiment of the present application. Referring to FIG. 1, a system 100 may have a host server 101 having a database 101a and a disk 101b, the database 101a being, for example, a host database for storing data. The data 11 in the database 101a is modified during use by the host server 101, and a log file 12 is generated and stored in the disk 101 b. The monitoring component 103 can obtain the log file 12, and perform parsing after obtaining the log file 12, so as to obtain a parsing result. Here, the database 101a is a relational database such as MySQL, for example, and the log file 12 is a binlog file, for example, which is in a regular binary format.
In one aspect, listening component 103 queries database 101a in its entirety to synchronize the data of the target table in database 101a in its entirety into the corresponding index of search engine 102. For example, the data for the entire table is synchronized into the corresponding index of search engine 102 through the pattern of "select x from db.tb". When the data size of the full query is very large, for example, more than ten million data, the memory of the system cannot store such large data. Therefore, according to an embodiment of the application, a scheme of multi-query in a range is adopted. For example: "select from db. tb where id > -10000 and id < 10100", define the range of query id at each query. In contrast, conventional page flip queries have the problem of deep page flip queries, resulting in a high processor occupancy and impact on-line usage.
In another aspect, listening component 103 listens to database 101a for incremental data on a continuous basis. More specifically, listening component 103 will internally establish a first link for sending a data request to the master server 101 where the master database 101a is located. The data request is, for example, a dump request in MySQL. In one embodiment, listening component 103 sends the dump request using a replication protocol. Thus, the master server 101 appears to receive the data request transmitted from the slave server. In response to the data request, server 200 may continue to actively push incremental log files 12 to listening component 103. In some embodiments, the intervals between pushes may reach a real-time level on the order of milliseconds. Thus, listening component 103 can continuously obtain log file 12 pushed by primary server 101 using the first link.
For obtaining the data modified by the database 101a, it is conventionally implemented by active message pushing of the business logic. Alternatively, an interceptor is used to push data to be computed to message middleware 105. However, if other business logic is developed later, pushing of a message of the new business logic is forgotten, which may result in incomplete data. In addition, if the data needs to be revised manually to the database due to some logic exception, the message is incomplete. There are also old module modifications that certainly result in incomplete data when not familiar with old logic. In the embodiment of the present application, the interception component 103 intercepts at the database level, so that the problem of incomplete messages does not occur.
It should be noted that only the value of the data is saved in the log file 12, the field corresponding to the data is not saved, and the field name is changed continuously in the actual operation, so that the field name acquisition and management become important. To this end, in accordance with an embodiment of the present application, listening component 103 establishes a second link, sending a database connection request to database 101a to obtain a plurality of field names associated with the log file. The database connection request may include a target table name by which the field name may be queried. In one embodiment, the Database connection request may be a jdbc (java Database connectivity) request. Listening component 103 determines the latest version field name from the acquired plurality of field names. Specifically, if the field name is not stored in the monitoring component 103, the obtained latest field name is used as the field name of the latest version; if the field name is stored by the monitoring component 103, the stored field name is directly used as the field name of the latest version; if the database 101a provides a form of the modification table, the latest version of the field name is requested from the database 101 a.
In one embodiment, upon receiving log file 12, listening component 103 parses log file 12 using the latest version field name, producing a parsed result. In one embodiment, log file 12 is in a regular binary format and listening component 103 parses incremental log file 14 into human-understandable string data. And the step of parsing includes establishing a mapping relationship between the latest version field name and the corresponding data in the log file 12. The parsing result includes field names and data mapped thereto.
In one embodiment, listening component 103 records the location at which log file 12 was parsed. The position indicates the starting position of the next resolution. In this way, when the listening component 103 can analyze at a new time, the end position of the previous analysis is used as the start position of the current analysis, and the analysis is continued. The sites comprise a collection of data needed by two positioning modes, namely a file name + bias and a GTID (Global Transaction Identifier). In one embodiment, the High Availability (HA) requirements of different scenarios can be met by integrating the collections into one complete piece of location information.
The location and the plurality of field names are stored as metadata for parsing. In one embodiment, configuration options for multiple storage locations are provided. For example, the storage locations include memory and databases. The database may include various types of databases, such as MySQL, H2DB, and so forth. And saving the metadata to the corresponding saving position according to the selection of the configuration option. For example, for upper layer applications, memory storage is more convenient to use. The use of MySQL saves scenarios appropriate for the need to build a separate library, and the use of H2DB saves scenarios appropriate for saving in file form without relying on permissions.
In one embodiment, listening component 103 pushes the parsing results to search engine 102. The search engine 102 may analyze, structure, etc. the parsed results and then store the parsed results in the management database 104. In another embodiment, if the parsed results do not need to be processed, they can also be pushed directly by listening component 103 into management database 104 for access by search engine 102. In one embodiment, the search engine 102 comprises an elastic search.
When the data of database 101a is not used solely to synchronize search engine 102, the data may be provided to message middleware 105. In one embodiment, listening component 103 pushes the results of the parsing to message middleware 105. Thereafter, listening component 103 listens for data sent by message middleware 105 and forwards the data to search engine 102. One portion of the data of message middleware 105 may be used directly by search engine 102 and another portion may be shared by one or more other parties, such as service 106. In one embodiment, the push of listening component 103 to message middleware 105 may be real-time, with delays as low as milliseconds. In one embodiment, the listening component 103 serializes the parsing results and then pushes the serialized parsing results to the message middleware 105 to speed up the transmission speed. Message middleware 105 stores the forwarded data and does not perform any further processing. The listening component 103 performs deserialization before forwarding the data from the message middleware 105 to the search engine 102 and then imports the data into the search engine 102. Due to differences in the design of database 101a and search engine 102, in one embodiment, a mapping rule is established between the two, i.e., to which field of search engine 102 the field of database 101a corresponds. When two or more table associations (e.g., parent-child relationships) are to be supported, it is necessary to consider how multiple tables enter the index of search engine 102 as a rule. Here, the data in the multiple tables is stored in the document under the index. In one embodiment, a Join (Join) field may be created in search engine 102 indicating an associative relationship between documents corresponding to two or more tables. In another embodiment, a document may include data for multiple associated tables, with the update data for each table being synchronized in real time to a portion of the document via local updates.
On the other hand, when a synchronization problem or a peak occurs, an offline resolution function is introduced. In one embodiment, the log file 12 can be obtained offline and downloaded to the computer where the listening component 103 is located, and the listening component 103 parses the log file obtained offline. Further, the listening component 103 looks back up the latest data in the log file to the database 101a according to the parsing result, thus ensuring that the new data is not overwritten by the old data.
FIG. 2 is a flow chart of a method for synchronizing a relational database with a search engine according to an embodiment of the present application. Referring to fig. 2, from another perspective, a method for synchronizing a relational database with a search engine according to the present application includes the following steps:
in step 201, a first link is established, and a slave server data request is sent to a master server where a relational database is located, so that the master server pushes a log file, and the log file is generated by modifying the relational database by the master server.
Referring to fig. 1, the listening component 103 establishes a first link, sends a slave server data request to the master server 101 for listening, and the master server 101 pushes the log file 12. Log file 12 results from host server 12 modifying database 101 a.
In step 202, a log file pushed by the main server is obtained using the first link.
Referring to fig. 1, the listening component 103 uses a first link to obtain the log file 12 pushed by the main server 101.
At step 203, a second link is established, and a database connection request is sent to the relational database to obtain a plurality of field names associated with the log file.
Referring to FIG. 1, listening component 103 establishes a second link and sends a database connection request to database 101a to obtain a plurality of field names associated with log file 12.
In step 204, the latest version field name is determined from the acquired plurality of field names.
In step 205, the log file is parsed using the latest version field name to obtain a parsing result.
In step 206, the parsed results are pushed to a search engine.
Referring to FIG. 1, listening component 103 pushes the parsing results to search engine 102.
FIG. 3 is a flow chart of a method for synchronizing a relational database with a search engine according to another embodiment of the present application. Referring to fig. 3, from another perspective, a method for synchronizing a relational database with a search engine according to the present application includes the following steps:
in step 301, a first link is established, and a slave server data request is sent to a master server where a relational database is located, so that the master server pushes a log file, and the log file is generated by modifying the relational database by the master server.
Referring to fig. 1, the listening component 103 establishes a first link, sends a slave server data request to the master server 101 for listening, and the master server 101 pushes the log file 12. Log file 12 results from host server 12 modifying database 101 a.
In step 302, a log file pushed by a main server is obtained by using a first link.
Referring to fig. 1, the listening component 103 uses a first link to obtain the log file 12 pushed by the main server 101.
At step 303, a second link is established and a database connection request is sent to the relational database to obtain a plurality of field names associated with the log file.
Referring to FIG. 1, listening component 103 establishes a second link and sends a database connection request to database 101a to obtain a plurality of field names associated with log file 12.
In step 304, the latest version field name is determined from the acquired plurality of field names.
In step 305, the log file is parsed using the latest version field name to obtain a parsing result.
At step 306, the parsing result is pushed to the message middleware.
Referring to FIG. 1, listening component 103 sends the results of the parsing to message middleware.
In step 307, data sent by the message middleware is listened to.
As shown in fig. 1, the listening component listens for data sent by message middleware 105.
At step 308, the data is forwarded to the search engine.
Referring to FIG. 1, listening component 103 forwards data sent by message middleware 105 to search engine 102.
Further details of the method can be found in the description above and will not be further elaborated upon here.
Flow charts are used herein to illustrate operations performed by systems according to embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in the exact order in which they are performed. Rather, various steps may be processed in reverse order or simultaneously. Meanwhile, other operations are added to or removed from these processes.
FIG. 4 is a hardware implementation environment of a synchronization device for a relational database and a search engine according to an embodiment of the present application. Device 300 may include an internal communication bus 401, a Processor (Processor)402, a Read Only Memory (ROM)403, a Random Access Memory (RAM)404, and a communication port 405. When implemented on a personal computer, the apparatus 400 may also include a hard disk 407. An internal communication bus 401 may enable data communication among the components of the apparatus 400. The processor 402 may make the determination and issue the prompt. In some embodiments, processor 402 may be comprised of one or more processors. The communication port 405 may enable data communication of the apparatus 400 with the outside. In some embodiments, the device 400 may send and receive information and data from a network through the communication port 405. The apparatus 400 may also include various forms of program storage units and data storage units such as a hard disk 407, Read Only Memory (ROM)403 and Random Access Memory (RAM)404, capable of storing various data files for computer processing and/or communication, as well as possible program instructions for execution by the processor 402. The processor executes these instructions to implement the main parts of the method. The result processed by the processor is transmitted to the terminal equipment through the communication port and displayed on the user interface.
The synchronization method described above can be implemented as a computer program, stored in the hard disk 407, and can be recorded in the processor 402 for execution to implement the synchronization method of the present application.
Having thus described the basic concept, it will be apparent to those skilled in the art that the foregoing disclosure is by way of example only, and is not intended to limit the present application. Various modifications, improvements and adaptations to the present application may occur to those skilled in the art, although not explicitly described herein. Such modifications, improvements and adaptations are proposed in the present application and thus fall within the spirit and scope of the exemplary embodiments of the present application.
Also, this application uses specific language to describe embodiments of the application. Reference throughout this specification to "one embodiment," "an embodiment," and/or "some embodiments" means that a particular feature, structure, or characteristic described in connection with at least one embodiment of the present application is included in at least one embodiment of the present application. Therefore, it is emphasized and should be appreciated that two or more references to "an embodiment" or "one embodiment" or "an alternative embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, some features, structures, or characteristics of one or more embodiments of the present application may be combined as appropriate.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
Aspects of the present application may be embodied entirely in hardware, entirely in software (including firmware, resident software, micro-code, etc.) or in a combination of hardware and software. The above hardware or software may be referred to as "data block," module, "" engine, "" unit, "" component, "or" system. The processor may be one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), digital signal processing devices (DAPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), processors, controllers, microcontrollers, microprocessors, or a combination thereof. Furthermore, aspects of the present application may be represented as a computer product, including computer stored program code, located in one or more computer storage media. For example, computer storage media may include, but are not limited to, magnetic storage devices (e.g., hard disk, floppy disk, magnetic tape … …), optical disks (e.g., Compact Disk (CD), Digital Versatile Disk (DVD) … …), smart cards, and flash memory devices (e.g., card, stick, key drive … …).
The computer storage medium may comprise a propagated data signal with the computer program code embodied therewith, for example, on baseband or as part of a carrier wave. The propagated signal may take any of a variety of forms, including electromagnetic, optical, and the like, or any suitable combination. A computer storage medium may be any computer storage medium that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code located on a computer storage medium may be propagated over any suitable medium, including radio, electrical cable, fiber optic cable, radio frequency signals, or the like, or any combination of the preceding.
Similarly, it should be noted that in the preceding description of embodiments of the application, various features are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure aiding in the understanding of one or more of the embodiments. This method of disclosure, however, is not intended to require more features than are expressly recited in the claims. Indeed, the embodiments may be characterized as having less than all of the features of a single embodiment disclosed above.
Numerals describing the number of components, attributes, etc. are used in some embodiments, it being understood that such numerals used in the description of the embodiments are modified in some instances by the use of the modifier "about", "approximately" or "substantially". Unless otherwise indicated, "about", "approximately" or "substantially" indicates that the number allows a variation of ± 20%. Accordingly, in some embodiments, the numerical parameters used in the specification and claims are approximations that may vary depending upon the desired properties of the individual embodiments. In some embodiments, the numerical parameter should take into account the specified significant digits and employ a general digit preserving approach. Notwithstanding that the numerical ranges and parameters setting forth the broad scope of the range are approximations, in the specific examples, such numerical values are set forth as precisely as possible within the scope of the application.
Although the present application has been described with reference to the present specific embodiments, it will be recognized by those skilled in the art that the foregoing embodiments are merely illustrative of the present application and that various changes and substitutions of equivalents may be made without departing from the spirit of the application, and therefore, it is intended that all changes and modifications to the above-described embodiments that come within the spirit of the application fall within the scope of the claims of the application.
Claims (14)
1. A method of synchronizing a relational database with a search engine, performed at a listening component, the method comprising the steps of:
establishing a first link, and sending a slave server data request to a master server where a relational database is located so as to enable the master server to push a log file, wherein the log file is generated by modifying the relational database through the master server;
acquiring a log file pushed by the main server by using the first link;
establishing a second link, and sending a database connection request to the relational database to acquire a plurality of field names associated with the log file;
determining the field name of the latest version according to the acquired field names;
analyzing the log file by using the field name of the latest version to obtain an analysis result; and
and pushing the analysis result to a search engine.
2. The method of claim 1, wherein parsing the log file using the latest version field name comprises: and establishing a mapping relation between the field name of the latest version and corresponding data in the log file.
3. The method of claim 1, further comprising recording a location when the log file is parsed, the location indicating a starting location of a next parsing.
4. The method of claim 3, further comprising saving the plurality of field names and the location as metadata.
5. The method of claim 4, further comprising:
providing configuration options of a plurality of storage positions, wherein each storage position comprises a memory and a database; and
and saving the metadata to a corresponding saving position according to the selection of the configuration option.
6. The method of claim 1, wherein pushing the parsed results to a search engine comprises:
pushing the analysis result to a message middleware;
monitoring data sent by the message middleware; and
forwarding the data to the search engine.
7. The method of claim 1, further comprising: and querying the relational database in full, and integrally synchronizing the data of the target table in the relational database into the corresponding index of the search engine.
8. The method of claim 1, further comprising parsing the log file obtained offline and recalling the latest data in the log file to the relational database according to the parsing result.
9. An apparatus for synchronizing a relational database with a search engine, comprising a listening component configured to:
establishing a first link, and sending a slave server data request to a master server where a relational database is located so as to enable the master server to push a log file, wherein the log file is generated by modifying the relational database through the master server;
acquiring a log file pushed by the main server by using the first link;
establishing a second link, and sending a database connection request to the relational database to acquire a plurality of field names associated with the log file;
determining the field name of the latest version according to the acquired field names;
analyzing the log file by using the field name of the latest version to obtain an analysis result; and
and pushing the analysis result to a search engine.
10. The apparatus of claim 9, further comprising message middleware, wherein the listening component is further configured to push the parsing results to a search engine as follows:
pushing the analysis result to a message middleware;
monitoring data sent by the message middleware; and
forwarding the data to the search engine.
11. The apparatus of claim 9, wherein the listening component is further configured to: and querying the relational database in full, and integrally synchronizing the data of the target table in the relational database into the corresponding index of the search engine.
12. The apparatus of claim 9, wherein the listening component is further configured to: and analyzing the log file acquired offline, and reversely checking the latest data in the log file from the relational database according to the analysis result.
13. A device for synchronizing a relational database with a search engine, comprising:
a memory for storing instructions executable by the processor; and
a processor for executing the instructions to implement the method of any one of claims 1-8.
14. A computer storage medium having computer program code stored thereon, which when executed by a processor implements the method of any of claims 1-8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110347559.1A CN112905707A (en) | 2021-03-31 | 2021-03-31 | Method and device for synchronizing relational database and search engine and computer storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110347559.1A CN112905707A (en) | 2021-03-31 | 2021-03-31 | Method and device for synchronizing relational database and search engine and computer storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112905707A true CN112905707A (en) | 2021-06-04 |
Family
ID=76109698
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110347559.1A Pending CN112905707A (en) | 2021-03-31 | 2021-03-31 | Method and device for synchronizing relational database and search engine and computer storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112905707A (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001034518A (en) * | 1999-07-27 | 2001-02-09 | Nec Software Chugoku Ltd | Master-slave relation information synchronization system in decentralized database |
EP2306319A1 (en) * | 2009-09-14 | 2011-04-06 | Software AG | Database server, replication server and method for replicating data of a database server by at least one replication server |
CN107180116A (en) * | 2017-06-28 | 2017-09-19 | 努比亚技术有限公司 | A kind of data synchronizing processing method, mobile terminal and computer-readable recording medium |
CN107783975A (en) * | 2016-08-24 | 2018-03-09 | 北京京东尚科信息技术有限公司 | The method and apparatus of distributed data base synchronization process |
CN108920659A (en) * | 2018-07-03 | 2018-11-30 | 广州唯品会信息科技有限公司 | Data processing system and its data processing method, computer readable storage medium |
CN110609844A (en) * | 2018-05-29 | 2019-12-24 | 优信拍(北京)信息科技有限公司 | Data updating method, device and system |
CN111026727A (en) * | 2019-10-24 | 2020-04-17 | 贝壳技术有限公司 | Table dimension retrieval data synchronization method, system and device based on log file |
CN111752939A (en) * | 2019-03-28 | 2020-10-09 | 北京京东尚科信息技术有限公司 | Data processing method, device, computer system and medium for multiple systems |
-
2021
- 2021-03-31 CN CN202110347559.1A patent/CN112905707A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2001034518A (en) * | 1999-07-27 | 2001-02-09 | Nec Software Chugoku Ltd | Master-slave relation information synchronization system in decentralized database |
EP2306319A1 (en) * | 2009-09-14 | 2011-04-06 | Software AG | Database server, replication server and method for replicating data of a database server by at least one replication server |
CN107783975A (en) * | 2016-08-24 | 2018-03-09 | 北京京东尚科信息技术有限公司 | The method and apparatus of distributed data base synchronization process |
CN107180116A (en) * | 2017-06-28 | 2017-09-19 | 努比亚技术有限公司 | A kind of data synchronizing processing method, mobile terminal and computer-readable recording medium |
CN110609844A (en) * | 2018-05-29 | 2019-12-24 | 优信拍(北京)信息科技有限公司 | Data updating method, device and system |
CN108920659A (en) * | 2018-07-03 | 2018-11-30 | 广州唯品会信息科技有限公司 | Data processing system and its data processing method, computer readable storage medium |
CN111752939A (en) * | 2019-03-28 | 2020-10-09 | 北京京东尚科信息技术有限公司 | Data processing method, device, computer system and medium for multiple systems |
CN111026727A (en) * | 2019-10-24 | 2020-04-17 | 贝壳技术有限公司 | Table dimension retrieval data synchronization method, system and device based on log file |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107818115B (en) | Method and device for processing data table | |
CN110046133B (en) | Metadata management method, device and system for storage file system | |
US8924365B2 (en) | System and method for range search over distributive storage systems | |
EP3702932A1 (en) | Method, apparatus, device and medium for storing and querying data | |
US9798762B2 (en) | Real time big data master data management | |
US20100306234A1 (en) | Cache synchronization | |
WO2009004620A2 (en) | Method and system for data storage and management | |
CN112084161B (en) | Database-based data processing method and device and readable storage medium | |
CN113220794A (en) | Method, server and computer readable medium for synchronizing query results between heterogeneous databases | |
KR102119258B1 (en) | Technique for implementing change data capture in database management system | |
US20150032689A1 (en) | Data definition language (ddl) expression annotation | |
CN113986873A (en) | Massive Internet of things data modeling processing, storing and sharing method | |
CN111046036A (en) | Data synchronization method, device, system and storage medium | |
KR20200056357A (en) | Technique for implementing change data capture in database management system | |
CN110505495A (en) | Multimedia resource takes out frame method, device, server and storage medium | |
CN114691704A (en) | Metadata synchronization method based on MySQL binlog | |
CN113918535A (en) | Data reading method, device, equipment and storage medium | |
CN114328981A (en) | Knowledge graph establishing and data obtaining method and device based on mode mapping | |
KR102253841B1 (en) | Apparatus for Processing Transaction with Modification of Data in Large-Scale Distributed File System and Computer-Readable Recording Medium with Program | |
CN114595286A (en) | Data synchronization method and device, electronic equipment and storage medium | |
CN116049306A (en) | Data synchronization method, device, electronic equipment and readable storage medium | |
CN112905707A (en) | Method and device for synchronizing relational database and search engine and computer storage medium | |
CN114840497A (en) | Method, system and device for preprocessing row migration of database and storage medium | |
CN113127717A (en) | Key retrieval method and system | |
CN117931095B (en) | Map data storage method, apparatus, electronic device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210604 |