CN107391758A - Database switching method, device and equipment - Google Patents

Database switching method, device and equipment Download PDF

Info

Publication number
CN107391758A
CN107391758A CN201710734499.2A CN201710734499A CN107391758A CN 107391758 A CN107391758 A CN 107391758A CN 201710734499 A CN201710734499 A CN 201710734499A CN 107391758 A CN107391758 A CN 107391758A
Authority
CN
China
Prior art keywords
data
database
business
operated
strategy
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
Application number
CN201710734499.2A
Other languages
Chinese (zh)
Other versions
CN107391758B (en
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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201710734499.2A priority Critical patent/CN107391758B/en
Publication of CN107391758A publication Critical patent/CN107391758A/en
Application granted granted Critical
Publication of CN107391758B publication Critical patent/CN107391758B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR 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/21Design, administration or maintenance of databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

This specification embodiment provides a kind of database switching method, device and equipment, and methods described includes:When there are data to write source database, directly data to be written target database will not be synchronized to, but be data to be synchronized by the data markers write;Reach predetermined lock in time, then the data being labeled into target database synchronization source database;After the data being labeled in source database are synchronized to target database, then target database switched into the database that the operation system preferentially accesses.Transition process of the data between disparate databases, the influence to business procession can be reduced, and then improves business processing efficiency.

Description

Database switching method, device and equipment
Technical field
This specification embodiment is related to technical field of data processing, more particularly to database switching method, device and equipment.
Background technology
With the variation of type of database, many operation systems all suffer from moving to business datum by source database The problem of target database.In order to solve the problems, such as that business datum migrates between disparate databases, correlation technique can respond Service request, while the data related to service request are write into source database, the data syn-chronization for writing source database is arrived Target database.
In summary, this technology for solving business datum and being migrated between disparate databases, can increase the visit of database Ask expense, and then influence business processing efficiency, therefore, it is necessary to a kind of new technology solves business datum in different types of number The problem of according to being migrated between storehouse.
The content of the invention
In view of this, this specification embodiment provides a kind of database switching method, device and equipment.
According to the first aspect of this specification embodiment, there is provided a kind of database switching method, including step:
It is data to be synchronized by the data markers write when there is data to write source database, wherein, source database is The database that operation system preferentially accesses;
If reaching predetermined lock in time, the data being labeled into target database synchronization source database;
After the data being labeled in source database are synchronized to target database, target database is switched into the business The database that System Priority accesses.
According to the second aspect of this specification embodiment, there is provided a kind of database switching device, including:
Data markers module, for being number to be synchronized by the data markers write when there is data to write source database According to, wherein, source database is the database that operation system preferentially accesses;
Data simultaneous module, for when reaching predetermined lock in time, the quilt into target database synchronization source database The data of mark;
Database handover module, after the data for being labeled in source database are synchronized to target database, by mesh Mark database switches to the database that the operation system preferentially accesses.
According to the third aspect of this specification embodiment, there is provided a kind of computer equipment, including:
Processor;
Store the memory of processor-executable instruction;
Wherein, the processor is coupled in the memory, for reading the programmed instruction of the memory storage, and makees For response, following operation is performed:
It is data to be synchronized by the data markers write when there is data to write source database, wherein, source database is The database that operation system preferentially accesses;
If reaching predetermined lock in time, the data being labeled into target database synchronization source database;
After the data being labeled in source database are synchronized to target database, target database is switched into the business The database that System Priority accesses.
Implement the embodiment that this specification provides, will not direct data to be written when there is data to write source database Target database is synchronized to, but is data to be synchronized by the data markers write;In arrival predetermined lock in time, then to The data being labeled in target database synchronization source database;The data being labeled in source database are synchronized to target data Behind storehouse, then target database switched into the database that the operation system preferentially accesses.Data can be reduced in different pieces of information Transition process between storehouse, the influence to business procession, and then improve business processing efficiency.
Brief description of the drawings
Fig. 1 is the Organization Chart of the system for realizing database switching shown in the exemplary embodiment of this specification one;
Fig. 2 is the flow chart of the database switching method shown in the exemplary embodiment of this specification one;
Fig. 3-6 is the signal of the front and rear data writing process of the database switching shown in the exemplary embodiment of this specification one Figure;
Fig. 7 is the block diagram of the database switching device shown in the exemplary embodiment of this specification one;
Fig. 8 is the hardware structure diagram of the computer equipment shown in the exemplary embodiment of this specification one.
Embodiment
Here exemplary embodiment will be illustrated in detail, its example is illustrated in the accompanying drawings.Following description is related to During accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represent same or analogous key element.Following exemplary embodiment Described in embodiment do not represent all embodiments consistent with this specification.On the contrary, they are only and such as institute The example of the consistent apparatus and method of some aspects be described in detail in attached claims, this specification.
It is only merely for the purpose of description specific embodiment in the term that this specification uses, and is not intended to be limiting this explanation Book." one kind " of used singulative, " described " and "the" are also intended to bag in this specification and in the appended claims Most forms are included, unless context clearly shows that other implications.It is also understood that term "and/or" used herein is Refer to and any or all may be combined comprising the associated list items purpose of one or more.
It will be appreciated that though various information may be described using term first, second, third, etc. in this specification, but These information should not necessarily be limited by these terms.These terms are only used for same type of information being distinguished from each other out.For example, do not taking off In the case of this specification scope, the first information can also be referred to as the second information, and similarly, the second information can also be claimed For the first information.Depending on linguistic context, word as used in this " if " can be construed to " ... when " or " when ... " or " in response to determining ".
Referring to Fig. 1, shown in Fig. 1 being the system for realizing data processing shown in the exemplary embodiment of this specification one 100 Organization Chart.System 100 can include the operation for entering row data communication via network 112 and one or more clients 106 Server 105, and independently of Operation Server 105 or it is integrated in the database 115,116 of Operation Server 105.Network 112 Such as internet, in-house network, extranets, wide area network (WAN), LAN (LAN), wired network, wireless network or other can be included Suitable network etc., or any combinations of two or more this kind of networks.Through the discussion of exemplary, Ying Liao Solution, term " data " and " information " interchangeably can be used to refer to may be present in computer based environment in this manual Text, image, audio, the information of video or any other form.
Commercially available HTTP (HTTP) server application can be included on Operation Server 105, such as HTTP server, Internet Information Service (IIS) and/or other servers.
Client 106 can be provided with the network equipment of application.Referred to herein as application can be to provide various services The application that is related to of operation system, such as financial system that account was transferred to or produced service is provided, the communication of Communications service is provided System etc., network equipment from hardware can include desktop PC, laptop computer, tablet PC, smart phone, Handheld computer, personal digital assistant (" PDA "), or the device of any other wired or wireless processor driving.
Once user initiates registration request, operation clothes using client 106 and by network 112 to Operation Server 105 Business device 105 can record the log-on message of the user, and preset authority is opened up in Operation Server 105 according to registration request Account.Furthermore, it is possible to it is stored with the account of each user's registration, (login password and/or business processing are close for the various passwords of each account Code etc.) and the authentication information that uploads during user's registration.
Follow-up user every time initiates the service request for some business by client 106, such as:Service data visitation Request etc. is transferred in request, business datum, so as to which when accessing Operation Server 105, Operation Server 105 is based on each industry The mark for showing user identity of the ID carried in business request etc, can know and record such service request.It is special It is other, the request time of the user can be recorded, it is selectable, IP address when initiating request can also be recorded, or adopted One in the type of hardware of network equipment, or the category information of operating system version that is based on of client release/client It is individual or multiple.Particularly, the service request updated for data occur, such as it is transferred to or produces the service request of resource, modification Request of service condition etc., Operation Server 105 can also record the service request, and corresponding internal or external by performing Operation after give user and specifically respond.Usually, all service requests, can be left in Operation Server 105 corresponding Record.Operation Server 105 can sort out all industry of different user respectively according to information such as ID, business description information Business request., can also be according to above-mentioned ID for the interaction between the service request of interbehavior, such as different registered users Classify and form set.
Operation Server 105 can store above-mentioned service request with database 115 or database 116, respond the business Business datum caused by the operation of request and the operation, database 115 and database 116 can be used for customer in response end 106 The database of service request.
For the application scenarios of redundancy backup, database 115 can be the redundancy backup of primary database and the primary database A database in database, database 116 can be one in the redundancy backup database of primary database and the primary database Database.
For the application scenarios of Data Migration, database 115 can be the migrating data of primary database and the primary database A database in storehouse, database 116 can be the databases in the migrating data storehouse of primary database and the primary database.Its In, primary database or migrating data storehouse can be Qracle databases, OceanBase databases, MySQL database etc..
Except database 115 and the external system 100 of database 116 can also include other databases.Be stored in database 115 or Data in database 116, it is associated with the operating procedure of various embodiments described below.
, may for the consideration of data safety, data-handling efficiency, database O&M cost etc. in practical application There is the demand in switch data storehouse.By taking the system shown in Fig. 1 as an example, database 115 is the number that Operation Server 105 is read and write always According to storehouse, source database can be referred to as, Operation Server 105, can preferential access originator after the service request of client 106 is received Database.Because the attributes such as the data-handling efficiency of database 116, safety guarantee, O&M cost are better than database 115, therefore, Need to replace database 115 with database 116, the database that Operation Server 105 preferentially accesses is switched to by database 115 Database 116, database 116 can be referred to as to the target database for being used for replacing source data.
In order to after target database replaces source database, still ensure that Operation Server 105 is that client 106 provides just Normal service, it is necessary to which business datum is moved into target database by source database before switch data storehouse.Below in conjunction with attached Figure, describe the database handoff procedure of this specification embodiment in detail.
Referring to Fig. 2, Fig. 2 is the flow chart of the database switching method shown in the exemplary embodiment of this specification one, should Embodiment can apply on the Operation Server shown in Fig. 1, comprise the following steps S201-S203:
Step S201, it is data to be synchronized by the data markers write when there is data to write source database, wherein, Source database is the database that operation system preferentially accesses.
If step S202, reaching predetermined lock in time, the number being labeled into target database synchronization source database According to.
Step S203, after the data being labeled in source database are synchronized to target database, target database is switched The database preferentially accessed for the operation system.
In the present embodiment, operation system can refer to service provider and provide the user each business involved during related service Equipment, such as:Service request for customer in response end, the Operation Server to client offer respective service.
In practical application, Operation Server receives the service request of client transmission or detects user's (such as business Keeper) directly in the service request triggered on Operation Server, source database can be performed corresponding with service request Operation, referred to herein as operation can be read operation, write operation, lock operation etc., write operation can refer to again insertion operation, change At least one of in operation, deletion action.And during business scenario difference, the service request that Operation Server receives is different, rings When answering the service request to source database execution operation, operated data may also be different, such as:Business scenario is electronics During the scene of commercial field, the service request of reception is asked for order processing, and operated data are order data;Business scenario For financial field scene when, the service request of reception is inquiry into balance request, and operated data can be account balance number According to.In other business scenarios, other kinds of service request, the other kinds of data of operation can also be received, this specification is real It is without limitation to apply example.
Received or the service request that detects when Operation Server responds, when writing data to source database, it can be determined that with Whether original SQL query condition is included as the unique index of data configuration to be operated corresponding to on-unit, if bag Contain, write operation directly is performed to target database, if do not included, according to the anti-industry looked into from database of where querying conditions Business table, judges the unique index for whether including the affiliated business of data to be operated in the traffic table, original if do not included SQL forbids performing write operation to target database, if including according to the unique index to mesh without band querying condition Mark database and perform write operation.
It can be data to be synchronized by the data markers write, when specifically marking, a synchrodata table can be established, Addition can characterize the sync mark of write data in the synchrodata table, such as:The index for the data write is added to together In step data table, or directly the information of the index for the data write and description write operation is added in synchrodata table; Corresponding write-in data sync mark can also be added directly in the tables of data of storage write-in data during mark, the sync mark can Using be this programme designer it is predetermined corresponding data can be represented as characters such as the letters of data to be synchronized, numerals.At other In embodiment, other modes can also be taken to mark data to be synchronized, this explanation embodiment is without limitation.
When writing data, when different to the operation performed by source database, the data of mark may also be different, example Such as:When performing deletion action to source database, the index of the data of deletion can be added to describing the information of deletion action Synchrodata table, after can also performing deletion action, the index of one group of data of gained is added to synchrodata table;To source number When performing insertion operation according to storehouse, the information of the index of the data of insertion and description insertion operation can be added to synchrodata Table, after can also performing insertion operation, the index of one group of data of gained is added to synchrodata table.
After the good data that this is write of mark, if not reaching predetermined lock in time, as long as there is data to write source number , can be to perform operation of the data markers that will be write as data to be synchronized again according to storehouse.Referred to herein as lock in time can be with Made a reservation for by the designer of this programme according to the application scenarios of reality.In some examples, the daily fixation period can be predefined for, Such as 3 points to 6 points of daily morning.In other examples, it is general less than predetermined that probability that source database operated can also be predefined for The period of rate threshold value, the probability threshold value can be other numerical value after 5%.
, can be to target database synchronization quilt if reaching the lock in time after the good data that this is write of mark The data of mark, when not having data to be synchronized in target database, data to be synchronized are directly write into target database, mesh When mark data have had the historical data related to data to be synchronized, according to sync mark or data to be synchronized to correlation Historical data is updated.
, can be preferentially same by the data of newest mark according to the mark time synchronously during labeled data in practical application Target database is walked, often completes the synchronization of one group or a data, the group or the data can be updated to same step number According to can be data to be synchronized by characterize data when specifically updating to distinguish synchronous data and not synchronous data Mark is deleted, and can also increase the mark that characterize data is synchronized data.In addition it is also possible to the data being synchronized to from last time are opened Begin, continue synchronous follow-up data.In other examples, can also synchronous labeled data in other sequences, this specification Embodiment is without limitation.
While the data being synchronously labeled, it is the database that operation system preferentially accesses that can keep source database, It is easy to, when there are data to need to write source database, while synchronous labeled, write data into source database, and mark and write Data.After the lock in time, data syn-chronization can be temporarily terminated, after next time reaches predetermined lock in time, followed by It is continuous to carry out data syn-chronization.
Under some scenes, when first group of data is not write from source database, beginning label data to be synchronized, so Mark and write before data to be synchronized in the data of source database, there may be at least part data to also need to be synchronized to number of targets According in storehouse, so, can also be same to target database after the data being labeled in source database are synchronized to target database Walk the data to be synchronized not being labeled in source database;Labeled data to be synchronized are not synchronized to target in source database After database, then target database switched into the database that operation system preferentially accesses.Referred to herein as source database in not Labeled data to be synchronized, can be true according to the business demand of reality by the designer or system manager of this programme It is fixed, such as:Data related to marked data in unlabelled data can be defined as to data to be synchronized, with having marked The related data of the data of note can be and the business identical data belonging to marked data.In other examples, may be used also So that business datum important in unlabelled data, the business datum that may be accessed repeatedly etc. are defined as into number to be synchronized According to this specification embodiment is without limitation.
After target database is switched into the database that the operation system preferentially accesses, it is contemplated that the target newly switched The database not stable operation under the actual operating environment of operation system, in fact it could happen that failure, and then traffic affecting and When handle, in order to avoid influence of the failure to business of target database, there are data to write in scheduled time slot that can be after handover It is data to be synchronized by the data markers write, when reaching predetermined lock in time, to source database when entering target database The data being labeled in synchronous target database.Referred to herein as the scheduled time can be by this programme designer or business pipe Reason personnel set according to business demand, are such as set as 1 hour, 1 day or other periods.
The new data in target database is synchronized to source database in scheduled time slot, target database can be worked as in institute State in scheduled time slot when there is abnormal operating condition, source database is switched into the data that the operation system preferentially accesses again Storehouse.Then it is data to be synchronized by the data markers write again when there is data to write source database;Reach predetermined same When walking the time, labeled data, the quilt into target database synchronization source database into source database synchronization target database The data of mark;After the data being labeled in source database are synchronized to target database, target database is switched to again The database that the operation system preferentially accesses.Pass through database switchback during failure, operation system and target data can be made Storehouse can preferably coordinate operation, avoid influence of the failure to business behind switch data storehouse, and also allow in time to target data Storehouse is adjusted, and can effectively reduce the rate of breakdown of target database, and then improve business processing efficiency.
, both can be into source database synchronization target database in the data being synchronously labeled due to the switchback of database Data, also can be to the data in target database synchronization source database, in order to avoid same business datum is back and forth in different numbers According to synchronous between storehouse, in synchronously labeled any group of data, by this group of data by the high database synchronization of optimistic lock version to The low database of optimism lock version.
In other examples, it can also circulate and perform switchback database, mark data to be synchronized, be same to target database The step of step data, switching target database are the database that the operation system preferentially accesses, until target database is in institute State and abnormal operating condition is occurred without in scheduled time slot.
In addition, if target database does not occur abnormal operating condition in the scheduled time slot, source can be directly abandoned Database.But in order to avoid target database breaks down within the short time after the scheduled time slot, influence at business Reason, can be selectively by the data syn-chronization write to source when having data write-in target database after the scheduled time slot Database, in some examples, when there can be the data to write target database after the scheduled time slot, obtain current time pair The data to be synchronized answered, wherein, current time and the time gap of the scheduled time slot are bigger, and corresponding data to be synchronized are got over It is few;It is data to be synchronized by the data markers write during corresponding with the current time Data Matching to be synchronized of the data of write-in. It data to be synchronized corresponding to current time, can be preset by this programme personnel, be treated for different time settings is different Synchrodata, such as:The importance of data is poorer, and the corresponding time is fewer, so can slowly reduction flag it is to be synchronized The amount of data, until no longer marking data to be synchronized.
After switching to the database that operation system preferentially accesses, when target database breaks down in scheduled time slot When, source database can be switched to the database that operation system preferentially accesses, the data to be synchronized of mark are all synchronous again To after target database, target database can be switched into the database that operation system preferentially accesses again again.Therefore, at least one The database that operation system preferentially accesses in the section time is not fixed, then during this period of time, Operation Server is likely to be received For the multiple service request (repeatedly request belongs to same business) of same business, first time, service request was in source database and mesh Being received before mark database switching, Operation Server 105 responds the first time service request, and corresponding operating is performed to source database, The status data of the business is updated to 1.After replacing source database with target database, target database turns into Operation Server The database preferentially accessed, second of service request are sent to Operation Server, and Operation Server responds second of business please Ask, corresponding operating is performed to target database, the status data of the business is updated to 2.
In summary, Operation Server responds service request twice, and disparate databases are performed with operation, can cause two The data of same business are inconsistent in database, and the data of the flowing water type of same business are consistent in disparate databases, easily go out Existing idempotent failure, causes user to provide damage.This specification embodiment, can be in the data of write-in source database in order to solve the problem When being flowing water type data, the business belonging to the data of said write and database purchase are recorded to predetermined business operation, its In, affiliated database is source database.
In addition, the data for belonging to same business record once in business operation record, and can be to solve the above problems, institute Before being recorded with the business belonging to data to be written and database purchase to predetermined business operation, the business behaviour can be transferred Note down;Judge the business and database belonging to the data of said write whether are recorded in the business operation record;Institute State in business operation record when there is no the business and database belonging to the data of said write, then by belonging to the data of said write Business and database recorded predetermined business operation record.In addition, in order to reduce the idempotent problem between disparate databases, Can be by the business operation record storage in target database, so without ensureing that business operation is remembered by other measures again Idempotence where record between database and target database.
In addition to flowing water type data, it is also possible to which the data for having non-flowing water type need to write target database or source database, non- Flowing water type data can refer to status data, may be frequently changed, right such as the accounting data of the remaining sum in electronic account etc In non-flowing water type data, if a part of data distribution of same business, in target database, another part data distribution exists In source database, the business processing that can cause to be related to non-flowing water type data reports an error, therefore, in switching source database or target every time In a period after the database that database preferentially accesses for operation system, if necessary to operate primary database, primary database is It is another in the database preferentially accessed by the operation system in source database and target database, source database and target database One database is from database, can determine operation strategy based at least one of following before primary database is operated:
The data type of data to be operated, the business belonging to data to be operated, predetermined business operation record;According to Identified operation strategy performs corresponding operating to primary database.
Wherein, the business operation records the business and database belonging to the data for including having operated;Identified operation Strategy is the strategy for forbidding performing primary database corresponding operating, or allows the strategy that corresponding operating is performed to primary database.
The database of its preferential access may be performed repeatedly in addition, it is contemplated that Operation Server responds single service request Operation, if the operation strategy of multi-pass operation is different, it is consistent to be easily caused the data of same business in disparate databases, therefore, When performing corresponding operating to primary database according to identified operation strategy, if the service request of each operation response is identical, To primary database perform each operation when institute according to operation strategy it is identical, this identical operation strategy can be in response to the business Before request performs operation first to primary database, according to the industry belonging to the data type of data to be operated, data to be operated Operation strategy determined by least one in business and predetermined business operation record.
It is determined that during operation strategy, during application scenarios difference, determine that the content of operation strategy institute foundation is different, be exemplified below Several application scenarios, and determine the mode of operation strategy:
Scene one:The data that business under the scene is related to are non-flowing water type data, or are needed under the scene to main number When the operation performed according to storehouse is read operation or locks operation, it can determine to operate according only to the business belonging to data to be operated Strategy.Referred to herein as operation can be write operation, read operation and lock operation any of, write operation can be insertion behaviour Any of work, deletion action and modification operation.
When according to the business belonging to data to be operated to determine operation strategy, it can receive or examine from Operation Server In the content that the service request that measures carries, the targeted business of the service request is obtained, the service request is responded and needs to operate Data, be the business belonging to the data that need to operate by the business of acquisition, then judge the number for belonging to the business from database According to whether it is fully synchronized arrive primary database, if it is, identified operation strategy can be allow to primary database perform phase The strategy that should be operated;If it is not, then identified operation strategy can be the strategy for forbidding performing primary database corresponding operating.
When reality judges, the synchronous mark for the data for belonging to the business can be inquired about in the synchrodata table from database Note, if found, it is determined that it is not fully synchronized to primary database to belong to the data of the business from database, if do not searched Arrive, the business can also be being searched for from database, is searching this according to the index of the business or the index of data to be operated After business, judge whether the data of the business have been synchronized to primary database, if it is not, then determining to belong to the industry from database The data of business are not fully synchronized to arrive primary database, if it is, determining that the data for belonging to the business from database are all same Walk primary database.
In other embodiments, when determining operation strategy, it can first judge that original SQL corresponding with on-unit is looked into Whether inquiry condition is included as the unique index of data configuration to be operated, if comprising according to the unique index, inquiring about from number Whether primary database is synchronized to according to the data of the business in storehouse, if it is, identified operation strategy can be allowed pair Primary database performs the strategy of corresponding operating, if not, identified operation strategy can be progress performs phase to primary database The strategy that should be operated.
If original SQL query condition does not include the unique index for data configuration to be operated, judge that original SQL is looked into Whether the major key ID configurations of inquiry condition are empty, if it is, determining the querying condition that the SQL query condition is batch operation, then According to the table name of synchrodata table and sync mark inquiry, whether the data of the business from database have been synchronized to master data Storehouse, if not, identified operation strategy can be the strategy that progress performs corresponding operating to primary database, if it is, institute is really Fixed operation strategy can be the strategy for allowing to perform primary database corresponding operating.
If the major key ID configurations of original SQL query condition are not sky, according to major key ID inquiries industry from database Whether the data of business are empty, if it is not, then whether the data for judging to be inquired according to major key ID have been synchronized to primary database, If it is, identified operation strategy can be the strategy for allowing to perform primary database corresponding operating, if not, identified Operation strategy can be the strategy that progress performs corresponding operating to primary database.
If being empty according to major key ID inquiries data of the business from database, looked into according to where querying conditions are counter From the traffic table of database, the unique index for whether including the affiliated business of data to be operated in the traffic table is judged, if Do not include, it is determined that the SQL query condition is the querying condition of batch operation, then according to the table name of synchrodata table and synchronous mark Whether note inquiry data of the business from database have been synchronized to primary database, if it is, identified operation strategy can To be the strategy for allowing to perform primary database corresponding operating, if not, identified operation strategy can be in progress to main number The strategy of corresponding operating is performed according to storehouse.
If the traffic table includes the unique index of the affiliated business of data to be operated, read from the traffic table The unique index of the affiliated business of data of extract operation, then according to the unique index, inquire about the data of the business from database Whether primary database has been synchronized to, if it is, identified operation strategy can allow to perform primary database corresponding behaviour The strategy of work, if not, identified operation strategy can be the strategy that progress performs corresponding operating to primary database.
During above-mentioned determination operation strategy, if identified operation strategy is to forbid performing phase to primary database It should operate, identified operation strategy can be represented by throwing mistake.Operation if necessary to be performed to primary database is grasped for reading Make, then when identified operation strategy is forbids performing corresponding operating to primary database, this specification embodiment, Ke Yiyun Perhaps Operation Server reads the data from database.
Under other scenes, the operation if necessary to be performed to primary database is write operation, the number of primary database to be written According to being probably flowing water type data, it is also possible to during non-flowing water type data, it is determined that during operation strategy, can judge with it is pending Operation corresponding to before whether original SQL query condition be included as the unique index of data configuration to be operated, first determine to wait to grasp The data type of the data of work, if non-flowing water type data, then judge original SQL query bar corresponding with on-unit Whether part is included as the unique index of data configuration to be operated, if flowing water type data, then according to data institute to be operated The business of category and predetermined business record table, to determine operation strategy.
Scene two:The existing non-flowing water type data of data that business under the scene is related to, there is flowing water type data, Ke Yigen again Operation strategy is determined according to the data type of data to be operated and the business belonging to it, can also be simultaneously according to number to be operated According to data type, the business belonging to it and predetermined business operation record determine operation strategy.
In the business belonging to the data type according to data to be operated and its, it is not flowing water type to judge data to be operated Data, and the data from database with the data to be operated with business, it is identified when being synchronized to primary database entirely Operation strategy can be the strategy for allowing to perform primary database corresponding operating.
In the business and data type according to belonging to data to be operated, it is not flowing water type number to judge data to be operated According to, and the data from database with the data to be operated with business, when not being synchronized to primary database entirely, identified behaviour It can be the strategy for forbidding performing primary database corresponding operating to make strategy.
Recorded in the data type according to data to be operated, the business belonging to it and predetermined business operation, judge to treat The data of operation are flowing water type data, and when there is no the business belonging to the data to be operated in business operation record, Identified operation strategy can be the strategy for allowing to perform primary database corresponding operating.
Judging that data to be operated are flowing water type data in addition, and having in business operation record described to be operated During business belonging to data, whether the data for determining whether to belong to the business in the business operation record belong to master data Storehouse, if belonged to, identified operation strategy can be the strategy for allowing to perform primary database corresponding operating.
If the data for belonging to the business in the business operation record belong to from database, can be further by treating Business belonging to the data of operation, judge whether the data for belonging to the business from database are fully synchronized to primary database, If fully synchronized arrive primary database, identified operation strategy can be the plan for allowing to perform primary database corresponding operating Slightly, if not fully synchronized arrive from database, identified operation strategy can forbid performing corresponding operating to primary database Strategy.
During above-mentioned determination operation strategy, if data to be operated are flowing water type data, logarithm can needed When the operation performed according to storehouse is write operation, according to the data type of data to be operated, the business belonging to it and predetermined business Operation note determines operation strategy, and the operation forbidden is write operation.
In addition, data to be operated are flowing water type data, identified operation strategy is to allow to perform phase to primary database It should operate, after corresponding operating is performed to primary database, the business belonging to operated data can be arrived with data-base recording The business operation record, wherein, affiliated database is primary database.It so can conveniently be directed to the data of flowing water type next time Carry out the determination of operation strategy.
, can be according to be operated affiliated if the data that business is related to only have flowing water type data under other scenes Business and predetermined business operation are recorded to determine operation strategy, and specific determination mode can refer to the determination side of above-described embodiment Formula, it will not be repeated here.
Below in conjunction with accompanying drawing 3 to 6, in the case where being related to illustrating under the business scenario of database switching, service switchover system Unite preferentially access database it is front and rear, how to handle the write operation of flowing water type data.Flowing water type data can refer to electronics account The business datum of family flowing water, order data etc, the business being related to have the dynamic process as flowing water.
In each business scenario shown in Fig. 3 to 6, including two databases, one of them is database Master, another Individual is database Slave, and transaction log is blacklist, for recording the business (service request belonging to the data operated For business), the affiliated database database of operation (response service request), the mark of data to be synchronized is in same step number According in table, according to the content recorded in the synchrodata table, it may be determined that go out data to be synchronized.
Referring to Fig. 3, in scene shown in Fig. 3, database Master is source database, is that Operation Server preferentially accesses Initial data base, database Slave is target database, can be specifically database Master redundancy backup database or Migrating data storehouse, the data in database Master do not have started synchronous to database Slave, do not generate business processing note yet Record (blacklist).
In practical application, if user logs in client in client device, and sent out by client to Operation Server Send the first service request (step 301) for business A:Business A state is set to 1, Operation Server receives the business After request, Operation Server can write the data (step S302) for business A state to be set to 1 to database Master: Represent that " business A state is 1 " character string.Then, for later stage synchrodata, the data of write-in can be marked, generate Fig. 3 Shown in synchrodata table 31.Because the data in database Master do not have started, operation clothes synchronous to database Slave Business device does not also perform operation to database Slave, so database Slave synchrodata is sky, table as shown in Figure 3 32。
In addition, in order to receive again judge during business A service request this operation be database Master, can By business A mark A and Database Identification Master corresponding records, to generate the blacklist as shown in table 33 in Fig. 3, be stored in Database Slave.
Referring to Fig. 4, in scene shown in Fig. 4, database Master is source database, is that Operation Server preferentially accesses Initial data base, database Slave is target database, can be specifically database Master redundancy backup database or Migrating data storehouse, database Master are stored with the data syn-chronization record generated in embodiment corresponding to Fig. 3, as shown in Figure 4 Table 41, according to table 41 by database Master at least part data syn-chronization to database Slave, database Slave is fortune The database that battalion's server currentization preferentially accesses, is stored with the blacklist generated in embodiment corresponding to Fig. 3, as shown in Figure 4 Table 42.
In practical application, if user logs in client in client device, and sent out by client to Operation Server Send the first service request (step 401) for business B:Business B state is set to 1, Operation Server receives the business After request, Operation Server can transfer the blacklist (step 402) shown in table 42 from database Slave, then judge what is transferred It whether there is business B (steps 403) in blacklist, judged result is in the absence of can be write to database Slave for by industry Business B state is set to 1 data (step S404):Represent that " business B state is 1 " character string.Then, in order to which the later stage is synchronous Data, the data of write-in can be marked, generate the synchrodata table 43 shown in Fig. 4.
In addition, in order to receive again judge during business B service request this operation be database Slave, can By business B mark B and Database Identification Slave corresponding records, to generate the blacklist as shown in table 44 in Fig. 4.
Referring to Fig. 5, in scene shown in Fig. 5, database Master is source database, is that Operation Server preferentially accesses Initial data base, database Slave is target database, can be specifically database Master redundancy backup database or Migrating data storehouse, database Master are stored with the data syn-chronization record generated in embodiment corresponding to Fig. 3, as shown in Figure 5 Table 51, according to table 51 by database Master at least part data syn-chronization to database Slave, database Slave is fortune The database that preferentially accesses of battalion's server currentization, be stored with the synchrodata generated in embodiment corresponding to Fig. 4 record with it is black List, difference table 52 and table 53 as shown in Figure 5.
In practical application, if user logs in client in client device, and sent out by client to Operation Server Send the second service request (step 501) for business A:Business A state is set to 2, Operation Server receives the business After request, Operation Server can transfer the blacklist (step 502) shown in table 53 from database Slave, then judge what is transferred Whether there is business A in blacklist, and in the presence of corresponding server identification whether be Slave (steps 503), judged result It is business A be present, corresponding server identification is not Slave, now, does not allow Operation Server to be write to database Slave For business A state to be set to 2 data, then refuse the service request (step S504).
Under other scenes, if database Master is the database that Operation Server initialization preferentially accesses, data Storehouse Slave is database Master redundancy backup database or migrating data storehouse, and database Master is stored with corresponding to Fig. 3 The data syn-chronization record generated in embodiment, table 51 as shown in Figure 5 need to be same by all of database Master according to table 51 The data syn-chronization of step is to database Slave, then though business A in the blacklist transferred be present, and server corresponding to business A Mark is not Slave, allows Operation Server to write the data for business A state to be set to 2 to database Slave yet.
Referring to Fig. 6, in scene shown in Fig. 6, database Master is source database, is that Operation Server preferentially accesses Initial data base, database Slave is target database, can be specifically database Master redundancy backup database or Migrating data storehouse, the data syn-chronization record generated in the embodiment according to corresponding to Fig. 3, by database Master at least part Data syn-chronization is to database Slave.
Database Slave is stored with corresponding to Fig. 4 and implemented after the database for switching to Operation Serverization preferentially to access The blacklist and synchrodata generated in example records, respectively table 62 and table 63 as shown in Figure 6, the data according to table 63 Synchronous recording, by database Slave at least part data syn-chronization to database Master, after switching again, database Master is the database that Operation Server current preference accesses.
In practical application, if user logs in client in client device, and sent out by client to Operation Server Send the second service request (step 601) for business A:Business A state is set to 2, Operation Server receives the business After request, Operation Server can transfer the blacklist (step 602) shown in table 62 from database Slave, then judge what is transferred Whether there is business A in blacklist, and in the presence of corresponding server identification whether be Master (steps 603), judge to tie Fruit is business A be present, and corresponding server identification is not Master, and now, Operation Server can be write to database Master Enter the data (step S604) for business A state to be set to 2:Represent that " business A state is 2 " character string.Then, it is Later stage synchrodata, the data of write-in can be marked, generate the synchrodata table 61 shown in Fig. 6.
Further, since also go request record in existing business A and this operation be database mark Master, can Not modified to blacklist.
, can be by data when meeting predetermined timing condition for the application scenarios any one of Fig. 3 to Fig. 6 Marked data syn-chronization is into database Slave in the Master of storehouse, or, data marked in database Slave are same Walk in database Master.
If in addition, need to realize the business of idempotent when business A or business B, can allowing to database Master or Before database Slave carries out operation corresponding with service request, judge whether to receive the service request first, if it is permit Perhaps it is corresponding with service request to database Master or database Slave progress to operate, if it is not, then forbidding to database Master or database Slave carries out operate corresponding with service request.
From above-described embodiment:The data handover scheme that this specification provides, can both realize same business in each number It is consistent according to the data in storehouse, it can also be ensured that the business idempotent in database handoff procedure.
Corresponding with the embodiment of preceding method, this specification additionally provides the embodiment of device.
Referring to Fig. 7, Fig. 7 is the block diagram of the database switching device shown in the exemplary embodiment of this specification one, the device It can include:Data markers module 710, data simultaneous module 720 and database handover module 730.
Wherein, data markers module 710, for being to treat by the data markers write when there is data to write source database Synchronous data, wherein, source database is the database that operation system preferentially accesses.
Data simultaneous module 720, for when reaching predetermined lock in time, into target database synchronization source database Labeled data.
Database handover module 730, will after the data for being labeled in source database are synchronized to target database Target database switches to the database that the operation system preferentially accesses.
In some examples, the database switching device of this specification embodiment can also include:
Depth synchronization module, after the data for being labeled in source database are synchronized to target database, to target The data to be synchronized not being labeled in database synchronization source database;
Database handover module 730 can be also used for:
After labeled data to be synchronized are not synchronized to target database in source database, target database is switched The database preferentially accessed for the operation system.
In other examples, the database switching device of this specification embodiment can also include:
Succeeding marker module, for switch to the operation system preferentially to access in target database database after it is pre- It is data to be synchronized by the data markers write when having data write-in target database in timing section.
Subsequent synchronisation module, for when reaching predetermined lock in time, the quilt into source database synchronization target database The data of mark.
In other examples, the database switching device of this specification embodiment can also include:
Data type acquisition module, for not occurring abnormal operating condition in the scheduled time slot in target database, And when having data write-in target database after the scheduled time slot, data to be synchronized corresponding to current time are obtained, wherein, currently Time and the time gap of the scheduled time slot are bigger, and corresponding data to be synchronized are fewer.
Supplemental markers module, during corresponding with the current time Data Matching to be synchronized of data for writing, by what is write Data markers are data to be synchronized.
In other examples, the database switching device of this specification embodiment can also include fault switch module, double To synchronization module and database switchback module:
The failure tackles module, for when there is abnormal operating condition in the scheduled time slot in target database, Again source database is switched into the database that the operation system preferentially accesses, and notifies the data simultaneous module to be still used for It is data to be synchronized by the data markers write when there is data to write source database.
The bi-directional synchronization module, for reaching predetermined lock in time constantly, to source database synchronization target data The data being labeled in storehouse, the data being labeled into target database synchronization source database.
The database switchback module, after the data for being labeled in source database are synchronized to target database, Again target database is switched into the database that the operation system preferentially accesses.
As an example, the bi-directional synchronization module is additionally operable in any group of data being synchronously labeled, by this group of data By the high database synchronization of optimistic lock version to the low database of optimistic lock version.
In other examples, source database is oracle database, and target database is OceanBase databases.
In other examples, the database switching device of this specification embodiment can also include:
Business record module, for when the data of write-in are flowing water type data, by the industry belonging to the data of said write Business and database purchase record to predetermined business operation, wherein, affiliated database is source database.
In other examples, the database switching device of this specification embodiment can also include:
Record transfers module, in the business belonging to the data by said write and database purchase to predetermined business Before operation note, the business operation record is transferred;
Judge module is recorded, for judging whether recorded in the business operation record belonging to the data of said write Business and database;
The business record module, for not having the business belonging to the data of said write in business operation record During with database, the business belonging to the data of said write and database be recorded into predetermined business operation and recorded.
As an example, the business operation record storage is in target database.
In other examples, the database switching device of this specification embodiment can also include:
Tactful determining module, for switch to the operation system preferentially to access in target database database after, it is main Before database is operated, operation strategy is determined based at least one of following:
The data type of data to be operated, the business belonging to data to be operated, predetermined business operation record;
Operation executing module, corresponding operating is performed to primary database for the operation strategy determined by;
Wherein, the database preferentially accessed by the operation system in source database and target database is primary database, Another database is from database;
The business operation records the business and database belonging to the data for including having operated;
Identified operation strategy is:
Forbid performing primary database the strategy of corresponding operating;Or,
Allow the strategy that corresponding operating is performed to primary database.
As an example, from database with the data to be operated with the data of business, be synchronized to primary database entirely When, identified operation strategy is the strategy for allowing to perform primary database corresponding operating;
Data from database with the data to be operated with business, when not being synchronized to primary database entirely, are determined Operation strategy be forbid to primary database perform corresponding operating strategy.
As an example, data to be operated are not flowing water type data, and same with the data to be operated from database The data of business, when being synchronized to primary database entirely, identified operation strategy is to allow to perform corresponding operating to primary database Strategy;
Data to be operated are not flowing water type data, and the number from database with the data to be operated with business According to when not being synchronized to primary database entirely, identified operation strategy is the strategy for forbidding performing primary database corresponding operating.
As an example, data to be operated are flowing water type data, and are not had in business operation record described to be operated Data belonging to business when, identified operation strategy be allow to primary database perform corresponding operating strategy;
The database switching device of this specification embodiment can also include:
First logging modle, for after primary database is performed corresponding operating, by the business belonging to operated data Primary database recorded the business operation record, wherein, affiliated database is primary database.
As an example, data to be operated are flowing water type data, have the number to be operated in the business operation record When belonging to the data of the business according to affiliated business, and in business operation record and being not belonging to primary database, identified behaviour Make strategy to forbid performing primary database the strategy of corresponding operating;
Data to be operated are flowing water type data, there is the industry belonging to the data to be operated in the business operation record Business, and when belonging to the data of the business in business operation record and belonging to primary database, identified operation strategy is fair Perhaps the strategy of corresponding operating is performed to primary database;
The database switching device of this specification embodiment can also include:
Second logging modle, for after primary database is performed corresponding operating, by the business belonging to operated data Recorded with data-base recording to the business operation, wherein, affiliated database is primary database.
As an example, data to be operated are flowing water type data, have the number to be operated in the business operation record According to affiliated business, the data that the business is belonged in business operation record are not belonging to primary database, and from database with The data to be operated are with the data of business, and when not being synchronized to primary database entirely, identified operation strategy is to forbid to master Database performs the strategy of corresponding operating;
Data to be operated are flowing water type data, and being recorded in the business operation record has belonging to the data to be operated Business, the data that the business is belonged in business operation record are not belonging to primary database, and are treated from database with described The data of operation are with the data of business, and when being synchronized to primary database entirely, identified operation strategy is to allow to hold primary database The strategy of row corresponding operating;
The database switching device of this specification embodiment can also include:
3rd logging modle, for after primary database is performed corresponding operating, by the business belonging to operated data Recorded with data-base recording to the business operation, wherein, affiliated database is primary database.
As an example, the business operation record storage is from database.
As an example, if data to be operated are flowing water type data, the operation forbidden is write operation.
As an example, the database switching device of this specification embodiment can also include:
Data read module, for when the operation forbidden is read operation, it is allowed to from database to the number to continue According to progress read operation.
As an example, the operation executing module is additionally operable to:
When the service request of each operation response is identical, each operation is performed to primary database according to identical operation strategy;
Before the operation strategy is responds the service request to primary database execution operation first, according to data to be operated Data type, in the business belonging to data to be operated and predetermined business operation record at least one of determined by operate Strategy.
The function of unit (or module) and the implementation process of effect specifically refer to right in the above method in said apparatus The implementation process of step is answered, will not be repeated here.
For device embodiment, because it corresponds essentially to embodiment of the method, so related part is real referring to method Apply the part explanation of example.Device embodiment described above is only schematical, wherein described be used as separating component The unit or module of explanation can be or may not be physically separate, and the part shown as unit or module can be with It is or may not be physical location or module, you can with positioned at a place, or multiple network lists can also be distributed to In member or module.Some or all of module therein can be selected to realize the mesh of this specification scheme according to the actual needs 's.Those of ordinary skill in the art are without creative efforts, you can to understand and implement.
The embodiment of this specification device can be applied on a computing device.Specifically can be by computer chip or entity Realize, or realized by the product with certain function.In a kind of typical realization, computer equipment is computer, is calculated The concrete form of machine can be personal computer, laptop computer, personal digital assistant, media player or these equipment In any several equipment combination.
Device embodiment can be realized by software, can also be realized by way of hardware or software and hardware combining.With Exemplified by software is realized, as the device on a logical meaning, being will be non-volatile by the processor of computer equipment where it Property the computer-readable recording medium such as memory in corresponding computer program instructions read what operation in internal memory was formed.From hardware view Speech, as shown in figure 8, being a kind of hardware structure diagram of this specification device place computer equipment, except the processing shown in Fig. 8 Outside device, internal memory, network interface and nonvolatile memory, computer equipment in embodiment where device generally according to The actual functional capability of the computer equipment, other hardware can also be included, this is repeated no more.
In one example, the memory of computer equipment can store processor executable program instructions;Processor can With coupled memory, for reading the programmed instruction of the memory storage, and as response, following operation is performed:There is number It is data to be synchronized by the data markers write during according to write-in source database, wherein, source database is that operation system is preferentially visited The database asked;If reaching predetermined lock in time, the data being labeled into target database synchronization source database;Source number After being synchronized to target database according to the data being labeled in storehouse, the operation system is switched to preferentially to access target database Database.
In other embodiments, the operation performed by processor may be referred to description related in embodiment of the method above, It will not be described here.
It is above-mentioned that this specification specific embodiment is described.Other embodiments are in the scope of the appended claims It is interior.In some cases, the action recorded in detail in the claims or step can be come according to different from the order in embodiment Perform and still can realize desired result.In addition, the process described in the accompanying drawings not necessarily require show it is specific suitable Sequence or consecutive order could realize desired result.In some embodiments, multitasking and parallel processing be also can With or be probably favourable.
The preferred embodiment of this specification is the foregoing is only, it is all in this explanation not to limit this specification Within the spirit and principle of book, any modification, equivalent substitution and improvements done etc., the model of this specification protection should be included in Within enclosing.

Claims (39)

1. a kind of database switching method, including step:
It is data to be synchronized by the data markers write when there is data to write source database, wherein, source database is business The database that System Priority accesses;
If reaching predetermined lock in time, the data being labeled into target database synchronization source database;
After the data being labeled in source database are synchronized to target database, target database is switched into the operation system The database preferentially accessed.
It is described after 2. the data according to the method for claim 1, being labeled in source database are synchronized to target database Method is further comprising the steps of:
The data to be synchronized not being labeled into target database synchronization source database;
It is described switch to the operation system preferentially to access target database database the step of, in source database not by The data to be synchronized of mark perform after being synchronized to target database.
3. target database according to the method for claim 1, is switched into the database that the operation system preferentially accesses Afterwards, methods described is further comprising the steps of:
It is data to be synchronized by the data markers write if data write target database in scheduled time slot;
When reaching predetermined lock in time, the labeled data into source database synchronization target database.
4. according to the method for claim 3, if target database does not occur misoperation shape in the scheduled time slot Condition, methods described are further comprising the steps of:
When having data write-in target database after the scheduled time slot, data to be synchronized corresponding to current time are obtained, wherein, when Preceding time and the time gap of the scheduled time slot are bigger, and corresponding data to be synchronized are fewer;
It is number to be synchronized by the data markers write during corresponding with the current time Data Matching to be synchronized of the data of write-in According to.
5. according to the method for claim 3, if there is abnormal operating condition in the scheduled time slot in target database, Methods described is further comprising the steps of:
Again source database is switched into the database that the operation system preferentially accesses;
It is data to be synchronized by the data markers write when there is data to write source database;
When reaching predetermined lock in time, the labeled data into source database synchronization target database, to target database The data being labeled in synchronous source database;
After the data being labeled in source database are synchronized to target database, target database is switched into the business again The database that System Priority accesses.
6. according to the method for claim 5, in any group of data being synchronously labeled, this group of data are locked into version by optimism This high database synchronization locks the low database of version to optimistic.
7. according to the method for claim 1, methods described is further comprising the steps of:
When the data of write-in are flowing water type data, by the business belonging to the data of said write and database purchase to predetermined industry Business operation note, wherein, affiliated database is source database.
8. according to the method for claim 7, by the business belonging to the data of said write and database purchase to predetermined Before business operation record, methods described is further comprising the steps of:
Transfer the business operation record;
Judge the business and database belonging to the data of said write whether are recorded in the business operation record;
Business belonging to the data of said write and database be recorded into the step of predetermined business operation records, in the industry Do not have to perform when the business and database belonging to the data of said write in business operation note.
9. according to the method for claim 7, the business operation record storage is in target database.
10. target database according to the method for claim 1, is switched into the database that the operation system preferentially accesses Afterwards, the described method comprises the following steps:
Before primary database is operated, operation strategy is determined based at least one of following:
The data type of data to be operated, the business belonging to data to be operated, predetermined business operation record;
Corresponding operating is performed to primary database according to identified operation strategy;
Wherein, the database preferentially accessed by the operation system in source database and target database is primary database, another Database is from database;
The business operation records the business and database belonging to the data for including having operated;
Identified operation strategy is:
Forbid performing primary database the strategy of corresponding operating;Or,
Allow the strategy that corresponding operating is performed to primary database.
11. according to the method for claim 10:
Data from database with the data to be operated with business, when being synchronized to primary database entirely, identified behaviour Make strategy to allow the strategy that corresponding operating is performed to primary database;
Data from database with the data to be operated with business, when not being synchronized to primary database entirely, identified behaviour Make strategy to forbid performing primary database the strategy of corresponding operating.
12. according to the method for claim 10:
Data to be operated are not flowing water type data, and the data from database with the data to be operated with business, When being synchronized to primary database entirely, identified operation strategy is the strategy for allowing to perform primary database corresponding operating;
Data to be operated are not flowing water type data, and the data from database with the data to be operated with business, not When being synchronized to primary database entirely, identified operation strategy is the strategy for forbidding performing primary database corresponding operating.
13. according to the method for claim 10:
Data to be operated are flowing water type data, and do not have the industry belonging to the data to be operated in business operation record During business, identified operation strategy is the strategy for allowing to perform primary database corresponding operating;
Methods described is further comprising the steps of:
After corresponding operating is performed to primary database, by the business belonging to operated data and data-base recording to the business Operation note, wherein, affiliated database is primary database.
14. according to the method for claim 10:
Data to be operated are flowing water type data, there is the business belonging to the data to be operated in the business operation record, And the data for belonging to the business in business operation record are when being not belonging to primary database, identified operation strategy is forbids pair Primary database performs the strategy of corresponding operating;
Data to be operated are flowing water type data, there is the business belonging to the data to be operated in the business operation record, And the data for belonging to the business in business operation record are when belonging to primary database, identified operation strategy is allows pair Primary database performs the strategy of corresponding operating;
Methods described is further comprising the steps of:
After corresponding operating is performed to primary database, by the business belonging to operated data and data-base recording to the business Operation note, wherein, affiliated database is primary database.
15. according to the method for claim 10:
Data to be operated are flowing water type data, there is the business belonging to the data to be operated in the business operation record, The data for belonging to the business in business operation record are not belonging to primary database, and from database with the number to be operated According to the data of same business, when not being synchronized to primary database entirely, identified operation strategy is corresponding to forbid performing primary database The strategy of operation;
Data to be operated are flowing water type data, and record has the industry belonging to the data to be operated in the business operation record Business, the data that the business is belonged in business operation record are not belonging to primary database, and from database with it is described to be operated Data with business data, when being synchronized to primary database entirely, identified operation strategy for allow to primary database perform phase The strategy that should be operated;
Methods described is further comprising the steps of:
After corresponding operating is performed to primary database, by the business belonging to operated data and data-base recording to the business Operation note, wherein, affiliated database is primary database.
16. according to the method for claim 10, the business operation record storage is from database.
17. the method according to any one of claim 10 to 16, if data to be operated are flowing water type data, forbid Operation be write operation.
18. the method according to any one of claim 10 to 16, when the operation forbidden is read operation, methods described is also wrapped Include following steps:
Allow carrying out read operation to the data to continue from database.
19. the method according to any one of claim 10 to 16, operation strategy is to master data determined by the basis Storehouse performs corresponding operating, in addition to:
When the service request of each operation response is identical, each operation is performed to primary database according to identical operation strategy;
Before the operation strategy is in response to the service request to primary database execution operation first, according to the number of data to be operated According to operation plan determined by least one in the business belonging to type, data to be operated and predetermined business operation record Slightly.
20. a kind of database switching device, including:
Data markers module, for being data to be synchronized by the data markers write when there is data to write source database, its In, source database is the database that operation system preferentially accesses;
Data simultaneous module, for when reaching predetermined lock in time, being labeled into target database synchronization source database Data;
Database handover module, after the data for being labeled in source database are synchronized to target database, by number of targets The database that the operation system preferentially accesses is switched to according to storehouse.
21. device according to claim 20, described device also include:
Depth synchronization module, after the data for being labeled in source database are synchronized to target database, to target data The data to be synchronized not being labeled in storehouse synchronization source database;
The database handover module is additionally operable to:
After labeled data to be synchronized are not synchronized to target database in source database, target database is switched into institute State the database that operation system preferentially accesses.
22. device according to claim 20, described device also include:
Succeeding marker module, for switch to the operation system preferentially to access in target database database after pre- timing It is data to be synchronized by the data markers write when having data write-in target database in section;
Subsequent synchronisation module, for when reaching predetermined lock in time, being labeled into source database synchronization target database Data.
23. device according to claim 22, described device also include:
Data type acquisition module, for not occurring abnormal operating condition, and institute in the scheduled time slot in target database State after scheduled time slot when there are the data to write target database, obtain data to be synchronized corresponding to current time, wherein, current time Bigger with the time gap of the scheduled time slot, corresponding data to be synchronized are fewer;
Supplemental markers module, during corresponding with the current time Data Matching to be synchronized of data for writing, the data that will be write Labeled as data to be synchronized.
24. device according to claim 22, described device also includes fault switch module, bi-directional synchronization module and data Storehouse switchback module:
The failure tackles module, for when target database abnormal operating condition occurs in the scheduled time slot, again Source database is switched into the database that the operation system preferentially accesses, and notifies the data simultaneous module to be still used to have It is data to be synchronized by the data markers write when data write source database;
The bi-directional synchronization module, for reaching predetermined lock in time constantly, into source database synchronization target database Labeled data, the data being labeled into target database synchronization source database;
The database switchback module, after the data for being labeled in source database are synchronized to target database, again Target database is switched into the database that the operation system preferentially accesses.
25. device according to claim 24, the bi-directional synchronization module is additionally operable in any group of synchronously labeled number According to when, this group of data are locked into the low database of version by the high database synchronization of optimistic lock version to optimistic.
26. device according to claim 20, described device also include:
Business record module, for when the data of write-in are flowing water type data, by the business belonging to the data of said write and Database purchase records to predetermined business operation, wherein, affiliated database is source database.
27. device according to claim 26, described device also include:
Record transfers module, in the business belonging to the data by said write and database purchase to predetermined business operation Before record, the business operation record is transferred;
Judge module is recorded, for judging the business belonging to the data of said write whether is recorded in the business operation record And database;
The business record module, for not having the business sum belonging to the data of said write in business operation record During according to storehouse, the business belonging to the data of said write and database be recorded into predetermined business operation and recorded.
28. device according to claim 26, the business operation record storage is in target database.
29. device according to claim 20, described device include:
Tactful determining module, for switch to the operation system preferentially to access in target database database after, master data Before storehouse is operated, operation strategy is determined based at least one of following:
The data type of data to be operated, the business belonging to data to be operated, predetermined business operation record;
Operation executing module, corresponding operating is performed to primary database for the operation strategy determined by;
Wherein, the database preferentially accessed by the operation system in source database and target database is primary database, another Database is from database;
The business operation records the business and database belonging to the data for including having operated;
Identified operation strategy is:
Forbid performing primary database the strategy of corresponding operating;Or,
Allow the strategy that corresponding operating is performed to primary database.
30. device according to claim 29:
Data from database with the data to be operated with business, when being synchronized to primary database entirely, identified behaviour Make strategy to allow the strategy that corresponding operating is performed to primary database;
Data from database with the data to be operated with business, when not being synchronized to primary database entirely, identified behaviour Make strategy to forbid performing primary database the strategy of corresponding operating.
31. device according to claim 29:
Data to be operated are not flowing water type data, and the data from database with the data to be operated with business, When being synchronized to primary database entirely, identified operation strategy is the strategy for allowing to perform primary database corresponding operating;
Data to be operated are not flowing water type data, and the data from database with the data to be operated with business, not When being synchronized to primary database entirely, identified operation strategy is the strategy for forbidding performing primary database corresponding operating.
32. device according to claim 29:
Data to be operated are flowing water type data, and do not have the industry belonging to the data to be operated in business operation record During business, identified operation strategy is the strategy for allowing to perform primary database corresponding operating;
Described device also includes:
First logging modle, for after primary database is performed corresponding operating, by the main number of business belonging to operated data The business operation record is recorded according to storehouse, wherein, affiliated database is primary database.
33. device according to claim 29:
Data to be operated are flowing water type data, there is the business belonging to the data to be operated in the business operation record, And the data for belonging to the business in business operation record are when being not belonging to primary database, identified operation strategy is forbids pair Primary database performs the strategy of corresponding operating;
Data to be operated are flowing water type data, there is the business belonging to the data to be operated in the business operation record, And the data for belonging to the business in business operation record are when belonging to primary database, identified operation strategy is allows pair Primary database performs the strategy of corresponding operating;
Described device also includes:
Second logging modle, for after primary database is performed corresponding operating, by the business and number belonging to operated data The business operation record is recorded according to storehouse, wherein, affiliated database is primary database.
34. device according to claim 29:
Data to be operated are flowing water type data, there is the business belonging to the data to be operated in the business operation record, The data for belonging to the business in business operation record are not belonging to primary database, and from database with the number to be operated According to the data of same business, when not being synchronized to primary database entirely, identified operation strategy is corresponding to forbid performing primary database The strategy of operation;
Data to be operated are flowing water type data, and record has the industry belonging to the data to be operated in the business operation record Business, the data that the business is belonged in business operation record are not belonging to primary database, and from database with it is described to be operated Data with business data, when being synchronized to primary database entirely, identified operation strategy for allow to primary database perform phase The strategy that should be operated;
Described device also includes:
3rd logging modle, for after primary database is performed corresponding operating, by the business and number belonging to operated data The business operation record is recorded according to storehouse, wherein, affiliated database is primary database.
35. device according to claim 29, the business operation record storage is from database.
36. the device according to any one of claim 29 to 35, if data to be operated are flowing water type data, forbid Operation be write operation.
37. the method according to any one of claim 29 to 35, described device also include:
Data read module, for when the operation forbidden is read operation, it is allowed to the data to continue are being entered from database Row read operation.
38. the device according to any one of claim 29 to 35, the operation executing module is additionally operable to:
When the service request of each operation response is identical, each operation is performed to primary database according to identical operation strategy;
Before the operation strategy is responds the service request to primary database execution operation first, according to the number of data to be operated According to operation plan determined by least one in the business belonging to type, data to be operated and predetermined business operation record Slightly.
39. a kind of computer equipment, including:
Processor;
Store the memory of processor-executable instruction;
Wherein, the processor is coupled in the memory, for reading the programmed instruction of the memory storage, and as sound Should, perform following operation:
It is data to be synchronized by the data markers write when there is data to write source database, wherein, source database is business The database that System Priority accesses;
If reaching predetermined lock in time, the data being labeled into target database synchronization source database;
After the data being labeled in source database are synchronized to target database, target database is switched into the operation system The database preferentially accessed.
CN201710734499.2A 2017-08-24 2017-08-24 Database switching method, device and equipment Active CN107391758B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710734499.2A CN107391758B (en) 2017-08-24 2017-08-24 Database switching method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710734499.2A CN107391758B (en) 2017-08-24 2017-08-24 Database switching method, device and equipment

Publications (2)

Publication Number Publication Date
CN107391758A true CN107391758A (en) 2017-11-24
CN107391758B CN107391758B (en) 2020-08-04

Family

ID=60345689

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710734499.2A Active CN107391758B (en) 2017-08-24 2017-08-24 Database switching method, device and equipment

Country Status (1)

Country Link
CN (1) CN107391758B (en)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108038153A (en) * 2017-12-04 2018-05-15 北京小度信息科技有限公司 The online data moving method and device of Hbase
CN108647105A (en) * 2018-05-22 2018-10-12 阿里巴巴集团控股有限公司 Idempotent control method in net system switching process, apparatus and system
CN108776622A (en) * 2018-06-06 2018-11-09 北京达佳互联信息技术有限公司 Method of data synchronization, device, computer equipment and storage medium
CN109753494A (en) * 2019-01-04 2019-05-14 北京环境特性研究所 A kind of target characteristic data library system and method for data synchronization
CN110019520A (en) * 2017-11-29 2019-07-16 财付通支付科技有限公司 Business executes method, system and device
CN110059135A (en) * 2019-04-12 2019-07-26 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
CN110471906A (en) * 2019-08-20 2019-11-19 阿里巴巴集团控股有限公司 Database switching method, device and equipment
CN110928945A (en) * 2018-09-04 2020-03-27 阿里巴巴集团控股有限公司 Data processing method and device for database and data processing system
CN111382199A (en) * 2018-12-29 2020-07-07 中兴通讯股份有限公司 Method and device for synchronously copying database
CN111475483A (en) * 2019-01-24 2020-07-31 阿里巴巴集团控股有限公司 Database migration method and device and computing equipment
CN112463132A (en) * 2020-11-13 2021-03-09 四川新网银行股份有限公司 Database switching tool and switching method
CN113722396A (en) * 2021-08-25 2021-11-30 武汉达梦数据库股份有限公司 Method and equipment for switching main service and standby service of data synchronization receiving end
CN113722297A (en) * 2021-09-14 2021-11-30 首约科技(北京)有限公司 Order system reconstruction smooth migration method
CN113836154A (en) * 2018-06-21 2021-12-24 创新先进技术有限公司 Database switching method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101706795A (en) * 2009-11-30 2010-05-12 上海世范软件技术有限公司 Method for synchronizing data of database in active/standby server
CN102906743A (en) * 2010-05-17 2013-01-30 慕尼黑技术大学 Hybrid OLTP and OLAP high performance database system
CN104391873A (en) * 2014-10-29 2015-03-04 上海达梦数据库有限公司 Database operation separation method and database operation separation system
WO2016101718A1 (en) * 2014-12-24 2016-06-30 北京奇虎科技有限公司 Method and device for complementing data
CN106202365A (en) * 2016-07-07 2016-12-07 帅斌鹏 Method, system and the data-base cluster that database update synchronizes
CN106980636A (en) * 2016-07-22 2017-07-25 平安科技(深圳)有限公司 Declaration form data processing method and device
CN106997306A (en) * 2016-01-26 2017-08-01 阿里巴巴集团控股有限公司 Physical machine Data Migration to high in the clouds methods, devices and systems

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101706795A (en) * 2009-11-30 2010-05-12 上海世范软件技术有限公司 Method for synchronizing data of database in active/standby server
CN102906743A (en) * 2010-05-17 2013-01-30 慕尼黑技术大学 Hybrid OLTP and OLAP high performance database system
CN104391873A (en) * 2014-10-29 2015-03-04 上海达梦数据库有限公司 Database operation separation method and database operation separation system
WO2016101718A1 (en) * 2014-12-24 2016-06-30 北京奇虎科技有限公司 Method and device for complementing data
CN106997306A (en) * 2016-01-26 2017-08-01 阿里巴巴集团控股有限公司 Physical machine Data Migration to high in the clouds methods, devices and systems
CN106202365A (en) * 2016-07-07 2016-12-07 帅斌鹏 Method, system and the data-base cluster that database update synchronizes
CN106980636A (en) * 2016-07-22 2017-07-25 平安科技(深圳)有限公司 Declaration form data processing method and device

Cited By (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110019520B (en) * 2017-11-29 2022-09-23 财付通支付科技有限公司 Service execution method, system and device
CN110019520A (en) * 2017-11-29 2019-07-16 财付通支付科技有限公司 Business executes method, system and device
CN108038153A (en) * 2017-12-04 2018-05-15 北京小度信息科技有限公司 The online data moving method and device of Hbase
CN108647105A (en) * 2018-05-22 2018-10-12 阿里巴巴集团控股有限公司 Idempotent control method in net system switching process, apparatus and system
CN108647105B (en) * 2018-05-22 2022-02-01 创新先进技术有限公司 Idempotent control method, device and system in system switching process
CN108776622A (en) * 2018-06-06 2018-11-09 北京达佳互联信息技术有限公司 Method of data synchronization, device, computer equipment and storage medium
CN113836154B (en) * 2018-06-21 2024-05-03 创新先进技术有限公司 Database switching method and device
CN113836154A (en) * 2018-06-21 2021-12-24 创新先进技术有限公司 Database switching method and device
CN110928945A (en) * 2018-09-04 2020-03-27 阿里巴巴集团控股有限公司 Data processing method and device for database and data processing system
CN110928945B (en) * 2018-09-04 2023-06-20 阿里巴巴集团控股有限公司 Data processing method and device for database and data processing system
CN111382199A (en) * 2018-12-29 2020-07-07 中兴通讯股份有限公司 Method and device for synchronously copying database
CN109753494A (en) * 2019-01-04 2019-05-14 北京环境特性研究所 A kind of target characteristic data library system and method for data synchronization
CN111475483B (en) * 2019-01-24 2023-05-05 阿里巴巴集团控股有限公司 Database migration method and device and computing equipment
CN111475483A (en) * 2019-01-24 2020-07-31 阿里巴巴集团控股有限公司 Database migration method and device and computing equipment
CN110059135A (en) * 2019-04-12 2019-07-26 阿里巴巴集团控股有限公司 A kind of method of data synchronization and device
CN110059135B (en) * 2019-04-12 2024-05-17 创新先进技术有限公司 Data synchronization method and device
CN110471906A (en) * 2019-08-20 2019-11-19 阿里巴巴集团控股有限公司 Database switching method, device and equipment
CN112463132B (en) * 2020-11-13 2023-06-06 四川新网银行股份有限公司 Database switching tool and switching method
CN112463132A (en) * 2020-11-13 2021-03-09 四川新网银行股份有限公司 Database switching tool and switching method
CN113722396A (en) * 2021-08-25 2021-11-30 武汉达梦数据库股份有限公司 Method and equipment for switching main service and standby service of data synchronization receiving end
CN113722396B (en) * 2021-08-25 2023-12-22 武汉达梦数据库股份有限公司 Method and equipment for switching main and standby services of data synchronous receiving end
CN113722297A (en) * 2021-09-14 2021-11-30 首约科技(北京)有限公司 Order system reconstruction smooth migration method

Also Published As

Publication number Publication date
CN107391758B (en) 2020-08-04

Similar Documents

Publication Publication Date Title
CN107391758A (en) Database switching method, device and equipment
CN105868231A (en) Cache data updating method and device
CN109714239B (en) Management message issuing method, VNFM (virtual network management frequency) equipment and server
EP3491808B1 (en) Interchangeable retrieval of content
US20190342753A1 (en) Device configuration method, apparatus and system
EP2766869A1 (en) Automatically aggregating contact information
CN106303428A (en) A kind of security protection cloud platform
CN107580032B (en) Data processing method, device and equipment
KR102172903B1 (en) Database management system based on blockchain technology
US10855637B2 (en) Architecture for large data management in communication applications through multiple mailboxes
US20190018878A1 (en) Dual overlay query processing
US10873552B2 (en) Large data management in communication applications through multiple mailboxes
CN104104582B (en) A kind of data storage path management method, client and server
CN109889588B (en) File acquisition method and device, computer equipment and storage medium
US20160241649A1 (en) Directory service discovery and/or learning
CN103546380A (en) Message forwarding method and device based on strategy routing
CN102073733B (en) Method and device for managing Hash table
US20100036892A1 (en) Determination of an updated data source from disparate data sources
CN105224541B (en) Uniqueness control method, information storage means and the device of data
CN106878052A (en) A kind of customer shift method and device
US9607072B2 (en) System and method for implementing nested relationships within a schemaless database
CN110199277A (en) It include metadata in data resource
CN111352938A (en) Data processing method, computer device and storage medium
CN111143366B (en) High-efficiency storage method for massive large object data
CN109885555B (en) User information management method and device

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: 20200922

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200922

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.