CN110377664A - Method of data synchronization, device, server and storage medium - Google Patents
Method of data synchronization, device, server and storage medium Download PDFInfo
- Publication number
- CN110377664A CN110377664A CN201910662737.2A CN201910662737A CN110377664A CN 110377664 A CN110377664 A CN 110377664A CN 201910662737 A CN201910662737 A CN 201910662737A CN 110377664 A CN110377664 A CN 110377664A
- Authority
- CN
- China
- Prior art keywords
- database
- consuming
- time
- standby
- primary
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
- G06F16/273—Asynchronous replication or reconciliation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/80—Database-specific techniques
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)
- Quality & Reliability (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present invention provides a kind of method of data synchronization, device, server and storage mediums, belong to database technical field.The described method includes: by primary database in acquisition Database Systems at least one for the synchronous time-consuming of database, this synchronize it is time-consuming for indicate primary database and any one for carried out between database data it is synchronous when each stage needed for time-consuming, when this, which synchronizes time-consuming, is greater than first object duration, current systematic synchronisation pattern is switched into goal systems synchronous mode, under the goal systems synchronous mode, when primary database receives database instruction, under the premise of being not necessarily to sync response of any standby database to database instruction, it will be in the disk of the implementing result write-in primary database of database instruction.Primary database no longer needs to wait when receiving database instruction the response of standby database, and implementing result write-in disk is directly improved the process performance of Database Systems so that primary database can execute database instruction faster.
Description
Technical field
The present invention relates to database technical field, in particular to a kind of method of data synchronization, device, server and storage are situated between
Matter.
Background technique
With the fast development of Internet technology, enterprise is higher and higher to the dependence of information system, and database is as letter
The core of breath system takes on important role.In the exigent industry of some data reliabilities, such as bank, security, electricity
The industries such as letter, electric business can cause serious loss, therefore if unexpected delay machine or loss of data occur for database to enterprise
Enterprise needs to formulate detailed DB Backup and disaster recovery strategy according to its type of service.When DB Backup, need
The database instruction executed in primary database is synchronized in standby database, to guarantee the data in standby database and primary database
Unanimously.
Currently, guaranteeing master data usually using a kind of paxos (Parker's Suo Si algorithm, distributed consensus algorithm) agreement
Library is consistent with data in standby database.The principle of paxos agreement is to add paxos layers in database layer, and primary database will execute
Database instruction be stored in binlog (binary log file) log, the paxos layers of binlog log by primary database
Other are distributed to for database.Each standby database is executed and is stored in the binlog log after receiving the binlog log
Database instruction, after being finished to primary database send response, when primary database receives most of standby databases
After response, primary database is by the implementing result write-in disk of database instruction in the binlog log and feedback database instruction is held
It goes successfully, so that primary database and standby database execute identical database instruction, guarantees that data are consistent.
Above-mentioned technical proposal the problem is that, when paxos layers of failure or network fluctuate, primary database may
Can not receive the response that standby database returns, the database instruction for causing primary database to execute can not execute or execute compared with
Slowly, to influence the process performance of Database Systems.
Summary of the invention
The embodiment of the invention provides a kind of method of data synchronization, device, server and storage mediums, for solving at present
Primary database may can not receive the response that standby database returns, the data for causing primary database to execute when database synchronization
Library instruction can not be executed or be executed relatively slowly, thus the problem of influencing the process performance of Database Systems.The technical solution is such as
Under:
On the one hand, a kind of method of data synchronization is provided, comprising:
Obtaining primary database in Database Systems, at least one for the synchronous time-consuming of database, the time-consuming that synchronizes is used for
Indicate the primary database and any one for carried out between database data it is synchronous when each stage needed for time-consuming;
When it is described synchronize it is time-consuming be greater than first object duration when, it is same that current systematic synchronisation pattern is switched into goal systems
Step mode;
Under the goal systems synchronous mode, when the primary database receives database instruction, without any
Standby database is under the premise of the sync response of the database instruction, described in the implementing result write-in by the database instruction
In the disk of primary database.
On the other hand, a kind of data synchronization unit is provided, comprising:
First obtains module, for obtaining synchronous consumption of the primary database at least one for database in Database Systems
When, it is described synchronize it is time-consuming for indicate the primary database and any one for carried out between database data it is synchronous when each stage
Required time-consuming;
First switching module, for when it is described synchronize it is time-consuming be greater than first object duration when, by the synchronous mould of current system
Formula switches to goal systems synchronous mode;
Writing module is used under the goal systems synchronous mode, when the primary database receives database instruction
When, under the premise of being not necessarily to sync response of any standby database to the database instruction, by holding for the database instruction
Row result is written in the disk of the primary database.
In an optional implementation manner, described first module is obtained, be also used in the Database Systems, obtained
It is time-consuming that first stage property needed for each stage when data synchronize is carried out between the primary database and a standby database, it will be described
The summation of first stage property time-consuming synchronizes time-consuming as the single of the Database Systems;By multiple lists of the Database Systems
The average value of subsynchronous time-consuming synchronizes time-consuming as described.
In another optional implementation, described first obtains module, is also used to obtain the primary database and executes
The waiting time-consuming and the first write-in that database instruction is spent are time-consuming, and the time-consuming waiting is that the primary database waits a standby number
Time-consuming needed for returning to sync response according to library, time-consuming first write-in is the primary database holding the database instruction
Time-consuming needed for the disk of the primary database is written in row result;The time-consuming and described first write-in consumption of the waiting is determined respectively
When weight;Wait the time-consuming weight time-consuming with first write-in synchronous with the single as the Database Systems for described
It is time-consuming.
In another optional implementation, described device further include:
Second obtains module, for for it is described at least one for database each standby in database, obtain the standby number
According to the time-consuming that executes in library, the execution is time-consuming for indicating time-consuming needed for the standby database completes the database instruction;
Second switching module is used for when the execution time-consuming is greater than the second target duration, and the standby database is current
Per-unit synchronous pattern switching to target per-unit synchronous mode;Under the target per-unit synchronous mode, the primary database without
Need to wait for the sync response of the standby database.
In another optional implementation, described second obtains module, is also used to obtain the standby database and completes
Second stage needed for each stage is time-consuming when the database instruction, using the summation of the second stage time-consuming as described in
The single of the completion database instruction of standby database executes time-consuming;Multiple singles of the standby database are executed into time-consuming
Average value executes time-consuming as described.
In another optional implementation, described second obtains module, is also used to obtain the standby database and completes
The communication time-consuming spent when the database instruction and the second write-in are time-consuming, the communication it is time-consuming for the standby database with it is described
Primary database carries out communicating required time-consuming, and time-consuming second write-in is standby database the holding the database instruction
Time-consuming needed for the disk of the standby database is written in row result;The time-consuming and described second write-in consumption of the communication is determined respectively
When weight;The time-consuming weight of time-consuming and described second write-in of the communication and the single as the standby database are executed into consumption
When.
In another optional implementation, described device further include:
Third switching module, for described in the Database Systems at least one all switch to for database it is described
When target per-unit synchronous mode, current systematic synchronisation pattern is switched into the goal systems synchronous mode.
In another optional implementation, described device further include:
4th switching module, for when it is described synchronize it is time-consuming be less than the first object duration when, current system is same
Step mode switches to default system synchronous mode;
Under the default system synchronous mode, when the primary database receives database instruction, the master data
Library executes the database instruction, by the database instruction be sent to it is described at least one for database, when the master data
When library receives the sync response of any standby database, the primary database is written into the implementing result of the database instruction
In disk.
In another optional implementation, described device further include:
Third obtains module, for the resource occupation information of database server where obtaining the Database Systems, institute
Stating includes at least two Database Systems in database server;
Distribution module, for being that the Database Systems distribute available hardware resource, institute according to the resource occupation information
It is related to the load condition of Database Systems to state available hardware resource size.
In another optional implementation, the distribution module is also used to obtain in the database server every
The resource distribution file of a Database Systems, the resource distribution file are used to indicate each Database Systems and can be used
Hardware resource size;When the hardware resource of the database server is not otherwise fully engaged, according to each data
The load condition of library system is that the Database Systems distribute available hardware resource, and the size of the available hardware resource can surpass
Cross the size of the hardware resource of the resource distribution file instruction of the Database Systems;When the hardware of the database server provides
It is that the Database Systems distribute available hardware resource according to the resource distribution file when source has been fully used.
In another optional implementation, the distribution module is also used to determine in the database server every
The priority of a Database Systems;When the resource occupation total amount for determining the database server according to the resource occupation information
It is when occupying threshold value more than target, the system of the Database Systems of at least one low priority in the database server is synchronous
Pattern switching is to the goal systems synchronous mode.
In another optional implementation, described device further include:
4th obtain module, for obtain primary database described in the Database Systems and it is described at least one for data
The running state information in library, the running state information be used to indicate the primary database and it is described at least one for database be
No normal operation;
Determining module, for determining and the primary database being caused to run not just when primary database operation is abnormal
Normal failure cause;
5th switching module will be described for according to the failure cause, the primary database to be switched to standby database
At least one is switched to new primary database for the standby database in database.
In another optional implementation, the 5th switching module is also used to determine that the failure cause is corresponding
Fault type;When the fault type is not target faults type, the primary database is switched to standby database, by institute
It states at least one and is switched to new primary database for the standby database in database, the target faults type is that general is described at least
Standby database in one standby database is switched to the fault type that can solve after new primary database;When the fault type is
When target faults type, handover mechanism is exempted from starting, described to exempt from handover mechanism and be used to indicate to exempt to cut in the time in target to detect institute
When stating the fault error reason of target faults type, keep the primary database constant.
On the other hand, a kind of server is provided, the server includes processor and memory, and the memory is used for
Program code is stored, said program code is loaded by the processor and executed to realize that the data in the embodiment of the present invention are synchronous
Performed operation in method.
On the other hand, a kind of storage medium is provided, program code, said program code are stored in the storage medium
For executing the method for data synchronization in the embodiment of the present invention.
Technical solution provided in an embodiment of the present invention has the benefit that
In embodiments of the present invention, by obtain Database Systems in primary database at least one for the synchronous of database
Time-consuming, this synchronize it is time-consuming for indicate primary database and any one for carried out between database data it is synchronous when each stage needed for
Time-consuming, when this synchronize it is time-consuming be greater than first object duration when, it is synchronous that current systematic synchronisation pattern is switched into goal systems
Mode, when primary database receives database instruction, is being not necessarily to any standby database pair under the goal systems synchronous mode
It, will be in the disk of the implementing result write-in primary database of database instruction under the premise of the sync response of database instruction.Pass through
Obtain in Database Systems primary database and at least one for the synchronous time-consuming of database, when this is synchronized time-consuming and first object
Length compares, and when this synchronizes time-consuming and is greater than the first object duration, current systematic synchronisation pattern is switched to goal systems
Synchronous mode will directly execute so that primary database no longer needs to wait when receiving database instruction the response of standby database
As a result write-in disk improves the treatability of Database Systems so that primary database can execute database instruction faster
Energy.
Detailed description of the invention
To describe the technical solutions in the embodiments of the present invention more clearly, make required in being described below to embodiment
Attached drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the invention, for
For those of ordinary skill in the art, without creative efforts, it can also be obtained according to these attached drawings other
Attached drawing.
Fig. 1 is a kind of implementation environment figure of method of data synchronization provided in an embodiment of the present invention;
Fig. 2 is a kind of flow chart of the method for data synchronization provided according to an exemplary embodiment;
Fig. 3 is the flow chart of another method of data synchronization provided according to an exemplary embodiment;
Fig. 4 is the flow chart of another method of data synchronization provided according to an exemplary embodiment;
Fig. 5 is a kind of block diagram of the data synchronization unit provided according to embodiments of the present invention;
Fig. 6 is a kind of structural schematic diagram of server provided in an embodiment of the present invention.
Specific embodiment
To make the object, technical solutions and advantages of the present invention clearer, below in conjunction with attached drawing to embodiment party of the present invention
Formula is described in further detail.
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistented with the present invention.On the contrary, they be only with it is such as appended
The example of device and method being described in detail in claims, some aspects of the invention are consistent.
The embodiment of the present invention relates generally to carry out the synchronous scene of data in Database Systems.In order to guarantee the peace of data
Entirely, in Database Systems, it will usually a primary database be set at least one for database.Wherein, primary database is external
Service is provided, at least one is synchronous with the data in primary database for database, when primary database breaks down, at least one
A standby database in standby database can become new primary database and the primary database of failure is replaced externally to provide service.
It should be noted that the operation in any data can be realized by database instruction in Database Systems,
For example, the operations such as increase, deletion, modification can be based on corresponding SQL (Structured Query in MYSQL system
Language, structured query language) sentence realization.
In embodiments of the present invention, it is related to two kinds of systematic synchronisation patterns, one is strong synchronous modes, refer to primary database
After receiving database instruction, when receiving sync response of any standby database to the database instruction, by the database
In the implementing result write-in disk of instruction.Another kind is asynchronous mode, is referred to when primary database receives database instruction, nothing
Need any standby database to the sync response of the database instruction, it will be in the implementing result write-in disk of the database instruction.
The process that Database Systems carry out database synchronization using strong synchronous mode is described below: primary database is connecing
After receiving database instruction, the database instruction is executed, in memory by the implementing result caching of the database instruction.Master data
Also the database instruction can be written in corresponding binlog log after receiving the database instruction for library, by the binlog days
Will is sent to the standby database in Database Systems, this respectively parses the binlog log for database, obtains and holds
The row database instruction, and implementing result is written in respective disk.Standby database after implementing result to be written to disk to
Primary database sends sync response, indicates that data are synchronized and finishes, primary database is in the synchronization for receiving any standby database
It, will be in the disk of the implementing result write-in primary database of caching in memory when response.At this point, the Database Systems complete one
It is synchronous to be properly termed as data of completion for database instruction.Wherein, for the SQL statement for inquiry, since inquiry can't
The data in database are modified, therefore the SQL statement that primary database will can't be used to inquire is stored in binlog log.
Database inevitably breaks down, and is described below when primary database breaks down how to carry out primary database
With the switching of standby database.When primary database, which breaks down, to provide service, mentioned by standby database to replace primary database
For service, primary database is just switched to standby database at this time, and Database Systems select one from least one in database
Standby database is switched to primary database and externally provides server.
Fig. 1 is a kind of implementation environment figure of method of data synchronization provided in an embodiment of the present invention, referring to Fig. 1, including it is multiple
Database server 101 and dispatch server 102,
Database server 101 can be connected by wireless network or cable network with dispatch server 102.Data
Library server 101 may include at least one of a server, multiple servers or cloud computing server cluster.Data
Library server 101 is for disposing an at least database.Each database, which can correspond to, is deployed with agent (agency) mould
Block, the relevant information of database server of the agent module for acquisition database and where database, as heartbeat message,
Communication is time-consuming, the time-consuming and resource occupation information of database server is written etc., is referred to as data acquisition module.Scheduling
Server 102 is used to receive the information of agent module transmission.
Fig. 2 is a kind of flow chart of the method for data synchronization provided according to an exemplary embodiment, as shown in Figure 2.The party
Method the following steps are included:
201, dispatch server obtains in Database Systems primary database at least one for the synchronous time-consuming of database, should
Synchronize it is time-consuming for identify the primary database and any one for carried out between database data it is synchronous when each stage needed for consumption
When.
In embodiments of the present invention, this synchronize time-consuming can for primary database and any one for the last between database
Carry out data it is synchronous when each stage needed for time-consuming, this synchronize time-consuming can also for primary database and any one for database it
Between repeatedly carry out data it is synchronous when each stage needed for time-consuming average value.Primary database and any one between database into
It may include four-stage that row data, which synchronize: the first stage, primary database and each standby database communication;Second stage, it is each
Standby database executes database instruction and disk is written in implementing result;Phase III, primary database receive standby database synchronization and ring
It answers;Fourth stage, primary database will be in the disks of the implementing result write-in primary database of database instruction.
In an optional implementation manner, dispatch server can in Database Systems, obtain in primary database and
It is time-consuming that first stage property needed for each stage when data synchronize is carried out between one standby database, by first stage property time-consuming
Summation synchronizes time-consuming as the single of the Database Systems, and multiple singles of the Database Systems are synchronized time-consuming average value and are made
Time-consuming is synchronized for this.Wherein, the summation of first stage property time-consuming can be the above-mentioned first stage to time-consuming total of fourth stage
With.By the way that multiple singles are synchronized time-consuming average value as time-consuming is synchronized, can be synchronized to avoid single caused by network jitter
It takes long time, so that this synchronizes and time-consuming can correctly reflect time-consuming needed for data synchronize each stage.
In an optional implementation manner, which synchronizes time-consuming can execute database instruction cost for primary database
Waiting is time-consuming and weight that the first write-in is time-consuming and.Correspondingly, dispatch server is obtained in primary database and a standby data
It is time-consuming that first stage property needed for each stage when data synchronization is carried out between library, using the summation of first stage property time-consuming as this
It is permissible that the single of Database Systems synchronizes time-consuming step are as follows: the available primary database of dispatch server executes database instruction
The waiting time-consuming of cost and the first write-in are time-consuming, the weight of the waiting time-consuming and the first write-in time-consuming are determined respectively, by this etc.
To time-consuming weight with single as the Database Systems synchronous time-consuming time-consuming with first write-in.It is time-consuming and the by that will wait
The time-consuming weight time-consuming synchronous with the single as Database Systems of one write-in, can intuitively reflect that data synchronize each rank
The time-consuming and Database Systems of section carry out total time-consuming when data synchronize.
Wherein, which is time-consuming needed for primary database waits a standby database to return to sync response, e.g., main
Database is to all for database transmission binlog journal file to the time-consuming for receiving any standby database return sync response.
Time-consuming first write-in is that time-consuming needed for the disk of primary database is written in the implementing result of database instruction by primary database.
The weight of waiting time-consuming can be any value between 1 to 2, and the time-consuming weight of first write-in can be between 1.5 to 2
Any value.In one implementation, when primary database uses ordinary magnetic disc, can be time-consuming by the first write-in
It is time-consuming that weight is set greater than waiting;When primary database uses SSD (Solid State Drive, solid state drive) magnetic
When disk, time-consuming weight can will be waited to be set greater than the first write-in time-consuming.This is because the writing speed of SSD is far longer than
The writing speed of ordinary magnetic disc, namely wait time-consuming more time-consuming than write-in longer.
It should be noted that when Database Systems are deployed on a database server, dispatch server can be with
The database server is same server, i.e., is deployed with Database Systems in the database server, and be deployed with reality
The scheduler module of existing dispatch server function.
202, when this, which synchronizes time-consuming, is greater than first object duration, dispatch server switches current systematic synchronisation pattern
To goal systems synchronous mode.
In embodiments of the present invention, synchronizing time-consuming is the delay time that Database Systems handle data library instruction.
The first object duration can be the maximum value for allowing to postpone.Such as, which can be 1 second, 2 seconds, 3 seconds, 5 seconds
Deng.The goal systems synchronous mode can be asynchronous mode.
In an optional implementation manner, the synchronous mould of the current system of the available Database Systems of dispatch server
Formula can switch when the current systematic synchronisation pattern is not goal systems synchronous mode to Database Systems sending mode
Instruction, Database Systems instruct according to the pattern switching the current systematic synchronisation pattern being switched to the synchronous mould of goal systems
Formula.When the current systematic synchronisation pattern is goal systems synchronous mode, dispatch server does not send pattern switching instruction,
The systematic synchronisation pattern that Database Systems can keep this current is constant.
In an optional implementation manner, dispatch server can also be according to the standby number of execution time-consuming switching of standby database
According to the current per-unit synchronous mode in library.For at least one for standby database each in database, dispatch server is available
This executes time-consuming for database, the execution time-consuming for indicate this for database complete database instruction needed for time-consuming, when
When the execution time-consuming is greater than the second target duration, dispatch server can be by the per-unit synchronous pattern switching current for database
To target per-unit synchronous mode, under the target per-unit synchronous mode, primary database synchronizes sound without waiting for this for database
It answers.Wherein, when target per-unit synchronous mode is all switched to for database when at least one for including in Database Systems, scheduling
The current systematic synchronisation pattern of the Database Systems can be switched to goal systems synchronous mode by server.The target single machine is same
Step mode can be single machine asynchronous mode.By switching the standby number when the execution time-consuming of standby database is greater than the second target duration
According to the current per-unit synchronous mode in library, carried out by force between time-consuming lesser standby database so that primary database can be executed with other
It is synchronous.It is by when whole standby databases switches to target per-unit synchronous mode, the current system of Database Systems is same
The caused Database Systems of the problems such as step mode switches to goal systems synchronous mode, can solve network delay or slow write magnetic disk
The problem of process performance declines.
In an optional implementation manner, dispatch server obtains permissible for the time-consuming step of the execution of database are as follows:
It is time-consuming that the available standby database of dispatch server completes second stage needed for each stage when database instruction, by this second
Interim time-consuming summation executes time-consuming as the single of the completions database instruction for database, and dispatch server can general
Multiple singles for database execute time-consuming average value and execute time-consuming as this.By the way that multiple singles are executed time-consuming put down
Mean value can cause certain execution of standby database time-consuming higher as time-consuming is executed to avoid network jitter, lead to standby database frequency
The problem of numerous switching per-unit synchronous mode.
For example, it is T that the single of a certain standby database, which executes time-consuming, dispatch server is stored with the N nearest for database
A single executes time-consuming, and N is positive integer.Then executing time-consuming is Tavg=(T1+T2+…+TN)/N。
In an optional implementation manner, dispatch server takes standby database to complete when database instruction needed for each stage
Second stage it is time-consuming, the summation of second stage time-consuming is used as the step of the single execution time-consuming of standby database permissible
Are as follows: the communication time-consuming that spends and the second write-in are time-consuming when available this of dispatch server completes database instruction for database,
Determine the communication time-consuming and the time-consuming weight of second write-in respectively, by the time-consuming weight of the communication time-consuming and second write-in and
Time-consuming is executed as this for the single of database.By the way that time-consuming and write-in disk the second write-in time-consuming weight and work will be communicated
Single for standby database executes time-consuming, can accurately reflect that standby database executes what a database instruction was spent
Time.
Wherein, the weight of communication time-consuming can be any value between 1 to 2, and the time-consuming weight of second write-in can
Think any value between 1.5 to 2.It, can be by the power of the second write-in time-consuming when the disk of standby database is ordinary magnetic disc
It is set greater than the time-consuming weight of communication again;When the disk of standby database is SSD, it can will communicate time-consuming weight and be set as big
In the time-consuming weight of the second write-in.
For example, a certain standby database is T with the communication time-consuming that primary database is once communicatednet, the second of disk is written
Time-consuming write-in is Tdisk, communicating time-consuming weight is Wnet, the time-consuming weight of the second write-in is Wdisk.Due to the magnetic for database
Disk is SSD then Wnet>Wdisk, W is set by the time-consuming weight of communicationnet=2, W is set by the time-consuming weight of the second write-indisk
=1.5, then the single for database executes time-consuming T=2*Tnet*Wnet+Tdisk*Wdisk。
203, it is synchronous to carry out data under the goal systems synchronous mode for Database Systems.
In embodiments of the present invention, under the goal systems synchronous mode, when primary database receives database instruction,
It, can be by the execution knot of the database instruction under the premise of being not necessarily to sync response of any standby database to the database instruction
Fruit is written in the disk of the primary database.
For example, executing the SQL statement when primary database receives the SQL statement of modification data and obtaining implementing result, simultaneously
The SQL statement is written in binlog log and is sent to all standby databases, but without waiting for the sync response of standby database, i.e.,
Implementing result can be written to the disk of primary database, then feedback runs succeeded.
It should be noted that dispatch server can continue to obtain this and synchronize time-consuming, when this synchronizes time-consuming less than the first mesh
When marking duration, step 204 and step 205 can be executed by current systematic synchronisation pattern and switch to strong synchronous mode.Certainly this
It is only a kind of trigger condition that current systematic synchronisation pattern is switched to strong synchronous mode, dispatch server can also be according to number
Current systematic synchronisation pattern is switched to according to the occupation condition of library server and load condition of Database Systems etc.
Strong synchronous mode.To carry out data using strong synchronous mode and synchronize when Database Systems meet the condition of strong synchronous mode,
To keep strong consistency of the primary database at least one for data in database.
204, when this, which synchronizes time-consuming, is less than the first object duration, dispatch server can be by the synchronous mould of current system
Formula switches to default system synchronous mode.
Wherein, which can be strong synchronous mode.
205, it is synchronous to carry out data under the default system synchronous mode for Database Systems.
Under the default system synchronous mode, when primary database receives database instruction, which executes should
The database instruction is sent at least one that all standby database namely the Database Systems include by database instruction
Standby database, when the primary database receives the sync response of any standby database, primary database is by the database instruction
Implementing result is written in the disk of the primary database.By the way that Database Systems are worked as when synchronizing time-consuming and being less than first object duration
Preceding systematic synchronisation pattern switches to strong synchronous mode, can guarantee primary database and each standby data when network condition is preferable
The strong consistency of data in library.
It should be noted that it is the scheduling illustratively shown that above-mentioned steps 202, which are only the embodiment of the present invention to step 205,
Server is according to time-consuming is synchronized, when this synchronizes time-consuming and is greater than first object duration, by the systematic synchronisation pattern of Database Systems
Asynchronous mode is switched to by strong synchronous mode, after switching, when this synchronizes time-consuming and is less than first object duration, by Database Systems
Systematic synchronisation pattern the process of strong synchronous mode is switched to by asynchronous mode.Above-mentioned steps label is merely for convenience of describing,
Be not offered as it is actual execute sequence, for example, can be executed according to 201 to 205 sequence, can also according to 201,204,205,
202,203 sequence executes.
In embodiments of the present invention, by obtain Database Systems in primary database at least one for the synchronous of database
This is synchronized time-consuming and compared with first object duration by time-consuming, will be current when this synchronizes time-consuming and is greater than the first object duration
Systematic synchronisation pattern be switched to goal systems synchronous mode, so that primary database is no longer needed to when receiving database instruction
To the response of standby database, disk directly is written into implementing result, so that primary database can execute database faster
Instruction, improves the process performance of Database Systems.
Fig. 3 is the flow chart of another method of data synchronization provided according to an exemplary embodiment, as shown in Figure 3.It should
Method the following steps are included:
301, the resource occupation information of database server where dispatch server obtains Database Systems.
In embodiments of the present invention, dispatch server can obtain the resource occupation information of database server in real time,
The resource occupation information of database server can be periodically obtained, such as obtained one every 1 minute, 3 minutes or 5 minutes
It is secondary.The Database Systems may include a primary database and at least one for database, the corresponding data of each database
Library server.The resource occupation information is the occupied information of hardware resource in the database server, which can be
CPU (Central Processing Unit, central processing unit) resource, memory source, hard disk resources etc..Dispatch server can
To obtain the resource occupation information of each database server, the hardware of each database distribution is adjusted according to the resource occupation information
Resource.
For example, Database Systems A includes primary database A1, standby database A2With standby database A3.Primary database A1It is deployed in
Database server D1Upper, standby database A2It is deployed in database server D2On, standby database A3It is deployed in database server
D3On.
It in an optional implementation manner, may include at least two in a database server for save the cost
A Database Systems, the resource occupation information of each Database Systems in the available database server of dispatch server.Its
In, the database number that at least two Database Systems for including in the database server include can be identical, can also not
Together, the embodiment of the present invention is to this without concrete restriction.
302, dispatch server is that Database Systems distribute available hardware resource according to the resource occupation information, this is available hard
Part resource is related to the load condition of the Database Systems.
In embodiments of the present invention, it is said for including at least two Database Systems in a database server
It is bright.The load of Database Systems is higher in database server, and the hardware resource for indicating that the Database Systems need is more, scheduling
Server can distribute biggish available hardware resource for the high Database Systems of the load.Certain dispatch server is each number
According to library system distribution available hardware resource total size no more than the hardware resource that database server includes size.
In an optional implementation manner, the size of the available hardware resource of Database Systems is dynamically changeable, should
The size of available hardware resource and the occupation condition of database server, the resource distribution file of the Database Systems and
The loading condition of the database is related.
Correspondingly, dispatch server is that the step of Database Systems distribute available hardware resource can according to resource occupation information
With are as follows: the resource distribution file of each Database Systems in database server is obtained, which is used to indicate often
The size for the hardware resource that a Database Systems can be used.When the hardware resource of the database server is not otherwise fully engaged
When, it is that Database Systems distribute available hardware resource according to the load condition of each Database Systems, the available hardware resource
Size can be more than the size for the hardware resource that the resource distribution file of the Database Systems indicates.When the database server
It is that the Database Systems distribute available hardware resource according to resource distribution file when hardware resource has been fully used.Pass through root
The available hardware resource that each Database Systems are adjusted according to the load condition dynamic of each Database Systems, can be to avoid database
The hardware resource waste of server, while improving the treatment effeciency for loading higher Database Systems.
For example, dispatch server obtains the resource distribution file a and data base set of Database Systems A in database server
The resource distribution file b of system B.The hardware resource that resource distribution file a referred database system A can be used is database service
The 50% of device, the hardware resource that resource distribution file b referred database system B can be used are 50%.Database Systems A's is negative
It carries lower, only used 25% hardware resource of database server, the load of Database Systems B is higher, is used for
50% hardware resource of database server.But there are hardware resource deficiencies, and processing capacity to be caused to decline by Database Systems B
The problem of, it is also necessary to 20% hardware resource of database server, dispatch server are indicated the 20% of database server
Idle hardware resource allocation give Database Systems B, so that Database Systems B can normally handle database instruction.Work as data
When the load of library system A is promoted, when Database Systems A uses 30% hardware resource of database server, database clothes
The hardware resource of business device has been fully used, according to resource distribution file, by the available of Database Systems A and Database Systems B
Hardware resource is respectively set to 50%.If the load of Database Systems A no longer rises, dispatch server can be by database
The idle hardware resource allocation of server gives Database Systems B, if the load continuous of Database Systems A rises, until reaching
50%, Database Systems A and Database Systems B will use the hardware resource of distribution to carry out data processing.
In an optional implementation manner, each Database Systems have priority, and dispatch server can be in database
When the resource occupation total amount of server is higher, the resource occupation amount of each Database Systems, database can be adjusted according to priority
The priority of system is higher, and the hardware resource of distribution is more.
In an optional implementation manner, each Database Systems have priority, and dispatch server can be in database
When the resource occupation total amount of server is higher, switching priority it is lower at least one Database Systems the synchronous mould of system
Formula.
Correspondingly, dispatch server is that the step of Database Systems distribute available hardware resource can according to resource occupation information
With are as follows: dispatch server can determine the priority of each Database Systems in database server, believe when according to resource occupation
When ceasing the resource occupation total amount for determining the database server more than target occupancy threshold value, by priority in the database server
At least one the lower systematic synchronisation pattern of Database Systems switches to goal systems synchronous mode.When according to resource occupation
When information determines the resource occupation total amount of the database server lower than default occupancy threshold value, by the number of goal systems synchronous mode
Strong synchronous mode is reverted to according to library system.Wherein, it can be 85%, 90%, 95% etc. which, which occupies threshold value,.The goal systems
Synchronous mode can be asynchronous mode.The default threshold value that occupies can be 70%, 75%, 80% etc..By in database service
When the resource occupation total amount of device is larger, the lower Database Systems of priority are switched to asynchronous mode, database can be discharged
The fractional hardware resource of server, so that the higher Database Systems of priority are able to use more hardware resource and carry out data
Processing.
In an optional implementation manner, dispatch server can be more than in the resource occupation total amount of database server
When target occupies threshold value, the systematic synchronisation pattern of the minimum Database Systems of priority is switched into goal systems synchronous mode,
If after switching, the resource occupation total amount of database server is still more than that target occupies threshold value, and dispatch server can will work as
The systematic synchronisation pattern of the minimum Database Systems of preceding priority switches to goal systems synchronous mode, until database server
Resource occupation total amount be less than target occupy threshold value.When the resource occupation for determining the database server according to resource occupation information
When total amount is lower than default occupancy threshold value, the Database Systems of goal systems synchronous mode are reverted into strong synchronous mode.
For example, having Database Systems A, Database Systems B, Database Systems C and Database Systems in database server
D, wherein priority ranking is Database Systems A > Database Systems B > Database Systems C > Database Systems D.When database takes
When the hardware resource occupancy total value of business device is more than 95%, the systematic synchronisation pattern of Database Systems D is cut in dispatch server instruction
It is changed to asynchronous mode, to save hardware resource.When the hardware resource of database server, which occupies total value, is lower than 80%, by data
The systematic synchronisation pattern of library system D is switched to strong synchronous mode.
In embodiments of the present invention, by obtaining the resource occupation information of database server, believed according to the resource occupation
Breath is that Database Systems distribute available hardware resource, can utilize the hardware resource of database server to greatest extent, avoid counting
According to the hardware resource waste of library server, while improving the treatment effeciency for loading higher Database Systems.
Fig. 4 is the flow chart of another method of data synchronization provided according to an exemplary embodiment, as shown in Figure 4.It should
Method the following steps are included:
401, dispatch server obtain Database Systems in primary database and at least one for database operating status believe
Breath, the running state information be used to indicate the primary database and this at least one for database whether normal operation.
In embodiments of the present invention, which may include the input and output thread state of database, memory
State, network state, heartbeat message etc..Dispatch server can obtain the running state information in real time, can also periodically obtain
Take the running state information.
In an optional implementation manner, when dispatch server judges that primary database is abnormal according to running state information
When, dispatch server can send connection request to the primary database, establish connection with the primary database, which is used for
Whether detection changes database normal.When dispatch server, which is based on the connection request, judges that the primary database is abnormal, determining should
Primary database is abnormal;When dispatch server, which is based on the connection request, judges that the primary database is normal, the operating status is determined
Information errors.Judge whether primary database is normal by the way that dispatch server is secondary, it can be to avoid because of agent module exception or net
Network fluctuation causes primary database caused by running state information mistake to miss switching problem, improves the stability of system.
402, when primary database operation is abnormal, dispatch server, which determines, causes primary database to run abnormal failure
Reason.
Dispatch server can determine that primary database runs abnormal failure cause according to running state information, such as negative
Carrying excessive leads to that thread queue is crowded, disk write-in is slow, CPU occupies exception, memory corruption etc..
403, primary database is switched to standby database, by least one for data according to failure cause by dispatch server
Standby database in library is switched to new primary database.
Dispatch server directly can carry out primary database and standby database when determining that primary database operation is abnormal
Switching can also carry out the switching of primary database and standby database according to the type of failure cause.The process is properly termed as disaster tolerance
Switching.
In an optional implementation manner, primary database is switched to standby data according to failure cause by dispatch server
Library, the step of at least one is switched to new primary database for the standby database in database, can be with are as follows: dispatch server is true
Primary database is switched to standby by the fixed corresponding fault type of the failure cause when the fault type is not target faults type
At least one is switched to new primary database for the standby database in database by database.Wherein, which is
At least one is switched to the fault type that can solve after new primary database for the standby database in database.When the failure classes
When type is target faults type, handover mechanism is exempted from starting, this exempts from handover mechanism and be used to indicate to exempt to cut in the time in target to detect
When the fault error reason of target faults type, keep primary database constant.By according to the corresponding fault type of failure cause
To determine whether to switch primary database and for database, it can just switch over, avoid when switch data library can solve problem
Due to the problems such as amount of access is excessive frequent switching database, cause database that can not normally provide server.
Wherein, target faults type can be excessive instantaneous amount of access, load too high, network congestion, hardware damage etc..Mesh
The length that mark exempts to cut the time can carry out dynamic modification, such as 1 minute, 10 minutes, 30 minutes according to actual needs, and the present invention is real
Example is applied to this without concrete restriction.
In an optional implementation manner, dispatch server can trigger warning information after the switching of each disaster tolerance, will
The warning information is used to indicate the reason of currently leading to primary database and standby database switching.By the warning information, work people
Member can be repaired and be adjusted to Database Systems based on the warning information, and the performance of Database Systems is improved.
In an optional implementation manner, when hardware fault occurs for the database server where Database Systems,
Dispatch server can be cancelled after the hardware fault reparation and exempt from the mechanism of cutting, this is exempted from database that the mechanism of cutting is related to from exempting from cut distribution
It sets in file and deletes.Exempt from the mechanism of cutting by cancelling after hardware fault is repaired, so as to avoid other databases from breaking down
When lead to not carry out disaster tolerance switching the case where.
It in embodiments of the present invention, can be in database event by obtaining the operating status of database in Database Systems
Disaster tolerance switching is carried out when barrier, to guarantee that Database Systems can normally provide server, while the failure for passing through failure cause
The problem of type is exempted to cut rule to be arranged, and can solve Database Systems frequent switching to provide service.
Fig. 5 is a kind of block diagram of the data synchronization unit provided according to embodiments of the present invention.The device is above-mentioned for executing
The step of when method of data synchronization executes, referring to Fig. 5, device includes: the first acquisition module 501, the first switching module 502 and writes
Enter module 503.
First obtains module 501, for obtaining in Database Systems primary database at least one for the synchronous of database
Time-consuming, synchronize it is time-consuming for indicate primary database and any one for carried out between database data it is synchronous when each stage needed for
It is time-consuming;
First switching module 502, for when synchronize it is time-consuming be greater than first object duration when, by current systematic synchronisation pattern
Switch to goal systems synchronous mode;
Writing module 503 is used under goal systems synchronous mode, when primary database receives database instruction,
Without any standby database under the premise of the sync response of database instruction, main number is written into the implementing result of database instruction
According in the disk in library.
In an optional implementation manner, first module 501 is obtained, is also used in Database Systems, obtains main number
According to first stage property time-consuming needed for each stage when data synchronize is carried out between library and a standby database, which is consumed
When summation synchronize time-consuming as the single of the Database Systems;Multiple singles of the Database Systems are synchronized into time-consuming be averaged
Value is used as and synchronizes time-consuming.
In another optional implementation, first obtains module 501, is also used to obtain primary database and executes database
Instruct the waiting time-consuming spent and the first write-in time-consuming, waiting time-consuming is that primary database waits a standby database return to synchronize sound
Required time-consuming is answered, time-consuming the first write-in is that primary database the implementing result of database instruction is written in the disk of primary database
Required time-consuming;It determines respectively and waits weight time-consuming and that the first write-in is time-consuming;Power time-consuming and that the first write-in is time-consuming will be waited
Weight time-consuming synchronous with the single as Database Systems.
In another optional implementation, device further include:
Second obtains module, for, for standby database each in database, obtaining holding for standby database at least one
Row is time-consuming, executes time-consuming for indicating time-consuming needed for standby database completes database instruction;
Second switching module is used for when executing time-consuming greater than the second target duration, will be same for the current single machine of database
Step mode switches to target per-unit synchronous mode;Under the target per-unit synchronous mode, primary database is without waiting for standby database
Sync response.
In another optional implementation, second obtains module, is also used to obtain standby database completion database and refers to
Second stage needed for each stage is time-consuming when enabling, using the summation of second stage time-consuming as the completion database of standby database
The single of instruction executes time-consuming;Multiple singles of standby database are executed into time-consuming average value as executing time-consuming.
In another optional implementation, second obtains module, is also used to obtain standby database completion database and refers to
The communication time-consuming spent when enabling and the second write-in are time-consuming, and communication is time-consuming to be carried out communicating required consumption with primary database for standby database
When, the time-consuming implementing result of database instruction is written for standby database of the second write-in is consumed needed for the disk of standby database
When;The weight that communication is time-consuming and the second write-in is time-consuming is determined respectively;By the weight and conduct that communication is time-consuming and the second write-in is time-consuming
The single of standby database executes time-consuming.
In another optional implementation, described device further include:
Third switching module, for all switching to target per-unit synchronous for database when at least one in Database Systems
When mode, current systematic synchronisation pattern is switched into goal systems synchronous mode.
In another optional implementation, device further include:
4th switching module, for when synchronizing time-consuming less than first object duration, current systematic synchronisation pattern to be cut
Shift to default system synchronous mode;
Under default system synchronous mode, when primary database receives database instruction, primary database executes database
Database instruction is sent at least one for database by instruction, when what primary database received any standby database synchronizes sound
It at once, will be in the disk of the implementing result write-in primary database of database instruction.
In another optional implementation, device further include:
Third obtains module, for the resource occupation information of database server where obtaining Database Systems, database
It include at least two Database Systems in server;
Distribution module can be provided for being that Database Systems distribute available hardware resource according to resource occupation information with hardware
Source size is related to the load condition of Database Systems.
In another optional implementation, distribution module is also used to obtain each database in database server
The resource distribution file of system, resource distribution file are used to indicate the big of the hardware resource that each Database Systems can be used
It is small;It is data according to the load condition of each Database Systems when the hardware resource of database server is not otherwise fully engaged
Library system distributes available hardware resource, and the size of available hardware resource can be more than that the resource distribution file of Database Systems indicates
Hardware resource size;It is number according to resource distribution file when the hardware resource of database server has been fully used
Available hardware resource is distributed according to library system.
In another optional implementation, distribution module is also used to determine each database in database server
The priority of system;When the resource occupation total amount for determining database server according to resource occupation information is more than that target occupies threshold value
When, it is same that the systematic synchronisation pattern of the Database Systems of at least one low priority in database server is switched into goal systems
Step mode.
In another optional implementation, device further include:
4th obtains module, for obtaining operating status of the primary database at least one for database in Database Systems
Information, running state information be used to indicate primary database and at least one for database whether normal operation;
Determining module, for determining and primary database being caused to run abnormal failure when primary database operation is abnormal
Reason;
5th switching module, for according to failure cause, primary database to be switched to standby database, by least one standby number
New primary database is switched to according to the standby database in library.
In another optional implementation, the 5th switching module is also used to determine the corresponding failure classes of failure cause
Type;When fault type is not target faults type, primary database is switched to standby database, by least one in database
Standby database be switched to new primary database, target faults type is by least one for the standby database switching in database
For the fault type that can solve after new primary database;When fault type is target faults type, handover mechanism is exempted from starting, is exempted from
Handover mechanism is used to indicate when target exempts to cut the fault error reason for detecting target faults type in the time, keeps master data
Library is constant.
In embodiments of the present invention, by obtain Database Systems in primary database at least one for the synchronous of database
This is synchronized time-consuming and compared with first object duration by time-consuming, will be current when this synchronizes time-consuming and is greater than the first object duration
Systematic synchronisation pattern be switched to goal systems synchronous mode, so that primary database is no longer needed to when receiving database instruction
To the response of standby database, disk directly is written into implementing result, so that primary database can execute database faster
Instruction, improves the process performance of Database Systems.
It should be understood that device provided by the above embodiment is when running application program, only with above-mentioned each functional module
Division progress for example, in practical application, can according to need and above-mentioned function distribution is complete by different functional modules
At the internal structure of device being divided into different functional modules, to complete all or part of the functions described above.Separately
Outside, apparatus and method embodiment provided by the above embodiment belongs to same design, and specific implementation process is detailed in embodiment of the method,
Which is not described herein again.
Fig. 6 is a kind of structural schematic diagram of server provided in an embodiment of the present invention, which can be because of configuration or property
Energy is different and generates bigger difference, may include one or more processors (central processing
Units, CPU) 601 and one or more memory 602, wherein at least one instruction is stored in memory 602,
The method that at least one instruction is loaded by processor 601 and executed to realize above-mentioned each embodiment of the method offer.Certainly, the clothes
Business device can also have the components such as wired or wireless network interface, keyboard and input/output interface, to carry out input and output,
The server can also include other for realizing the component of functions of the equipments, and this will not be repeated here.
The embodiment of the invention also provides a kind of storage mediums, and the storage medium application is in server, the storage medium
It is stored with program code, which is used to execute the method for data synchronization in the embodiment of the present invention.
Those of ordinary skill in the art will appreciate that realizing that all or part of the steps of above-described embodiment can pass through hardware
Complete, relevant hardware can also be instructed to complete by program, program can store in a kind of storage medium, it is above-mentioned
The storage medium mentioned can be read-only memory, disk or CD etc..
The foregoing is merely a prefered embodiment of the invention, is not intended to limit the invention, all in the spirit and principles in the present invention
Within, any modification, equivalent replacement, improvement and so on should all be included in the protection scope of the present invention.
Claims (16)
1. a kind of method of data synchronization, which is characterized in that the described method includes:
Obtaining primary database in Database Systems, at least one for the synchronous time-consuming of database, the time-consuming that synchronizes is used to indicate
The primary database and any one for carried out between database data it is synchronous when each stage needed for time-consuming;
When it is described synchronize it is time-consuming be greater than first object duration when, current systematic synchronisation pattern is switched into the synchronous mould of goal systems
Formula;
Under the goal systems synchronous mode, when the primary database receives database instruction, without any standby number
According to library under the premise of the sync response of the database instruction, the main number is written into the implementing result of the database instruction
According in the disk in library.
2. the method according to claim 1, wherein primary database and at least one in the acquisition Database Systems
A standby database synchronizes time-consuming, comprising:
In the Database Systems, obtains and carry out each rank when data synchronize between the primary database and a standby database
The first stage property of Duan Suoxu is time-consuming, synchronous using the summation of the first stage property time-consuming as the single of the Database Systems
It is time-consuming;
Multiple singles of the Database Systems are synchronized into time-consuming average value and synchronize time-consuming as described.
3. according to the method described in claim 2, it is characterized in that, described obtain in the primary database and a standby database
Between carry out data it is synchronous when each stage needed for first stage property it is time-consuming, using the summation of the first stage property time-consuming as institute
The single for stating Database Systems synchronizes time-consuming, comprising:
It obtains the waiting time-consuming and first that the primary database execution database instruction is spent and time-consuming is written, the waiting time-consuming is
Time-consuming needed for the primary database waits a standby database to return to sync response, time-consuming first write-in is the main number
Time-consuming needed for the disk of the primary database is written into the implementing result of the database instruction according to library;
The weight for waiting time-consuming and described first write-in time-consuming is determined respectively;
Time-consuming weight with single as the Database Systems synchronous time-consuming time-consuming with first write-in is waited by described.
4. the method according to claim 1, wherein primary database and at least one in the acquisition Database Systems
A standby database synchronize time-consuming after, the method also includes:
For it is described at least one for database each standby in database, obtain the time-consuming that executes of the standby database, it is described to hold
Row is time-consuming for indicating time-consuming needed for the standby database completes the database instruction;
When the execution is time-consuming is greater than the second target duration, by the current per-unit synchronous pattern switching of the standby database to mesh
Mark per-unit synchronous mode;
Under the target per-unit synchronous mode, sync response of the primary database without waiting for the standby database.
5. according to the method described in claim 4, it is characterized in that, the acquisition standby database executes time-consuming, comprising:
It obtains the standby database and completes the time-consuming of second stage needed for each stage when the database instruction, by described second
Interim time-consuming summation executes time-consuming as the single of the completion database instruction of the standby database;
Multiple singles of the standby database are executed into time-consuming average value and execute time-consuming as described.
6. according to the method described in claim 5, it is characterized in that, the standby database completion database that obtains refers to
Second stage needed for each stage is time-consuming when enabling, using the summation of the second stage time-consuming as the list of the standby database
It is secondary to execute time-consuming, comprising:
It obtains the standby database and completes the communication time-consuming spent when the database instruction and the second write-in time-consuming, the communication
Time-consuming is that the standby database carries out communicating required time-consuming with the primary database, and time-consuming second write-in is the standby number
Time-consuming needed for the disk of the standby database is written into the implementing result of the database instruction according to library;
The time-consuming weight of time-consuming and described second write-in of the communication is determined respectively;
The time-consuming weight of time-consuming and described second write-in of the communication and the single as the standby database are executed into time-consuming.
7. according to the method described in claim 4, it is characterized in that, the per-unit synchronous mode that the standby database is current
It switches to after target per-unit synchronous mode, the method also includes:
It, will when at least one all switches to the target per-unit synchronous mode for database described in the Database Systems
Current systematic synchronisation pattern switches to the goal systems synchronous mode.
8. the method according to claim 1, wherein primary database and at least one in the acquisition Database Systems
A standby database synchronize time-consuming after, the method also includes:
When it is described synchronize it is time-consuming be less than the first object duration when, it is same that current systematic synchronisation pattern is switched into default system
Step mode;
Under the default system synchronous mode, when the primary database receives database instruction, the primary database is held
The row database instruction, by the database instruction be sent to it is described at least one for database, when the primary database connects
When receiving the sync response of any standby database, the implementing result of the database instruction is written to the disk of the primary database
In.
9. the method according to claim 1, wherein primary database and at least one in the acquisition Database Systems
A standby database synchronize time-consuming before, the method also includes:
The resource occupation information of Database Systems place database server is obtained, includes extremely in the database server
Few two Database Systems;
It is that the Database Systems distribute available hardware resource, the available hardware resource size according to the resource occupation information
It is related to the load condition of Database Systems.
10. according to the method described in claim 9, it is characterized in that, it is described according to the resource occupation information be the data
Library system distributes available hardware resource, comprising:
The resource distribution file of each Database Systems in the database server is obtained, the resource distribution file is for referring to
Show the size for the hardware resource that each Database Systems can be used;
When the hardware resource of the database server is not otherwise fully engaged, according to the load shape of each Database Systems
State is that the Database Systems distribute available hardware resource, and the size of the available hardware resource can be more than the data base set
The size of the hardware resource of the resource distribution file instruction of system;
It is the data according to the resource distribution file when the hardware resource of the database server has been fully used
Library system distributes available hardware resource.
11. according to the method described in claim 9, it is characterized in that, it is described according to the resource occupation information be the data
Library system distributes available hardware resource, comprising:
Determine the priority of each Database Systems in the database server;
When the resource occupation total amount for determining the database server according to the resource occupation information is more than that target occupies threshold value
When, the systematic synchronisation pattern of the Database Systems of at least one low priority in the database server is switched into the mesh
Mark system synchronous mode.
12. the method according to claim 1, wherein primary database and at least in the acquisition Database Systems
One standby database synchronize time-consuming after, the method also includes:
Obtain primary database described in the Database Systems and it is described at least one for database running state information, it is described
Running state information be used to indicate the primary database and it is described at least one for database whether normal operation;
When primary database operation is abnormal, determines and the primary database is caused to run abnormal failure cause;
According to the failure cause, the primary database is switched to standby database, by it is described at least one in database
Standby database is switched to new primary database.
13. according to the method for claim 12, which is characterized in that it is described according to the failure cause, by the master data
Library is switched to standby database, by it is described at least one for the standby database in database be switched to new primary database, comprising:
Determine the corresponding fault type of the failure cause;
When the fault type is not target faults type, the primary database is switched to standby database, by described at least
Standby database in one standby database is switched to new primary database, and the target faults type is that at least one is standby by described in
Standby database in database is switched to the fault type that can solve after new primary database;
When the fault type is target faults type, handover mechanism is exempted from starting, and the handover mechanism of exempting from is used to indicate in mesh
When mark exempts to cut the fault error reason for detecting the target faults type in the time, keep the primary database constant.
14. a kind of data synchronization unit, which is characterized in that described device includes:
First obtains module, for obtaining synchronous time-consuming of the primary database at least one for database, institute in Database Systems
State synchronize it is time-consuming for indicate the primary database and any one for carried out between database data it is synchronous when each stage needed for
Time-consuming;
First switching module, for when it is described synchronize it is time-consuming be greater than first object duration when, current systematic synchronisation pattern is cut
Shift to goal systems synchronous mode;
Writing module is used under the goal systems synchronous mode, when the primary database receives database instruction,
Without any standby database under the premise of the sync response of the database instruction, by the implementing result of the database instruction
It is written in the disk of the primary database.
15. a kind of server, which is characterized in that the server includes processor and memory, and the memory is for storing
Program code, said program code is as processor load and perform claim requires number described in 1 to 13 any claim
According to synchronous method.
16. a kind of storage medium, which is characterized in that for storing program code, said program code is used for the storage medium
Perform claim requires method of data synchronization described in 1 to 13 any claim.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910662737.2A CN110377664B (en) | 2019-07-22 | 2019-07-22 | Data synchronization method, device, server and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910662737.2A CN110377664B (en) | 2019-07-22 | 2019-07-22 | Data synchronization method, device, server and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110377664A true CN110377664A (en) | 2019-10-25 |
CN110377664B CN110377664B (en) | 2022-10-21 |
Family
ID=68254859
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910662737.2A Active CN110377664B (en) | 2019-07-22 | 2019-07-22 | Data synchronization method, device, server and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110377664B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021147197A1 (en) * | 2020-01-20 | 2021-07-29 | 深圳壹账通智能科技有限公司 | Data synchronization method and apparatus, computer device, and storage medium |
CN115544147A (en) * | 2022-10-18 | 2022-12-30 | 山东水发紫光大数据有限责任公司 | Machine room data reading method, device, equipment and storage medium |
WO2023173870A1 (en) * | 2022-03-15 | 2023-09-21 | 苏州浪潮智能科技有限公司 | Control method and apparatus for storage device, electronic device and non-volatile readable storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102955851A (en) * | 2012-10-30 | 2013-03-06 | 北京奇虎科技有限公司 | Database switching method and device |
CN105159795A (en) * | 2015-08-21 | 2015-12-16 | 小米科技有限责任公司 | Data synchronization method, apparatus and system |
CN105279210A (en) * | 2014-06-26 | 2016-01-27 | 赛贝斯股份有限公司 | Automatic mode switching in a synchronous replication environment |
CN108897658A (en) * | 2018-05-31 | 2018-11-27 | 康键信息技术(深圳)有限公司 | Primary database monitoring method, device, computer equipment and storage medium |
-
2019
- 2019-07-22 CN CN201910662737.2A patent/CN110377664B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102955851A (en) * | 2012-10-30 | 2013-03-06 | 北京奇虎科技有限公司 | Database switching method and device |
CN105279210A (en) * | 2014-06-26 | 2016-01-27 | 赛贝斯股份有限公司 | Automatic mode switching in a synchronous replication environment |
CN105159795A (en) * | 2015-08-21 | 2015-12-16 | 小米科技有限责任公司 | Data synchronization method, apparatus and system |
CN108897658A (en) * | 2018-05-31 | 2018-11-27 | 康键信息技术(深圳)有限公司 | Primary database monitoring method, device, computer equipment and storage medium |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021147197A1 (en) * | 2020-01-20 | 2021-07-29 | 深圳壹账通智能科技有限公司 | Data synchronization method and apparatus, computer device, and storage medium |
WO2023173870A1 (en) * | 2022-03-15 | 2023-09-21 | 苏州浪潮智能科技有限公司 | Control method and apparatus for storage device, electronic device and non-volatile readable storage medium |
CN115544147A (en) * | 2022-10-18 | 2022-12-30 | 山东水发紫光大数据有限责任公司 | Machine room data reading method, device, equipment and storage medium |
CN115544147B (en) * | 2022-10-18 | 2023-12-08 | 山东水发紫光大数据有限责任公司 | Machine room data reading method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN110377664B (en) | 2022-10-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7779298B2 (en) | Distributed job manager recovery | |
US7321992B1 (en) | Reducing application downtime in a cluster using user-defined rules for proactive failover | |
EP2710461B1 (en) | Cross-cloud computing for capacity management and disaster recovery | |
US7523344B2 (en) | Method and apparatus for facilitating process migration | |
EP2715539B1 (en) | Distributed computing framework | |
CA3168286A1 (en) | Data flow processing method and system | |
CN113641511B (en) | Message communication method and device | |
CN110377664A (en) | Method of data synchronization, device, server and storage medium | |
US20080288812A1 (en) | Cluster system and an error recovery method thereof | |
CN111338773A (en) | Distributed timed task scheduling method, scheduling system and server cluster | |
US10445295B1 (en) | Task-based framework for synchronization of event handling between nodes in an active/active data storage system | |
CN101137984A (en) | Systems, methods, and software for distributed loading of databases | |
EP2224341A1 (en) | Node system, server switching method, server device, and data transfer method | |
WO2021139174A1 (en) | Faas distributed computing method and apparatus | |
CN105827678A (en) | High-availability framework based communication method and node | |
CN113220509A (en) | Double-combination alternating shift system and method | |
JP5154843B2 (en) | Cluster system, computer, and failure recovery method | |
CN113986450A (en) | Virtual machine backup method and device | |
CN105323271B (en) | Cloud computing system and processing method and device thereof | |
CN117421158A (en) | Database fault processing method, system and storage medium | |
CN117076196A (en) | Database disaster recovery management and control method and device | |
CN107644035B (en) | Database system and deployment method thereof | |
CN114598591A (en) | Embedded platform node fault recovery system and method | |
CN109408581A (en) | A kind of method for interchanging data, device, equipment and storage medium | |
CN118051563B (en) | Disaster recovery method based on isomorphic clusters of distributed database |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20230920 Address after: 518057 Tencent Building, No. 1 High-tech Zone, Nanshan District, Shenzhen City, Guangdong Province, 35 floors Patentee after: TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd. Patentee after: TENCENT CLOUD COMPUTING (BEIJING) Co.,Ltd. Address before: 518057 Tencent Building, No. 1 High-tech Zone, Nanshan District, Shenzhen City, Guangdong Province, 35 floors Patentee before: TENCENT TECHNOLOGY (SHENZHEN) Co.,Ltd. |