Description of the embodiments
In order for those skilled in the art to better understand the technical solutions in the embodiments of the present specification, the technical solutions in the embodiments of the present specification will be described in detail below with reference to the drawings in the embodiments of the present specification, and it is apparent that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification shall fall within the scope of protection.
First, the backup method of the asset data provided in the embodiments of the present disclosure is based on a primary backup mechanism, that is, backup the asset data in the primary database to the backup database, so as to ensure availability and reliability of the asset data. It should be noted that, the backup method adopts an asynchronous backup mode, that is, the asset data in the main database is changed, that is, after the marketing service is successfully processed, the changed asset data is backed up to the backup database. By the processing, the problem that when the main database and the standby database are in different places, the marketing business is successfully processed after the asset data in the main database are synchronously backed up to the standby database, and the development of each marketing business is seriously time-consuming can be avoided.
Referring to fig. 1, a schematic diagram of a database system according to an exemplary embodiment of the present disclosure is shown, in which fig. 1 includes a city a and a city B, where city a has an a machine room and B machine room, city B has a c machine room, taking a main database 110 in the a machine room as an example, the main database 110 has a corresponding standby database 111 in a different machine room in the same city, for example, B machine room, and also has a corresponding standby database 112 in a different machine room, for example, c machine room.
Based on the database system illustrated in fig. 1, the asset data in the primary database 110 may be backed up to the backup database 111 and the backup database 112, respectively, by applying the backup method for asset data provided in the embodiments of the present disclosure.
The following embodiments are shown to explain in detail the backup method of asset data:
referring to fig. 2, a flowchart of an embodiment of a method for backing up asset data according to an exemplary embodiment of the present disclosure is provided, the method includes the following steps:
step 202: after the asset data in the main database is changed, judging whether the condition of backing up the changed asset data to the standby database is satisfied.
Step 204: if yes, multiplying the changed asset data by a preset first proportion value, and then writing the first proportion value into a standby database, wherein the first proportion value is a decimal less than 1.
The following describes steps 202 and 204 in detail:
taking the asset data as the budget remaining amount as an example, the deduction operation can be performed on the budget remaining amount every time the marketing business is successfully carried out, namely, every time the marketing business is successfully carried out, the asset data in the main database is changed.
In the embodiment of the present disclosure, after the asset data in the main database is changed, the database system does not directly backup the changed asset data to the backup database, but first determines whether a condition for backup of the changed asset data to the backup database is satisfied, and if the condition is satisfied, multiplies the changed asset data by a preset first proportion value, and then writes the first proportion value into the backup database, where the first proportion value is a fraction smaller than 1. For convenience of description, the asset data written to the backup database will be referred to herein as backup asset data.
In an embodiment, the condition for backing up the changed asset data to the backup database may be: the changed asset data does not exceed a current change threshold, wherein the current change threshold may be determined by: dividing the backup asset data in the backup database by a preset second proportion value, wherein the second proportion value is a fraction smaller than 1 and larger than the first proportion value.
For example, assuming backup asset data in backup database 111 and backup database 112 is 80 and assuming the second scale value is 0.8 and the first scale value is 0.6, then the current change threshold is 100 as described above; assuming that the asset data in the main database 110 is changed to 99 after one deduction operation, the condition for backing up the changed asset data to the backup database is satisfied as described above, and at this time, the asset data 99 may be multiplied by 0.6 and then backed up to the backup database 111 and the backup database 112, respectively, and at this time, the backup asset data in each of the backup database 111 and the backup database 112 is 59 (99×0.6×59).
Continuing to assume that the asset data in the main database 110 is changed to 97, and at this time, the current change threshold is 74 (59/0.8≡74), and if the condition for backing up the changed asset data to the backup database is not satisfied as described above, the changed asset data 97 may not be backed up to the backup database 111 and the backup database 112, and then, until the asset data in the main database 110 is changed to 74 or below, the data backup may be performed.
As can be seen from the above description, in the embodiment of the present specification, instead of once changing the asset data in the main database, a data backup is performed, so that network resources can be saved; in addition, because the asset data in the main database is backed up to the standby database according to a certain proportion value, the service processing based on the asset data in the standby database can be effectively ensured when the main database is down, and the phenomenon of excess processing, such as exceeding the residual budget, can not occur.
In addition, in the embodiment of the present specification, in order to implement the above steps 202 and 204, a backup attribute bit may be set for the asset data in the primary database, and a specific value on the backup attribute bit represents the backup asset data in the backup database, and for convenience of description, the specific value is referred to as a backup attribute value. In view of this, in the embodiment of the present specification, after the changed asset data is multiplied by the preset first proportion value and then written into the backup database, the backup attribute value of the asset data may be updated in the primary database.
For example, in the above description, after the asset data 59 is backed up to the backup database 111 and the backup database 112, the backup attribute value of the asset data in the primary database 110 may be updated to 59.
Through the processing, after the asset data in the main database is changed next time, the backup asset data in the backup database can be directly obtained to judge whether the condition of backing up the changed asset data to the backup database is met.
In addition, in this embodiment of the present disclosure, a backup status bit may also be set for the asset data in the primary database, where a value on the backup status bit may be used to record whether the asset data is successfully backed up to the backup database, for example, if the value on the backup status bit is failover-asyn-success, it indicates that the asset data is successfully backed up to the backup database, and if the value on the backup status bit is failover-asyn-null, it indicates that the asset data is not backed up to the backup database.
Correspondingly, a backup status bit may also be set for the backup asset data in the backup database, and similarly, a value on the backup status bit may be used to record whether the asset data in the primary database is successfully backed up to the backup database, for convenience of description, a value on the backup status bit is referred to as a backup status value, for example, after the changed asset data is multiplied by a preset first proportion value and written into the backup database, the backup status value of the backup asset data is updated in the backup database to a first preset value for representing synchronization of the primary and the backup, for example, a failure-asyn-success.
Subsequently, a specific process of implementing failover based on the backup method is described:
in this embodiment of the present disclosure, after the main database is down, the traffic request flow is first drained to the backup database by modifying the drainage path, and at this time, each service request is completed based on the backup asset data in the backup database, for example, each time a service request is completed, the backup asset data in the backup database is subtracted, and specific information of each service request is recorded.
Specifically, if the backup status value of the backup asset data in the backup database is the first preset value, the backup status value of the backup asset data indicates that the backup asset data is available, and at this time, the backup status value of the backup asset data may be changed from the first preset value to a second preset value for indicating that the backup asset data has been called after the service request is processed based on the backup asset data, by which the backup asset data in the backup database may be indicated to have been changed.
By the above processing, after the main database resumes normal use, the asset data in the main database is modified based on the backup asset data with the backup status value being the second preset value, that is, the data migration of the main database is realized based on the backup asset data which is called during the downtime of the main database.
In addition, since after the main database resumes normal use, that is, by modifying the drainage path, the service request flow is redirected back to the main database, a certain time is required to achieve data migration of the main database, in this period, in order to avoid excessive processing, the backup status value of the asset data in the main database may be changed to a third preset value, so as to indicate that the asset data is in a migration status, where in the migration status, the asset data is not allowed to be lower than the corresponding backup asset data.
For example, assuming that the asset data in the main database is 90, the backup attribute value thereof is 60, then the main database is down, the backup asset data in the backup database is called, and then the main database resumes normal use, but the specific information that the backup asset data is deducted during the down period of the main database cannot be known yet, so that if the asset data in the main database is deducted, the asset data is not allowed to be deducted to 60 or less until the data migration is completed.
According to the technical scheme provided by the embodiment of the specification, after the asset data in the main database is changed, whether the condition of backing up the changed asset data to the standby database is met is judged, if yes, the changed asset data is multiplied by the preset first proportion value and then written into the standby database, the first proportion value is a fraction smaller than 1, the purposes of effectively ensuring the usability of the main database and the standby database and avoiding the problem of excessive processing of the asset data can be achieved, and meanwhile, the problem that service processing is seriously time-consuming when the main database and the standby database are located in different places can be effectively avoided.
Corresponding to the above method embodiments, the present disclosure further provides a backup device for asset data, referring to fig. 3, which is a block diagram of an embodiment of the backup device for asset data provided in an exemplary embodiment of the present disclosure, where the device may include: a judging module 31 and a backup module 32.
The judging module 31 is configured to judge whether a condition of backing up the changed asset data to the backup database is satisfied after the asset data in the primary database is changed;
and the backup module 32 is configured to, if the condition for backing up the changed asset data to the backup database is satisfied, multiply the changed asset data by a preset first proportion value, and then write the first proportion value into the backup database, where the first proportion value is a fraction smaller than 1.
In an embodiment, the meeting the condition of backing up the changed asset data to the backup database includes:
the changed asset data does not exceed the current change threshold;
the device further comprises (not shown in fig. 3):
and the threshold determining module is used for dividing the backup asset data in the backup database by a preset second proportion value, wherein the second proportion value is a decimal less than 1 and greater than the first proportion value.
The apparatus further comprises: and the attribute bit updating module is used for updating the backup attribute value of the asset data in the main database into the current backup asset data in the backup database.
In an embodiment, the apparatus further comprises (not shown in fig. 3):
and the first status bit updating module is used for updating the backup status value of the backup asset data in the backup database to a first preset value, and the first preset value is used for representing primary and backup synchronization.
In an embodiment, the apparatus further comprises (not shown in fig. 3):
and the second status bit updating module is used for changing the backup status value of the backup asset data in the backup database from the first preset value to a second preset value if the backup asset data in the backup database is called during the failure period of the main database, wherein the second preset value is used for indicating that the backup asset data is called.
And the data returning module is used for modifying the asset data in the main database according to the backup asset data with the backup state value of the second preset value in the backup database after the main database is recovered to be normally used.
In an embodiment, the apparatus further comprises (not shown in fig. 3):
and the third status bit updating module is used for changing the backup status value of the asset data in the main database into a third preset value, wherein the third preset value is used for indicating that the asset data in the main database is in a state of returning, and the state of returning indicates that the asset data in the main database is not allowed to be lower than the backup asset data in the backup database.
It should be understood that, as two modules with independent functions, the judging module 31 and the backup module 32 may be configured in the device at the same time as shown in fig. 3, or may be configured in the device separately from each other, so the configuration shown in fig. 3 should not be construed as limiting the embodiment of the present disclosure.
In addition, the implementation process of the functions and roles of each module in the above device is specifically shown in the implementation process of the corresponding steps in the above method, and will not be described herein again.
The embodiment of the specification also provides a business server, which at least comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the method for backing up the assets. The method at least comprises the following steps: after the asset data in the main database is changed, judging whether the condition of backing up the changed asset data to the standby database is met; and if so, multiplying the changed asset data by a preset first proportion value, and then writing the first proportion value into the standby database, wherein the first proportion value is a decimal less than 1.
Fig. 4 is a schematic diagram of a more specific service server hardware structure according to an embodiment of the present disclosure, where the apparatus may include: processor 10, memory 420, input/output interface 430, communication interface 440, and bus 450. Wherein processor 410, memory 420, input/output interface 430, and communication interface 440 enable communication connections within the device between each other via bus 450.
The processor 410 may be implemented by a general-purpose CPU (Central Processing Unit ), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc. for executing relevant programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 420 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage device, dynamic storage device, or the like. Memory 420 may store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present specification are implemented in software or firmware, the relevant program codes are stored in memory 420 and invoked for execution by processor 410.
The input/output interface 430 is used to connect with an input/output module to realize information input and output. The input/output module may be configured as a component in a device (not shown) or may be external to the device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
The communication interface 440 is used to connect communication modules (not shown) to enable communication interactions of the device with other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 450 includes a path to transfer information between components of the device (e.g., processor 410, memory 420, input/output interface 430, and communication interface 440).
It should be noted that although the above device only shows the processor 410, the memory 420, the input/output interface 430, the communication interface 440, and the bus 450, in the implementation, the device may further include other components necessary to achieve normal operation. Furthermore, it will be understood by those skilled in the art that the above-described apparatus may include only the components necessary to implement the embodiments of the present description, and not all the components shown in the drawings.
The embodiments of the present specification also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the foregoing method of backing up asset data. The method at least comprises the following steps: after the asset data in the main database is changed, judging whether the condition of backing up the changed asset data to the standby database is met; and if so, multiplying the changed asset data by a preset first proportion value, and then writing the first proportion value into the standby database, wherein the first proportion value is a decimal less than 1.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
From the foregoing description of embodiments, it will be apparent to those skilled in the art that the present embodiments may be implemented in software plus a necessary general purpose hardware platform. Based on such understanding, the technical solutions of the embodiments of the present specification may be embodied in essence or what contributes to the prior art in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the embodiments or some parts of the embodiments of the present specification.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points. The apparatus embodiments described above are merely illustrative, in which the modules illustrated as separate components may or may not be physically separate, and the functions of the modules may be implemented in the same piece or pieces of software and/or hardware when implementing the embodiments of the present disclosure. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The foregoing is merely a specific implementation of the embodiments of this disclosure, and it should be noted that, for a person skilled in the art, several improvements and modifications may be made without departing from the principles of the embodiments of this disclosure, and these improvements and modifications should also be considered as protective scope of the embodiments of this disclosure.