CN109271376A - Database upgrade method, apparatus, equipment and storage medium - Google Patents

Database upgrade method, apparatus, equipment and storage medium Download PDF

Info

Publication number
CN109271376A
CN109271376A CN201811455586.5A CN201811455586A CN109271376A CN 109271376 A CN109271376 A CN 109271376A CN 201811455586 A CN201811455586 A CN 201811455586A CN 109271376 A CN109271376 A CN 109271376A
Authority
CN
China
Prior art keywords
database
data
primary
primary database
backup
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811455586.5A
Other languages
Chinese (zh)
Inventor
万月亮
李刚
火莽
火一莽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ruian Technology Co Ltd
Original Assignee
Beijing Ruian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ruian Technology Co Ltd filed Critical Beijing Ruian Technology Co Ltd
Priority to CN201811455586.5A priority Critical patent/CN109271376A/en
Publication of CN109271376A publication Critical patent/CN109271376A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

The invention discloses a kind of database upgrade method, apparatus, equipment and storage mediums, firstly, the data in the data and backup database in primary database are then split as two parts data by detecting that the data capacity in primary database is more than capacity threshold;Backup database is upgraded into primary database, releases the synchronized relation of primary database and backup database;New backup database is configured for primary database, the data after splitting in primary database is retained into a part, by a part of data sharing of reservation into new backup database;Corresponding backup database is configured for the primary database after upgrading, the data after splitting in the primary database after upgrading are retained into another part, and by another part data sharing of reservation into corresponding backup database.The technical solution of the present embodiment realizes the smooth expansion of database on the basis of not influencing business experience.

Description

