CN117235177A - Database synchronous operation method, device, equipment and computer medium - Google Patents

Database synchronous operation method, device, equipment and computer medium Download PDF

Info

Publication number
CN117235177A
CN117235177A CN202311092749.9A CN202311092749A CN117235177A CN 117235177 A CN117235177 A CN 117235177A CN 202311092749 A CN202311092749 A CN 202311092749A CN 117235177 A CN117235177 A CN 117235177A
Authority
CN
China
Prior art keywords
database
statement
log
target
target operation
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
Application number
CN202311092749.9A
Other languages
Chinese (zh)
Inventor
欧阳旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Bilibili Technology Co Ltd
Original Assignee
Shanghai Bilibili Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai Bilibili Technology Co Ltd filed Critical Shanghai Bilibili Technology Co Ltd
Priority to CN202311092749.9A priority Critical patent/CN117235177A/en
Publication of CN117235177A publication Critical patent/CN117235177A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a database synchronous operation method, a device, equipment and a computer readable medium, which are used for determining whether a first database is newly added with target operation or not by monitoring a database log of the first database, if the first database is newly added with the target operation, acquiring a first database operation statement corresponding to the target operation from the database log, determining a second database operation statement used for executing the target operation in a second database according to the first database operation statement, and executing the target operation on the second database according to the second database operation statement, so that synchronous operation on a plurality of databases can be realized without modifying service codes, the abnormal risk of codes can be reduced, the aim of synchronous operation of a plurality of databases can be realized with less workload, and the research and development efficiency is improved.

Description

