WO2014059804A1 - 数据同步方法及系统 - Google Patents

数据同步方法及系统 Download PDF

Info

Publication number
WO2014059804A1
WO2014059804A1 PCT/CN2013/079087 CN2013079087W WO2014059804A1 WO 2014059804 A1 WO2014059804 A1 WO 2014059804A1 CN 2013079087 W CN2013079087 W CN 2013079087W WO 2014059804 A1 WO2014059804 A1 WO 2014059804A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
binary log
storage system
data storage
binary
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.)
Ceased
Application number
PCT/CN2013/079087
Other languages
English (en)
French (fr)
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Publication of WO2014059804A1 publication Critical patent/WO2014059804A1/zh
Priority to US14/682,261 priority Critical patent/US20150213100A1/en
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2056Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant by mirroring
    • G06F11/2071Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant by mirroring using a plurality of controllers
    • G06F11/2074Asynchronous techniques
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • G06F16/184Distributed file systems implemented as replicated file system
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2056Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant by mirroring
    • G06F11/2058Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant by mirroring using more than 2 mirrored copies
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0646Horizontal data movement in storage systems, i.e. moving data in between storage devices or systems
    • G06F3/065Replication mechanisms

Definitions

  • the present invention relates to the field of data storage and transmission technologies, and more particularly to a data synchronization method and system. Background technique
  • UGC User Generated Content
  • Community networks, video sharing, and blogging are all major applications of UGC.
  • UGC business is emerging, which has aroused widespread concern in the industry.
  • the system is designed with a disaster recovery solution.
  • the disaster recovery solution requires at least two copies of the complete data available. Each data copy is independent of each other and provides full real-time service. When an exception or disaster occurs in the copy, causing the data copy to fail to provide normal services, the request can be switched to other available data points to provide uninterrupted real-time services, and how to make the data between the data copies consistent. It is a difficult problem for disaster recovery solutions. If there is a simple, efficient and low-cost disaster recovery model, it will bring profound changes to the field.
  • the data storage system is responsible for storing data, providing read and write services, and providing synchronous services for data.
  • the service process After a write operation of the user reaches the service process, the service process first queries the system for how many copies of the available data. If the number of available data copies is N, the service process will copy the write operation to N shares, respectively. A data copy sends this write so that each data copy can update the data to the latest state.
  • the data storage system has a dependency on the data synchronization system. First, the storage of data depends on whether the synchronization of the data is successful. If a write operation succeeds at the main write point, If another data copy update fails, then all writes to the data copy are considered to be unsuccessful;
  • the embodiment of the invention provides a data synchronization method and system, so as to reduce the overall complexity and coupling of the system, and provide users with high reliability and availability data synchronization services.
  • the technical solution is as follows:
  • a data synchronization method including:
  • a data synchronization system comprising:
  • a first writing module configured to write external update data into the first data storage system
  • a generating module configured to record the write operation and generate a binary log
  • a second writing module configured to: Logs are written to the binary log files of the cache pool and disk respectively;
  • the synchronization module is configured to: when the update data is synchronized, search for a binary log corresponding to the update data from the buffer pool, and send the binary log to the second data storage system for data synchronization.
  • Embodiments of the present invention also provide a method for data synchronization, a system for data synchronization, and a non-transitory computer program product including executable program code for data synchronization.
  • the technical solutions are as follows: A method for data synchronization, comprising:
  • the second data storage system is configured to cause the second data storage system to synchronously update data in the second data storage system according to the binary log corresponding to the latest write operation.
  • a system for data synchronization including a first data storage system and a data synchronization system,
  • the first data storage system is configured to generate a binary log according to a data write operation performed in the first data storage system and write the binary log to a memory; and the data synchronization system is configured to be independent of the a first data storage system, searching a binary log corresponding to the latest write operation in the written binary log, and transmitting the binary log corresponding to the latest write operation to the second data storage system, so that the second The data storage system synchronously updates the data in the second data storage system according to the binary log corresponding to the latest write operation.
  • a non-transitory computer program product comprising executable program code for data synchronization, the executable program code operable to: when executed,
  • the second data storage system is configured to cause the second data storage system to synchronously update data in the second data storage system according to the binary log corresponding to the latest write operation.
  • the embodiment of the present invention further provides a disaster tolerance system, including a first data storage system, a data synchronization system, and a second data storage system.
  • the first data storage system is configured to generate a binary log according to a data write operation performed in the first data storage system and write the binary log to a memory; and the data synchronization system is configured to be independent of the a first data storage system, searching for a binary log corresponding to the latest write operation in the written binary log, and corresponding to a binary log of the latest write operation is sent to the second data storage system;
  • the second data storage system is configured to synchronously update data in the second data storage system according to the binary log corresponding to the latest write operation.
  • An embodiment of the present invention further provides another disaster tolerance system, including multiple systems for data synchronization, wherein each system for data synchronization includes a data storage system and a data synchronization system, the data storage system is configured to:
  • the data in the data storage system is synchronously updated according to its binary log corresponding to the latest write operation.
  • the data synchronization system is configured to, when the data is stored in the data storage system, search for a binary log corresponding to the latest write operation in the written binary log, independently of the data storage system, and The binary log corresponding to the most recent write operation is sent to other data storage systems of the system for data synchronization.
  • the technical solution provided by the embodiment of the present invention provides the following advantages:
  • the embodiment of the present invention provides a synchronization strategy based on asynchronous transfer of a buffer pool and a binary log file, and separates the data storage system from the data synchronization system, and the data synchronization system responsible for updating each data copy to the latest state according to the binary log.
  • the system service performance is not reduced at all, and the overall complexity, coupling, and bandwidth cost of the system are greatly reduced.
  • FIG. 1 is a flowchart of a data synchronization method according to an embodiment of the present invention
  • FIG. 2 is a system architecture connection diagram in a data synchronization method according to an embodiment of the present invention
  • FIG. 3 is a structural diagram of a data synchronization system according to an embodiment of the present invention.
  • FIG. 4 is a flowchart of a method for data synchronization provided by an embodiment of the present invention
  • FIG. 5 is a block diagram of a system for data synchronization according to an embodiment of the present invention
  • FIG. 6 is a block diagram of a disaster tolerance system according to an embodiment of the present invention.
  • Embodiments of the present invention provide a data synchronization method and system.
  • FIG. 1 is a flowchart of a data synchronization method according to an embodiment of the present invention
  • FIG. 2 is a connection diagram of a system architecture in a data synchronization method according to an embodiment of the present invention
  • the method includes:
  • Step S101 writing external update data into the first data storage system
  • the service process When the user has a write operation, the service process writes the user's update data to the first data storage system.
  • the service process is a module that provides services such as data writing and reading to the user.
  • the number of service processes may be multiple, corresponding to services in different range segments, and the so-called number segment is a continuous ID range.
  • the basic unit of deployment or migration for example, every 100,000 consecutive IDs becomes a deployment number segment.
  • Step S102 recording the write operation and generating a binary log
  • BinLog Binary Log
  • Some basic information such as write time, write operation serial number, write operation content, etc.
  • Step S103 Write the binary log into a binary log file of the buffer pool and the disk respectively;
  • a cache pool is set in the first data storage system, and the cache pool is implemented by using shared memory for storing BinLog of user write operations.
  • the service process writes the BinLog that records the write operation to the cache pool.
  • the cache pool is responsible for storing the BinLog for the most recent period of time. When the cache pool is full, the earliest stored BinLog is automatically deleted.
  • BinLog file A binary log file (hereinafter referred to as "BinLog file") is also created in the disk of the first data storage system for storing the BinLog of the user write operation.
  • BinLog write After the buffer pool is reached, the service process writes the BinLog to the BinLog file of the disk, and then returns the result of the successful write operation to the outside.
  • the number of BinLogs that can be written in a BinLog file can be set by the system. For example, a BinLog file can write 100,000 BinLogs. When a BinLog file is filled with 100,000 BinLogs, a new BinLog file is created to write. Just enter the new BinLog. Therefore, in addition to writing to the cache pool, BinLog is also written to the BinLog file of the disk.
  • the cache pool has a time limit for the storage of a BinLog
  • the BinLog will be automatically deleted, and the BinLog will be written to the BinLog file of the disk, so that the B i nLo g is saved.
  • the purpose of this is to cause the data of the cache pool to be lost even if the machine suddenly powers down and restarts. Or when the machine suddenly encounters a large number of write operations, and the BinLog that was first written into the cache pool has not been synchronized yet automatically deleted by the cache pool, the BinLog can also be found in the BinLog file of the disk to ensure that the subsequent synchronization system can Read the required sync data.
  • Step S104 When synchronizing the update data, searching for a binary log corresponding to the update data from the buffer pool, and sending the binary log to the second data storage system for data synchronization;
  • the synchronization of the data is completed by the synchronization process in the data synchronization system.
  • the synchronization process runs asynchronously with the service process.
  • the synchronization process is the module responsible for data synchronization.
  • the number segment responsible for the synchronization process can be consistent with the number segment responsible for the service process.
  • the foregoing method further includes:
  • the synchronization process searches for the BinLog corresponding to the update data from the BinLog file saved in the disk, and sends the BinLog to the second data storage system to complete the synchronization. Work.
  • the service process When the synchronization process is performing data synchronization, the service process reads and writes services externally, and the synchronization process and the service process are independent of each other.
  • the method further includes: updating data covered by the binary log file in the first data storage system Regenerate the binary log separately and write the regenerated binary log to a new binary log file.
  • a synchronization strategy based on asynchronous transfer of a buffer pool and a binary log file is proposed, and the data storage system is separated from the data synchronization system.
  • the first data storage system is only responsible for the basic logic of service writing, and does not care about other data.
  • the data state of the data copy in the storage system, the data synchronization system is responsible for updating each data copy to the latest state. In this mode, the system service performance is not reduced at all, and the overall complexity, coupling, and bandwidth cost of the system are greatly reduced. reduce.
  • FIG. 3 is a schematic diagram of a data synchronization system according to an embodiment of the present invention.
  • a first writing module 301 configured to write external update data into the first data storage system
  • a generating module 302 configured to record the write operation and generate a binary log
  • a second writing module 303 configured to separately write the binary log into a binary log file of the buffer pool and the disk;
  • the synchronization module 304 is configured to: when the update data is synchronized, search for a binary log corresponding to the update data from the buffer pool, and send the binary log to the second data storage system for data synchronization.
  • the cache pool is responsible for storing the binary logs of the most recent period of time.
  • the second write module 303 is also used to automatically delete the earliest stored binary logs when the cache pool is full.
  • the second write module 303 writes the binary log to the buffer pool first, and then writes it to the binary log file of the disk, and then returns the result of the successful write operation to the outside.
  • the synchronization module 304 When the synchronization module 304 performs data synchronization, when the binary log corresponding to the update data that needs to be synchronized is not found in the cache pool, the synchronization module 304 is saved from the disk. The binary log file searches for the binary log corresponding to the update data, and sends the binary log to the second data storage system for data synchronization.
  • system further includes a recovery module 305, configured to regenerate the update data covered by the binary log file in the first data storage system into a binary log when the binary log file in the disk is abnormally lost, and The regenerated binary log is written to a new binary log file.
  • a recovery module 305 configured to regenerate the update data covered by the binary log file in the first data storage system into a binary log when the binary log file in the disk is abnormally lost, and The regenerated binary log is written to a new binary log file.
  • the method for data synchronization may include step 401, step 402, and step 403.
  • step 401 generating a Binlog according to a data write operation performed in the first data storage system
  • step 403 independent of generating Binlog and writing Binlog to the memory, searching for the Binlog corresponding to the latest write operation in the written Binlog, and transmitting the Binlog corresponding to the latest write operation to the second data storage system, so that The second data storage system synchronously updates the data in the second data storage system according to the Binlog corresponding to the latest write operation.
  • the external computing device performs a data write operation to the first data storage system.
  • a Binlog is generated according to the data write operation.
  • the above process can be implemented by one or more service processes. Then, the Binlog corresponding to the latest write operation is found in the written Binlog, and the Binlog corresponding to the latest write operation is sent to the second data storage system.
  • This process can be implemented with one or more synchronization processes that correspond to the service processes. Steps 401, 402 and step 403 are separated from each other and are independent of each other. In other words, steps 401, 402 need not consider whether step 403 is completed or not, that is, without waiting for step 403 to complete, it can be started again.
  • the above-described method for data synchronization while ensuring successful synchronization between a plurality of data storage systems, significantly reduces the complexity and coupling of the method. The bandwidth cost required to synchronize between multiple data storage systems is also greatly reduced.
  • Binlog can be used to recover data writes.
  • the above method may further comprise: in the case of data loss in the first data storage system, simulating the write operation according to the written Binlog to recover the lost data. Specifically, first according to the first A data stored in a data storage system that determines the write operation corresponding to the lost data. The written Binlog is searched in the memory according to the write operation corresponding to the lost data. The lost data is recovered according to the written Binlog analog write operation. Through the above operations, the security of the first data storage system is effectively guaranteed.
  • the memory may comprise a buffer pool.
  • the cache pool can be implemented using memory.
  • a portion of the storage space in memory can be used as a buffer pool.
  • the service process will record the Binlog write buffer pool for this write operation.
  • Using memory to implement Cache pools is easy to implement and can significantly increase access rates.
  • writing the Binlog to the memory includes: when the buffer pool is full, replacing the earliest written Binlog with the current Binlog to be written in the buffer pool. It is easy to implement with a first-in, first-out mechanism.
  • the memory may comprise a magnetic disk.
  • a disk is typically a non-volatile memory.
  • the data stored on the disk is not lost, thus ensuring the security of the Binlog.
  • writing the Binlog to the memory comprises: writing the Binlog to a Binlog file of the disk, wherein each Binlog file can include a preset number of Binlogs. Each Binlog can have a unique serial number. In this way, the system can efficiently utilize the disk management Binlog.
  • writing the Binlog to the memory includes writing the Binlog to the buffer pool and the disk.
  • Finding the Binlog corresponding to the most recent write operation in the written Binlog includes looking up the Binlog in the cache pool for the latest write operation.
  • Finding the Binlog corresponding to the latest write operation in the written Binlog also includes finding the Binlog corresponding to the latest write operation on the disk for the case where the Binlog corresponding to the latest write operation is not found in the cache pool.
  • the Binlog is written to the Binlog file saved on the disk.
  • the Binlog write cache pool ensures that the synchronization process can quickly find the Binlog from the cache pool.
  • it can be ensured that the synchronization process can find the Binlog written in the buffer pool, for example, if the Binlog to be searched has been replaced by the Binlog written later, and can be saved in the Binlog on the disk.
  • the Binlog written is found in the file. This ensures that the data synchronization system can read the required Binlog.
  • the method for data synchronization of the present invention further includes: The number of Binlogs written and the number of simultaneous updates to the data in the second data storage system are compared. Wherein, in the case that the number of writes of the Binlog is greater than the number of times of synchronous update of the data in the second data storage system, searching for the Binlog corresponding to the latest write operation in the written Binlog, and corresponding to The Binlog of the latest write operation is sent to the second data storage system.
  • the number of Binlogs written is 6, and the number of simultaneous updates to the data in the second data storage system is four. Because 6 is greater than 4, the Binlog corresponding to the latest write operation (ie, the 5th and 6th Binlog) is searched from the written Binlog in the memory and sent to the second data storage system in sequential order. So that the second data storage system synchronizes the data copy according to the Binlog.
  • the method may further comprise: returning information indicating that the write operation was successful to the computing device performing the write operation after the Binlog is written to the memory. Thereby, the computing device can perform a new write operation in time.
  • steps 401, 402 and 403 in the method are independent of one another. Therefore, as long as the Binlog is written to the memory, the write operation is considered successful. Regardless of whether the data in the data storage system other than the first data storage system has been updated, a new write operation to the first data storage system can continue.
  • FIG. 5 is a block diagram of a system for data synchronization according to an embodiment of the present invention. As shown in Figure 5, the system includes a first data storage system and a data synchronization system.
  • the first data storage system is operative to generate a Binlog based on a data write operation in the first data storage system and to write the Binlog to the memory.
  • the memory in Figure 5 is shown as a Binlog file in the cache pool and disk.
  • the data synchronization system is configured to search for a Binlog corresponding to the latest write operation in the written Binlog, and send a Binlog corresponding to the latest write operation to the second data storage system, so as to be independent of the first data storage system.
  • the second data storage system synchronously updates the data in the second data storage system according to the Binlog corresponding to the latest write operation.
  • the first data storage system is further configured to return information indicating that the write operation is successful to the computing device performing the write operation after the Binlog is written to the memory.
  • the data synchronization system is further configured to recover the lost data according to the written Binlog analog write operation in the case of data loss in the first data storage system.
  • the data synchronization system is further configured to recover the lost data according to the written Binlog analog write operation in the case of data loss in the first data storage system.
  • a non-transitory computer program product comprising executable program code for data synchronization.
  • the executable program code is operable to: when executed, generate a Binlog according to a data write operation performed in the first data storage system; write a Binlog to the memory; and write the Binlog separately and write the Binlog to the memory, Searching for the Binlog corresponding to the latest write operation in the incoming Binlog, and transmitting the Binlog corresponding to the latest write operation to the second data storage system, so that the second data storage system stores the second data according to the Binlog corresponding to the latest write operation.
  • the data in the system is updated synchronously.
  • executable program code described above is further operable to implement all of the steps of the method for data synchronization when executed.
  • additional functionality of the executable code is not further described herein.
  • the code may directly cause the processor to perform specified operations, be compiled to cause the processor to perform specified operations, and/or be combined with other software, hardware, and/or firmware components (eg, libraries for implementing standard functions) for processing The device performs the specified operation.
  • a disaster tolerance system is also provided, as shown in FIG.
  • the system includes a first data storage system, a data synchronization system, and a second data storage system.
  • the first data storage system is for generating a Binlog based on a data write operation in the first data storage system and writing the Binlog to the memory.
  • the data synchronization system is configured to search for a Binlog corresponding to the latest write operation in the written Binlog independently of the first data storage system, and send a Binlog corresponding to the latest write operation to the second data storage system.
  • the second data storage system is for synchronously updating data in the second data storage system based on the Binlog corresponding to the most recent write operation.
  • the first data storage system and the data synchronization system are implemented by the same computing device.
  • the disaster tolerant system includes multiple systems for data synchronization. Each of these systems for data synchronization includes a data storage system and a data synchronization system.
  • the data storage system is used to generate a Binlog according to a write operation and write a Binlog to the memory when a write operation of data is performed in the data storage system.
  • the data storage system is further configured to synchronize data in the data storage system according to its Binlog corresponding to the latest write operation when data is written in another data storage system for data synchronization. New.
  • the data synchronization system is configured to search for a Binlog corresponding to the latest write operation in the written Binlog independently of the data storage system when the data is written in the data storage system, and send the Binlog corresponding to the latest write operation.
  • each system for data synchronization includes a data storage system and a data synchronization system. Therefore, each system used for data synchronization can be configured to receive external update data. Thus, when a system for data synchronization is currently used to receive external update data, another system for data synchronization can be configured to receive external update data instead. As a result, the disaster recovery system is maintained in normal operation.
  • the data synchronization method and system proposed in the foregoing embodiments have the following advantages:
  • the synchronization process works asynchronously with the service process, and the coupling is reduced.
  • the two systems can be independently designed, developed, launched, and maintained, and the design is simple, and the operation and maintenance cost is reduced.
  • the synchronization success rate is improved, the user write operation can return a successful result as long as the BinLog file is successfully written;
  • the introduction of the cache pool greatly reduces the number of times the synchronization process reads the disk, and improves the performance of the entire system;
  • the BinLog file ensures Any synchronous data can be found.
  • the storage medium may be a magnetic disk, an optical disk, or a read-only memory. Read-Only Memory (ROM) or Random Access Memory (RAM).

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Computer Security & Cryptography (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Hardware Redundancy (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明实施例公开了一种数据同步方法及系统,所述数据同步方法包括:将外部的更新数据写入第一数据存储系统中;将该写入操作进行记录并生成二进制日志;将该二进制日志分别写入缓存池和磁盘的二进制日志文件中;在将该更新数据进行同步时,从缓存池中查找该更新数据所对应的二进制日志,并将该二进制日志发送给第二数据存储系统进行数据同步。本发明实施例提出了一种基于缓存池和二进制日志文件的异步传送的同步策略,将数据存储系统与数据同步系统分离,数据同步系统负责将各个数据拷贝根据二进制日志更新到最新的状态,在该模式下,系统服务性能没有丝毫降低的同时,系统的整体复杂度、耦合性、带宽成本都大幅降低。

Description

数据同步方法及系统 相关申请的交叉引用
本申请要求于 2012 年 10 月 18 日提交中国专利局、 申请号为
201210397350.7、 发明名称为 "数据同步方法及系统"的中国专利申请的优 先权, 其全部内容通过引用结合在本申请中。 技术领域
本发明涉及数据存储与传输技术领域, 并且更具体地, 涉及一种数据 同步方法及系统。 背景技术
UGC (User Generated Content, 用户原创内容)是一种用户使用互联网 的新方式, 即由原来的以下载为主变成下载和上传并重。 社区网络、 视频 分享和博客等都是 UGC 的主要应用形式。 随着全球互联网业务的不断发 展, UGC业务正在日渐崛起, 引起了业界的广泛关注。
为了安全运营, 系统设计时会引入容灾方案, 容灾方案要求系统至少 有两份可用的完整数据拷贝, 各个数据拷贝在部署上相互独立, 并且都能 提供全量的实时服务, 当其中一个数据拷贝出现异常或者灾难从而导致该 数据拷贝无法提供正常的服务时, 可以把请求切换到其他可用的数据点, 以提供不间断的实时服务, 如何使各个数据拷贝之间的数据能够保持一致 性, 是容灾方案面临的一个难题, 如果能有一种简单、 高效、 低成本的容 灾模型, 将为该领域带来意义深远的变革。
现有技术中, 数据存储系统负责数据的存储, 提供读写服务, 同时提 供数据的同步服务。 用户的一个写操作到达服务进程后, 服务进程首先会 查询系统一共有多少个可用数据拷贝, 假设有可用的数据拷贝数为 N, 那 么服务进程会把这个写操作复制成 N份, 分别对每一个数据拷贝发送这个 写操作, 从而使每个数据拷贝都能将数据更新到最新状态。
(1) 耦合性高。数据存储系统与数据同步系统有依赖关系。 首先, 数据 的存储依赖于数据的同步是否成功, 如果某个写操作在主写点成功了, 但 是另外一个数据拷贝更新失败了, 那么所有数据拷贝的这个写操作都认为 是失败的;
(2) 设计复杂。 两个系统同等重要, 为了保证对外的正常服务, 某一个 系统出现异常时都会影响另一个系统的正常服务, 这种设计直接导致运維 成本增力口
(3) 搭建新数据拷贝困难。 当需要搭建一个新数据拷贝的时候, 需要导 入原先的历史数据, 同时还需要系统停写支持;
(4) 数据拷贝越多性能越差。 当可用的数据拷贝越多时, 某一个数据拷 贝更新失败会导致更多的写操作被判为无效, 致使系统性能下降。 发明内容
本发明实施例提供了一种数据同步方法及系统, 以降低系统的整体 复杂度、 耦合性, 为用户提供高可靠性、 可用性的数据同步服务。 所述 技术方案如下:
一种数据同步方法, 包括:
将外部的更新数据写入第一数据存储系统中;
将该写入操作进行记录并生成二进制日志;
将该二进制日志分别写入緩存池和磁盘的二进制日志文件中; 在将该更新数据进行同步时, 从緩存池中查找该更新数据所对应的 二进制日志, 并将该二进制日志发送给第二数据存储系统进行数据同步。
一种数据同步系统, 包括:
第一写入模块, 用于将外部的更新数据写入第一数据存储系统中; 生成模块, 用于将该写入操作进行记录并生成二进制日志; 第二写入模块, 用于将该二进制日志分别写入緩存池和磁盘的二进 制日志文件中;
同步模块, 用于在将该更新数据进行同步时, 从緩存池中查找该更 新数据所对应的二进制日志, 并将该二进制日志发送给第二数据存储系 统进行数据同步。
本发明实施例还提供了一种用于数据同步的方法、 一种用于数据同 步的系统以及一种包括用于数据同步的可执行程序代码的非暂时性计算 机程序产品。 技术方案如下: 一种用于数据同步的方法, 包括:
根据在第一数据存储系统中进行的数据写操作生成二进制日志; 将所述二进制日志写入存储器; 以及
独立于所述生成二进制日志和所述将所述二进制日志写入存储器, 在所写入的二进制日志中查找对应于最新写操作的二进制日志, 并将所 述对应于最新写操作的二进制日志发送给第二数据存储系统, 以使所述 第二数据存储系统根据所述对应于最新写操作的二进制日志对所述第二 数据存储系统中的数据进行同步更新。
一种用于数据同步的系统, 包括第一数据存储系统以及数据同步系 统,
所述第一数据存储系统用于根据在所述第一数据存储系统中进行的 数据写操作生成二进制日志以及将所述二进制日志写入存储器; 以及 所述数据同步系统用于, 独立于所述第一数据存储系统, 在所写入 的二进制日志中查找对应于最新写操作的二进制日志, 并将所述对应于 最新写操作的二进制日志发送给第二数据存储系统, 以使所述第二数据 存储系统根据所述对应于最新写操作的二进制日志对所述第二数据存储 系统中的数据进行同步更新。
一种包括用于数据同步的可执行程序代码的非暂时性计算机程序产 品, 所述可执行程序代码可操作用于: 当执行时,
根据在第一数据存储系统中进行的数据写操作生成二进制日志; 将所述二进制日志写入存储器; 以及
独立于所述生成二进制日志和所述将所述二进制日志写入存储器, 在所写入的二进制日志中查找对应于最新写操作的二进制日志, 并将所 述对应于最新写操作的二进制日志发送给第二数据存储系统, 以使所述 第二数据存储系统根据所述对应于最新写操作的二进制日志对所述第二 数据存储系统中的数据进行同步更新。
本发明实施例还提供了一种容灾系统, 包括第一数据存储系统、 数 据同步系统以及第二数据存储系统,
所述第一数据存储系统用于根据在所述第一数据存储系统中进行的 数据写操作生成二进制日志以及将所述二进制日志写入存储器; 以及 所述数据同步系统用于, 独立于所述第一数据存储系统, 在所写入 的二进制日志中查找对应于最新写操作的二进制日志, 并将所述对应于 最新写操作的二进制日志发送给所述第二数据存储系统;
所述第二数据存储系统用于根据所述对应于最新写操作的二进制日 志对所述第二数据存储系统中的数据进行同步更新。
本发明实施例还提供了另一种容灾系统, 包括多个用于数据同步的 系统,其中每个用于数据同步的系统包括数据存储系统和数据同步系统, 所述数据存储系统用于:
当在所述数据存储系统中进行数据的写操作时, 根据所述写操作生 成二进制日志, 以及将所述二进制日志写入存储器;
当在另一个用于数据同步的系统的数据存储系统中进行数据的写操 作时, 根据其对应于最新写操作的二进制日志对所述数据存储系统中的 数据进行同步更新。
所述数据同步系统用于, 当在所述数据存储系统中进行数据的写操 作时, 独立于所述数据存储系统, 在所写入的二进制日志中查找对应于 最新写操作的二进制日志, 并将所述对应于最新写操作的二进制日志发 送给其他用于数据同步的系统的数据存储系统。
本发明实施例提供的技术方案带来的有益效果是: 本发明实施例提 出了一种基于緩存池和二进制日志文件的异步传送的同步策略, 将数据 存储系统与数据同步系统分离, 数据同步系统负责将各个数据拷贝根据 二进制日志更新到最新的状态, 在该模式下, 系统服务性能没有丝毫降 低的同时, 系统的整体复杂度、 耦合性、 带宽成本都大幅降低。 附图说明
为了更清楚地说明本发明实施例中的技术方案, 下面将对实施例描 述中所需要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图 仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出 创造性劳动的前提下, 还可以根据这些附图获得其他的附图。
图 1是本发明实施例提供的一种数据同步方法的流程图;
图 2是本发明实施例提供的一种数据同步方法中的系统架构连接关 系图;
图 3是本发明实施例提供的一种数据同步系统的组成图;
图 4是本发明实施例提供的一种用于数据同步方法的流程图; 图 5是本发明实施例提供的一种用于数据同步的系统的框图; 以及 图 6是本发明实施例提供的一种容灾系统的框图。 具体实施方式
本发明实施例提供一种数据同步方法及系统。
为使本发明的目的、 技术方案和优点更加清楚, 下面将结合附图对 本发明实施方式作进一步地详细描述。
请参考图 1, 图 1 为本发明实施例提供的一种数据同步方法的流程 图; 图 2是本发明实施例提供的一种数据同步方法中的系统架构连接关 系图; 请同时参考图 1与图 2, 所述方法包括:
步骤 S101 : 将外部的更新数据写入第一数据存储系统中;
当用户有写入操作时, 服务进程将用户的更新数据写入第一数据存 储系统中。 其中, 服务进程为给用户提供数据写入、 读取等服务的模块, 服务进程的数量可以为多个, 分别对应于不同号段范围内的业务, 所谓 号段为一个连续的 ID范围, 是部署或迁移的基本单位, 例如每十万个连 续 ID成为一个部署号段。
步骤 S102 : 将该写入操作进行记录并生成二进制日志;
在将用户的更新数据成功写入第一数据存储系统之后, 服务进程将 本次的写入操作进行记录并生成二进制日志(Binary Log , 以下简称 " BinLog "), BinLog记录了本次写入操作的一些基本信息例如写入时间、 写操作序号、 写操作内容等;
步骤 S103 : 将该二进制日志分别写入緩存池和磁盘的二进制日志文 件中;
第一数据存储系统中设置了一个緩存池, 该緩存池使用共享内存实 现, 用于存储用户写操作的 BinLog。 当外部的更新数据写入第一数据存 储系统后, 服务进程将记录本次写入操作的 BinLog写入到緩存池中。 緩 存池负责存储最近一段时间的 BinLog, 当緩存池存储满的时候自动删除 最早存入的 BinLog。
在第一数据存储系统的磁盘中还建立了一个二进制日志文件(以下 简称 " BinLog文件"), 用于存储用户写入操作的 BinLog。 BinLog写入 到緩存池后, 服务进程再将该 BinLog写入到磁盘的 BinLog文件中, 然 后对外部返回本次写操作成功的结果。 一个 BinLog 文件可以写入的 BinLog条数可以由系统进行设定,例如一个 BinLog文件可以写入十万条 的 BinLog, 当一个 BinLog 文件写满十万条 BinLog, 再建立一个新的 BinLog文件进行写入新的 BinLog即可。 因此, BinLog除了写入緩存池 之外, 还一并写入到了磁盘的 BinLog文件中, 由于緩存池对某一 BinLog 的存储有时间限制, 当新的 BinLog写入緩存池时, 最早存入緩存池中的 BinLog将被自动删除掉, 而将 BinLog写入到磁盘的 BinLog文件中, 使 得该 B i nLo g被保存下来, 这样做的目的是即使机器突然掉电重启而导致 緩存池的数据丟失, 或者机器突然遭遇海量的写操作而导致最早写入緩 存池中的 BinLog还没进行同步即被緩存池自动删除掉的时候,该 BinLog 还能在磁盘的 BinLog文件中找到, 以保证后面同步系统能够读取到需要 的同步数据。
步骤 S104 : 在将该更新数据进行同步时, 从緩存池中查找该更新数 据所对应的二进制日志, 并将该二进制日志发送给第二数据存储系统进 行数据同步;
数据的同步由数据同步系统中的同步进程完成, 同步进程与服务进 程异步运行, 同步进程为负责数据同步的模块, 同步进程负责的号段可 以与服务进程负责的号段一致。
当有外部的更新数据写入第一数据存储系统中, 且同步进程检測到 某个数据拷贝(例如第二数据存储系统中的数据拷贝)的数据状态并没有 达到最新时, 就需要进行数据同步。 在将该更新数据进行同步时, 同步 进程从緩存池中查找需要同步的该更新数据所对应的 BinLog, 并将这些 BinLog按先后顺序发送给该数据拷贝进行数据同步, 使得每个数据拷贝 (例如第一、 第二数据存储系统中的数据拷贝)都达到最新数据状态。 在 同步数据时,可以一次只发送一个 BinLog,也可以一次发送多个 BinLog。
由于緩存池只保留最近一段时间的 BinLog, 当需要同步的更新数据 所对应的 BinLog在緩存池中并没有找到时, 上述方法进一步包括:
同步进程再从保存在磁盘中的 BinLog 文件中查找该更新数据所对 应的 BinLog, 并将该 BinLog发送给第二数据存储系统, 进而完成同步动 作。
同步进程在进行数据同步的时候, 服务进程对外进行读写服务, 同 步进程和服务进程互相独立。
如果因为异常原因, 磁盘中的二进制日志文件出现异常丟失, 例如 被误删除或者系统出现故障导致文件丟失时, 所述方法进一步包括: 将第一数据存储系统中该二进制日志文件所涵盖的更新数据分别重 新生成二进制日志, 并将所述重新生成的二进制日志写入一个新的二进 制日志文件中。
上述实施例中提出了一种基于緩存池和二进制日志文件的异步传送 的同步策略, 将数据存储系统与数据同步系统分离, 第一数据存储系统 只负责业务写的基本逻辑, 而不用关心其它数据存储系统中数据拷贝的 数据状态, 数据同步系统负责将各个数据拷贝更新到最新的状态, 在该 模式下, 系统服务性能没有丝毫降低的同时, 系统的整体复杂度、 耦合 性、 带宽成本都大幅降低。
请参考图 3, 图 3 为本发明实施例提供的一种数据同步系统的组成 图; 所述系统包括:
第一写入模块 301, 用于将外部的更新数据写入第一数据存储系统 中;
生成模块 302, 用于将该写入操作进行记录并生成二进制日志; 第二写入模块 303, 用于将该二进制日志分别写入緩存池和磁盘的 二进制日志文件中;
同步模块 304, 用于在将该更新数据进行同步时, 从緩存池中查找 该更新数据所对应的二进制日志, 并将该二进制日志发送给第二数据存 储系统进行数据同步。
緩存池负责存储最近一段时间的二进制日志, 第二写入模块 303还 用于当緩存池存储满的时候, 自动删除最早存入的二进制日志。
第二写入模块 303将二进制日志先写入到緩存池, 再写入磁盘的二 进制日志文件中, 之后再对外部返回本次写操作成功的结果。
同步模块 304在进行数据同步时, 当需要同步的更新数据所对应的 二进制日志在緩存池中没有找到时, 同步模块 304再从保存在磁盘中的 二进制日志文件中查找该更新数据所对应的二进制日志, 并将该二进制 日志发送给第二数据存储系统进行数据同步。
进一步地, 所述系统还包括恢复模块 305, 用于当磁盘中的二进制 日志文件异常丟失时, 将第一数据存储系统中该二进制日志文件所涵盖 的更新数据分别重新生成二进制日志, 并将所述重新生成的二进制日志 写入一个新的二进制日志文件中。
关于本实施例的数据同步系统的进一步细节, 还可参阅上述实施例 的数据同步方法及相关描述。
图 4示出了根据本发明一个优选实施例的用于数据同步的方法的流 程图。 如图 4 所示, 该用于数据同步方法可以包括步骤 401、 步骤 402 和步骤 403。
在步骤 401 : 根据在第一数据存储系统中进行的数据写操作生成 Binlog;
在步骤 402 : 将 Binlog写入存储器;
在步骤 403 : 独立于生成 Binlog和将 Binlog写入存储器, 在所写入 的 Binlog中查找对应于最新写操作的 Binlog, 并将对应于最新写操作的 Binlog 发送给第二数据存储系统, 以使第二数据存储系统根据对应于最 新写操作的 Binlog对第二数据存储系统中的数据进行同步更新。
外部计算设备向第一数据存储系统进行数据写操作。 当数据写操作 成功后, 根据该数据写操作生成 Binlog。 将 Binlog写入存储器。 上述过 程可以由一个或多个服务进程实现。 然后, 在所写入的 Binlog中查找对 应于最新写操作的 Binlog, 并将对应于最新写操作的 Binlog发送给第二 数据存储系统。 该过程可以用一个或多个分别与服务进程相对应的同步 进程实现。 步骤 401、 402与步骤 403之间彼此分离、 相互独立。换言之, 步骤 401、 402无需考虑步骤 403完成与否, 即, 无需等待步骤 403完成, 即可再次启动。 由此, 上述用于数据同步的方法, 在保证在多个数据存 储系统之间成功同步的同时, 方法的复杂度、 耦合性显著降低。 在多个 数据存储系统之间进行同步所要求的带宽成本也大幅降低。
Binlog 可以用于恢复数据写操作。 根据本发明一个优选实施例, 上 述方法还可以包括在第一数据存储系统中的数据丟失的情况下, 根据所 写入的 Binlog模拟该写操作来恢复所丟失的数据。 具体地, 首先根据第 一数据存储系统中现存的数据, 确定丟失的数据所对应的写操作。 根据 丟失的数据所对应的写操作在存储器中查找所写入的 Binlog。 根据所写 入的 Binlog模拟写操作来恢复所丟失的数据。 通过上述操作, 有效保证 了第一数据存储系统的安全性。
根据本发明一个优选实施例, 存储器可以包括緩存池。 优选地, 緩 存池可以使用内存实现。 例如, 在第一数据存储系统中, 可以将内存中 的一部分存储空间用作緩存池。 当外部的更新数据写入第一数据存储系 统后, 服务进程将记录本次写操作的 Binlog写入緩存池。 使用内存实现 緩存池易于实现, 并且能够显著提高存取速率。
緩存池容量有限。 根据本发明一个优选实施例, 将 Binlog写入存储 器包括: 当緩存池写满时, 在緩存池中用当前待写入的 Binlog替换最早 写入的 Binlog。 采用先入先出机制, 易于实现。
根据本发明一个优选实施例, 存储器可以包括磁盘。 磁盘一般为非 易失性存储器。 在第一数据存储系统突然掉电时, 存储在磁盘中的数据 不会丟失, 从而保证了 Binlog的安全性。
优选地, 将 Binlog写入存储器包括: 将 Binlog写入到磁盘的 Binlog 文件中, 其中每个 Binlog文件能够包括预设数目的 Binlog。 每个 Binlog 可以具有唯一序号。 这样, 系统能够高效地利用磁盘管理 Binlog。
根据本发明一个优选实施例, 将 Binlog写入存储器包括将 Binlog写 入到緩存池和磁盘。 在所写入的 Binlog 中查找对应于最新写操作的 Binlog 包括在緩存池中查找对应于最新写操作的 Binlog。 在所写入的 Binlog中查找对应于最新写操作的 Binlog还包括对于未能在緩存池找到 对应于最新写操作的 Binlog的情况, 在磁盘中查找对应于最新写操作的 Binlog
根据本发明的一个优选实施例, Binlog写入緩存池后,再将该 Binlog 写入保存在磁盘中的 Binlog文件中。 具体地, 一方面, Binlog写入緩存 池可以保证同步进程能够迅速地从緩存池中查找到 Binlog。 另一方面, 可以保证同步进程在没有从緩存池中查找到所写入的 Binlog的情况下, 例如待查找的 Binlog已经被后写入的 Binlog所替换的情况, 能够在保存 在磁盘中的 Binlog文件中查找到所写入的 Binlog。 这样, 保证了数据同 步系统能够读取到需要的 Binlog。
根据本发明的一个实施例, 本发明的用于数据同步的方法还包括: 比较所写入的 Binlog的数目以及对第二数据存储系统中的数据进行同步 更新的次数。 其中, 在所写入的 Binlog的数目大于对第二数据存储系统 中的数据进行同步更新的次数的情况下, 进行在所写入的 Binlog中查找 对应于最新写操作的 Binlog, 并将对应于最新写操作的 Binlog发送给第 二数据存储系统。
例如, 在一个实施例中, 所写入的 Binlog数目是 6, 对第二数据存 储系统中的数据进行同步更新的次数是 4。 因为 6大于 4, 所以从存储器 中的所写入的 Binlog中查找对应于最新写操作的 Binlog (即, 第 5个和 第 6个 Binlog) 并将其按照先后顺序发送给第二数据存储系统, 以使第 二数据存储系统根据该 Binlog对其数据拷贝进行同步更新。
上述检測第二数据存储系统中的数据状态的方法, 可操作性强。 根据本发明一个实施例, 该方法还可以包括: 在将 Binlog写入存储 器之后, 向执行写操作的计算设备返回写操作成功的信息。 从而, 使计 算设备可以及时进行新的写操作。 如前所述, 该方法中的步骤 401、 402 和 403是相互独立的。 因此, 只要将 Binlog写入存储器, 即可认为写操 作已经成功。 无论第一数据存储系统以外的其他数据存储系统中的数据 是否已经更新, 都可以继续对第一数据存储系统进行新的写操作。
根据本发明另一方面, 还提供了一种用于数据同步的系统。 图 5是 本发明实施例提供的一种用于数据同步的系统的框图。 如图 5所示, 该 系统包括第一数据存储系统和数据同步系统。
第一数据存储系统用于根据在第一数据存储系统中进行的数据写操 作生成 Binlog, 以及将 Binlog写入存储器。 在图 5中存储器示出为緩存 池和磁盘中的 Binlog文件。数据同步系统用于独立于第一数据存储系统, 在所写入的 Binlog中查找对应于最新写操作的 Binlog, 并将对应于最新 写操作的 Binlog发送给第二数据存储系统, 以使所述第二数据存储系统 根据所述对应于最新写操作的 Binlog对所述第二数据存储系统中的数据 进行同步更新。
优选地, 第一数据存储系统还用于在将 Binlog写入存储器之后, 向 执行写操作的计算设备返回写操作成功的信息。
优选地, 数据同步系统还用于在第一数据存储系统中的数据丟失的 情况下, 根据所写入的 Binlog模拟写操作来恢复所丟失的数据。 本领域普通技术人员参考上面所详细描述的用于数据同步的方法, 可以理解用于数据同步的系统的具体操作。 为了简洁, 在此不再赘述。
根据本发明一个实施例, 还提供了一种包括用于数据同步的可执行 程序代码的非暂时性计算机程序产品。 可执行程序代码可操作用于: 当 执行时, 根据在第一数据存储系统中进行的数据写操作生成 Binlog; 将 Binlog写入存储器; 以及独立于生成 Binlog和将 Binlog写入存储器, 在 所写入的 Binlog中查找对应于最新写操作的 Binlog, 并将对应于最新写 操作的 Binlog发送给第二数据存储系统, 以使第二数据存储系统根据对 应于最新写操作的 Binlog对第二数据存储系统中的数据进行同步更新。
本领域普通技术人员可以理解, 上述可执行程序代码进一步可操作 用于当执行时, 实施用于数据同步的方法的所有步骤。 为了简洁, 在此 不对可执行程序代码的附加功能进行进一步描述。注意, 代码可直接使处 理器实施指定操作、 经编译以使处理器实施指定操作、 和 /或与其他软件、 硬件、 和 /或固件元件 (例如用于实施标准功能的库) 结合以使处理器实施 指定操作。
根据本发明另一方面, 还提供了一种容灾系统, 如图 2所示。 所述 系统包括第一数据存储系统、 数据同步系统以及第二数据存储系统。
第一数据存储系统用于根据在第一数据存储系统中进行的数据写操 作生成 Binlog以及将 Binlog写入存储器。 数据同步系统用于独立于第一 数据存储系统, 在所写入的 Binlog中查找对应于最新写操作的 Binlog, 并将对应于最新写操作的 Binlog发送给第二数据存储系统。 第二数据存 储系统用于根据对应于最新写操作的 Binlog对第二数据存储系统中的数 据进行同步更新。
根据本发明一个优选实施例, 第一数据存储系统和数据同步系统用 同一计算设备实现。
图 6是根据本发明另一个实施例的容灾系统的框图。 该容灾系统包 括多个用于数据同步的系统。 其中每个用于数据同步的系统包括数据存 储系统和数据同步系统。
数据存储系统用于当在数据存储系统中进行数据的写操作时, 根据 写操作生成 Binlog, 以及将 Binlog写入存储器。 数据存储系统还用于当 在另一个用于数据同步的系统的数据存储系统中进行数据的写操作时, 根据其对应于最新写操作的 Binlog对数据存储系统中的数据进行同步更 新。
数据同步系统用于当在数据存储系统中进行数据的写操作时, 独立 于数据存储系统,在所写入的 Binlog中查找对应于最新写操作的 Binlog, 并将对应于最新写操作的 Binlog发送给其他用于数据同步的系统的数据 存储系统。
本领域普通技术人员参考上面所详细描述的用于数据同步的方法, 可以理解上述容灾系统的具体操作。 为了简洁, 在此不再赘述。
上述容灾系统, 每个用于数据同步的系统均包括数据存储系统和数 据同步系统。 因此, 每个用于数据同步的系统均可配置为接收外部更新 数据。从而当当前用于接收外部更新数据的用于数据同步的系统故障时, 另一个用于数据同步的系统可配置为替代它接收外部更新数据。 由此, 保持容灾系统一直正常运行。
上述实施例中提出的数据同步方法及系统, 具有以下优点: 同步进程与服务进程异步工作, 降低了耦合性, 两个系统可以独立 设计、 开发、 上线以及維护, 设计简单, 运維成本降低, 提高了同步的 成功率, 用户写入操作只要写 BinLog文件成功就可以对外返回成功的结 果; 緩存池的引入大大减少了同步进程读磁盘的次数, 提高了整个系统 的性能; BinLog文件保证了任何同步数据都可以查找到, 新搭建一个数 据拷贝的时候, 不用停止业务的写服务, 可以同步 BinLog将新的数据拷 贝更新到最新状态。
需要说明的是, 在本文中, 术语 "包括" 、 "包含" 或者其任何其 他变体意在涵盖非排他性的包含, 从而使得包括一系列要素的过程、 方 法、 物品或者设备不仅包括那些要素, 而且还包括没有明确列出的其他 要素, 或者是还包括为这种过程、 方法、 物品或者设备所固有的要素。 在没有更多限制的情况下, 由语句 "包括一个…… " 限定的要素, 并不 排除在包括所述要素的过程、 方法、 物品或者设备中还存在另外的相同 要素。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分 流程, 是可以通过计算机程序来指令相关的硬件来完成, 所述的程序可 存储于一计算机可读取存储介质中, 该程序在执行时, 可包括如上述各 方法的实施例的流程。 其中, 所述的存储介质可为磁碟、 光盘、 只读存 储记忆体(Read-Only Memory, ROM)或随机存储记忆体 (Random Access Memory, RAM) 等。
以上所述仅为本发明的较佳实施例, 并不用以限制本发明, 凡在本发 明的精神和原则之内, 所作的任何修改、 等同替换、 改进等, 均应包含在 本发明的保护范围之内。

Claims

权利要求书
1、 一种数据同步方法, 其特征在于, 包括:
将外部的更新数据写入第一数据存储系统中;
将该写入操作进行记录并生成二进制日志;
将该二进制日志分别写入緩存池和磁盘的二进制日志文件中; 在将该更新数据进行同步时, 从緩存池中查找该更新数据所对应的 二进制日志,并将该二进制日志发送给第二数据存储系统进行数据同步。
2、 根据权利要求 1所述的方法, 其特征在于, 当所述緩存池存满二 进制日志时, 自动删除最早存入的二进制日志。
3、 根据权利要求 1所述的方法, 其特征在于, 所述二进制日志先写 入到緩存池, 再写入磁盘的二进制日志文件中。
4、 根据权利要求 1所述的方法, 其特征在于, 当需要同步的该更新 数据所对应的二进制日志在緩存池中没有找到时,所述方法进一步包括: 再从保存在磁盘中的二进制日志文件中查找该更新数据所对应的二 进制日志, 并将该二进制日志发送给第二数据存储系统进行数据同步。
5、 根据权利要求 4所述的方法, 其特征在于, 当磁盘中的二进制日 志文件异常丟失时, 所述方法进一步包括:
将第一数据存储系统中该二进制日志文件所涵盖的更新数据分别重 新生成二进制日志, 并将所述重新生成的二进制日志写入一个新的二进 制日志文件中。
6、 一种数据同步系统, 其特征在于, 包括:
第一写入模块, 用于将外部的更新数据写入第一数据存储系统中; 生成模块, 用于将该写入操作进行记录并生成二进制日志; 第二写入模块, 用于将该二进制日志分别写入緩存池和磁盘的二进 制日志文件中;
同步模块, 用于在将该更新数据进行同步时, 从緩存池中查找该更 新数据所对应的二进制日志, 并将该二进制日志发送给第二数据存储系 统进行数据同步。
7、 根据权利要求 6所述的系统, 其特征在于, 所述第二写入模块还 用于当所述緩存池存满二进制日志时,自动删除最早存入的二进制日志。
8、 根据权利要求 6所述的系统, 其特征在于, 所述第二写入模块将 所述二进制日志先写入到緩存池, 再写入磁盘的二进制日志文件中。
9、 根据权利要求 6所述的系统, 其特征在于, 所述同步模块在进行 数据同步时, 当需要同步的更新数据所对应的二进制日志在緩存池中没 有找到时, 所述同步模块再从保存在磁盘中的二进制日志文件中查找该 更新数据所对应的二进制日志, 并将该二进制日志发送给第二数据存储 系统进行数据同步。
10、 根据权利要求 9所述的系统, 其特征在于, 所述系统还包括恢 复模块, 用于当磁盘中的二进制日志文件异常丟失时, 将第一数据存储 系统中该二进制日志文件所涵盖的更新数据分别重新生成二进制日志, 并将所述重新生成的二进制日志写入一个新的二进制日志文件中。
11、 一种用于数据同步的方法, 包括:
根据在第一数据存储系统中进行的数据写操作生成二进制日志; 将所述二进制日志写入存储器; 以及
独立于所述生成二进制日志和所述将所述二进制日志写入存储器, 在所写入的二进制日志中查找对应于最新写操作的二进制日志, 并将所 述对应于最新写操作的二进制日志发送给第二数据存储系统, 以使所述 第二数据存储系统根据所述对应于最新写操作的二进制日志对所述第二 数据存储系统中的数据进行同步更新。
12、 根据权利要求 11所述的方法, 其特征在于, 所述方法进一步包 括: 在所述第一数据存储系统中的所述数据丟失的情况下, 根据所述所 写入的二进制日志模拟所述写操作来恢复所丟失的数据。
13、 根据权利要求 11所述的方法, 其特征在于, 所述存储器包括緩 存池。
14、 根据权利要求 13所述的方法, 其特征在于, 所述緩存池用内存 实现。
15、 根据权利要求 14所述的方法, 其特征在于, 所述将所述二进制 日志写入存储器包括: 当所述緩存池写满时, 在所述緩存池中用当前待 写入的二进制日志替换最早写入的二进制日志。
16、 根据权利要求 11所述的方法, 其特征在于, 所述存储器包括磁 盘。
17、 根据权利要求 16所述的方法, 其特征在于, 所述将所述二进制 日志写入存储器包括:
将所述二进制日志写入到所述磁盘的二进制日志文件中, 其中每个 二进制日志文件能够包括预设数目的二进制日志。
18、 根据权利要求 11所述的方法, 其特征在于,
所述将所述二进制日志写入存储器包括将所述二进制日志写入到緩 存池和磁盘;
所述在所写入的二进制日志中查找对应于最新写操作的二进制日志 包括:
在所述緩存池中查找所述对应于最新写操作的二进制日志; 以及 对于未能在所述緩存池找到所述对应于最新写操作的二进制日志的 情况, 在所述磁盘中查找所述对应于最新写操作的二进制日志。
19、 根据权利要求 11所述的方法, 其特征在于, 所述方法进一步包 括:
比较所述所写入的二进制日志的数目以及对所述第二数据存储系统 中的数据进行同步更新的次数;
其中, 在所述所写入的二进制日志的数目大于对所述第二数据存储 系统中的数据进行同步更新的次数的情况下, 进行所述在所写入的二进 制日志中查找对应于最新写操作的二进制日志, 并将所述对应于最新写 操作的二进制日志发送给第二数据存储系统。
20、 根据权利要求 11所述的方法, 其特征在于, 所述方法进一步包 括: 在将所述二进制日志写入存储器之后, 向执行所述写操作的计算设 备返回所述写操作成功的信息。
21、 一种用于数据同步的系统, 包括第一数据存储系统以及数据同 步系统,
所述第一数据存储系统用于根据在所述第一数据存储系统中进行的 数据写操作生成二进制日志以及将所述二进制日志写入存储器; 以及 所述数据同步系统用于, 独立于所述第一数据存储系统, 在所写入 的二进制日志中查找对应于最新写操作的二进制日志, 并将所述对应于 最新写操作的二进制日志发送给第二数据存储系统, 以使所述第二数据 存储系统根据所述对应于最新写操作的二进制日志对所述第二数据存储 系统中的数据进行同步更新。
22、 根据权利要求 21所述的用于数据同步的系统, 其特征在于, 所 述数据同步系统进一步用于在所述第一数据存储系统中的所述数据丟失 的情况下, 根据所述所写入的二进制日志模拟所述写操作来恢复所丟失 的数据。
23、 根据权利要求 21所述的用于数据同步的系统, 其特征在于, 所 述第一数据存储系统进一步用于在将所述二进制日志写入存储器之后, 向执行所述写操作的计算设备返回所述写操作成功的信息。
24、 一种包括用于数据同步的可执行程序代码的非暂时性计算机程 序产品, 所述可执行程序代码可操作用于: 当执行时,
根据在第一数据存储系统中进行的数据写操作生成二进制日志; 将所述二进制日志写入存储器; 以及
独立于所述生成二进制日志和所述将所述二进制日志写入存储器, 在所写入的二进制日志中查找对应于最新写操作的二进制日志, 并将所 述对应于最新写操作的二进制日志发送给第二数据存储系统, 以使所述 第二数据存储系统根据所述对应于最新写操作的二进制日志对所述第二 数据存储系统中的数据进行同步更新。
25、 一种容灾系统, 包括第一数据存储系统、 数据同步系统以及第 二数据存储系统,
所述第一数据存储系统用于根据在所述第一数据存储系统中进行的 数据写操作生成二进制日志以及将所述二进制日志写入存储器; 以及 所述数据同步系统用于, 独立于所述第一数据存储系统, 在所写入 的二进制日志中查找对应于最新写操作的二进制日志, 并将所述对应于 最新写操作的二进制日志发送给所述第二数据存储系统;
所述第二数据存储系统用于根据所述对应于最新写操作的二进制日 志对所述第二数据存储系统中的数据进行同步更新。
26、 根据权利要求 25所述的容灾系统, 其特征在于, 所述第一数据 存储系统和所述数据同步系统用同一计算设备实现。
27、 一种容灾系统, 包括多个用于数据同步的系统, 其中每个用于 数据同步的系统包括数据存储系统和数据同步系统,
所述数据存储系统用于:
当在所述数据存储系统中进行数据的写操作时, 根据所述写操作生 成二进制日志, 以及将所述二进制日志写入存储器;
当在另一个用于数据同步的系统的数据存储系统中进行数据的写操 作时, 根据其对应于最新写操作的二进制日志对所述数据存储系统中的 数据进行同步更新。
所述数据同步系统用于, 当在所述数据存储系统中进行数据的写操 作时, 独立于所述数据存储系统, 在所写入的二进制日志中查找对应于 最新写操作的二进制日志, 并将所述对应于最新写操作的二进制日志发 送给其他用于数据同步的系统的数据存储系统。
PCT/CN2013/079087 2012-10-18 2013-07-09 数据同步方法及系统 Ceased WO2014059804A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US14/682,261 US20150213100A1 (en) 2012-10-18 2015-04-09 Data synchronization method and system

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201210397350.7A CN103780638B (zh) 2012-10-18 2012-10-18 数据同步方法及系统
CN201210397350.7 2012-10-18

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US14/682,261 Continuation US20150213100A1 (en) 2012-10-18 2015-04-09 Data synchronization method and system

Publications (1)

Publication Number Publication Date
WO2014059804A1 true WO2014059804A1 (zh) 2014-04-24

Family

ID=50487526

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2013/079087 Ceased WO2014059804A1 (zh) 2012-10-18 2013-07-09 数据同步方法及系统

Country Status (3)

Country Link
US (1) US20150213100A1 (zh)
CN (1) CN103780638B (zh)
WO (1) WO2014059804A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109857812A (zh) * 2019-02-27 2019-06-07 珠海天燕科技有限公司 一种处理缓存中数据的方法和装置
CN115905255A (zh) * 2022-11-10 2023-04-04 海尔优家智能科技(北京)有限公司 一种缓存与数据库一致性的方法、存储介质及电子装置

Families Citing this family (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105843702B (zh) 2015-01-14 2019-04-12 阿里巴巴集团控股有限公司 一种用于数据备份的方法以及装置
CN106202075B (zh) * 2015-04-29 2021-02-19 中兴通讯股份有限公司 一种数据库主备切换的方法及装置
CN105159795A (zh) * 2015-08-21 2015-12-16 小米科技有限责任公司 数据同步方法、装置和系统
CN105574083B (zh) * 2015-12-09 2019-03-15 浪潮(北京)电子信息产业有限公司 一种数据写入方法、系统及数据读取方法和系统
CN106897024B (zh) * 2015-12-18 2020-07-31 北京国双科技有限公司 数据写入方法及装置
CN105677511B (zh) * 2015-12-30 2018-08-17 首都师范大学 一种降低同步开销的数据写入方法和装置
CN107423303B (zh) * 2016-05-24 2021-02-26 北京京东尚科信息技术有限公司 数据同步的方法和系统
CN106126730B (zh) * 2016-07-01 2019-10-11 百势软件(北京)有限公司 一种批量生成告警信息的方法及装置
CN107783975B (zh) * 2016-08-24 2021-02-26 北京京东尚科信息技术有限公司 分布式数据库同步处理的方法和装置
CN108121711B (zh) * 2016-11-28 2021-12-24 北京国双科技有限公司 一种数据处理方法和客户端设备
CN106648994B (zh) * 2017-01-04 2020-09-11 华为技术有限公司 一种备份操作日志的方法,设备和系统
CN109672712A (zh) * 2017-10-17 2019-04-23 中兴通讯股份有限公司 数据同步方法、装置、超级控制器、域控制器及存储介质
CN108170768B (zh) * 2017-12-25 2023-03-24 腾讯科技(深圳)有限公司 数据库同步方法、装置及可读介质
CN109753531A (zh) * 2018-12-26 2019-05-14 深圳市麦谷科技有限公司 一种大数据统计方法、系统、计算机设备及存储介质
CN109828720B (zh) * 2019-01-21 2022-06-03 上海达梦数据库有限公司 数据存储方法、装置、服务器和存储介质
CN109901799B (zh) * 2019-02-28 2022-08-19 新华三信息安全技术有限公司 一种日志读写方法及装置
CN110941623A (zh) * 2019-11-12 2020-03-31 北京达佳互联信息技术有限公司 数据的同步方法及装置
CN111176572B (zh) * 2019-12-27 2022-03-22 浪潮(北京)电子信息产业有限公司 一种存储数据的保护方法、装置、设备及介质
CN111404737B (zh) * 2020-03-10 2021-07-27 腾讯科技(深圳)有限公司 一种容灾处理方法以及相关装置
CN112100147B (zh) * 2020-07-27 2024-06-07 杭州玳数科技有限公司 基于Flink实现Binlog到HIVE的实时采集方法和系统
CN114647490A (zh) * 2022-03-14 2022-06-21 北京计算机技术及应用研究所 一种嵌入式数据库高可靠事务处理方法和装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050027748A1 (en) * 2003-07-30 2005-02-03 International Business Machines Corporation Apparatus method and system for asynchronous replication of a hierarchically-indexed data store
CN1670709A (zh) * 2004-03-19 2005-09-21 株式会社日立制作所 利用日志同步数据库数据非同步传送的恢复方式及装置
CN1753373A (zh) * 2004-09-23 2006-03-29 华为技术有限公司 一种远程容灾系统及方法
US20090259698A1 (en) * 2006-12-27 2009-10-15 Brother Kogyo Kabushiki Kaisha Data synchronizing system, acquiring terminal, and providing terminal
CN102567338A (zh) * 2010-12-16 2012-07-11 凌群电脑股份有限公司 模拟系统日志的数据同步系统

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4488258A (en) * 1982-09-20 1984-12-11 Allen-Bradley Programmable controller with control program comments
US6671705B1 (en) * 1999-08-17 2003-12-30 Emc Corporation Remote mirroring system, device, and method
US7346616B2 (en) * 2002-03-20 2008-03-18 Extended System, Inc. Synchronizing data shared between two devices independent of any other devices that may also share the data
US7702698B1 (en) * 2005-03-01 2010-04-20 Yahoo! Inc. Database replication across different database platforms
JP2006252019A (ja) * 2005-03-09 2006-09-21 Hitachi Ltd ストレージネットワークシステム
AU2006331932B2 (en) * 2005-12-19 2012-09-06 Commvault Systems, Inc. Systems and methods for performing data replication
US8793223B1 (en) * 2009-02-09 2014-07-29 Netapp, Inc. Online data consistency checking in a network storage system with optional committal of remedial changes
US8510270B2 (en) * 2010-07-27 2013-08-13 Oracle International Corporation MYSQL database heterogeneous log based replication

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050027748A1 (en) * 2003-07-30 2005-02-03 International Business Machines Corporation Apparatus method and system for asynchronous replication of a hierarchically-indexed data store
CN1670709A (zh) * 2004-03-19 2005-09-21 株式会社日立制作所 利用日志同步数据库数据非同步传送的恢复方式及装置
CN1753373A (zh) * 2004-09-23 2006-03-29 华为技术有限公司 一种远程容灾系统及方法
US20090259698A1 (en) * 2006-12-27 2009-10-15 Brother Kogyo Kabushiki Kaisha Data synchronizing system, acquiring terminal, and providing terminal
CN102567338A (zh) * 2010-12-16 2012-07-11 凌群电脑股份有限公司 模拟系统日志的数据同步系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109857812A (zh) * 2019-02-27 2019-06-07 珠海天燕科技有限公司 一种处理缓存中数据的方法和装置
CN115905255A (zh) * 2022-11-10 2023-04-04 海尔优家智能科技(北京)有限公司 一种缓存与数据库一致性的方法、存储介质及电子装置

Also Published As

Publication number Publication date
CN103780638A (zh) 2014-05-07
US20150213100A1 (en) 2015-07-30
CN103780638B (zh) 2019-02-19

Similar Documents

Publication Publication Date Title
WO2014059804A1 (zh) 数据同步方法及系统
KR101662212B1 (ko) 부분동기화 지원 데이터베이스 관리 시스템 및 데이터베이스 관리 시스템에서 부분동기화 방법
US9934242B2 (en) Replication of data between mirrored data sites
CN110019514B (zh) 数据同步方法、装置以及电子设备
US20180150501A1 (en) Database system, server device, computer program product, and information processing method
WO2018049983A1 (zh) 数据同步方法、系统、同步获取方法及装置
CN107018185B (zh) 云存储系统的同步方法和装置
WO2015101084A1 (zh) 恢复数据的方法、服务器及系统
CN105468475A (zh) 数据库的备份方法及备份装置
CN105159795A (zh) 数据同步方法、装置和系统
US20120278429A1 (en) Cluster system, synchronization controlling method, server, and synchronization controlling program
US20190317872A1 (en) Database cluster architecture based on dual port solid state disk
CN106919465B (zh) 用于存储系统中多重数据保护的方法和装置
US9525733B2 (en) Method and system for data synchronization
CN107329859B (zh) 一种数据保护方法及存储设备
CN103138912A (zh) 数据同步方法及系统
CN105069152B (zh) 数据处理方法及装置
CN113326251A (zh) 数据管理方法、系统、设备和存储介质
CN106873902B (zh) 一种文件存储系统、数据调度方法及数据节点
CN111984474A (zh) 一种双控集群故障恢复的方法、系统及设备
CN104281631A (zh) 分布式数据库系统及其数据同步方法和节点
CN113515574B (zh) 一种数据同步方法及装置
WO2017014814A1 (en) Replicating memory volumes
CN110121694B (zh) 一种日志管理方法、服务器和数据库系统
KR101713537B1 (ko) 데이터의 일관성을 보장하는 상태기기 기반의 복제 및 체크포인트데이터와 복제로그를 이용한 분산 복구를 처리하는 데이터 복제 방법 및 데이터 저장 시스템

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 13846572

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 15.09.2015)

122 Ep: pct application non-entry in european phase

Ref document number: 13846572

Country of ref document: EP

Kind code of ref document: A1