Database upgrade method, apparatus, equipment and storage medium
Technical field
The present embodiments relate to database technical field more particularly to a kind of database upgrade method, apparatus, equipment and Storage medium.
Background technique
Database be store in a certain way together, can with multiple user sharings, have redundancy as small as possible, with Application program data acquisition system independent of each other.As the continuous development of business can generate increasingly huger data, lead to data The memory capacity in library reaches bottleneck, and then brings serious performance issue to the inquiry use of operation system, influences making for user With experience.
In the prior art, dilatation is carried out to database mainly to realize by the following two kinds mode, mode one: work as data When library encounters storage bottleneck problem, increase new storage devices node, keep former library data motionless, newly-increased data are stored in In newly added equipment node.Mode two: it is out of service, N number of database is created, Data Migration service routine is built and former data is carried out Data Migration, more new routing rule, the service of restarting of modification service configuration connect new library, restore the service that database externally provides.
However, first way is stored in new device node due to increasing data newly, and newly-increased data tend to belong to use The hot spot data that family is more concerned about, the pressure accessed after increasing with operation system user can lay particular emphasis on newly-increased data equipment section Point causes database access performance issue so as to cause database loads are unbalanced.Second of data-base capacity-enlarging mode, first temporarily Withdrawing business will affect the usage experience of user, and secondly all dilatation work will generally be completed at the appointed time, to technical requirements It is excessively high, found after a period of time again problematic if last service starts and runs, data are difficult to rollback and are likely to result in number According to partial loss.
Summary of the invention
The present invention provides a kind of database upgrade method, apparatus, equipment and storage medium, is not influencing business experience basis On, realize the smooth expansion of database.
In a first aspect, the embodiment of the invention provides a kind of database upgrade methods, comprising:
Detect that the data capacity in primary database or backup database is more than capacity threshold, then by the primary database In data and backup database in data two parts data are split as according to identical mode;
The backup database is upgraded into primary database, and releases the primary database after the primary database and upgrading Synchronized relation;
New backup database is configured for the primary database, and the data after splitting in the primary database are retained one Point, and by a part of data sharing of reservation into new backup database;
Corresponding backup database is configured for the primary database after upgrading, by the number after splitting in the primary database after upgrading According to reservation another part, and by another part data sharing of reservation into corresponding backup database.
Second aspect, the embodiment of the invention also provides a kind of database upgrade devices, comprising:
Data split module, for detecting that the data capacity in primary database or backup database is more than capacity threshold Value, then be split as two parts number according to identical mode for the data in the data and backup database in the primary database According to;
Relation broken module, for the backup database to be upgraded to primary database, and release the primary database with The synchronized relation of primary database after upgrading;
Primary database configuration module, for configuring new backup database for the primary database, by the primary database Data after middle fractionation retain a part, and by a part of data sharing of reservation into new backup database;
Primary database configuration module after upgrading, for configuring corresponding backup database for the primary database after upgrading, Data after splitting in primary database after upgrading are retained into another part, and by another part data sharing of reservation to correspondence Backup database in.
The third aspect, the embodiment of the invention also provides a kind of equipment, the equipment includes:
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processing Device realizes the database upgrade method as described in first aspect among the above.
Fourth aspect, the embodiment of the invention also provides a kind of computer readable storage mediums, are stored thereon with computer Program realizes the database upgrade method as described in first aspect when the program is executed by processing unit.
Database upgrade method, apparatus, equipment and the storage medium provided in above-described embodiment, firstly, by detecting Data capacity in primary database or backup database is more than capacity threshold, then by the data and Backup Data in primary database Data in library are split as two parts data according to identical mode;Backup database is upgraded into primary database, and releases master The synchronized relation of database and backup database;New backup database is configured for primary database, after splitting in primary database Data retain a part, and by a part of data sharing of reservation into new backup database;For the master data after upgrading Library configures corresponding backup database, the data after splitting in the primary database after upgrading is retained another part, and will retain Another part data sharing into corresponding backup database.As it can be seen that technical solution provided in this embodiment, solves existing The problem of out of service or migrating data is needed in technology realizes the smooth of database on the basis of not influencing business experience Dilatation.
Detailed description of the invention
Fig. 1 is the flow chart for the database upgrade method that the embodiment of the present invention one provides;
Fig. 2 is a kind of structural schematic diagram for distributed data base that the embodiment of the present invention one provides;
Fig. 3 is the flow chart of database upgrade method provided by Embodiment 2 of the present invention;
Fig. 4 is the structural representation that backup database provided by Embodiment 2 of the present invention upgrades to database after primary database Figure;
Fig. 5 is the structural schematic diagram of the new backup database distributed data base of configuration provided by Embodiment 2 of the present invention;
Fig. 6 is the flow chart of database upgrade method provided by Embodiment 2 of the present invention;
Fig. 7 is the structural schematic diagram for the database upgrade device that the embodiment of the present invention three provides;
Fig. 8 is a kind of structural schematic diagram for equipment that the embodiment of the present invention four provides.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched The specific embodiment stated is used only for explaining the present invention rather than limiting the invention.It also should be noted that in order to just Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
Fig. 1 is the flow chart for the database upgrade method that the embodiment of the present invention one provides, and the present embodiment is applicable to upgrade The case where database, database upgrade method provided in this embodiment can be executed by database upgrade device, the data qurush Stage arrangement can be realized by way of software and/or hardware.The device for setting database upgrade is integrated in the server, that is, counts It is executed according to the method for qurush grade by server.
Specifically, as shown in Figure 1, the method for database upgrade provided in an embodiment of the present invention, mainly includes the following steps:
S110, detect that the data capacity in primary database or backup database is more than capacity threshold, then by the master The data in data and backup database in database are split as two parts data according to identical mode.
In the present embodiment, the database can be distributed data base.Distributed data base is usually using lesser Computer system, every computer can be individually stored in a place, may all have data base administration system in every computer A complete copy copy or copied part copy of system (DatabaseManagement System, DBMS), and have The database of oneself part.Many computers by that will be located at different location are interconnected by network, can be collectively constituted One complete, global large database concentrated, be physically distributed in logic.
In general, the back end for storing user data can be MySQL database, and MySQL is in distributed data base One association type data base management system, linked database can save the data in different tables, rather than by all numbers According to being placed in one big warehouse, to improve the speed of database, and the flexibility of database purchase is enhanced.
In general, distributed data base may include having multiple database instance objects, on each database instance object again There may be multiple data to divide library, and each data point library can be divided into more parts again on logic level.For example, for specification For the distributed data base of 32dbs-128bu, the data on each database instance object can be stored in 32 data point On library (db), while the data in data point library are divided into 128 buckets (bucket, bu) again, and therefore, each data divide inventory to exist 128/32=4 bu, each bu are used to store a part of data of user.The storage rule of user data can be according to subregion word Duan Jinhang Hash (HASH) calculates, which bu is determination data should be placed into.
Fig. 2 is a kind of structural schematic diagram for distributed data base that the embodiment of the present invention one provides.As shown in Fig. 2, one Service 205 includes two primary databases, the first primary database 201 and the second primary database 202, and each primary database has corresponding Backup database, i.e. the first primary database 201 have corresponding first backup database 203, i.e. the second primary database 202 tool There is corresponding second backup database 204.Further, it is same to carry out data for configuration primary database backup database corresponding with its Step, and two primary databases being mutually in step backup database corresponding with its is set and uses identical virtual IP The address (Internet Protocol, IP).Primary database and backup database are set as double main synchronized relation type database structures Frame.That is primary database backup database corresponding with its can be read and write, active and standby each other, and default is only negative with a primary database The write-in of data is blamed, another backup database is spare.Primary database is the master library of backup database, and backup database is main again The master library of database, they are principal and subordinate each other.When primary database is inaccessible Backup Data can be enabled automatically according to virtual IP address Library is used as primary database.Guarantee the availability of database by the way of double main synchronization+KEEPALIVED+ virtual IP address. It should be noted that illustrate only two primary databases and the corresponding backup database of primary database in Fig. 2, Each primary database and corresponding backup database are not shown, it will be appreciated by those skilled in the art that Fig. 2 is only this A part of the structural schematic diagram of the distributed data base of application, rather than complete structural schematic diagram.
But increasing with amount of user data, existing database possibly can not continue the newly-increased user data of storage, Therefore, it is necessary to upgrade to database, user data fractionation is stored to other databases.
In the present embodiment, when upgrading to database, it is necessary first to determine which database to be upgraded be It is a.
Further, in the present embodiment, the data capacity in primary database and backup database is monitored in real time, Detect that data capacity of the primary database perhaps in backup database is more than capacity threshold then to primary database or Backup Data Library is upgraded.It should be noted that primary database or backup database are double main synchronized relation type data in the present embodiment Library framework can only monitor the data capacity of one of database.
Further, capacity threshold can be determined by the total capacity of database, and illustratively, capacity threshold is database Total capacity 80%.It should be noted that the present embodiment is only illustrated capacity threshold, and it is non-limiting.It can be according to number According to the actual use situation in library, suitable capacity threshold is set.Data capacity in primary database and backup database is carried out Real time monitoring can be the data capacity used in real time monitoring primary database and backup database, when having used Data capacity be more than capacity threshold, then database is upgraded.
In the present embodiment, it is arranged in the server belonging to primary database instance objects and backup database instance objects Double virtual IP address.Illustratively, the first virtual ip address of the first primary database 201 is IP00, is set in affiliated server The second virtual ip address for setting the first primary database 201 is IP01, correspondingly, the first virtual IP address of the first backup database 201 Address is IP00, and the second virtual ip address that the first backup database 203 is arranged in affiliated server is IP01.
Data in primary database are split as two parts data, retain a part in the first virtual ip address IP00, Retain another part in the second virtual ip address IP01.Correspondingly, the data in backup database are split as two parts number According to reservation a part retains another part in the second virtual ip address IP01 in the first virtual ip address IP00.
S120, backup database is upgraded to primary database, and it is synchronous with the database after upgrading to release primary database Relationship.
In the present embodiment, primary database and backup database are double main synchronized relation type database frameworks, therefore, main number There is identical data content according to library and backup database.
Specifically, the configuration of modification service, upgrades to primary database for backup database.Further, service is modified Configuration can be to be modified in configuration file, is also possible in configuration center.In the present embodiment only to the modification of service configuration into Row explanation, and it is non-limiting.
Algorithm based on 2 index times upgrades double main synchronized relation type database frameworks.When data to be upgraded When lab setting is 1, the index that database can carry out 2 upgrades again.Where it is assumed that upgrading before, database 1, then into When row upgrades for the first time, database just becomes 2, that is, has 2 databases.When carrying out second of dilatation, database just becomes 4, that is, there are 4 databases, when carrying out third time dilatation, database just becomes 8, that is, has 8 databases, ensure that data The dynamic smoothing dilatation in library.It should be noted that the database includes primary database and backup database.
It further, is 2N database configuration by original N number of database configuration modification.Wherein, N is positive integer.Example Property, the database in 2 libraries is configured, the database configuration in 4 libraries is changed to, during modification it is noted that primary database be The mapping relations between primary database after upgrading.Such as: the library of %2=0 can become %4=0 and %4=2;%2=1's Library can become %4=1 and %4=3;Modification can be still counted by addressing system to correct after fractionation to guarantee in this way According to.
Primary database and backup database are double main synchronized relation type database frameworks, therefore, main primary database and backup There is a data channel, in database operational process, by the data channel, backup database is available between database The data of primary database, to back up.
In a particular embodiment, by modification service configuration, after backup database is upgraded to primary database, master is deleted The data channel between primary database after database and upgrading.It should be noted that only being synchronized to releasing in the present embodiment The method of relationship is illustrated, and non-limiting.Can the reasonable side for releasing synchronized relation be arranged according to the actual situation in user Method.
S130, new backup database is configured for primary database, the data after splitting in primary database are retained into a part, And by a part of data sharing of reservation into new backup database.
In the present embodiment, be primary database configure new backup database refer to for primary database configure one it is new standby Part database, in order to guarantee the high availability of data, configuration primary database is synchronous with new backup database progress data, and sets Primary database that two are mutually in step and new backup database are set using identical virtual ip address, using double main synchronizations+ The mode of KEEPALIVED+ void IP guarantees the availability of database.It establishes between primary database and new backup database Data after splitting in primary database are retained a part using the data channel by data channel, and by a part of reservation Data sharing is into new backup database.
S140, corresponding backup database is configured for the primary database after upgrading, will be split in the primary database after upgrading Data afterwards retain another part, and by another part data sharing of reservation into corresponding backup database.
In the present embodiment, corresponding backup database is configured for the primary database after upgrading to refer to for the main number after upgrading A corresponding backup database is configured according to library.In order to guarantee the high availability of data, primary database after configuration upgrading and new Backup database carry out that data are synchronous, and the primary database after two upgradings being mutually in step and corresponding Backup Data are set Library uses identical virtual ip address, guarantees the availability of database using the mode of double main synchronization+KEEPALIVED+ void IP. The data channel between primary database and corresponding backup database after establishing upgrading will be risen using the data channel Data after splitting in primary database after grade retain another part, and by another part data sharing of reservation to corresponding standby In part database.
The database upgrade method provided in the present embodiment, firstly, by detecting primary database or backup database In data capacity be more than capacity threshold, then by the data in the data and backup database in primary database according to identical side Formula is split as two parts data;Backup database is upgraded into primary database, and releases the same of primary database and backup database Step relationship;New backup database is configured for primary database, the data after splitting in primary database is retained into a part, and will protect A part of data sharing stayed is into new backup database;Corresponding backup database is configured for the primary database after upgrading, Data after splitting in primary database after upgrading are retained into another part, and by another part data sharing of reservation to correspondence Backup database in.As it can be seen that technical solution provided in this embodiment, solves and needs out of service or move in the prior art The problem of moving data, on the basis of not influencing business experience, realizes the smooth expansion of database.
Embodiment two
Fig. 3 is the flow chart of database upgrade method provided by Embodiment 2 of the present invention, on the basis of the above embodiments, The method for having advanced optimized database upgrade, as shown in figure 3, the database upgrade method after optimization mainly includes walking as follows It is rapid:
S310, configuration is different from the second of the first virtual address in the server where primary database and backup database Virtual address.
In the present embodiment, double virtual IP address are set in the server belonging to primary database and backup database.Exist First virtual address having the same in server where primary database and backup database.Upgrade to database When, need to be different from the second virtual address of the first virtual address for primary database and backup database configuration.
Illustratively, as shown in Fig. 2, the first virtual ip address of the first primary database 201 is IP00, in affiliated service The second virtual ip address that the first primary database 201 is arranged in device is IP01, correspondingly, the first of the first backup database 201 Virtual ip address is IP00, and the second virtual ip address that the first backup database 203 is arranged in affiliated server is IP01. First virtual ip address of the second primary database 202 is IP01, and the of the second primary database 202 is arranged in affiliated server Two virtual ip address are IP11, correspondingly, the first virtual ip address of the second backup database 204 is IP00, in affiliated clothes The second virtual ip address that the first backup database 203 is arranged in business device is IP11.
It should be noted that being only illustrated to the method for configuration virtual address, user can be according to reality in the present embodiment The method of the reasonable configuration virtual address of border situation design.
S320, the data in the data and backup database in primary database are subjected to water by way of major key modulus Truncation point, is split as two parts data.
S330, it the data after fractionation is retained to a part is stored in first virtual address, the data after fractionation are protected Another part is stayed to be stored in second virtual address.
In the present embodiment, major key refers to the combination of a column or multiple row in the table of database, and value can unique terrestrial reference Know table in every a line, by major key can enforced table entity integrity.Major key is mainly used for the external key association of other tables, with And the modification and deletion of this record.There is no major key, particular row is highly difficult in update or deletion table, because safe method is not protected Card only deletes relevant row.
Major key modulus, which refers to, carries out modulo operation according to the major key of database and the number of nodes of storage, then according to modulus As a result, data can be evenly distributed in each database.Major key modulus can guarantee that the data distribution in group is more equal It is even, database access request load balancing is made according to major key modulus route addressing mode.
Illustratively, when being extended to two databases by a database, according to major key unique encodings The major key ID of data all in primary database and backup database is pressed 2 modulus by (identification, ID) divided by 2 Remainder is classified.Further, major key ID is 0 divided by 2 remainders, then is stored in the corresponding data of major key ID that remainder is 0 First virtual address IP0, major key ID are 1 divided by 2 remainders, then the corresponding data of major key ID that remainder is 1 are stored in the second void Quasi- address ip 1.
As shown in Fig. 2, when being extended to four databases by two databases, according to major key unique encodings (identification, ID) is to 4 modulus.Assuming that based on data in the first primary database 201 and the first backup database 203 Key ID is 0 data for being divided by 2 remainders, and the data in the second primary database 202 and the second backup database 204 are that major key ID is removed It is 1 data for being with 2 remainders.So, to the corresponding master of data in the first primary database 201 and the first backup database 203 Key ID classifies divided by 4 by remainder.Major key ID is stored in the first virtual address IP00, major key divided by the data that 4 remainders are 0 ID is stored in the second virtual address IP01 divided by the data that 4 remainders are 2.To the second primary database 202 and the second backup database The corresponding major key ID of data in 204 classifies divided by 4 by remainder.Major key ID is stored in the divided by the data that 4 remainders are 1 One virtual address IP10, major key ID are stored in the first virtual address IP11 divided by the data that 4 remainders are 3.
It should be noted that major key ID is deposited to 2N modulus, and respectively when being 2N database by N number of database upgrade It stores up to the first virtual address and the second virtual address.
S340, the backup database is upgraded to by primary database by the method for modification server configuration, and releases institute The synchronized relation of database after stating primary database and the upgrading.
Specifically, the configuration of modification service, upgrades to primary database for backup database.Further, service is modified Configuration can be to be modified in configuration file, is also possible in configuration center.In the present embodiment only to the modification of service configuration into Row explanation, and it is non-limiting.
It further, is 2N database configuration by original N number of database configuration modification.Wherein, N is positive integer.Example Property, the database in 2 libraries is configured, the database configuration in 4 libraries is changed to, during modification it is noted that primary database be The mapping relations between primary database after upgrading.Such as: the library of %2=0 can become %4=0 and %4=2;%2=1's Library can become %4=1 and %4=3;Modification can be still counted by addressing system to correct after fractionation to guarantee in this way According to.
Primary database and backup database are double main synchronized relation type database frameworks, therefore, main primary database and backup There is a data channel, in database operational process, by the data channel, backup database is available between database The data of primary database, to back up.
In a particular embodiment, by modification service configuration, after backup database is upgraded to primary database, master is deleted The data channel between primary database after database and upgrading.It should be noted that only being synchronized to releasing in the present embodiment The method of relationship is illustrated, and non-limiting.Can the reasonable side for releasing synchronized relation be arranged according to the actual situation in user Method.
Fig. 4 is the structural representation that backup database provided by Embodiment 2 of the present invention upgrades to database after primary database Figure;As shown in figure 4, top service device 401 respectively with after the first primary database 401, upgrading the first primary database 402, the The second primary database 404 after two primary databases 403 and upgrading establishes communication connection.After first primary database 401 and upgrading Data channel between first primary database 402 disconnects, the first primary database after releasing the first primary database 401 and upgrading Synchronized relation between 402.The data channel between the second primary database 405 after second primary database 404 and upgrading disconnects, The synchronized relation between the second primary database 405 after releasing the second primary database 404 and upgrading.
S350, new backup database is configured for the primary database, the data after splitting in the primary database are protected A part is stayed, and by a part of data sharing of reservation into new backup database.
It is stored in second virtual address and second virtual address in S360, the deletion primary database Data.
In the present embodiment, be primary database configure new backup database refer to for primary database configure one it is new standby Part database, in order to guarantee the high availability of data, configuration primary database is synchronous with new backup database progress data, and sets Primary database that two are mutually in step and new backup database are set using identical virtual ip address, using double main synchronizations+ The mode of KEEPALIVED+ void IP guarantees the availability of database.It establishes between primary database and new backup database Data after splitting in primary database are retained a part using the data channel by data channel, and by a part of reservation Data sharing is into new backup database.
S370, corresponding backup database is configured for the primary database after upgrading, will be split in the primary database after upgrading Data afterwards retain another part, and by another part data sharing of reservation into corresponding backup database.
First virtual address and first virtual address in primary database after S380, the deletion upgrading The data of middle storage.
In the present embodiment, corresponding backup database is configured for the primary database after upgrading to refer to for the main number after upgrading A corresponding backup database is configured according to library.In order to guarantee the high availability of data, primary database after configuration upgrading and new Backup database carry out that data are synchronous, and the primary database after two upgradings being mutually in step and corresponding Backup Data are set Library uses identical virtual ip address, guarantees the availability of database using the mode of double main synchronization+KEEPALIVED+ void IP. The data channel between primary database and corresponding backup database after establishing upgrading will be risen using the data channel Data after splitting in primary database after grade retain another part, and by another part data sharing of reservation to corresponding standby In part database.
Fig. 5 is the structural schematic diagram of the new backup database distributed data base of configuration provided by Embodiment 2 of the present invention; As shown in figure 5, the first new backup database 506 is configured for the first primary database 502, for the first primary database after upgrading Corresponding first backup database 507 of 503 configurations, configures the second new backup database 508 for the second primary database 503, is The second primary database 504 after upgrading configures corresponding second backup database 509, and the after the first primary database 501, upgrading The second primary database 505 after one primary database 502, the second primary database 503 and upgrading is built with the top service 501 respectively Vertical communication connection.
Illustratively, the first primary database 501 is deleted deposits in the second virtual address IP01 and the second virtual address IP01 The data that the data of storage, i.e. major key ID are 2 divided by 4 remainders.First primary database 502 configures the first new backup database 506, The data channel between the first primary database 502 and the first new backup database 506 is established, using identical virtual IP address Location guarantees the availability of database using the mode of double main synchronization+KEEPALIVED+ void IP.First primary database 502 is by first The data stored in virtual address IP00 and the first virtual address IP00, i.e. major key ID is divided by the synchronous hair of data that 4 remainders are 0 It send to the first new backup database 506.
The first primary database 502 after upgrading is deleted to be stored in the first virtual address IP00 and the first virtual address IP00 Data, i.e. major key ID divided by 4 remainders be 0 data.The first primary database 503 after upgrading configures corresponding first backup number According to library 507, the first primary database 503 after upgrading and the data channel between corresponding first backup database 507 are established, is made With identical virtual ip address, guarantee the availability of database using the mode of double main synchronization+KEEPALIVED+ void IP.Upgrading The data that the first primary database 503 afterwards will store in the second virtual address IP01 and the second virtual address IP01, i.e. major key ID is synchronized divided by the data that 4 remainders are 2 and is sent to corresponding first backup database 507.
It should be noted that the second primary database 503 and the second new backup database 508, delete the second virtual address The data stored in IP11 and the second virtual address IP11.The second primary database 504 and corresponding second after upgrading Backup database 509 deletes the data stored in the first virtual address IP10 and the first virtual address IP10.Second master data The second primary database 504 after library 503 and the second new backup database 508 and upgrading and corresponding second backup database 509 delete the operation of redundant data and the operation of synchrodata and the first primary database 502 and the first new backup database 506 relevant operation is similar, and the present embodiment is not illustrated its operating process.
On the basis of the above embodiments, the embodiment of the present invention provides a kind of preferred embodiment.Fig. 6 is the embodiment of the present invention two The flow chart of the database upgrade method of offer.As shown in fig. 6, primary database 601 and top service 611 are established and are communicated to connect, Primary database 601 and backup database 602 are double main double main synchronized relation type database frameworks, i.e. 601 He of primary database simultaneously Backup database 602 is active and standby each other.The first virtual address IP0 is respectively set in primary database 601 and backup database 602, storage There is data A.When detecting that the data capacity in primary database 601 or backup database 602 is more than capacity threshold, by master data The data A in data A and backup database 602 in library 601 carries out horizontal cutting by way of major key modulus, is split as Data A1 and data A2.Further, according to major key unique encodings (identification, ID) to 2 modulus, i.e., by master data The major key ID of all data classifies divided by 2 by remainder in library 601 and backup database 602.Further, major key ID is removed Using the data that 2 remainders are 0 as data A1, then data A1 is stored in the first virtual address IP0, major key ID is 1 divided by 2 remainders Data are data A2, then data A2 are stored in the second virtual address IP1.There is the first virtual address i.e. in primary database 601 IP0 and storing data A1 and the second virtual address IP1 and storing data A2.In backup database 602 virtually with first Location IP0 and storing data A1 and the second virtual address IP1 and storing data A2.
After data A is split as data A1 and data A2, by the method for modification server configuration by backup database 602 upgrade to primary database, that is, establish the communication connection between backup database 602 and top service 611.Release primary database 601 with upgrading after primary database 602 synchronized relation, i.e., cutting primary database 601 and upgrading after primary database 602 between Data transmission channel.
After the synchronized relation of primary database 602 after releasing primary database 601 and upgrading, primary database 601 deletes the The data A2 stored in two virtual address IP1 and the second virtual address IP1, only retains the first virtual address IP0 and first The data A1 stored in virtual address IP0.Likewise, the primary database 602 after upgrading deletes the first virtual address IP0 and the The data A1 stored in one virtual address IP0 only retains and stores in the second virtual address IP1 and the second virtual address IP1 Data A2.
New backup database 603 is configured for primary database 601, establishes primary database 601 and new backup database 603 Between double main synchronized relations, that is, establish the data transmission channel between primary database 601 and new backup database 603, will The data that retains in primary database 601, and will be stored in the first virtual address IP0 and the first virtual address IP0 of reservation A1 is shared to new backup database 603.
Corresponding backup database 604 is configured for the primary database 602 after upgrading, the primary database 602 after establishing upgrading Double main synchronized relations between corresponding backup database 604, that is, establish primary database 602 and corresponding backup after upgrading Data transmission channel between database 604, by the second virtual address IP1 retained in the primary database 602 after upgrading and The data A2 stored in second virtual address IP1 is shared to new backup database 603.So far, database upgrade finishes.
By aforesaid operations step, the backup database in former double main sync databases is made to become new primary database, it is former Data level to be stored in the corresponding database of the first virtual address is stored according to modulus rule to the first void after having split In the quasi- corresponding database in address and the corresponding database of the second virtual address, and make each database by deleting redundant data Data capacity reduces half, to realize the smooth expansion of database.
The embodiment of the present invention carries out smooth horizontal extension to database by way of increasing new database, to mention Rise the performance of entire accumulation layer.The horizontal extension of database is to split to carry out based on level, and the number of horizontal extension represents water The flat number for splitting iteration.Service carries out as usual during dilatation, guarantees the High Availabitity of database, and implementation process error rate is low, expands It can be debugged at any time during appearance, not influence normal service on line, each database reduces the data storage of half after dilatation is complete, adopts Data level fractionation is carried out with major key modulus mode, is counted in service layer according to major key modulus routing addressing when accessing database According to access, thus the load balancing for requesting access to database realizing.
The database upgrade method provided in the present embodiment, by first it is detected that in primary database or backup database Data capacity be more than capacity threshold, then by the data in the data and backup database in primary database according to identical mode It is split as two parts data;Backup database is upgraded into primary database, and it is synchronous with backup database to release primary database Relationship;New backup database is configured for primary database, the data after splitting in primary database is retained into a part, and will retain A part of data sharing into new backup database;Corresponding backup database is configured for the primary database after upgrading, it will Data after splitting in primary database after upgrading retain another part, and by another part data sharing of reservation to corresponding In backup database.As it can be seen that technical solution provided in this embodiment, solves and needs out of service or migration in the prior art The problem of data, realizes the smooth expansion of database on the basis of not influencing business experience.
Embodiment three
Fig. 7 is the structural schematic diagram for the database upgrade device that the embodiment of the present invention three provides, and the present embodiment is applicable to The case where upgrade database, the database upgrade device can be realized by way of software and/or hardware.Set data qurush The device of grade is integrated in the server, i.e., the method for database upgrade is executed by server.
Specifically, as shown in fig. 7, the database upgrade device that the embodiment of the present invention three provides specifically includes following part:
Data split module 710, for detecting that the data capacity in primary database or backup database is more than capacity Data in data and backup database in the primary database are then split as two parts number according to identical mode by threshold value According to.
Relation broken module 720 for the backup database to be upgraded to primary database, and releases the primary database With the synchronized relation of the backup database.
Primary database configuration module 730, for configuring new backup database for the primary database, by the master data Data after splitting in library retain a part, and by a part of data sharing of reservation into new backup database.
Primary database configuration module 740 after upgrading, for configuring corresponding Backup Data for the primary database after upgrading Data after splitting in primary database after upgrading are retained another part, and another part data sharing of reservation are arrived by library In corresponding backup database.
The database upgrade device provided in the present embodiment, by first it is detected that in primary database or backup database Data capacity be more than capacity threshold, then by the data in the data and backup database in primary database according to identical mode It is split as two parts data;Backup database is upgraded into primary database, and it is synchronous with backup database to release primary database Relationship;New backup database is configured for primary database, the data after splitting in primary database is retained into a part, and will retain A part of data sharing into new backup database;Corresponding backup database is configured for the primary database after upgrading, it will Data after splitting in primary database after upgrading retain another part, and by another part data sharing of reservation to corresponding In backup database.As it can be seen that technical solution provided in this embodiment, solves and needs out of service or migration in the prior art The problem of data, realizes the smooth expansion of database on the basis of not influencing business experience.
Further, described device further include:
Virtual address configuration module, in the server where primary database and backup database configuration be different from the Second virtual address of one virtual address.
Further, the data fractionation module includes:
Split cells, for the data in the data and backup database in the primary database to be passed through major key modulus Mode carry out horizontal cutting, be split as two parts data;
Storage unit is stored in first virtual address for the data after splitting to be retained a part, after fractionation Data retain another part and be stored in second virtual address.
Further, described device further include: removing module, it is described second virtual in the primary database for deleting The data stored in address and second virtual address;Described first in primary database after deleting the upgrading is virtual The data stored in address and first virtual address.
Further, the relation broken module, specifically for the method by modification server configuration by the backup Database upgrade is primary database.
Specifically, primary database and backup database are set as double main synchronized relation type database frameworks.
Specifically, the algorithm based on 2 index times upgrades double main synchronized relation type database frameworks.
Data provided by any embodiment of the invention can be performed in database upgrade device provided by the embodiment of the present invention Library upgrade method has the corresponding functional module of execution method and beneficial effect.
Example IV
Fig. 8 is a kind of structural schematic diagram for equipment that the embodiment of the present invention four provides, as shown in figure 8, the equipment includes place Manage device 810 and memory 820;The quantity of processor 810 can be one or more in equipment, with a processor 810 in Fig. 8 For;Processor 810 in equipment can be connected with memory 820 by bus or other modes, to be connected by bus in Fig. 8 It is connected in example.
Memory 820 is used as a kind of computer readable storage medium, can be used for storing software program, journey can be performed in computer Sequence and module, if the corresponding program instruction/module of database upgrade method in the embodiment of the present invention is (for example, data qurush Data in stage arrangement split the master data after module 710, relation broken module 720, primary database configuration module 730 and upgrading Library configuration module 740).Software program, instruction and the module that processor 810 is stored in memory 820 by operation, thus The various function application and data processing for executing equipment, that is, realize above-mentioned database upgrade method.
Memory 820 can mainly include storing program area and storage data area, wherein storing program area can store operation system Application program needed for system, at least one function;Storage data area, which can be stored, uses created data etc. according to terminal.This Outside, memory 820 may include high-speed random access memory, can also include nonvolatile memory, for example, at least one Disk memory, flush memory device or other non-volatile solid state memory parts.In some, memory 820 can be wrapped further The memory remotely located relative to processor 810 is included, these remote memories can pass through network connection to equipment.Above-mentioned net Network includes but is not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
Embodiment five
The embodiment of the present invention five also provides a kind of storage medium comprising computer executable instructions, and the computer can be held Row instruction is used to execute a kind of database upgrade method when being executed by computer processor, this method comprises:
Detect that the data capacity in primary database or backup database is more than capacity threshold, then by the primary database In data and backup database in data two parts data are split as according to identical mode;
The backup database is upgraded into primary database, and releases the primary database after the primary database and upgrading Synchronized relation;
New backup database is configured for the primary database, and the data after splitting in the primary database are retained one Point, and by a part of data sharing of reservation into new backup database;
Corresponding backup database is configured for the primary database after upgrading, by the number after splitting in the primary database after upgrading According to reservation another part, and by another part data sharing of reservation into corresponding backup database.
Certainly, a kind of storage medium comprising computer executable instructions, computer provided by the embodiment of the present invention The method operation that executable instruction is not limited to the described above, can also be performed data qurush provided by any embodiment of the invention Relevant operation in grade method.
By the description above with respect to embodiment, it is apparent to those skilled in the art that, the present invention It can be realized by software and required common hardware, naturally it is also possible to which by hardware realization, but in many cases, the former is more Good embodiment.Based on this understanding, technical solution of the present invention substantially in other words contributes to the prior art Part can be embodied in the form of software products, which can store in computer readable storage medium In, floppy disk, read-only memory (Read-Only Memory, ROM), random access memory (Random such as computer Access Memory, RAM), flash memory (FLASH), hard disk or CD etc., including some instructions are with so that a computer is set Standby (can be personal computer, server or the network equipment etc.) executes method described in each embodiment of the present invention.
It is worth noting that, in the embodiment of above-mentioned database upgrade device, included each unit and module are It is divided according to the functional logic, but is not limited to the above division, as long as corresponding functions can be realized;Separately Outside, the specific name of each functional unit is also only for convenience of distinguishing each other, the protection scope being not intended to restrict the invention.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation, It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.

