Oracle Learning Notes (1)-Data backup and recovery

Source: Internet
Author: User
Tags copy log reset backup
oracle| Backup | notes | recovery | data
Data backup

Either way, the backup of the database is a backup of the data file/control File/redo file.
1, exp/imp Backup mode
2. Offline backup mode (offline Backup)
3, Online backup method (online Backup)
4, Standy mode of operation


1, exp/imp Backup mode
(1) Order mode
Can be done in the online environment.

(2) OEM method
Export using the Export Backup Wizard.

2. Offline backup mode (offline Backup)
Copy the relevant files.
(1) closing the database;
(2) Copy files, Datafile/control file/redo log file;
(3) Open the database.

3, Online backup method (online Backup)
Conditions:
(1) The database cannot be closed;
(2) The database must be in the archive Mode (archive mode), that is, redo log file is full, save the complete redo log file
on the disk;

The way to get the data in Archive mode:
(1) Setting archive mode;
Set the following parameters in the Initorcl.ora file:
#启动arch背景的处理程序
Log_archive_start=true
#设置archive where log file is stored
Log_archive_dest=/home/oradata/orcl/archive
#设置脱机事务日志的文件名
Log_archive_format=-s%.arc
(2) Set archive mode under Mount State, open the database;
startup Mount Pfile=initorcl.ora;
ALTER DATABASE Archivelog;
ALTER DATABASE open;

Online Backup Method One
(1) Set tablespace as backup mode;
Alter tablespace TABLESPACE_NAME begin backup;
(2) Copy the relevant data table
Copy sourcefile DestFile
(3) Restore tablespace to normal state
Alter tablespace Tablespace_name end backup;
(4) Backup control file
ALTER DATABASE backup Controlfile to ' CONTROL.BK '
(5) Copy redo log file

4, Standy mode of operation
This mode is the primary backup mode from the server.
Method:
(1) Prepare backup host
(2) Backup of primary database
The method is as follows:
A, full offline backup
b, Online backup
C, backing up the database control file
ALTER DATABASE backup standby controlfile as ' filename '
(3) Determine the main machine is in Archivelog mode
The action method is shown in 3.
(4) Copy backup Datafiles/control file from the main machine to the backup host.
The copied files are as follows:
A, control file
b, backup datafiles;
C, archived redo logs
D, Onlie Redo logs
E, initialization file
(5) Set up the main machine initialization parameters
(6) Set up the backup host initialization parameters
?????
May differ from (5) settings.
(7) Open the backup host database
A, open the database in the Nomount state and alter to start the standby machine
Start Nomount Pfile=initstandby.ora;
ALTER DATABASE mount standby database;
b, after standby mode startup, the backup machine has been able to accept the primary database archive redo log, available FTP or Oracle
The method provided is to automatically obtain data from Oracle.
(8) Start the BACKUP database
ALTER DATABASE recover managed standby database;



Data recovery

1. Recovery of offline backups (loss of data)
(1) Determine database shutdown
(2) Copy related backup files to relevant location (Control File,redo log file,datafiles)
(3) Start the database
2, Archive mode recovery
(1) Complete recovery
A, close the database;
Shutdown
b, open the database during the Mount phase
startup Mount;
C, Database recovery
Set AutoRecovery on;
Recover database;
D, after completing the recovery, open the database
ALTER DATABASE open;
(2) Recovery a single file or data table;
A, take the tablespace that needs to be recovered offline
Alter tablespace AppData offline immediate;
B. Replace corrupted files with good backup files
C, determine the existence of the archive log file to be restored
D, start recovery;
Recover Tablespace AppData;
Recover datafile ' user01.dbf ';
E, after completion, alter let Tablespace online
Alter Tablespace AppData Online;

(3) Incomplete recovery
If the transaction log file is corrupted, be aware that the log sequence number of the Datafiles and control file record is not the same, or not full recovery.
In the mount phase, log sequence number is set to 1 so that the database can be opened.

Use Cancel to restore to a point in time
A, mount to open the database
startup Mount;
B, Recovery
Recover database until cancel;
C, after the completion, open the database (open mode), reset control file and datafiles log sequence number is set to 1;
ALTER DATABASE open resetlogs;


Use a specified time
A, mount to open the database
startup Mount;
B, Recovery
Recover database until time ' 2001-09-10:18:00:00 ';
C, after the completion, open the database (open mode), reset control file and datafiles log sequence number is set to 1;
ALTER DATABASE open resetlogs;


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.