What is backup, recovery, what is their relationship? What is backup so-called backup, which is the process of copying the database to a dump device. Among them, the dump device refers to a tape or disk for placing a database copy. A copy of the database stored in the dump device is also also referred to as a backup or dump of the original database. As shown below:
Backup of Oracle Database is divided into physical backups and logical backups. The physical backup is a backup process that copies the actual composition of the operating system file from one place to another, usually from the disk to the tape. You can use the Oracle's recovery manager (Recovery Manager, RMAN) or the operating system command to perform the physical backup of the database. Logical backups use the SQL language to extract data from the database and store the binary file. Oracle's logic backup tool is exp. Database logic backups are supplemented by physical backups. Depending on the status of the database during physical backup, the backup can be divided into two types of consistent backups and inconsistent backups: Consistency Backup: Consistency Backup is when all readable database files for the database And the control file has the same system change number (SCN), and the data file does not contain any changes other than the current SCN. When doing a database checkpoint, Oracle makes all control files and data files. For read-only table spaces and offline table space, Oracle also believes them consistent. The only way to make the database in a consistent state is that the database is normally shut down (shut down with the shutdown normal or shutdown immediate command). Therefore, only backups under the following conditions are consistency backups: The database is turned off (shut down with the shutdown normal or shutdown immediate command). Inconsistency Backup: Inconsistency Backup is a backup of a system change number (SCN) of the readable write-writable database file and control files in inconsistencies. For a 7 * 24 working database, since it is impossible to shut down, the database data is constantly changing, so it can only perform inconsistencies. Under the inconsistency of the SCN, the database must be started with the application of the reform log to enable SCN. Therefore, if you do not match backup, the database must be set to an archive status and make sense to redo log archiving. Backup under the following conditions is inconsistency backup:
The database is open. The database is turned off, but it is turned off with abnormal means. For example, the database is closed by shutdown Abort or machine power-off. What is recovery of so-called recovery, that is, transitioning the database from the presence of a fault to a faultless state. Recovery is divided into two types according to the cause of the fault: instance recovery. This recovery is an Oracle instance failure, Oracle automatically recovers. Medium recovery. This recovery is the recovery when the media is stored. The recovery mentioned later in this book refers to the recovery of the media. RESTORE Physical Backup and Recovery Physical Backup is a means of media recovery. Loading is a backup back to disk, and recovery is to use redo log (part of the physical backup) to modify the data file back to the disk (another part of the physical backup) to restore the database. As shown in the figure below: According to the degree of recovery of the database, the recovery method is divided into two types: Fully recovery: Restore the database to the status of the database when the database fails. This recovery is made by loading a database backup and and applying all of the redo logs. Incomplete recovery: Restore the database to a status of a certain time database before the database fails. This recovery is done by loading a database backup and a redo log for a part. After the incomplete recovery, you must reset the online re-log log when you start the database. For example, at 10:00 am, due to disk damage, the database is aborted. Now use two methods for the restoration of the database, the first method makes the database normally and makes the data in the time of recovery (10:00) database, then the first recovery method is a fully recovery type; The second method can make the database normally, but can only make the data in the previous (for example, 9:00) database, then the status of the database is not capable of restoring the status of the database to fail (10:00), then second The recovery method belongs to an incomplete recovery type. In fact, if the database backup is a consistent backup, the loaded database can be used, so that you can also use the point where the log is restored to the database backup. This is also an incomplete recovery.
Backup and recovery relationship back up an Oracle database, similar to buying medical insurance - not aware of its importance before encountering a disease, giving the amount of insurance premium depends on the type of insurance policy. Similarly, as the type and frequency of the production backup, the feasibility of restoration after the database is faulty, the difficulty is different from the time spent. Database failure refers to a special event that affects the normal use of the database during the running process of database. There are many types of database failures. The most serious is that the media failure (such as disk corruption), such a failure, if it is not recovered, will result in the loss of data in the database. Database troubleshoot types are: statement failed. The user process failed. The instance failed. User or application error operation. Such errors may be unexpectedly deleted an error operation such as data in the table. Medium failed. Such as the hard disk fails, the data in the hard disk is lost. natural disaster. Such as earthquakes, floods, etc. Due to the different type of fault, the method of restoring the database is also different. Recovering the database is both a common recovery means by loading a backup, it is also a main method of recovering the failure of the media. Backup and recovery should consider the following three questions: Backup and recovery policies should consider the business, operation, and technical problems of the disaster recovery plan to make a test backup and recovery strategy? Restore depends on what backups. As the DBA, there is a responsibility to maintain the recoverability of the database from the following three aspects: minimize the number of times of failure of the database, so that the database is maximized; when the database is inevitably invalid, the recovery time is minimized, This makes the recovery efficiency up to the highest; when the database is invalid, make sure that the data is lost as possible or not, the data has the greatest recoverability. By backing up and recovery strategies As DBA, first, you need to understand how companies use database systems, as well as the availability, recovery performance, and data of the company's availability, and recovery time requirements. Then, DBA needs to make the company's managers understand how much the cost of maintaining the availability of such a database. The best way to do this is to assess the cost of recovery, and loss of data to the company. After the price is evaluated, the discussion of backup and recovery can be made. At this point, you want to define the availability requirements of the database, and define the order of the work focus based on the degree of impact on the database availability. For example, if the database requires 7 * 24 availability, its importance is higher than any other job, and any other work that needs to be shut down can not be done. In addition, the situation of database changes is also a factor for backup and recovery strategies. For example, if the data is constantly changing, new data or data file is added, or the table structure has a large change, it should be backed up; contrary, if the data is static or read, backup is backup. In any case, the principle of such a principle should be followed, and if you doubt the recoverableity of the database, you should back up.
The composition of the disaster recovery program is responsible for disaster recovery, and must answer the following questions: What kind of disaster recovery is possible? What is the disaster recovery situation if data is lost? What is the degree of volatility of data in the system? If there is a problem, how fast is the speed recovery? In various cases, the cost of recovering the strategy, and the cost of re-entry data in the corresponding spending time? The answer to these issues forms a disaster recovery plan. The computer is very bad. Any one of the chips, motherboard circuits, memory, and power supplies, etc., will cause computer systems to work properly. Of course, these damage can be repaired and will not cause damage to the application and data. However, if the computer's hard drive is corrupted, the data is lost, and the data must be restored with backup. The most important step in disaster recovery is to design a hard disk backup process of sufficient frequency. The backup process should meet the recoverableity of the system requirements. For example, if the database can have a long shutdown time, a cold backup can be performed once a week, and archive the redo log; however, if the database only has very little shutdown time, only the backup and recovery can be considered from the perspective of the hardware. Problem, such as using a hard disk mirror or dual-machine system. The basis for selecting backup policies is that the ratio of the cost of data and the cost of ensuring that the data is not lost. If you can backup every day, you will be ideal, but you should consider its reality. Enterprises are trying to reduce maintenance costs, and the reality can be adopted. Just carefully plan, and find a way to reach the bottom line of the database availability, it is also possible to make a small amount of money to successfully backup and recovery. DBA should also develop a standard file for recoverable and availability in the form of a service protocol. This document should be a basis for discussing DBA services and whether the service can achieve expected standards. Doing so allows all relevant personnel to have a potentially crisis of the same expectations. The importance of the test backup and recovery policy The backup and recovery policy must be used after the test is correct. If you have backed up, you don't know if the backup supports the hoped recovery target, and there is no backup at all. The recovery strategy should also take into account the dependence on the environment. For example, if the machine's hard drive is faded, how long can the supplier provide a new hard disk; can you find the operating system administrator when the machine needs to be restarted? Another problem that needs to be considered is whether the database can withstand natural damage. A backup medium should be stored in different parts of the computer, so as not to be destroyed with the backup when natural disasters. The problem that needs to be considered is what the problem has a problem in DBA? Can the backup DBA perform backup strategies? Does he find the supported documentation? Does these documents exist? There is no better plan to specify a good plan, but it has not tested its effectiveness and makes it out of the east. A good plan should also accommodate people for errors, especially for the development of systems. The ideal test plan should include the following: a series of test examples and status description; whether the test results are successful; the steps to solve these states. DBA should only consider putting the backup plan into implementation for the actual production system for implementation of the actual use. The test of backup policies cannot be terminated when the database is actually used.
Small range testing ensures that the backup policy can meet future needs. With the maturity of the application system, the backup strategy should also be mature accordingly. If the backup policy does not meet new needs, you should be redesigned. Test backup strategies have some other benefits: Testing artificial backup processes may find artificial omissions to promote DBA to consider automatic backup methods. As long as the automatic backup process has been tested, and the automatic backup is beneficial to the backup problem after the database changes (for example, adding table space). Another advantage of testing is that the problem of data blocks can be found. If one or more data blocks of the data file are corrupted, the physical backup method of the database is used, and the damaged data block will be copied into the backup file, which causes the backup damage and the damage of the database. This problem will not be discovered if it is not tested. Of course, you can also check the data of DB_BLOCK_CHECKSUM in the init.ora file or the integrity check of data with the DBVERIFY utility. Why do you want to make a backup recovery plan and write an operation script backup recovery plan is extremely important, in case the lost hand, the loss is unrecivalent. Backup recovery plans and write operation scripts require high-level professionals to ensure that they are not lost. Of course, if the user has a high level of professionals, there is no problem with this work, no foreign aid.