Claims (10)

1. a kind of database upgrade method characterized by comprising
Detect that the data capacity in primary database or backup database is more than capacity threshold, then it will be in the primary database Data in data and backup database are split as two parts data according to identical mode;
The backup database is upgraded into primary database, and it is synchronous with the primary database after upgrading to release the primary database Relationship;
New backup database is configured for the primary database, and the data after splitting in the primary database are retained into a part, And by a part of data sharing of reservation into new backup database;
Corresponding backup database is configured for the primary database after upgrading, the data after splitting in the primary database after upgrading are protected Another part is stayed, and by another part data sharing of reservation into corresponding backup database.
2. the method according to claim 1, wherein in the data and backup database by primary database In data be split as before two parts data according to identical mode, further includes:
Configuration is different from the second virtual address of the first virtual address in the server where primary database and backup database.
3. according to the method described in claim 2, it is characterized in that, in the data and backup database by primary database Data two parts data are split as according to identical mode, comprising:
Data in data and backup database in the primary database are subjected to horizontal cutting by way of major key modulus Point, it is split as two parts data;
Data after fractionation are retained into a part and are stored in first virtual address, the data after fractionation are retained into another part It is stored in second virtual address.
4. according to the method described in claim 3, it is characterized by further comprising: deleting described second in the primary database The data stored in virtual address and second virtual address;
It is stored in first virtual address and first virtual address in primary database after deleting the upgrading Data.
5. the method according to claim 1, wherein described upgrade to primary database for the backup database, Include:
The backup database is upgraded into primary database by the method for modification server configuration.
6. the method according to claim 1, wherein including: that primary database and backup database are set as double masters Synchronized relation type database framework.
7. according to the method described in claim 6, it is characterised by comprising: the algorithm based on 2 index times closes double main synchronizations It is that type database framework is upgraded.
8. a kind of database upgrade device characterized by comprising
Data split module, for detecting that the data capacity in primary database or backup database is more than capacity threshold, then Data in data and backup database in the primary database are split as two parts data according to identical mode;
Relation broken module for the backup database to be upgraded to primary database, and releases the primary database and upgrading The synchronized relation of primary database afterwards;
Primary database configuration module will be torn open for configuring new backup database for the primary database in the primary database Data after point retain a part, and by a part of data sharing of reservation into new backup database;
Primary database configuration module after upgrading will rise for configuring corresponding backup database for the primary database after upgrading Data after splitting in primary database after grade retain another part, and by another part data sharing of reservation to corresponding standby In part database.
9. a kind of equipment, which is characterized in that the equipment includes:
One or more processors;
Memory, for storing one or more programs,
When one or more of programs are executed by one or more of processors, so that one or more of processors are real The now database upgrade method as described in any in claim 1-7.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that program dress processed Set the database upgrade method realized as described in any in claim 1-7 when execution.
CN201811455586.5A 2018-11-30 2018-11-30 Database upgrade method, apparatus, equipment and storage medium Pending CN109271376A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811455586.5A CN109271376A (en) 2018-11-30 2018-11-30 Database upgrade method, apparatus, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811455586.5A CN109271376A (en) 2018-11-30 2018-11-30 Database upgrade method, apparatus, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN109271376A true CN109271376A (en) 2019-01-25