Database synchronous operation method, device, equipment and computer medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a computer readable medium for database synchronization operation.
Background
This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. The description herein is not to be taken as an admission of prior art as including in this section.
In the process of software development, adding, deleting and modifying the database is a problem that frequently needs to be processed in the process of software development, and in the process of research and development, the open source database is adopted to replace the closed source database, so that the dependence on a specific database is reduced from the technical bottom layer, and the data safety and compatibility are improved.
However, in the replacement process, compatibility, stability and service continuity of the program are to be achieved, so that double writing of data is required in the replacement process, that is, the service data is written into the first database and simultaneously written into the second database. The implementation mode adopted at present is that by adding a writing operation to a second database in a DAO (database access) layer, the second database is written simultaneously when service data is written into a first database, but the method needs to modify the original service code, and the writing operation to the second database needs to be added in the original service code DAO (database access) layer, so that on one hand, the abnormal risk of the code is increased, the normal service stability and the continuity are affected, and on the other hand, a large amount of research and development workload is needed, and the research and development efficiency is reduced.
In view of the foregoing, there is a need to provide a safer and more efficient database synchronization method.
Disclosure of Invention
Aspects of the present application provide a database synchronization operation method, apparatus, device, and computer-readable storage medium for performing a database synchronization operation more safely and efficiently.
In one aspect of the present application, a database synchronization operation method is provided, where the method includes:
determining whether a target operation is newly added to a first database by monitoring a database log of the first database;
if the target operation is newly added, a first database operation statement corresponding to the target operation is obtained from the database log;
determining a second database operation statement for executing the target operation in a second database according to the first database operation statement;
and executing the target operation on the second database according to the second database operation statement.
In another aspect of the present application, there is provided a database synchronous operation apparatus, wherein the apparatus includes:
the database monitoring module is used for determining whether the first database is newly added with target operation or not by monitoring a database log of the first database;
the first operation sentence acquisition module is used for acquiring a first database operation sentence corresponding to the target operation from the database log if the target operation is newly added;
a second operation statement determining module, configured to determine a second database operation statement for executing the target operation in a second database according to the first database operation statement;
and the second database operation module is used for executing the target operation on the second database according to the second database operation statement.
In another aspect of the present application, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the database synchronization method of operation as described above.
In another aspect of the application, a computer readable storage medium having stored thereon computer program instructions executable by a processor to implement a database synchronization method as described above is provided.
In the scheme provided by the embodiment of the application, whether the first database is newly added with target operation is determined by monitoring the database log of the first database, if so, a first database operation statement corresponding to the target operation is obtained from the database log, a second database operation statement for executing the target operation in a second database is determined according to the first database operation statement, and then the target operation is executed on the second database according to the second database operation statement, so that synchronous operation on a plurality of databases can be realized without modifying service codes, the abnormal risk of codes can be reduced, the aim of synchronous operation of a plurality of databases can be realized with less workload, and the research and development efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings can be obtained according to these drawings without inventive effort to a person skilled in the art.
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the accompanying drawings in which:
FIG. 1 is a flowchart of a database synchronization method according to an embodiment of the present application;
FIG. 2 is a flowchart of a database synchronization method according to another embodiment of the present application;
FIG. 3 is a schematic diagram of a database synchronization device according to an embodiment of the present application;
FIG. 4 is a schematic diagram of an electronic device suitable for implementing aspects of embodiments of the present application;
the same or similar reference numbers in the drawings refer to the same or similar parts.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In one exemplary configuration of the application, the terminal, the devices of the services network each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer-readable media include both permanent and non-permanent, removable and non-removable media, and information storage may be implemented by any method or technology. The information may be computer program instructions, data structures, modules of the program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device.
The embodiment of the application provides a database synchronous operation method, a device, equipment and a computer readable storage medium, which are used for carrying out synchronous operation on a database more safely and efficiently, determining whether a target operation is newly added to a first database by monitoring a database log of the first database, acquiring a first database operation statement corresponding to the target operation from the database log if the target operation is newly added, determining a second database operation statement used for executing the target operation in a second database according to the first database operation statement, and then executing the target operation on the second database according to the second database operation statement, so that synchronous operation on a plurality of databases can be realized under the condition that service codes are not required to be modified, the abnormal risk of the codes can be reduced, the aim of synchronous operation of a plurality of databases can be realized with less workload, and the research and development efficiency is improved.
It should be noted that, the embodiment of the present application is not limited to an application scenario in which a synchronization operation is required due to database replacement, but may be applied to an application scenario in which a synchronization operation is required for a plurality of databases due to other reasons, which can also have a technical effect of safely and efficiently performing a synchronization operation on a database.
In an actual scenario, the execution body of the method may be a database server, or an application program disposed on the database server, where the database server may be an independent server, or may be one of server clusters, or may be one virtual server in cloud computing, and is mainly used for performing a synchronization operation on multiple databases.
Fig. 1 shows a process flow of a database synchronization operation method according to an embodiment of the present application, where the method at least includes the following processing steps:
step S101, determining whether a target operation is newly added to a first database by monitoring a database log of the first database.
Step S102, if the target operation is newly added, a first database operation statement corresponding to the target operation is obtained from the database log.
Step S103, determining a second database operation statement for executing the target operation in a second database according to the first database operation statement.
Step S104, executing the target operation on the second database according to the second database operation statement.
According to the database synchronous operation method provided by the embodiment of the application, whether the first database is newly added with target operation is determined by monitoring the database log of the first database, if so, a first database operation statement corresponding to the target operation is obtained from the database log, a second database operation statement for executing the target operation in the second database is determined according to the first database operation statement, and then the target operation is executed on the second database according to the second database operation statement, so that synchronous operation on a plurality of databases can be realized under the condition that service codes are not required to be modified, the code abnormal risk can be reduced, the aim of synchronous operation on a plurality of databases can be realized with less workload, and the research and development efficiency is improved.
It should be noted that the first database and the second database may be different types of databases or the same type of databases, and the embodiment of the present application is not limited. The types of the databases may be classified according to whether an open source is available, for example, an open source database and a closed source database, and may be classified according to a data model, for example, a relational database, a key value type database, a document type database, and the like, and may be classified according to a database provider, for example, a MySQL, oracle, mongoDB database, and the like. In some embodiments, the first database and the second database may be different types of databases, so that the embodiments of the present application are utilized to implement synchronization operations between different types of databases, in some examples, the first database may be a closed source database, and the second database may be an open source database, so that the embodiments of the present application are utilized to implement replacement of the closed source database by the open source database, and reduce reliance on a specific closed source database. Of course, if the first database and the second database are the same type of database, the method for synchronously operating the databases provided by the embodiment of the application can also realize synchronous operation, and therefore, the method is also within the protection scope of the application.
In some modification embodiments, the determining whether the first database is newly added with the target operation by monitoring the database log of the first database includes:
monitoring a database log of a first database to obtain newly added change content in the database log;
and determining whether the first database is newly added with the target operation according to whether the newly added change content comprises the operation command of the target operation.
The monitoring mechanism of the database log is real-time monitoring, so that the newly added change content in the database log is monitored, namely whether an operation instruction of target operation is included in each file is detected, such as an insert operation instruction (i.e. a write instruction), an update operation instruction (i.e. a modify instruction) and the like, and if the operation instruction is detected in the newly added change content, the first database can be determined to be newly added with the target operation, and the second database is required to be synchronously operated; if the operation instruction is not detected in the newly added change content, the fact that the first database has no newly added target operation can be determined, and target operation on the second database is not needed.
Through the embodiment, the aim of judging whether the first database is newly added with the target operation can be fulfilled by detecting the newly added change content in the database log each time, the operation is simple, the efficiency is high, and the real-time performance of the synchronous operation of the second database and the first database can be effectively improved.
Based on the foregoing embodiments, in some modified embodiments, the monitoring the database log of the first database includes:
monitoring a database log of the first database through a file system monitor, watch service.
The file system monitor watch service is an operating system-based file system monitor, can monitor the change of all files (such as database log files) of the system, does not need to traverse and compare, is a monitoring based on signal transceiving, and has higher monitoring efficiency, so that the real-time performance of synchronous operation of the second database and the first database can be further improved through the embodiment.
To deploy the filesystem monitor WatchService, in some variant embodiments, before the listening to the database log of the first database by the filesystem monitor WatchService, further comprises:
acquiring a log file storage path set for a database log of the first database;
and setting the log file storage path as a monitoring path of a file system monitor WatchService.
The method comprises the steps that a log file storage path set for a database log of a first database can be flexibly set according to actual requirements, and on the basis, the purpose of monitoring the database log of the first database in real time can be achieved by using the WatchService only by setting the log file storage path as a monitoring path of a file system monitor WatchService.
In some variant embodiments, the determining a second database operation statement for performing the target operation in a second database according to the first database operation statement includes:
analyzing the first database operation statement to obtain a first operation command and operation content;
determining a second operation command corresponding to the first operation command according to a preset operation command mapping relation, wherein the first operation command is used for executing the target operation in the first database, and the second operation command is used for executing the target operation in the second database;
and generating a second database operation statement for executing the target operation in a second database according to the second operation command and the operation content.
The first operation command and the operation content are obtained by analyzing the first database operation statement, and can be realized by adopting methods such as regular expression matching.
The above is a general method for determining the operation statement of the second database according to the operation statement of the first database, and because the operation commands of the first database and the second database for the same operation are often different, according to the embodiment, the conversion of the operation statement of the first database and the operation statement of the second database can be realized by means of the preset operation command mapping relationship, so as to further realize the purpose of synchronous operation of different types of databases.
In other alternative embodiments, the step S103, determining, according to the first database operation statement, a second database operation statement for executing the target operation in a second database may include:
judging whether the operation grammar of executing the target operation in the first database and the second database is the same or not;
and if the first database operation sentences are the same, the first database operation sentences are used as second database operation sentences aiming at a second database.
The operation grammar comprises an operation command and an operation statement writing rule, if the operation grammar of the first database and the operation grammar of the second database for executing the target operation are the same, the operation statement of the first database can be directly applied to the second database for executing the target operation without conversion, so that the efficiency of the database synchronous operation can be effectively improved by firstly judging whether the operation grammar of the first database and the operation grammar of the second database for executing the target operation are the same or not and directly using the operation grammar of the first database and the operation statement for executing the target operation on the second database without conversion under the same condition.
In addition, if the operation grammars of the two are different, the method of performing operation statement conversion according to the preset operation command mapping relationship provided in the foregoing embodiment may be continuously used to generate the second database operation statement to perform the target operation on the second database, which is not described herein.
In some variations, the target operation includes a write operation and/or a modify operation.
In some variant embodiments, the first database comprises an Oracle database, the second database comprises a MySQL database, and the target operation comprises a write operation and/or a modify operation, thereby implementing a synchronized double write operation between the Oracle database and the MySQL database.
Because the operation commands of the Oracle database and the MySQL database for writing operation and modifying operation are the same, the operation sentence conversion process provided by the embodiment is not needed, the first database operation sentence can be directly used as a second database operation sentence aiming at a second database, and the synchronous double writing operation between the Oracle database and the MySQL database can be realized, so that the double writing efficiency is further improved.
For ease of understanding, the above database synchronization operation method of the present application will be further described with reference to a specific example.
In a specific example, the above method for operating the database synchronization provided by the embodiment of the present application is used to implement a dual-write operation of a first database and a second database, and when a database write (insert) or update operation is monitored in the first database, a write (insert) or update operation is simultaneously performed on the corresponding second database, thereby implementing the dual-write operation of the databases.
Specifically, please refer to fig. 2, which is a flowchart illustrating a database synchronization method according to another embodiment of the present application, the method may include the following steps:
1. starting a log output function of a first database, which specifically comprises the following steps:
1.1, setting a LOG file directory of the first database by a command Isnrctl SET log_ DIRECTORY directory.
1.2, setting the LOG FILE name of the first database by a command Isnrctl SET log_file_name.
1.3, setting the state of the LOG of the first database to be an on state through a command Isnrctl SET log_status on.
2. The log monitoring service of the first database is operated, when insert, update operation is monitored in the log of the first database, corresponding insert, update operation is executed on the second database, so that the aim of synchronous operation of the same data in different databases is fulfilled, and the method specifically comprises the following steps:
2.1, the java.nio.file.watch service interface based on the watch service of the file system monitor realizes the monitoring of the log file change of the first database, the watch service is the watch service monitor based on the operating system, can monitor the change of all files of the system, does not need to traverse and compare, is the monitoring based on signal receiving and transmitting, has high efficiency, and the embodiment of the application monitors the log file of the first database in real time by using the java.nio.file.watch service interface so as to monitor the file change condition.
2.2, setting a listening path according to the log file storage path of the first database set in the previous step, and simultaneously setting a listening mode StandardWatchEventKinds ENTRY MODIFY [ monitor modification event of file ], and instantiating a watch service, which can be implemented with reference to the following code:
path = Paths get (log file storage Path of first database);
WatchService watcher=FileSystems.getDefault(newWatchService():
path.register(watcher,StandardWatchEventKinds.ENTRY_MODIFY)。
2.3, simultaneously creating a thread, continuously acquiring log file change information of the current first database, acquiring newly added change content when the log changes, and skipping if no insert or update statement exists in the changed content; if the changed content contains insert or update sentences, taking the example that the operation grammar of the target operation executed by the first database and the second database is the same, extracting the operation sentences in the operation sentences to be executed once in the corresponding second database, and when the second database is a MySQL database, referring to the following codes to execute:
while(true){
String_modifycontent=(Path)event context()-
If modifycontent contain("insert")or modifycontent contain("update")
extraction of SQL operation statement (i.e., content within double quotation marks) code by regular expression is as follows
Pattern p=Pattern.compile("\"(?)\);
Matcher m=p.matcher(modifycontent)
while(m.find())
{
Sql=m.group()
Execution of the SQL operation statement in MySQL
Creating MySQL connection through JDBC, executing SQL operation statement
connect=drivermnager.getconnection ("jdbciMySQL database address
stmt=conn createStatement():
stmt executeUpdate(sql)
}
By the method, double writing of the first database and the second database is realized, so that data can be simultaneously inserted or updated in the two databases under the condition that the existing business logic is not affected.
Through the specific embodiment, the following beneficial effects can be obtained:
1. zero modification and zero invasion of service codes are realized, double writing of the database can be realized without modifying the service codes, the abnormal risk of codes caused by adding double writing functions of the database is reduced, and the continuity of normal service stability is affected.
2. Because no service code is modified, the research and development efficiency is improved.
Based on the same inventive concept, the embodiment of the application also provides a database synchronous operation device, which can be the database synchronous operation method in the previous embodiment, and the principle of solving the problem is similar to that of the method. The database synchronous operation device provided by the embodiment of the application can implement the database synchronous operation method, and the database synchronous operation device can be realized by software, hardware or a combination of the software and the hardware. For example, the database synchronization operating means may comprise integrated or separate functional modules or units for performing the corresponding steps in the methods described above. Since the apparatus embodiments are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points. The device embodiments described below are merely illustrative. Referring to fig. 3, the database synchronization operation apparatus may include:
a database monitoring module 101, configured to determine whether a target operation is newly added to a first database by monitoring a database log of the first database;
the first operation sentence obtaining module 102 is configured to obtain, if a target operation is newly added, a first database operation sentence corresponding to the target operation from the database log;
a second operation sentence determining module 103, configured to determine a second database operation sentence for executing the target operation in a second database according to the first database operation sentence;
and the second database operation module 104 is configured to execute the target operation on the second database according to the second database operation statement.
In some variant embodiments, the database listening module 101 includes:
the database monitoring unit is used for monitoring a database log of the first database to obtain newly added change content in the database log;
and the new operation judging unit is used for determining whether the first database is newly added with the target operation according to whether the newly added change content comprises the operation command of the target operation.
In some variant embodiments, the database listening unit comprises:
and the database monitoring subunit is used for monitoring the database log of the first database through the file system monitor WatchService.
In some modification embodiments, the database synchronization operation apparatus further includes:
the log storage path acquisition module is used for acquiring a log file storage path set for a database log of the first database;
and the monitoring path setting module is used for setting the log file storage path as a monitoring path of a file system monitor WatchService.
In some variant embodiments, the second operation sentence determining module 103 includes:
the first operation statement analyzing unit is used for analyzing the first database operation statement to obtain a first operation command and operation content;
an operation command mapping unit, configured to determine a second operation command corresponding to the first operation command according to a preset operation command mapping relationship, where the first operation command is used to execute the target operation in the first database, and the second operation command is used to execute the target operation in the second database;
and the second operation sentence generating unit is used for generating a second database operation sentence for executing the target operation in a second database according to the second operation command and the operation content.
In some variant embodiments, the second operation sentence determining module 103 includes:
the grammar identical judging unit is used for judging whether the operation grammar for executing the target operation in the first database and the second database is identical or not;
and the grammar identical processing unit is used for taking the first database operation statement as a second database operation statement aiming at a second database if the grammar identical processing unit is identical.
In some variations, the target operation includes a write operation and/or a modify operation.
In some variations, the first database comprises an Oracle database, the second database comprises a MySQL database, and the target operation comprises a write operation and/or a modify operation.
In some variant embodiments, the determining a second database operation statement for performing the target operation in a second database according to the first database operation statement includes:
and taking the first database operation statement as a second database operation statement aiming at a second database.
The database synchronous operation device provided by the embodiment of the application has the same beneficial effects as the database synchronous operation method provided by the previous embodiment of the application due to the same inventive concept.
Based on the same inventive concept, the embodiment of the present application further provides an electronic device, where the corresponding method of the electronic device may be the database synchronous operation method in the foregoing embodiment, and the principle of solving the problem is similar to that of the method. The electronic equipment provided by the embodiment of the application comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the database synchronization methods and/or techniques of the various embodiments of the present application described above.
The electronic device may be a user device, or a device formed by integrating the user device and a network device through a network, or may also be an application running on the device, where the user device includes, but is not limited to, a computer, a mobile phone, a tablet computer, a smart watch, a bracelet, and other various terminal devices, and the network device includes, but is not limited to, a network host, a single network server, a plurality of network server sets, or a computer set based on cloud computing, where the network device is implemented, and may be used to implement a part of processing functions when setting an alarm clock. Here, the Cloud is composed of a large number of hosts or web servers based on Cloud Computing (Cloud Computing), which is a kind of distributed Computing, one virtual computer composed of a group of loosely coupled computer sets.
Fig. 4 shows a structure of an electronic device suitable for implementing the method and/or the technical solution in the embodiment of the present application, the electronic device 1200 includes a central processing unit (CPU, central Processing Unit) 1201, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory 1202 or a program loaded from a storage section 1208 into a random access Memory (RAM, random Access Memory) 1203. In the RAM 1203, various programs and data required for the system operation are also stored. The CPU 1201, ROM 1202, and RAM 1203 are connected to each other through a bus 1204. An Input/Output (I/O) interface 1205 is also connected to the bus 1204.
The following components are connected to the I/O interface 1205: an input section 1206 including a keyboard, mouse, touch screen, microphone, infrared sensor, etc.; an output portion 1207 including a display such as a Cathode Ray Tube (CRT), a liquid crystal display (LCD, liquid Crystal Display), an LED display, an OLED display, or the like, and a speaker; a storage portion 1208 comprising one or more computer-readable media of hard disk, optical disk, magnetic disk, semiconductor memory, etc.; and a communication section 1209 including a network interface card such as a LAN (local area network ) card, a modem, or the like. The communication section 1209 performs communication processing via a network such as the internet.
In particular, the methods and/or embodiments of the present application may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. The above-described functions defined in the method of the present application are performed when the computer program is executed by a Central Processing Unit (CPU) 1201.
Another embodiment of the present application also provides a computer readable storage medium having stored thereon computer program instructions executable by a processor to implement the method and/or the technical solution of any one or more of the embodiments of the present application described above.
In particular, the present embodiments may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowchart or block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of devices, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple elements or page components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the apparatus claims can also be implemented by means of one unit or means in software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.

Claims (10)

1. A method of database synchronous operation, wherein the method comprises:
determining whether a target operation is newly added to a first database by monitoring a database log of the first database;
if the target operation is newly added, a first database operation statement corresponding to the target operation is obtained from the database log;
determining a second database operation statement for executing the target operation in a second database according to the first database operation statement;
and executing the target operation on the second database according to the second database operation statement.
2. The database synchronization operation method according to claim 1, wherein the determining whether the first database is newly added with a target operation by listening to a database log of the first database comprises:
monitoring a database log of a first database to obtain newly added change content in the database log;
and determining whether the first database is newly added with the target operation according to whether the newly added change content comprises the operation command of the target operation.
3. The database synchronization operation method according to claim 2, wherein the monitoring the database log of the first database includes:
monitoring a database log of the first database through a file system monitor, watch service.
4. The database synchronization operation method according to claim 3, wherein before the monitoring of the database log of the first database by the file system monitor WatchService, further comprising:
acquiring a log file storage path set for a database log of the first database;
and setting the log file storage path as a monitoring path of a file system monitor WatchService.
5. The database synchronization operation method according to claim 1, wherein the determining a second database operation statement for executing the target operation in a second database according to the first database operation statement includes:
analyzing the first database operation statement to obtain a first operation command and operation content;
determining a second operation command corresponding to the first operation command according to a preset operation command mapping relation, wherein the first operation command is used for executing the target operation in the first database, and the second operation command is used for executing the target operation in the second database;
and generating a second database operation statement for executing the target operation in a second database according to the second operation command and the operation content.
6. The database synchronization operation method according to claim 1, wherein the determining a second database operation statement for executing the target operation in a second database according to the first database operation statement includes:
judging whether the operation grammar of executing the target operation in the first database and the second database is the same or not;
and if the first database operation sentences are the same, the first database operation sentences are used as second database operation sentences aiming at a second database.
7. The database synchronization operation method according to claim 1, wherein the target operation includes a write operation and/or a modify operation.
8. A database synchronous operation device, wherein the device comprises:
the database monitoring module is used for determining whether the first database is newly added with target operation or not by monitoring a database log of the first database;
the first operation sentence acquisition module is used for acquiring a first database operation sentence corresponding to the target operation from the database log if the target operation is newly added;
a second operation statement determining module, configured to determine a second database operation statement for executing the target operation in a second database according to the first database operation statement;
and the second database operation module is used for executing the target operation on the second database according to the second database operation statement.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 7.
10. A computer readable medium having stored thereon computer program instructions executable by a processor to implement the method of any of claims 1 to 7.
CN202311092749.9A 2023-08-28 2023-08-28 Database synchronous operation method, device, equipment and computer medium Pending CN117235177A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311092749.9A CN117235177A (en) 2023-08-28 2023-08-28 Database synchronous operation method, device, equipment and computer medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311092749.9A CN117235177A (en) 2023-08-28 2023-08-28 Database synchronous operation method, device, equipment and computer medium

Publications (1)

Publication Number Publication Date
CN117235177A true CN117235177A (en) 2023-12-15

Family

ID=89093908

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311092749.9A Pending CN117235177A (en) 2023-08-28 2023-08-28 Database synchronous operation method, device, equipment and computer medium

Country Status (1)

Country Link
CN (1) CN117235177A (en)

Similar Documents

Publication Publication Date Title
US10936292B2 (en) Offline capabilities for live applications in a cloud collaboration platform
CN110647579A (en) Data synchronization method and device, computer equipment and readable medium
US9727601B2 (en) Predicting validity of data replication prior to actual replication in a transaction processing system
CN108920698A (en) A kind of method of data synchronization, device, system, medium and electronic equipment
CN109634587B (en) Method and equipment for generating warehousing script and warehousing data
US20120158742A1 (en) Managing documents using weighted prevalence data for statements
US11599385B2 (en) System and method for distribution of dependent builds across orchestration job scheduler slaves
CN112346647B (en) Data storage method, device, equipment and medium
CN110781197B (en) Hive offline synchronous verification method and device and electronic equipment
US20150120682A1 (en) Automated recognition of patterns in a log file having unknown grammar
CN114077518B (en) Data snapshot method, device, equipment and storage medium
CN115408391A (en) Database table changing method, device, equipment and storage medium
US11036527B2 (en) Class splitting in object-oriented environments
US8473773B2 (en) Method and system to provide a compliance clock service suitable for cloud deployment
US10902020B2 (en) Multiple cache processing of streaming data
CN111047427A (en) Data reporting method, device, server and storage medium
US20230012881A1 (en) Method and apparatus for reading data, electronic device and storage medium
US9286349B2 (en) Dynamic search system
CN111176944A (en) Block chain intelligent contract calling record analysis method, device, terminal and storage medium
CN117235177A (en) Database synchronous operation method, device, equipment and computer medium
US9201936B2 (en) Rapid provisioning of information for business analytics
CN110674224B (en) Entity data processing method, device and equipment and computer readable storage medium
CN113127496B (en) Method and device for determining change data in database, medium and equipment
CN114116907A (en) Database synchronization method and device, electronic equipment and storage medium
US8818955B2 (en) Reducing storage costs associated with backing up a database

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