What are the database recovery technologies?
Database recovery technologies include: 1. Data dump, that is, the process in which the DBA regularly copies the entire database to a tape or another disk and saves it. 2. Register the log file. The log file is a file used to record the update operations of the transaction on the database. Setting up the log file can perform transaction failure recovery, system failure recovery, and assist backup copies in media failure recovery.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
Overview of Database Recovery
The database management system must have the function of recovering the database from an error state to a known correct state. This is database recovery. . The recovery subsystem is an important part of the database management system and is quite large, often accounting for more than ten percent of the entire system code. Whether the recovery technology used in the database system is effective not only plays a decisive role in the reliability of the system, but also has a great impact on the operating efficiency of the system. It is an important indicator to measure the performance of the system.
System failure is called a soft failure, and media failure is called a hard failure. Hard faults refer to external storage faults, such as disk damage, head collision, instantaneous strong magnetic field interference, etc. This type of failure will destroy the database or part of the database and affect all transactions that are accessing this part of the data. Summary of various types of failures, there are two possibilities for the impact on the database. One is that the database itself is damaged. The second is that the database has not been damaged, but the data may be incorrect. This is caused by the abnormal termination of the transaction. The recovery mechanism involves two key issues: 1. How to establish redundant data; 2. How to use these redundant data to implement database recovery. The most common techniques for creating redundant data are data dumps and log files. Usually in a database system, these two methods are used together. Data dump Data dump is the basic technology used in database recovery. The so-called dump is the process in which the DBA regularly copies the entire database to a tape or another disk and saves it. These spare data become standby copies or backup copies. Dumps can be divided into static dumps and dynamic dumps. Static dump is a dump operation performed when there are no running transactions in the system. That is, when the dump operation starts, the database is in a consistent state, and no access or modification activities to the database are allowed during the dump. Obviously, what you get from a static dump must be a consistent copy of the data. Dynamic dump means that the database is allowed to be accessed or modified during the dump. However, the data on the backup copy at the end of the dump is not guaranteed to be correct and valid. To this end, it is necessary to register the modification activities of each transaction to the database during the dump period and create a log file. In this way, the backup copy plus the log file can restore the database to the correct state at a certain moment. Dumps can be divided into two methods: massive dumps and incremental dumps. Mass dump refers to dumping the entire database each time. Incremental dump refers to dumping only the data updated since the previous dump. From a recovery perspective, it is generally more convenient to use backup copies obtained from mass dumps for recovery. Register log file Format and content of log file Log file is used to A file that records transaction updates to the database. There are two main formats of log files: log files in records and log files in data blocks. For log files in units of records, the contents that need to be registered include: 1. The start mark of each transaction The content of each log record includes: 1. Transaction identification (indicate which transaction it is) The role of log files Log files play a very important role in data recovery. It can be used for transaction failure recovery and system failure recovery, and assists backup copies in media failure recovery. The specific functions are: 1. Log files must be used for transaction failure recovery and system failure recovery. 2. In dynamic dump mode, log files must be created, backup copies and Log files are combined to effectively restore the database. 3. In static dump mode, log files can also be created. Register log file In order to ensure that the database is recoverable, two principles must be followed when registering log files: Recovery of transaction failure Recovery of transaction failure is automatically performed by the system Completed, transparent to users. The system recovery steps are: 1. Scan the log file in reverse direction (that is, scan the log file from the end forward) to find the update operation of the transaction. 2. Perform the reverse operation of the update operation of the transaction. That is, the "value before update" in the log record is written to the database. In this way, if the record is an insertion operation, it is equivalent to a delete operation; if the record is a delete operation, an insertion operation is performed; if it is a modification operation, it is equivalent to modifying the previous value instead of the modified value. 3. Continue to scan the log file in reverse, find other update operations of the transaction, and perform the same processing. 4. Continue processing in this manner until the start mark of this transaction is read, and transaction failure recovery is completed. Recovery from system failure Recovery from transaction failure is automatically completed by the system and is transparent to users. The recovery steps of the system are: 1. Scan the log file forward to find the transactions that have been submitted before the failure occurs, and record their transaction identifiers in the redo queue. At the same time, find out the transactions that have not been completed when the failure occurs, and count their transaction representations into the undo queue. 2. Undo each transaction in the undo (UNDO) queue. The method for UNDO processing is to reversely scan the log file and perform the reverse operation on the update operation of each UNDO transaction, that is, write the "pre-update value" in the log record to the database. 3. Redo REDO processing for each transaction in the redo queue The method for REDO processing is: forward scan the log file and re-register the log file for each REDO transaction operation. That is, the "updated value" in the log record is written to the database. The method to recover from the failure is to reinstall the database and then redo the completed transactions. 1. Loading the latest database backup copy is to restore the database to the consistency state of the latest dump. 2. Load the corresponding copy of the log file and redo the completed transaction. That is, first scan the log file to find out the identity of the transaction that was committed when the failure occurred, and count it into the redo queue. Then scan the log file forward and redo all transactions in the redo queue. That is, the "updated value" in the log record is written to the database. Recovery from media failure requires DBA intervention. However, the DBA only needs to reinstall the recently dumped database copy and related log file copies, and then order the recovery commands provided by the system. The specific recovery operation is still completed by the DBMS. As the disk capacity becomes larger and larger, the price becomes cheaper and cheaper. In order to avoid disk media failure affecting the availability of the database, many database management systems Provides data distribution function for database recovery. According to the DBA's request, the entire database or key data in it is automatically copied to another disk. Since database mirroring is achieved by copying data, frequent copying of data will naturally reduce system operating efficiency. Therefore, in time applications, users often choose to only mirror key data and log files instead of mirroring the entire database. Mirror. (Recommended tutorial: mysql video tutorial) The above is the detailed content of What are the database recovery technologies?. For more information, please follow other related articles on the PHP Chinese website!Computer virus
Recovery implementation technology
Data dump methods can be divided into four categories: dynamic incremental dump, dynamic mass dump, static incremental dump, and static mass dump.
2. The end mark of each transaction
3. Each transaction All update operations
2. Type of operation (insert, delete or modify)
3. Operation object (record internal identification)
4. Old value of data before update
5. New value of data after update
1. The order of registration must be strictly in accordance with the time order of concurrent transaction execution
2. Log files must be written first, and then written database. Recovery strategy
Recovery from media failure
Database Mirroring

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

How to connect to MySQL using phpMyAdmin? The URL to access phpMyAdmin is usually http://localhost/phpmyadmin or http://[your server IP address]/phpmyadmin. Enter your MySQL username and password. Select the database you want to connect to. Click the "Connection" button to establish a connection.
