Data synchronization method, system, device and equipment and storage medium
By monitoring the status of dedicated networks between cloud servers in the configuration center and dynamically updating the configuration files, the database data inconsistency caused by dedicated network failures is solved, the availability and consistency of data operations is achieved, and incremental data is automatically synchronized after the network is restored.
Patent Information
- Application Number
- CN202411753022.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2044-12-02
AI Technical Summary
When the dedicated network between two cloud servers fails, data synchronization cannot be achieved between the two databases, resulting in data inconsistency and affecting the availability of database services.
The configuration center monitors the status of the dedicated network between the two servers. When a failure occurs, the configuration file is updated as a network failure configuration file, indicating that one of the servers is used as a read and write server; when the dedicated network returns to normal, the configuration file is updated as a network normal configuration file, and both parties are restored as read and write servers.
Ensure the availability and consistency of data operations during a dedicated network failure, avoid the unavailability of database services caused by data inconsistency, and automatically synchronize incremental data during the failure after the dedicated network is restored.
Smart Images

Figure CN119561954A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a data synchronization method, system, device, equipment and storage medium. Background Art
[0002] Dual-cloud multi-master database runs two database services on two cloud servers respectively, thus forming a database cluster. Figure 1 The figure shows a schematic diagram of the data synchronization architecture of an existing dual-cloud multi-master database cluster. The dual-cloud multi-master database cluster includes Cloud A (cloud server) and Cloud B. Cloud A and Cloud B each run a database service. Users access the database service through the Domain Name System (DNS) and perform database-related operations. The database-related operations can be performed on any database. The two databases automatically synchronize (replicate) data in both directions. One of the purposes of setting up dual cloud servers is to improve service availability. For example, if the area where a database service is located is disconnected from the Internet, the database service in another area can still provide services. A multi-master database means that each node of the database is a master node, which is equal to each other and can provide database read and write. The master nodes replicate data to each other to ensure data consistency. A multi-master database is designed to increase the concurrency of database operations so that the database service can serve more users at the same time.
[0003] Currently, the two databases are synchronized through a dedicated network established between the two cloud servers. However, when the dedicated network between the two cloud servers fails, the two databases cannot synchronize data due to the failure of the dedicated network, which eventually leads to data inconsistency between the two databases, and even causes database service unavailability due to data inconsistency between the two databases. Summary of the invention
[0004] The present application provides a data synchronization method, system, device, equipment and storage medium to solve the problem that when a dedicated line network between two cloud servers fails, data synchronization between the two databases cannot be achieved because the dedicated line network is unavailable.
[0005] In view of the above technical problems, the technical solution of this application is solved by the following embodiments:
[0006] An embodiment of the present application provides a data synchronization method, which is applied to a configuration center, including: monitoring a dedicated network for data synchronization between two servers; when it is detected that the dedicated network has a fault, updating a current configuration file to a network fault configuration file; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server; when it is detected that the dedicated network has returned to normal, updating the current configuration file to a network normal configuration file; wherein the network normal configuration file is used to indicate that both servers are read-write servers.
[0007] Wherein, the monitoring of the dedicated line network for data synchronization between two servers includes: monitoring the dedicated line network for data synchronization between two servers through a preset monitoring service; the method also includes: receiving a configuration file corresponding to the network status of the dedicated line network pushed by the monitoring service; wherein, when the monitoring service detects that the dedicated line network has a fault, the monitoring service pushes a network fault configuration file; and when the monitoring service detects that the dedicated line network has returned to normal, the monitoring service pushes a network normal configuration file.
[0008] Among them, when the dedicated line network is monitored to have a fault, the current configuration file is updated to a network fault configuration file, including: when the monitoring center detects that the dedicated line network has a fault, the network fault configuration file pushed by the monitoring center is received, and the current configuration file is overwritten with the network fault configuration file; when the dedicated line network is monitored to have returned to normal, the current configuration file is updated to a network normal configuration file, including: when the monitoring center detects that the dedicated line network has returned to normal, the network normal configuration file pushed by the monitoring center is received, and the network fault configuration file that is the current configuration file is overwritten with the network normal configuration file.
[0009] An embodiment of the present application also provides a data synchronization method, which is applied to a first server, including: receiving a data operation request, and reading a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server; when the configuration file is a network fault configuration file, identifying the operation type corresponding to the data operation request, executing the data operation request of the read operation type on the first server, and executing the data operation request of the write operation type on the read-write server; wherein the read-write server is the first server or a preset second server; when the configuration file is updated from a network fault configuration file to a network normal configuration file, executing the data operation request on the first server, and performing data synchronization between the first server and the second server through a dedicated network between the first server and the second server.
[0010] The receiving of the data operation request includes: receiving the data operation request from a domain name system; or receiving the data operation request forwarded from the second server.
[0011] Wherein, executing the data operation request of the write operation type on the read-write server includes: determining whether the first server is the read-write server according to the network fault configuration file; if the first server is the read-write server, executing the data operation request of the write operation type on the first server; if the first server is not the read-write server, sending the data operation request of the write operation type to the second server through a public network, so that the second server executes the data operation request of the write operation type.
[0012] Wherein, the data synchronization between the first server and the second server includes: when the first server is the read-write server, in the process of reading the configuration file from the configuration center, recording the first update time and the second update time; wherein, the first update time is the time when the configuration file is updated from the network normal configuration file to the network fault configuration file; the second update time is the time when the configuration file is updated from the network fault configuration file to the network normal configuration file; copying the first incremental data generated by the first database between the first update time and the second update time, and, through the dedicated network between the first server and the second server, sending the first incremental data to the second server, so that the second server updates the data in the second database with the first incremental data; when the first server is not the read-write server, receiving the second incremental data from the second server through the dedicated network between the first server and the second server, and updating the data in the first database with the second incremental data.
[0013] The embodiment of the present application also provides a data synchronization system, which includes: a configuration center and two servers respectively connected to the configuration center; data synchronization is performed between the two servers via a dedicated network; the configuration center monitors the dedicated network used for data synchronization between the two servers; when a fault is detected in the dedicated network, the current configuration file is updated to a network fault configuration file; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server; when the dedicated network is detected to be restored to normal, the current configuration file is updated to a network normal configuration file; wherein the network normal configuration file is used to indicate that both servers are read-write servers; the two servers respectively perform the following operations: receive a data operation request, and read a configuration file from a preset configuration center; when the configuration file is a network fault configuration file, identify the operation type corresponding to the data operation request, execute the data operation request of the read operation type on the current server, and execute the data operation request of the write operation type on the read-write server; when the configuration file is updated from the network fault configuration file to the network normal configuration file, the data operation request is executed on the current server, and data synchronization is performed between the current server and the other server through the dedicated network between the current server and the other server.
[0014] An embodiment of the present application also provides a data synchronization device, which is arranged in a configuration center, and includes: a network monitoring module, used to monitor a dedicated network between two servers for data synchronization; a first update module, used to update a current configuration file to a network failure configuration file when it is detected that the dedicated network has a failure; wherein the network failure configuration file is used to indicate that one of the two servers is a read-write server; a second update module, used to update the current configuration file to a network normal configuration file when it is detected that the dedicated network has returned to normal; wherein the network normal configuration file is used to indicate that both servers are read-write servers.
[0015] An embodiment of the present application also provides a data synchronization device, which is arranged on a first server, and includes: a receiving module, used to receive a data operation request, and read a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server; an identification and processing module, used to identify the operation type corresponding to the data operation request when the configuration file is a network fault configuration file, execute the data operation request of the read operation type on the first server, and execute the data operation request of the write operation type on the read-write server; wherein the read-write server is the first server or a preset second server; a processing and synchronization module, used to execute the data operation request on the first server when the configuration file is updated from a network fault configuration file to a network normal configuration file, and synchronize data between the first server and the second server through a dedicated network between the first server and the second server.
[0016] An embodiment of the present application also provides a data synchronization device, comprising: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; and at least one memory connected to the at least one bus, wherein the processor is configured to: execute a data synchronization program stored in the memory to implement any of the above-mentioned data synchronization methods executed in the configuration center, or to implement any of the above-mentioned data synchronization methods executed on the first server.
[0017] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are executed to implement any of the above-mentioned data synchronization methods executed in the configuration center, or to implement any of the above-mentioned data synchronization methods executed on the first server.
[0018] The above technical solution provided by the embodiment of the present application has the following advantages over the prior art: the method provided by the embodiment of the present application can be received by the first server for a data operation request, and a configuration file is read from a preset configuration center; wherein the configuration file is used to indicate a read-write server; when the configuration file is a network fault configuration file, the operation type corresponding to the data operation request is identified, and the data operation request of the read operation type is executed on the first server, and the data operation request of the write operation type is executed on the read-write server; wherein the configuration file is a network fault configuration file, indicating that a failure occurs in the dedicated line network between the first server and the second server; the read-write server is the first server or the preset second server; when the configuration file is updated from a network fault configuration file to a network normal configuration file, the data operation request is executed on the first server, and data synchronization is performed between the first server and the second server. The embodiment of the present application receives a data operation request while reading a configuration file in the configuration center. When the configuration file is a network failure configuration file, the read-write server specified in the configuration file is first determined, and all read operations are performed on the local end, and all write operations are performed on the read-write server. The incremental data generated by the write operation during the dedicated network failure is collected in the read-write server. When the configuration file is a normal network configuration file, that is, after the dedicated network returns to normal, the read-write operation is performed on the local end, and the incremental data generated by the write operation during the dedicated network failure is synchronized. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0022] Figure 1 This is a diagram of the data synchronization architecture of the existing dual-cloud multi-master database cluster;
[0023] Figure 2 is a structural diagram of a data synchronization system according to an embodiment of the present application;
[0024] Figure 3 is a flow chart of a data synchronization method performed in a configuration center according to an embodiment of the present application;
[0025] Figure 4 is a specific structural diagram of a data synchronization system according to an embodiment of the present application;
[0026] Figure 5 is a flowchart of a data synchronization method performed on a first server according to an embodiment of the present application;
[0027] Figure 6 is a structural diagram of a data synchronization device disposed in a configuration center according to an embodiment of the present application;
[0028] Figure 7 is a structural diagram of a data synchronization device disposed on a first server according to an embodiment of the present application;
[0029] Figure 8 is a structural diagram of a data synchronization device according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0031] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0032] The embodiment of the present application provides a data synchronization system. The data synchronization system can be applied in a dual-cloud multi-master database cluster.
[0033] like Figure 2 , which is a structural diagram of a data synchronization system according to an embodiment of the present application.
[0034] The data synchronization system includes: a configuration center and two servers respectively connected to the configuration center; the two servers perform data synchronization via a dedicated network. The two servers respectively run database services. The first server of the two servers runs a first database, and the second server of the two servers runs a second database. The first server is any one of the two servers, and the other server is the second server.
[0035] The configuration center monitors the dedicated network between the two servers for data synchronization; when it is detected that the dedicated network has a fault, the current configuration file is updated to a network fault configuration file; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server; when it is detected that the dedicated network has returned to normal, the current configuration file is updated to a network normal configuration file; wherein the network normal configuration file is used to indicate that both servers are read-write servers.
[0036] Further, the configuration center may be a Zookeeper configuration center. The Zookeeper configuration center is used to manage configuration files. The configuration files are used to indicate the read-write server in the two servers. The number of read-write servers is at least one. The read-write server can perform read operations and write operations on the database running thereon, and the server not designated as a read-write server can only perform read operations on the database running thereon.
[0037] Furthermore, the dedicated network used for data synchronization between the two servers can be monitored by a preset monitoring service to determine whether the dedicated network fails. When the monitoring service detects that the dedicated network fails, it can push a network failure configuration file to the configuration center. When the monitoring service detects that the dedicated network returns to normal, it can push a network normal configuration file to the configuration center. In this way, the configuration center updates the current configuration file to the configuration file pushed by the monitoring service, and the database service in the server can read the updated configuration file from the configuration center.
[0038] The two servers respectively perform the following operations: receive a data operation request, and read a configuration file from a preset configuration center; when the configuration file is a network failure configuration file, identify the operation type corresponding to the data operation request, execute the data operation request of the read operation type on the current server, and execute the data operation request of the write operation type on the read-write server; when the configuration file is updated from a network failure configuration file to a network normal configuration file, execute the data operation request on the current server, and synchronize data between the current server and another server through a dedicated network between the first server and the second server.
[0039] Further, the database service in the first server receives a database operation request, which comes from a domain name system, or the database operation request is forwarded from the second server.
[0040] Based on the above data synchronization system, the embodiment of the present application provides a data synchronization method. In conjunction with the data synchronization method, the operations required to be performed by each device in the data synchronization system will be described in detail below.
[0041] For the configuration center in the data synchronization system, the embodiment of the present application provides a data synchronization method executed in the configuration center. Figure 3 , which is a flow chart of a data synchronization method performed in a configuration center according to an embodiment of the present application.
[0042] Step S310: monitor the dedicated network used for data synchronization between two servers.
[0043] The dedicated network is used to connect two servers in a dual-cloud multi-master database cluster. The dedicated network can be a wired network or a wireless network.
[0044] In an embodiment of the present application, a dedicated network used for data synchronization between two servers may be monitored in real time to determine whether a failure occurs in the dedicated network.
[0045] In the embodiment of the present application, a dedicated network for data synchronization between two servers can be monitored through a preset monitoring service. The monitoring service can be installed in a configuration center or an independent device independent of the configuration center. For example: Figure 4 , which is a specific structural diagram of a data synchronization system according to an embodiment of the present application.
[0046] Step S320, determining whether a failure of the dedicated network is detected; if yes, executing step S330; if no, executing step S340.
[0047] A dedicated network failure means that two servers cannot communicate through the dedicated network. For example, the dedicated network is disconnected.
[0048] Step S330: When it is detected that the dedicated network fails, the current configuration file is updated to a network failure configuration file; wherein the network failure configuration file is used to indicate that one of the two servers is a read-write server.
[0049] A read-write server is a server that can perform read operations against the database it runs on, and can also perform write operations against the database.
[0050] The network failure profile is used to indicate how the two servers perform database operations when a dedicated network fails. The network failure profile includes: one of the two servers is a read-write server, the other server forwards the data operation request corresponding to the write operation to the read-write server for processing, and the two servers each process the received data operation request corresponding to the read operation.
[0051] Furthermore, one of the two servers is selected in advance as a read-write server and the other server is selected as a read-only server, and a network fault profile is generated accordingly. The read-only server refers to a server that only performs read operations on the database running on it. When selecting the read-write server, one of the two servers can be randomly selected as the read-write server.
[0052] Further, in the network fault configuration file, only the server as the read-write server can be indicated, and another server is defaulted as a read-only server. In the network fault configuration file, both the server as the read-write server and the server as the read-only server can be indicated.
[0053] In an embodiment of the present application, when a failure in the dedicated network is detected, the current configuration file of the configuration center may be a normal network configuration file. The normal network configuration file is used to indicate that when the dedicated network is normal, the two servers each process the received data operation request. When the dedicated network fails, if the normal network configuration file is still used to perform database operations, the two servers will be unable to synchronize data. Therefore, when the dedicated network fails, the embodiment of the present application replaces the normal network configuration file with the network failure configuration file.
[0054] Step S340, when it is monitored that the dedicated network returns to normal, the current configuration file is updated to a normal network configuration file; wherein the normal network configuration file is used to indicate that both servers are read-write servers.
[0055] The restoration of the dedicated network to normal means that the two servers can synchronize data through the dedicated network instead of being unable to do so.
[0056] In an embodiment of the present application, the monitoring service can push a configuration file corresponding to the network status of the dedicated network when it detects that the dedicated network has changed its network status. The configuration center receives the configuration file corresponding to the network status of the dedicated network pushed by the monitoring service; wherein, when the monitoring service detects that the dedicated network has a fault, it pushes a network fault configuration file; and when the monitoring service detects that the dedicated network has returned to normal, it pushes a network normal configuration file.
[0057] After receiving the network fault configuration file sent by the monitoring service, the current configuration file is updated to the network fault configuration file. After receiving the network normal configuration file sent by the monitoring service, the current configuration file is updated to the network normal configuration file. In other words, when the monitoring center detects that the dedicated network has a fault, the network fault configuration file pushed by the monitoring center is received, and the current configuration file is overwritten with the network fault configuration file; when the monitoring center detects that the dedicated network has returned to normal, the network normal configuration file pushed by the monitoring center is received, and the network fault configuration file that is the current configuration file is overwritten with the network normal configuration file.
[0058] In the embodiment of the present application, the monitoring service can also send a network status message corresponding to the current network status of the dedicated line network when it detects that the dedicated line network has changed its network status. After receiving the network status message sent by the monitoring service, the configuration center obtains the configuration file corresponding to the network status message from multiple preset configuration files according to the network status message. Among them, when the network status message indicates that the dedicated line network has a fault, the network fault configuration file is obtained; when the network status message indicates that the dedicated line network has returned to normal, the network normal configuration file is obtained.
[0059] In an embodiment of the present application, a dedicated network for data synchronization between two servers is monitored; when a fault is detected in the dedicated network, the current configuration file is updated to a network fault configuration file; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server; when the dedicated network is detected to be restored to normal, the current configuration file is updated to a network normal configuration file; wherein the network normal configuration file is used to indicate that both servers are read-write servers. The embodiment of the present application monitors in real time whether a fault occurs in the dedicated network between the two servers. In the event of a fault, the configuration file is updated to a network fault configuration file. After reading the network fault configuration file, the two servers can perform read operations on their own end and write operations on the designated read-write server. All write operations during the dedicated network fault are performed on one server, which can ensure that the incremental data during the dedicated network fault is stored in one server. After the dedicated network fault is eliminated, the incremental data during the dedicated network fault can be automatically synchronized to another server to ensure data consistency between the two servers.
[0060] For the server in the data synchronization system, the embodiment of the present application provides a data synchronization method executed on a first server. The first server is any one of the two servers, and the other server is the second server. That is to say, each of the two servers executes the data synchronization method of this embodiment.
[0061] In the embodiment of the present application, a software development kit (SDK) can be installed in the first server, so that the SDK executes the data synchronization method in the first server. Furthermore, a third-party tool can be integrated in the SDK to realize the separation of read and write operations in the first server. The third-party tool can be Apache ShardingSphere-JDBC, which is a jar package.
[0062] like Figure 5 2 is a flow chart of a data synchronization method performed on a first server according to an embodiment of the present application.
[0063] Step S510, receiving a data operation request, and reading a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server.
[0064] A data operation request is used to request to perform a database operation on a database.
[0065] Database operations include but are not limited to: add, delete, modify and query operations.
[0066] The types of database operations include: read operation type and write operation type. Among them, query operation corresponds to read operation type, and add, delete and modify operations correspond to write operation type.
[0067] In an embodiment of the present application, a data operation request is received from a domain name system; or, a data operation request is received forwarded from the second server.
[0068] Furthermore, the client sends a data operation request, which arrives at the Domain Name System (DNS), which distributes the data operation request to one of the two servers; if the server that receives the data operation request is a read-write server, it directly processes the data operation request; if the server that receives the data operation request is a read-only server, it forwards the data operation request to the other server that is a read-write server.
[0069] Step S520, when the configuration file is a network fault configuration file, identify the operation type corresponding to the data operation request, execute the data operation request of the read operation type on the first server, and execute the data operation request of the write operation type on the read-write server; wherein the read-write server is the first server or a preset second server.
[0070] According to the network fault configuration file, determine whether the first server is the read-write server; if the first server is the read-write server, execute the data operation request of the write operation type on the first server; if the first server is not the read-write server, send the data operation request of the write operation type to the second server through a public network, so that the second server executes the data operation request of the write operation type.
[0071] Public networks and dedicated networks are different networks. For example, the public network is the Internet.
[0072] Step S530, when the configuration file is updated from the network failure configuration file to the network normal configuration file, the data operation request is executed on the first server, and data synchronization is performed between the first server and the second server through the dedicated network between the first server and the second server.
[0073] The first server runs a first database, and the second server runs a second database.
[0074] In an embodiment of the present application, after the configuration file is updated from the network failure configuration file to the network normal configuration file, the incremental data generated during the dedicated network failure is first synchronized between the first server and the second server, and then the first server and the second server respectively execute the received data operation request normally and perform normal data synchronization. In other words, after the configuration file is updated from the network failure configuration file to the network normal configuration file, data synchronization is first performed between the first server and the second server for the incremental data generated during the dedicated network failure, and then normal database services and normal data synchronization operations are performed, that is, the data operation request received by the first server is executed and data synchronization is performed between the first server and the second server for the data operation request.
[0075] Furthermore, in the case where the first server is the read-write server, in the process of reading the configuration file from the configuration center, a first update time and a second update time are recorded; wherein the first update time is the time when the configuration file is updated from a normal network configuration file to a network fault configuration file; and the second update time is the time when the configuration file is updated from a network fault configuration file to a normal network configuration file; the first incremental data generated by the first database between the first update time and the second update time is copied, and the first incremental data is sent to the second server through a dedicated network between the first server and the second server, so that the second server uses the first incremental data to update the data in the second database.
[0076] Furthermore, in the case where the first server is not the read-write server, the second incremental data from the second server is received through the dedicated network between the first server and the second server, and the data in the first database is updated using the second incremental data. If the first server is not a read-write server, then the second server is a read-write server, that is, the second server handles all write operations during the dedicated network failure. In this case, the second server can copy the incremental data generated by the second database during the dedicated network failure and synchronize it to the first server through the dedicated network that has been restored to normal, so that the first database in the first server and the second database in the second server maintain data consistency. The second incremental data is the incremental data generated by the second database between the first update time and the second update time.
[0077] In an embodiment of the present application, a first server receives a data operation request and reads a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server; when the configuration file is a network fault configuration file, the operation type corresponding to the data operation request is identified, and the data operation request of the read operation type is executed on the first server, and the data operation request of the write operation type is executed on the read-write server; wherein the configuration file is a network fault configuration file indicating that a dedicated line network between the first server and the second server fails; the read-write server is the first server or a preset second server; when the configuration file is updated from a network fault configuration file to a network normal configuration file, the data operation request is executed on the first server, and data synchronization is performed between the first server and the second server. The embodiment of the present application receives a data operation request while reading a configuration file in the configuration center. When the configuration file is a network failure configuration file, the read-write server specified in the configuration file is first determined, and all read operations are performed on the local end, and all write operations are performed on the read-write server. The incremental data generated by the write operation during the dedicated network failure is collected in the read-write server. When the configuration file is a normal network configuration file, that is, after the dedicated network returns to normal, the read-write operation is performed on the local end, and the incremental data generated by the write operation during the dedicated network failure is synchronized.
[0078] Furthermore, in an embodiment of the present application, if this end is a read-write server, the incremental data generated by the write operation during the dedicated network failure is synchronized to another server; if the other server is a read-write server, the incremental data generated by the write operation during the dedicated network failure synchronized from the other server is received.
[0079] Furthermore, in an embodiment of the present application, in the event that a dedicated network used for data synchronization between a dual-cloud multi-master database fails, the dual-cloud multi-master database can provide database services normally and perform database read and write operations normally. By executing a read-write separation method for the database of one of the servers, the problem of data inconsistency in the databases running on the two servers can be avoided, thereby improving service availability.
[0080] The present application also provides a data synchronization device disposed in a configuration center. Figure 6 , which is a structural diagram of a data synchronization device disposed in a configuration center according to an embodiment of the present application.
[0081] The data synchronization device arranged in the configuration center includes:
[0082] The network monitoring module 610 is used to monitor the dedicated network used for data synchronization between two servers.
[0083] The first updating module 620 is used to update the current configuration file to a network fault configuration file when it is detected that the dedicated network has a fault; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server.
[0084] The second updating module 630 is used to update the current configuration file to a normal network configuration file when it is detected that the dedicated network has returned to normal; wherein the normal network configuration file is used to indicate that both servers are read-write servers.
[0085] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiments and will not be repeated here.
[0086] The present application also provides a data synchronization device disposed on a first server. Figure 7 2 is a structural diagram of a data synchronization device disposed on a first server according to an embodiment of the present application.
[0087] The data synchronization device provided on the first server includes:
[0088] The receiving module 710 is used to receive a data operation request and read a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server.
[0089] The identification and processing module 720 is used to identify the operation type corresponding to the data operation request when the configuration file is a network fault configuration file, execute the data operation request of the read operation type on the first server, and execute the data operation request of the write operation type on the read-write server; wherein the read-write server is the first server or a preset second server.
[0090] The processing and synchronization module 730 is used to execute the data operation request on the first server when the configuration file is updated from the network failure configuration file to the network normal configuration file, and to synchronize data between the first server and the second server through the dedicated line network between the first server and the second server.
[0091] The functions of the device described in the embodiment of the present application have been described in the above method embodiment. Therefore, for any details not provided in the description of this embodiment, please refer to the relevant descriptions in the above embodiments and will not be repeated here.
[0092] The present application also provides a data synchronization device, such as Figure 8 , which is a structural diagram of a data synchronization device according to an embodiment of the present application.
[0093] The data synchronization device includes: a processor 810, a communication interface 820, a memory 830 and a communication bus 840. The processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840.
[0094] The memory 830 is used to store computer programs.
[0095] In one embodiment of the present application, the processor 810, when executing the program stored in the memory 830, implements any one of the aforementioned data synchronization methods executed in the configuration center, including: monitoring a dedicated network for data synchronization between two servers; when it is detected that the dedicated network has a fault, updating the current configuration file to a network fault configuration file; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server; when it is detected that the dedicated network has returned to normal, updating the current configuration file to a network normal configuration file; wherein the network normal configuration file is used to indicate that both servers are read-write servers.
[0096] Wherein, the monitoring of the dedicated line network for data synchronization between two servers includes: monitoring the dedicated line network for data synchronization between two servers through a preset monitoring service; the method also includes: receiving a configuration file corresponding to the network status of the dedicated line network pushed by the monitoring service; wherein, when the monitoring service detects that the dedicated line network has a fault, the monitoring service pushes a network fault configuration file; and when the monitoring service detects that the dedicated line network has returned to normal, the monitoring service pushes a network normal configuration file.
[0097] Among them, when the dedicated line network is monitored to have a fault, the current configuration file is updated to a network fault configuration file, including: when the monitoring center detects that the dedicated line network has a fault, the network fault configuration file pushed by the monitoring center is received, and the current configuration file is overwritten with the network fault configuration file; when the dedicated line network is monitored to have returned to normal, the current configuration file is updated to a network normal configuration file, including: when the monitoring center detects that the dedicated line network has returned to normal, the network normal configuration file pushed by the monitoring center is received, and the network fault configuration file that is the current configuration file is overwritten with the network normal configuration file.
[0098] In one embodiment of the present application, the processor 810, when executing the program stored in the memory 830, implements any one of the aforementioned data synchronization methods executed on the first server, including: receiving a data operation request, and reading a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server; when the configuration file is a network failure configuration file, identifying the operation type corresponding to the data operation request, executing the data operation request of the read operation type on the first server, and executing the data operation request of the write operation type on the read-write server; wherein the read-write server is the first server or a preset second server; when the configuration file is updated from a network failure configuration file to a network normal configuration file, executing the data operation request on the first server, and performing data synchronization between the first server and the second server through a dedicated network between the first server and the second server.
[0099] The receiving of the data operation request includes: receiving the data operation request from a domain name system; or receiving the data operation request forwarded from the second server.
[0100] Wherein, executing the data operation request of the write operation type on the read-write server includes: determining whether the first server is the read-write server according to the network fault configuration file; if the first server is the read-write server, executing the data operation request of the write operation type on the first server; if the first server is not the read-write server, sending the data operation request of the write operation type to the second server through a public network, so that the second server executes the data operation request of the write operation type.
[0101] Wherein, the data synchronization between the first server and the second server includes: when the first server is the read-write server, in the process of reading the configuration file from the configuration center, recording the first update time and the second update time; wherein, the first update time is the time when the configuration file is updated from the network normal configuration file to the network fault configuration file; the second update time is the time when the configuration file is updated from the network fault configuration file to the network normal configuration file; copying the first incremental data generated by the first database between the first update time and the second update time, and, through the dedicated network between the first server and the second server, sending the first incremental data to the second server, so that the second server updates the data in the second database with the first incremental data; when the first server is not the read-write server, receiving the second incremental data from the second server through the dedicated network between the first server and the second server, and updating the data in the first database with the second incremental data.
[0102] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the data synchronization method provided in the configuration center as in any of the aforementioned method embodiments are implemented, or the steps of the data synchronization method provided in the first server as in any of the aforementioned method embodiments are implemented. Since the data synchronization method has been described in detail above, for any details not fully described in the description of this embodiment, please refer to the relevant descriptions in the aforementioned embodiments, and no further description will be given here.
[0103] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0105] It should be understood that the terms used in the text are only for the purpose of describing specific example embodiments, and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used in the text may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0106] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A data synchronization method, characterized in that: Applicable to the configuration center, including: Monitor the dedicated network used for data synchronization between two servers; When a failure of the dedicated network is detected, the current configuration file is updated to a network failure configuration file; wherein the network failure configuration file is used to indicate that one of the two servers is a read-write server; When it is monitored that the dedicated network returns to normal, the current configuration file is updated to a normal network configuration file; wherein the normal network configuration file is used to indicate that both servers are read-write servers.
2. The method according to claim 1, characterized in that The monitoring of a dedicated network for data synchronization between two servers includes: Monitor the dedicated network used for data synchronization between two servers through the preset monitoring service; The method further comprises: Receive a configuration file corresponding to the network status of the dedicated network pushed by the monitoring service; wherein, when the monitoring service detects that the dedicated network has a fault, the monitoring service pushes a network fault configuration file; and when the monitoring service detects that the dedicated network has returned to normal, the monitoring service pushes a network normal configuration file.
3. The method according to claim 2, characterized in that When the dedicated line network is detected to have a fault, updating the current configuration file to a network fault configuration file includes: When the monitoring center detects that the dedicated network has a fault, receiving a network fault configuration file pushed by the monitoring center, and using the network fault configuration file to overwrite a current configuration file; When the dedicated line network is detected to be back to normal, updating the current configuration file to a normal network configuration file includes: When the monitoring center detects that the dedicated network has returned to normal, the normal network configuration file pushed by the monitoring center is received, and the normal network configuration file is used to overwrite the network fault configuration file that is the current configuration file.
4. A data synchronization method, characterized in that: Applied to the first server, comprising: Receive a data operation request, and read a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server; In the case where the configuration file is a network fault configuration file, identifying the operation type corresponding to the data operation request, executing the data operation request of the read operation type on the first server, and executing the data operation request of the write operation type on the read-write server; wherein the read-write server is the first server or a preset second server; When the configuration file is updated from the network failure configuration file to the network normal configuration file, the data operation request is executed on the first server, and data synchronization is performed between the first server and the second server through a dedicated network between the first server and the second server.
5. The method according to claim 4, characterized in that The receiving of the data operation request comprises: Receive data operation requests from the domain name system; or, A data operation request is received from the second server.
6. The method according to claim 4, characterized in that The data operation request of executing a write operation type on the read-write server includes: determining, according to the network fault configuration file, whether the first server is the read-write server; In the case where the first server is the read-write server, executing the data operation request of a write operation type on the first server; In the case that the first server is not the read-write server, the data operation request of the write operation type is sent to the second server through the public network, so that the second server executes the data operation request of the write operation type.
7. The method according to claim 4, characterized in that The synchronizing data between the first server and the second server includes: In the case where the first server is the read-write server, in the process of reading the configuration file from the configuration center, a first update time and a second update time are recorded; wherein the first update time is the time when the configuration file is updated from the network normal configuration file to the network fault configuration file; and the second update time is the time when the configuration file is updated from the network fault configuration file to the network normal configuration file; Copying first incremental data generated in the first database between the first update time and the second update time, and sending the first incremental data to the second server through a dedicated network between the first server and the second server, so that the second server updates the data in the second database by using the first incremental data; In the case that the first server is not the read-write server, the second incremental data from the second server is received through a dedicated network between the first server and the second server, and the second incremental data is used to update the data in the first database.
8. A data synchronization system, characterized in that: The data synchronization system comprises: a configuration center and two servers respectively connected to the configuration center; data synchronization is performed between the two servers via a dedicated line network; The configuration center monitors the dedicated network for data synchronization between the two servers; when it is detected that the dedicated network fails, the current configuration file is updated to a network failure configuration file; wherein the network failure configuration file is used to indicate that one of the two servers is a read-write server; when it is detected that the dedicated network returns to normal, the current configuration file is updated to a network normal configuration file; wherein the network normal configuration file is used to indicate that both servers are read-write servers; The two servers respectively perform the following operations: receive a data operation request, and read a configuration file from a preset configuration center; when the configuration file is a network failure configuration file, identify the operation type corresponding to the data operation request, execute the data operation request of the read operation type on the current server, and execute the data operation request of the write operation type on the read-write server; when the configuration file is updated from a network failure configuration file to a network normal configuration file, execute the data operation request on the current server, and synchronize data between the current server and the other server through a dedicated network between the current server and the other server.
9. A data synchronization device, characterized in that: Settings in the configuration center include: A network monitoring module is used to monitor the dedicated network used for data synchronization between two servers; A first updating module is used to update the current configuration file to a network fault configuration file when a fault is detected in the dedicated network; wherein the network fault configuration file is used to indicate that one of the two servers is a read-write server; The second updating module is used to update the current configuration file to a normal network configuration file when it is monitored that the dedicated network has returned to normal; wherein the normal network configuration file is used to indicate that both servers are read-write servers.
10. A data synchronization device, characterized in that: Set up on the first server, including: A receiving module, used to receive a data operation request and read a configuration file from a preset configuration center; wherein the configuration file is used to indicate a read-write server; an identification and processing module, configured to, when the configuration file is a network fault configuration file, identify an operation type corresponding to the data operation request, execute the data operation request of a read operation type on the first server, and execute the data operation request of a write operation type on the read-write server; wherein the read-write server is the first server or a preset second server; A processing and synchronization module is used to execute the data operation request on the first server when the configuration file is updated from a network failure configuration file to a network normal configuration file, and to synchronize data between the first server and the second server through a dedicated line network between the first server and the second server.
11. A data synchronization device, characterized in that: include: at least one communication interface; at least one bus connected to the at least one communication interface; at least one processor connected to the at least one bus; At least one memory connected to the at least one bus, wherein the processor is configured to: execute a data synchronization program stored in the memory to implement the data synchronization method executed in the configuration center according to any one of claims 1 to 3, or to implement the data synchronization method executed in the first server according to any one of claims 4 to 7.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are executed to implement the data synchronization method executed in the configuration center according to any one of claims 1 to 3, or to implement the data synchronization method executed in the first server according to any one of claims 4 to 7.
Citation Information
Patent Citations
Fault recovery method and monitoring node
CN107026760A
Cluster file synchronization method, cluster file synchronization system, device and storage medium
CN107908708A
Data synchronization method, system and device, computer equipment and storage medium
CN115730016A
Data transmission method and device, electronic equipment and readable storage medium
CN117278572A
Method and system for switching master and standby management software
WO2012149744A1