Family

ID=65186642

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811455586.5A Pending CN109271376A (en) 2018-11-30 2018-11-30 Database upgrade method, apparatus, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109271376A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110222030A (en) * 2019-05-13 2019-09-10 福建天泉教育科技有限公司 The method of Database Dynamic dilatation, storage medium
CN110221778A (en) * 2019-05-27 2019-09-10 携程计算机技术(上海)有限公司 Processing method, system, storage medium and the electronic equipment of hotel's data
CN112765617A (en) * 2020-12-23 2021-05-07 北京连山科技股份有限公司 Data remote cooperative protection method and system
CN113704270A (en) * 2021-09-03 2021-11-26 携程金融科技(上海)有限公司 Method, system, equipment and medium for expanding capacity of self-increment key of SQL Server database
CN115114260A (en) * 2021-08-24 2022-09-27 腾讯科技(深圳)有限公司 Data processing method and device, electronic equipment and storage medium
CN117931530A (en) * 2024-03-22 2024-04-26 山东昌禹知商信息技术服务有限公司 Database physical backup recovery processing method and system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102930062A (en) * 2012-11-30 2013-02-13 南京富士通南大软件技术有限公司 Rapid horizontal extending method for databases
US20140330785A1 (en) * 2012-03-29 2014-11-06 Hitachi Data Systems Corporation Highly available search index with storage node addition and removal
CN105069109A (en) * 2015-08-07 2015-11-18 北京思特奇信息技术股份有限公司 Dilatation method and system of distributed database
CN105930387A (en) * 2016-04-14 2016-09-07 北京思特奇信息技术股份有限公司 Data operation system and method based on data routing and sharding
CN108228848A (en) * 2018-01-10 2018-06-29 山东浪潮通软信息科技有限公司 A kind of expansible business datum divides library implementation method
CN108319596A (en) * 2017-01-16 2018-07-24 阿里巴巴集团控股有限公司 A kind of expansion method and device of database
CN108399262A (en) * 2018-03-14 2018-08-14 北京思特奇信息技术股份有限公司 A kind of data-base capacity-enlarging method and system

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140330785A1 (en) * 2012-03-29 2014-11-06 Hitachi Data Systems Corporation Highly available search index with storage node addition and removal
CN102930062A (en) * 2012-11-30 2013-02-13 南京富士通南大软件技术有限公司 Rapid horizontal extending method for databases
CN105069109A (en) * 2015-08-07 2015-11-18 北京思特奇信息技术股份有限公司 Dilatation method and system of distributed database
CN105930387A (en) * 2016-04-14 2016-09-07 北京思特奇信息技术股份有限公司 Data operation system and method based on data routing and sharding
CN108319596A (en) * 2017-01-16 2018-07-24 阿里巴巴集团控股有限公司 A kind of expansion method and device of database
CN108228848A (en) * 2018-01-10 2018-06-29 山东浪潮通软信息科技有限公司 A kind of expansible business datum divides library implementation method
CN108399262A (en) * 2018-03-14 2018-08-14 北京思特奇信息技术股份有限公司 A kind of data-base capacity-enlarging method and system

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110222030A (en) * 2019-05-13 2019-09-10 福建天泉教育科技有限公司 The method of Database Dynamic dilatation, storage medium
CN110222030B (en) * 2019-05-13 2021-08-06 福建天泉教育科技有限公司 Dynamic database capacity expansion method and storage medium
CN110221778A (en) * 2019-05-27 2019-09-10 携程计算机技术(上海)有限公司 Processing method, system, storage medium and the electronic equipment of hotel's data
CN112765617A (en) * 2020-12-23 2021-05-07 北京连山科技股份有限公司 Data remote cooperative protection method and system
CN115114260A (en) * 2021-08-24 2022-09-27 腾讯科技(深圳)有限公司 Data processing method and device, electronic equipment and storage medium
CN113704270A (en) * 2021-09-03 2021-11-26 携程金融科技(上海)有限公司 Method, system, equipment and medium for expanding capacity of self-increment key of SQL Server database
CN113704270B (en) * 2021-09-03 2023-10-17 携程金融科技(上海)有限公司 Automajor key capacity expansion method of SQL Server database and related equipment
CN117931530A (en) * 2024-03-22 2024-04-26 山东昌禹知商信息技术服务有限公司 Database physical backup recovery processing method and system
CN117931530B (en) * 2024-03-22 2024-06-07 山东昌禹知商信息技术服务有限公司 Database physical backup recovery processing method and system

