First, the meaning:
When we use a database, always hope that the content of the database is reliable, correct, but due to the fault of computer systems (hardware failure, network failure, process
Fault and system failure) affects the operation of the database system, affecting the correctness of the data in the database, and even damages the database, so that all or part of the data in the database
Loss. Therefore, after the above fault occurs, it is desirable to re-establish a complete database, which is called database recovery. Recovery subsystem is a database management system
An important component. Recovery processing changes with the structure of the fault type that occurs.
Second, the method of backup
The Oracle database has three standard backups. Export / Import (Export / Import), cold backup, thermal spare.
Export backup is a logical backup, including reading a series of database logs and writes in a file, and the reads of these logs are independent of their location.
Cold backup and thermal backups are physical backups (also known as low-level backups), which involves files that make up the database, but does not consider logical content.
Below we introduce these three backup methods and its characteristics:
(1) Export / Import (Export / Import)
EXPORT / IMPORT is used to remove data data from Oracle to the database.
1. EXPORT backs up the data into a binary system file called "Export Dump File" and will regenerate the database
In the file.
It has three modes:
a. User mode: Export all user objects and data in the object;
b. Table Mode: Export all user tables or specified tables;
c. Overall database: Export all objects in the database.
It has three types of backup:
a. Complete Export: Back up the entire database;
b. CoMulative Erport: Back up the data changed on the previous accumulated backup;
c. Increamental Export: The data changes after the last backup is backed up.
Export's commands can be performed interactively, and the specific meaning of each parameter is shown in the appendix.
When conducting a backup, we should consider a problem, that is, the consistency of the export, exporting each time reading a table during the export process, thus
It starts at a feature, but different tables read the time difference, so when the export begins to read a table, the data in the table is exported.
According to this, when most tables are connected to each other, the changes in these related formats will result in inconsistencies in the export during the export process.
Sex, to avoid this, we can arrange the export process to do when it is not operated. In addition, when the RESTRICTEP CONSISTENT option is in Oracle
You can guarantee that the data consistency is derived.
2, import import: The imported process is the exported reverse process, this command reads the exported dump binary file and runs files, restores object users, and data. The method of implementing the import command is related to the Export solution. 1. If the full-time scheme implemented in Export, all data objects, including tablespaces, data files, users when IMPORT, but consider the physical layout in the database, pre-create table space It is useful to users. 2. If Export uses the Incremental / Cumulative mode, you need to set a table space, user, and data files in advance. (2): Cold backup cold backups occur in situations where the database has been properly closed, and will provide us a complete database when properly closed. Each file used by the database is backed up, including: ☆ All data files ☆ All control files ☆ All online redo log files ☆ Init.ora file (optional) is worth noting that the cold backup must be a database shutdown Under completion, when the database is open, the execution database file system backup is invalid. The cooling backup is: 1: Normally Close the instance to be backed up; 2: Back up the entire database to a directory 3: Start Database 1: Sqldba> Connect INTERNALSQLDBA> Shutdown Normal2: SqlDBA>! CP
• Full Offline Entire Database Backup, this backup is the basis for future backups after the database is initially completed. It provides all copies related to the database.% Dbshut% cp /oracle/oradata/oracle7/system.dbf /oracle/oradata/oracle7/RBS.DBF /Oracle/roadata/roacle7/temp.dbf/oracle/oradata/oracle7 /Tools.dbf/oracle/oradata/racle7/USERS.DBF/OracleCle/app/racle/Product/7.3.2/dbs/Application.dbf/oracle/app/oracle/Product/7.3.2/dbs/apptmpsp.dbf / Oracle/app/oracle/product/7.3.2/dbs/apprlbksp.dbf/oracle/oradata/oracle7/redooracle.log / Oracle/oradata/oracle7/control1.ctl /oracle/roadata/Oracle7/control2.ctl / oracle / OraData/oracle7/control3.cta
Do a SQL file, write as above.
The Billing System Can Recover To The Point of Failure When The Failure Occur. Seven, Backup File Recovery: 7.1 Recovery File: The following is the recovery of the "/ etc / passwd" file (, put the correct tape (, run the following command) Restore "/ etc / passwd" file # rsh www mt -f / dev / rmt / 0 rew (find the nearest tape, advance to the nearest "/ etc / passwd", such as Wednesday "/ etc / passwd "File, run the following command) #RSH WWW MT -F / DEV / RMT / 0N FSF 2 # ufsrestore if www: / dev / rmt / 0nufsrestore> ls.:tc/ufsrestore> CD etc UFSRESTORE> LS./Etc:PasswdufsRestore > add passwdWarnign: ./ etc: File existsufsrestore> verboseverbose mode onufsrestore> extractExtract requested filesYou have not read any volumes yet .Unless you know which volume your file (s) are on you should start witch the last volume and work to wards the first .Specify next volume #: 1extract file ./etc/passwdAdd linksSet directory mode, ower, and times.set owner / mode for (yn) nDirectories already exit, set mode anyway (yn) yufsrestore> quit hot backup '.'?? It can be performed in the database open mode, generally starting backup by changing the status of the table space using the alter command, after the backup is complete, to restorate the original state, otherwise the redo log is wrong, causing the database next time to start The influencing table space is completely covered. The requirements for the hot backup are: 1. The hot backup work must require the database in the ArchiveLog mode, in SQLDB A State The ALTER DATABASE ArchiveLog | noarchiveLog command changes the backup mode. 2. The hot backup can only be carried out without using the database without using or low usage. 3. The hot backup requires a lot of file space. In general, Oracle writes the online redo log file in a loop, when filling the first redo log file, until the last one, the last one is filled, the background process LGWR covers the first, In the ArchiveLog mode, the background process Arch gives it a copy before each Redo log file is overwritten, generally, the Redo log file of these documents is written into the disk or tape. If the disk space is enough, it is recommended to use a disk, which greatly reduces the time required to complete the backup.
Before making a hot backup, to config.ora file log_archive_start set to true will log_archive_dest predetermined position archive redo log files: log_archive_dest = / wwwdg / oracle / arch / archlog_archive_start = true once the database is running in archivelog mode, you can Bope. The command file of the hot spare is made of three parts: 1. Data file a table space a spatial backup: a. Set table space is a backup state. b. Data file of the backup table space. c. The recovery table space is normal. 2, backup archiving should be log files: a. Temporary stop archive process B. Log under the file c in the Archive Redo Log target directory c. Restart the Archive process d. Backup archived Redo Log file 3, with Alter Database Backup ControlFile Command to back up the copy file before the hot backup runs the log_archive_dest directory may be full, then the directory is to be backed up, then delete the file, release space, this process has the following steps: 1, temporarily stop Archive process. 2. Record the files in the log_archive_dest directory. 3, restart the Archive process. 4, back up the Archive Redo log file. 5, delete files in the directory. sqldba lmode = y << EOF arch1archive log stop; exitEOF arch1FILES = 'ls /wwwdg/oracle/arch/arch*.dbf';sqldba lmode = y << EOF arch2connect internalarchive log start; exitEOF arch2tar -rvf / dev / rmt / 0 FILESRM -F $ FILES logic backup combined with physical backups. In the previous introduction, the method of the three backups. When the database is backed up, the characteristics of the three backups of the data should be flexible, and we first compare the characteristics of the three methods.
Frame-type Reconstruction Features EXPORT Export Logic You can restore any database objects to the status hutdown when it is exported? Hutdown will receive the nearest Copyes of DataFile, copy to the $ Oracle_Home / DBS directory. When too many archive log files; automatically recover data to the point of failure ;? svrmgrl> alter database open:??;% Svrmgrl svrmgrl> connect internal ... svrmgrl> startup mount pfile = filename exclusive svrmgrl> alter database recover Notes?? After doing some backup, you can remove the log ***. Arc before Current Log Sequence. # Su - Oracle% SVRMGRLSVRMGRL> Connect Internal; SVRMGRL> Archive log list; # This is marked with current log sequence. Assume as 360. SVRMGRL> EXIT $ CD /BILLDG/Oracle/app/oracle/product/7.3.2/dbs/arch $ RM ......... # will log360.arc as log359.arc, log358.arc .............delete. Cold backup physical type can restore the database to any time point of the database to it.
When the database is time-hours, the processing business is also an hour, and the cold backup export is OK. If you only export one or two tables, it is enough. Generally speaking, the backup ultimate execution always includes logic and physics, exporting confirmation database correctness in logic and physically backup ensuring physical. In addition, some storage media is required when making backups. For these media, it should be managed to be managed. According to the backup content, the media is unified, so as to make the media when backup and recovery, resulting in the original backup loss. 2: Media should be stored in different locations with computer equipment, and the backup is damaged with computer equipment when there is an unexpected machine room. Appendix: TAR Option [Arguments] FileName ... Option: C: Create a new tarfilet specified by the command line: List the content in Tarfile x: Open TARFILE; F: Use the subsequent filename or / dev / RMT / 0 | 1V: List the recovered file name; P: Restore files Example: #tar CVF / DEV / RMT / 0 / Oracle Backup / root All content #TAR TVF / DEV / RMT / 0 listing tape All content #TAR XVF / DEV / RMT / 0 / Oracle restores the contents of the / oracle directory on the tape to the current directory
Export the user name / password for the account of the account that runs the export command. Buffeer is used to take the size of the buffer of the data line. The name of the file exporting the dump file corresponds to whether the fragmentation of the fragmentation should be compressed, which will affect the Storage clause, whether the GRANTS exports should export the authorization indexes on the database object whether I want to export the index ROWS on the table should be exported. Export line. If it is 'n', only the DDLCONSSTRAINTS that generates only the database object in the export file exports the old agreement condition Full, such as 'Y', will execute a series of database accounts to export the entire database to export Owner. Then execute the user export operation of these accounts TABLES to be exported; the Table Export Operation of these tables is executed, the Table Export operation of these tables, the length (in bytes), usually used, unless they are in two The type of exported operation in different operating systems inctype is executing (valid value has "complete", cumulative, and "ivcremental") RECORD in incremental export type tag, indicate whether to log logs Stored to the name of the log exported in the data dictionary to pass to the name of the exported parameter file. This file will contain all the parameters of the entry Item Analyze indicate whether to write the statistics of the object to the export dump file in the export dump file. All exported objects are uniformly copy. Log Export Log The name MLS of the file to be written indicates whether the MLS label MLS_Label_ specifies the format of the MLS label
Import the user name / password of the Select Item UserId run the entry command. Buffeer is used to take the size of the buffer of the data line. The name of the file import dump file show is specified whether the file content is displayed, not executed. EGORE indicates whether the error encountered is ignored when executing the 'create' command. This parameter should be used if the object being imported already exists. If Full is set to 'Y', the entire database introduction operation fromUser has parameters in the case of full = n. It is a series of database accounts that should be read from the export dump file. Touser A series of database accounts, exporting objects that deduct dump files will import these accounts. GRANTS imports whether or not to import the authorized indexes on the database object to import the index ROWS on the table should be transferred. As it is 'n', execute the DDLfull of the database object in the import file, if you set it to 'Y', then a series of tables of table RECordLength dumps to import for TABLES to import (in words) Unit), usually use default unless the type of imported operation in the import file inctype is transmitted in two different operating systems (effective values "," COMPLETE ", Cumulative, and" Ivcremental " PARFILE To pass the name of the imported parameter file. This file will contain the entry INALYZE of all parameters. Analyze indicate whether to write the statistics of the object to the imported dump file. The name MLS of the file to be written. to import MLS numerals hot backup command file: ORACLE_SID = oracle7ORACLE_HOME = / wwwdg / oraclesqldba lmode = y << EOF arch1connect internalalter tablespace SYSTEM begin backup; tar -cvf / dev / rmt / 0 / wwwdg / oracle / dbms / sys01!. DBFALTER TABLESPACE SYSTEM END BACKUP;
ALTER TABLESPACE BWT Begin Backup;! TAR-CVF / DEV / RMT / 0 / Wwwd1.dbfalter TableSpace BWT End Backup;
Archive log stopexiteof arch1files = 'ls /wwwwg/oracle/arch/arch*.dbf';
SQLDBA LMODE = Y << EOF Arch2connect InternalarChive Log Start; Exiteof Arch2
Tar -RVF / DEV / RMT / 0 $ filesrm -f $ files
SQLDBA LMODE = Y << EOFARCH3ALTER DATABASE BACKUP ControlFile To '/wwwdg/oracle/dbms/bwtcontrfile.backup' ;Exiteof Arch3
Tar -RVF / DEV / RMT / 0 / Wwwdg/oracle/bwt/bwtcontrofile.backup