Database backup method and device, equipment, storage medium and program product
By automatically selecting slave database instances whose delay time is less than the threshold for MySQL database backup, it solves the problems of complexity and low efficiency of existing backup methods, improves backup efficiency, and saves resources.
Patent Information
- Application Number
- CN202410679505.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-08-30
AI Technical Summary
Existing MySQL backup methods are complicated and inefficient. Especially when the slave node is upgraded to the master node when the master node fails, the backup management is complicated, and the binlog setting is too large, which results in repeated uploading of some file contents and a waste of resources.
By obtaining database cluster information, it automatically selects slave instances with delay times less than the threshold based on preset policies and instance configuration information for full backup and binary log file backup, reducing data copies and saving network and computing resources.
It improves the efficiency of database backup, simplifies backup management, reduces resource waste, and realizes automatic selection of slave nodes for backup.
Smart Images

Figure CN118567909A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of database technology, specifically to the field of data backup technology, and more specifically to a database backup method, device, equipment, storage medium and program product. Background Art
[0002] Existing MySQL backups usually use full backups and binlog backups to meet data recovery needs at any point in time. These backups are usually single-machine backups, and each MySQL cluster is often deployed in a one-master-multiple-slave mode. In fact, only one slave node needs to be selected for backup. Sometimes when the master node fails, a slave node will be upgraded to the master node, which makes management more complicated. In addition, binlog is usually set to a large size, which makes it easy to upload some file contents repeatedly.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a database backup method, apparatus, device, storage medium and program product for improving backup efficiency and reducing computing resources.
[0005] According to a first aspect of the present disclosure, a database backup method is provided, the method comprising:
[0006] In response to a database backup instruction, obtaining database cluster information, the database cluster information including a database instance and the database instance configuration information;
[0007] Determine the target database slave instance according to the preset strategy and the database instance configuration information; and
[0008] Perform full backup and binary log file backup based on the instance configuration information of the target database slave library.
[0009] According to an embodiment of the present disclosure, determining the target database slave instance according to the preset strategy and the database instance configuration information includes:
[0010] Determine the database slave instance of the database instance according to the field status identifier; and
[0011] A target database slave instance is determined according to the database slave instance and the database instance configuration information.
[0012] According to an embodiment of the present disclosure, determining a target database slave instance according to the database slave instance and the database instance configuration information includes:
[0013] Determining the delay time between the database slave instance and the master database; and
[0014] Determine the database slave instance whose delay time is less than a preset threshold as the target database slave instance.
[0015] According to an embodiment of the present disclosure, performing full backup and binary log file backup according to instance configuration information of the target database slave library includes:
[0016] Log in to the database and perform a full backup from the database; and
[0017] Perform binary log file backup according to the instance configuration information of the target database slave library.
[0018] According to an embodiment of the present disclosure, performing binary log file backup according to instance configuration information of the target database slave library includes:
[0019] Determine the binary log file and storage location according to the instance configuration information of the target database slave library;
[0020] Log in to the host where the target database slave instance is located to obtain the latest modification time of each binary log file;
[0021] Determine the target binary log file according to the last backup time of the binary log file and the latest modification time; and
[0022] Back up the target binary log file.
[0023] According to an embodiment of the present disclosure, backing up the target binary log file includes:
[0024] Determine the backup location of the previous backup of the target binary log file;
[0025] Starting to back up the target binary log file from the backup location; and
[0026] Back up the merged binary log files to the storage location.
[0027] A second aspect of the present disclosure provides a database backup device, the device comprising:
[0028] An acquisition module, configured to acquire database cluster information in response to a database backup instruction, wherein the database cluster information includes a database instance and configuration information of the database instance;
[0029] A determination module, used to determine a target database slave instance according to a preset strategy and the database instance configuration information; and
[0030] The backup module is used to perform full backup and binary log file backup according to the instance configuration information of the target database slave library.
[0031] According to an embodiment of the present disclosure, the determination module includes: a first determination submodule and a second determination submodule.
[0032] A first determination submodule is used to determine a database slave instance of the database instance according to a field status identifier; and
[0033] The second determination submodule is used to determine the target database slave database instance according to the database slave database instance and the database instance configuration information.
[0034] According to an embodiment of the present disclosure, the second determining submodule includes a first determining unit and a second determining unit.
[0035] A first determining unit is used to determine the delay time between the database slave instance and the master database; and
[0036] The second determining unit is used to determine the database slave instance whose delay time is less than a preset threshold as the target database slave instance.
[0037] According to an embodiment of the present disclosure, the backup module includes: a first backup submodule and a second backup submodule.
[0038] The first backup submodule is used to log in to the database and perform full backup from the database; and
[0039] The second backup submodule is used to perform binary log file backup according to the instance configuration information of the target database slave library.
[0040] According to an embodiment of the present disclosure, the second backup submodule includes a third determining unit, an acquiring unit, a fourth determining unit and a backup unit.
[0041] A third determining unit, configured to determine a binary log file and a storage location according to the instance configuration information of the target database slave library;
[0042] An acquisition unit, used for logging into the host where the slave instance of the target database is located to obtain the latest modification time of each binary log file;
[0043] A fourth determining unit is used to determine a target binary log file according to the last backup time of the binary log file and the latest modification time; and
[0044] The backup unit is used to back up the target binary log file.
[0045] According to an embodiment of the present disclosure, the backup unit is specifically used to determine the backup location of the previous backup of the target binary log file; start backing up the target binary log file from the backup location; and back up the merged binary log file to the storage location.
[0046] A third aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned database backup method.
[0047] A fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned database backup method.
[0048] The fifth aspect of the present disclosure also provides a computer program product, including a computer program, which implements the above-mentioned database backup method when executed by a processor.
[0049] A database backup method provided by an embodiment of the present disclosure responds to a database backup instruction, obtains database cluster information, the database cluster information includes a database instance and the database instance configuration information; determines the target database slave instance according to a preset strategy and the database instance configuration information; and performs a full backup and a binary log file backup according to the instance configuration information of the target database slave. Compared with related technologies, the embodiment of the present disclosure automatically selects the slave node of the cluster during backup, reduces data copying when backing up binary log file data, saves network, computing and other resources of the application server, and improves data backup efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0051] Figure 1 The application scenario diagram of the database backup method, apparatus, device, storage medium and program product according to the embodiments of the present disclosure is schematically shown;
[0052] Figure 2 A flowchart of a database backup method provided according to an embodiment of the present disclosure is schematically shown;
[0053] Figure 3 One of the flowcharts of a method for determining a target database slave database instance according to an embodiment of the present disclosure is schematically shown;
[0054] Figure 4The second flowchart of the method for determining a target database slave database instance according to an embodiment of the present disclosure is schematically shown;
[0055] Figure 5 A flowchart of a database backup method provided according to another embodiment of the present disclosure is schematically shown;
[0056] Figure 6 A flowchart of a database backup method provided according to another embodiment of the present disclosure is schematically shown;
[0057] Figure 7 A flowchart of backing up the target binary log file provided according to another embodiment of the present disclosure is schematically shown;
[0058] Figure 8 A structural block diagram of a database backup device according to an embodiment of the present disclosure is schematically shown; and
[0059] Fig. 9 A block diagram of an electronic device suitable for implementing a database backup method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0060] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0061] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0062] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.
[0063] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0064] Based on the above technical problems, an embodiment of the present disclosure provides a database backup method, which includes: in response to a database backup instruction, obtaining database cluster information, the database cluster information including a database instance and the database instance configuration information; determining a target database slave library instance according to a preset strategy and the database instance configuration information; and performing a full backup and a binary log file backup according to the instance configuration information of the target database slave library.
[0065] Figure 1 The application scenario diagram of the database backup method, apparatus, device, storage medium and program product according to the embodiments of the present disclosure is schematically shown.
[0066] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a database backup scenario. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0067] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0068] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0069] Server 105 may be a back-end server, which may execute the database backup method provided by the embodiment of the present disclosure, and in response to a database backup instruction, obtain database cluster information, wherein the database cluster information includes a database instance and the database instance configuration information; determine a target database slave instance according to a preset strategy and the database instance configuration information; and perform a full backup and a binary log file backup according to the instance configuration information of the target database slave.
[0070] It should be noted that the database backup method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the database backup device provided in the embodiment of the present disclosure can generally be set in the server 105. The database backup method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the database backup device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0071] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0072] It should be noted that the database backup method and device determined in the embodiments of the present disclosure can be used in the field of Internet technology, the field of financial technology, and any field other than the financial field. The application field of the database backup method and device determined in the embodiments of the present disclosure is not limited.
[0073] The following will be based on Figure 1 The application scenario described by Figure 2~Figure 6 The database backup method according to the embodiment of the present disclosure is described in detail.
[0074] Figure 2 The flowchart of a database backup method provided according to an embodiment of the present disclosure is schematically shown. Figure 2 As shown, the database backup method of this embodiment includes operations S210 to S230, and the method can be executed by a server or other computing devices.
[0075] In operation S210 , in response to a database backup instruction, database cluster information is acquired, where the database cluster information includes a database instance and configuration information of the database instance.
[0076] In one example, when a database master node fails and needs to be repaired, the database needs to be backed up and restored, and a slave node is selected for backup. After receiving the database backup instruction, the MySQL database cluster information is obtained from the configuration management system. The database cluster information includes the database instances in the cluster and the database instance configuration information corresponding to each database instance.
[0077] In operation S220, a target database slave instance is determined according to a preset strategy and the database instance configuration information.
[0078] In operation S230, a full backup and a binary log file backup are performed according to the instance configuration information of the target database slave library.
[0079] In one example, a database slave instance is automatically selected from multiple database instances as the target database slave instance according to a preset strategy. For the specific process, see operations S310 and S320. After determining the target database slave, perform a full backup and binlog backup according to the instance configuration information of the target database slave. The backup process can be seen in operations S410 and S420, which will not be repeated here.
[0080] A database backup method provided by an embodiment of the present disclosure responds to a database backup instruction, obtains database cluster information, the database cluster information includes a database instance and the database instance configuration information; determines the target database slave instance according to a preset strategy and the database instance configuration information; and performs a full backup and a binary log file backup according to the instance configuration information of the target database slave. Compared with related technologies, the embodiment of the present disclosure automatically selects the slave node of the cluster during backup, reduces data copying when backing up binary log file data, saves network, computing and other resources of the application server, and improves data backup efficiency.
[0081] Figure 3~Figure 4 This is a process for automatically determining a target database slave instance in an embodiment of the present disclosure. Figure 3 One of the flowcharts of a method for determining a target database from a library instance provided according to an embodiment of the present disclosure is schematically shown. Figure 4 The second flowchart of the method for determining a target database slave database instance provided according to an embodiment of the present disclosure is schematically shown.
[0082] like Figure 3 As shown, operation S310 and operation S320 are included.
[0083] In operation S310, a database slave instance of the database instance is determined according to the field status identifier.
[0084] In operation S320, a target database slave instance is determined according to the database slave instance and the database instance configuration information.
[0085] like Figure 4 As shown, operation S320 includes operation S321 and operation S322.
[0086] In operation S321, the delay time between the database slave instance and the master database is determined.
[0087] In operation S322, it is determined that the database slave instance whose delay time is less than a preset threshold is the target database slave instance.
[0088] In an example, log in to the obtained MySQL database instance, use the "SHOW VARIABLES" statement to obtain the instance configuration information, and determine the database slave instance of the database instance according to the field status identifier. Specifically, obtain the parameter of the read-only field, which indicates whether the status of the current database is read-only. If it is determined to be read-only, the database is determined to be a slave.
[0089] In one example, the delay time between the database slave instance and the master database is determined by using a query statement. Specifically, the delay between the slave and the master is obtained through "Seconds_Behind_Master" or "Seconds_Behind_Source" by using the "SHOW SLAVE STATUS" or "SHOW REPLICA STATUS" statement. If the delay time of the library exceeds the preset threshold, it indicates that the delay time between the current slave and the master database is too long, which may cause too much unsynchronized data. Therefore, the database slave instance whose delay time is less than the preset threshold is determined as the target database slave instance. The target database slave instance data is fully backed up as the data source to be backed up.
[0090] Figure 5~Figure 7 The data backup process provided for the embodiment of the present disclosure includes full backup and binary log file backup, namely binlog backup. Figure 5 A flowchart of a database backup method provided according to another embodiment of the present disclosure is schematically shown. Figure 5 As shown, operation S410 and operation S420 are included.
[0091] In operation S410, the database is logged in to perform a full backup from the database.
[0092] In operation S420, binary log files are backed up according to the instance configuration information of the target database slave library.
[0093] Figure 6 A flowchart of a database backup method provided according to another embodiment of the present disclosure is schematically shown. Figure 6 As shown, operation S420 includes operation S421 to operation S424.
[0094] In operation S421, a binary log file and a storage location are determined according to the instance configuration information of the target database slave library.
[0095] In one example, when backing up binlog, query the "log_bin_index" and "log_bin_basename" fields in the instance configuration information to obtain the binlog position. Use the "SHOW MASTER STATUS" statement to obtain the binlog file and position currently being written.
[0096] In operation S422, log in to the host where the target database slave instance is located to obtain the latest modification time of each binary log file.
[0097] In operation S423, a target binary log file is determined according to the last backup time of the binary log file and the latest modification time.
[0098] In one example, log in to the host where the target database slave instance is located, read the last modification time of each binlog file obtained in operation S421, and select the binlog file whose last modification time is after the start time of the previous binlog backup according to the previous binlog backup time.
[0099] In operation S424, the target binary log file is backed up.
[0100] Figure 7 A flowchart of backing up the target binary log file provided according to another embodiment of the present disclosure is schematically shown.
[0101] like Figure 7 As shown, operation S424 includes operation S4241 to operation S4243.
[0102] In operation S4241, a backup location of a previous backup of the target binary log file is determined.
[0103] In operation S4242, backing up the target binary log file starts from the backup location.
[0104] In operation S4243, the merged binary log file is backed up to the storage location.
[0105] In one example, in order to reduce data copying when performing binlog backup and save network, computing and other resources of the application server. When backing up binlog, read the file and position of the last binlog event backed up by the previous binlog backup, start backing up the binlog file from the specified position of the file, and merge it into the binlog file backed up last time. When backing up to the binlog file obtained in operation S421, back up to the file position obtained in operation S421. Record the backup file name and position.
[0106] Based on the above database backup method, the present disclosure also provides a database backup device. Figure 8 The device is described in detail.
[0107] Figure 8 The structure block diagram of a database backup device according to an embodiment of the present disclosure is schematically shown. Figure 8 As shown, the database backup device 700 of this embodiment includes an acquisition module 710 , a determination module 720 and a backup module 730 .
[0108] The acquisition module 710 is used to respond to the database backup instruction and acquire database cluster information, wherein the database cluster information includes a database instance and the database instance configuration information. In one embodiment, the acquisition module 710 can be used to perform the operation S210 described above, which will not be described in detail here.
[0109] The determination module 720 is used to determine the target database slave instance according to the preset strategy and the database instance configuration information. In one embodiment, the determination module 720 can be used to perform the operation S220 described above, which will not be repeated here.
[0110] The backup module 730 is used to perform full backup and binary log file backup according to the instance configuration information of the target database slave library. In one embodiment, the backup module 730 can be used to perform the operation S230 described above, which will not be repeated here.
[0111] According to an embodiment of the present disclosure, the determination module includes: a first determination submodule and a second determination submodule.
[0112] The first determination submodule is used to determine the database slave instance of the database instance according to the field status identifier; in one embodiment, the first determination submodule can be used to perform the operation S310 described above, which will not be repeated here.
[0113] The second determination submodule is used to determine the target database slave instance according to the database slave instance and the database instance configuration information. In one embodiment, the second determination submodule can be used to perform the operation S320 described above, which will not be described in detail here.
[0114] According to an embodiment of the present disclosure, the second determining submodule includes a first determining unit and a second determining unit.
[0115] The first determining unit is used to determine the delay time between the database slave instance and the master database; in one embodiment, the first determining unit can be used to perform the operation S321 described above, which will not be repeated here.
[0116] The second determining unit is used to determine the database slave instance whose delay time is less than a preset threshold as the target database slave instance. In one embodiment, the second determining unit can be used to perform the operation S322 described above, which will not be described in detail here.
[0117] According to an embodiment of the present disclosure, the backup module includes: a first backup submodule and a second backup submodule.
[0118] The first backup submodule is used to log in to the database and perform a full backup from the database; in one embodiment, the first backup submodule can be used to perform the operation S410 described above, which will not be repeated here.
[0119] The second backup submodule is used to perform binary log file backup according to the instance configuration information of the target database slave library. In one embodiment, the second backup submodule can be used to perform the operation S420 described above, which will not be described in detail here.
[0120] According to an embodiment of the present disclosure, the second backup submodule includes a third determining unit, an acquiring unit, a fourth determining unit and a backup unit.
[0121] The third determining unit is used to determine the binary log file and storage location according to the instance configuration information of the target database slave library; in one embodiment, the third determining unit can be used to perform the operation S421 described above, which will not be repeated here.
[0122] The acquisition unit is used to log in to the host where the target database slave library instance is located to obtain the latest modification time of each of the binary log files; in one embodiment, the acquisition unit can be used to perform the operation S422 described above, which will not be repeated here.
[0123] The fourth determining unit is used to determine the target binary log file according to the last backup time of the binary log file and the latest modification time. In one embodiment, the fourth determining unit can be used to perform the operation S423 described above, which will not be repeated here.
[0124] The backup unit is used to back up the target binary log file. In one embodiment, the backup unit can be used to perform the operation S424 described above, which will not be described in detail here.
[0125] According to an embodiment of the present disclosure, the backup unit is specifically used to determine the backup location of the previous backup of the target binary log file; start backing up the target binary log file from the backup location; and back up the merged binary log file to the storage location.
[0126] According to an embodiment of the present disclosure, any multiple modules among the acquisition module 710, the determination module 720 and the backup module 730 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 710, the determination module 720 and the backup module 730 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the acquisition module 710, the determination module 720 and the backup module 730 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0127] Fig. 9 A block diagram of an electronic device suitable for implementing a database backup method according to an embodiment of the present disclosure is schematically shown.
[0128] like Fig. 9 As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 to a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0129] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0130] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. The drive 909 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 909 as needed, so that the computer program read therefrom is installed into the storage portion 908 as needed.
[0131] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the database backup method according to the embodiment of the present disclosure is implemented.
[0132] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0133] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the database backup method provided by the embodiment of the present disclosure.
[0134] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 901. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0135] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0136] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0137] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0138] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0139] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0140] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A database backup method, characterized in that: The method comprises: In response to a database backup instruction, obtaining database cluster information, the database cluster information including a database instance and the database instance configuration information; Determine the target database slave instance according to the preset strategy and the database instance configuration information; and Perform full backup and binary log file backup based on the instance configuration information of the target database slave library.
2. The method according to claim 1, characterized in that Determining the target database slave instance according to the preset strategy and the database instance configuration information includes: Determine the database slave instance of the database instance according to the field status identifier; and A target database slave instance is determined according to the database slave instance and the database instance configuration information.
3. The method according to claim 2, characterized in that Determining the target database slave instance according to the database slave instance and the database instance configuration information includes: Determining the delay time between the database slave instance and the master database; and Determine the database slave instance whose delay time is less than a preset threshold as the target database slave instance.
4. The method according to claim 1, characterized in that: The full backup and binary log file backup according to the instance configuration information of the target database slave library includes: Log in to the database and perform a full backup from the database; and Perform binary log file backup according to the instance configuration information of the target database slave library.
5. The method according to claim 4, characterized in that The backing up of binary log files according to the instance configuration information of the target database slave library includes: Determine the binary log file and storage location according to the instance configuration information of the target database slave library; Log in to the host where the target database slave instance is located to obtain the latest modification time of each binary log file; Determine the target binary log file according to the last backup time of the binary log file and the latest modification time; and Back up the target binary log file.
6. The method according to claim 5, characterized in that The backing up of the target binary log file includes: Determine the backup location of the previous backup of the target binary log file; Starting to back up the target binary log file from the backup location; and Back up the merged binary log files to the storage location.
7. A database backup device, characterized in that: The device comprises: An acquisition module, configured to acquire database cluster information in response to a database backup instruction, wherein the database cluster information includes a database instance and configuration information of the database instance; A determination module, used to determine a target database slave instance according to a preset strategy and the database instance configuration information; and The backup module is used to perform full backup and binary log file backup according to the instance configuration information of the target database slave library.
8. An electronic device, comprising: one or more processors; a storage device for storing one or more computer programs, It is characterized in that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