Similar Documents

Publication Publication Date Title
CN109271376A (en) Database upgrade method, apparatus, equipment and storage medium
CN103354923B (en) A kind of data re-establishing method, device and system
JP2019101703A (en) Storage system and control software arrangement method
US10157214B1 (en) Process for data migration between document stores
US20130218934A1 (en) Method for directory entries split and merge in distributed file system
CN108509462B (en) Method and device for synchronizing activity transaction table
US20120192207A1 (en) Pipeline Across Isolated Computing Environments
CN112764968B (en) Data processing method, device, equipment and storage medium
US9009273B2 (en) Address server
US9854037B2 (en) Identifying workload and sizing of buffers for the purpose of volume replication
CN107391033B (en) Data migration method and device, computing equipment and computer storage medium
US11199972B2 (en) Information processing system and volume allocation method
JP4693540B2 (en) Database reconfiguration device and database reconfiguration program
CN108319596A (en) A kind of expansion method and device of database
US7849264B2 (en) Storage area management method for a storage system
CN105357042A (en) High-availability cluster system, master node and slave node
CN113010496A (en) Data migration method, device, equipment and storage medium
CN104054076A (en) Data storage method, database storage node failure processing method and apparatus
CN104517067A (en) Method, device and system for data access
CN105760391A (en) Data dynamic redistribution method and system, data node and name node
CN107943615B (en) Data processing method and system based on distributed cluster
CN111078119A (en) Data reconstruction method, system, device and computer readable storage medium
US20150212847A1 (en) Apparatus and method for managing cache of virtual machine image file
CN110858168A (en) Cluster node fault processing method and device and cluster node
CN111400273B (en) Database capacity expansion method and device, electronic equipment and machine-readable storage medium

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190125

RJ01 Rejection of invention patent application after publication