Rman Backup and recovery data

Source: Internet
Author: User
Tags unique id

1. Check the database schema:
Sqlplus/nolog
Conn/as SYSDBA
Archive log list (to see if the database is in archive mode)

If it is not archived, the database archive mode is modified.
Startup Mount
ALTER DATABASE Archivelog
ALTER DATABASE Open

2. Connect to target Database

Command: Connect target/(connect target system/oracle@ora10g, if the database is not up, you can also start the database directly under the Rman command with startup)
Can connect to target database. (Rman is connected to the target database while the other side is connected to control file (Nocatalog mode), and the backup information for Rman is stored in control file)

3. Use the list backupset command to see if there is anything to back up

4. Frequently used backup commands:
Back up the entire library:
Rman> BACKUP database plus archivelog delete input; (Back up the entire library and control files, server parameter files and all archived redo logs, and delete old archive logs)
Backup table Space:
Rman> backup tablespace system plus archivelog Delete input; (Back up the specified tablespace and archived redo logs, and delete old archive logs) _
Backup Archive log:
rman> Backup Archivelog all delete input;


====================== Backup of the entire database ==================

1. Full backup of the entire database.

Just enter the command: backup database;

2.list backupset to view backup details

List of Backup Sets
===================

BS Key Type LV Size Device Type Elapsed Time Completion time
------- ---- -- ---------- ----------- ------------ ---------------
1 full 6.80M DISK 00:00:02 06-dec-08
BP key:1 status:available Compressed:no tag:tag20081206t201041
Piece Name:/home/oracle/flash_recovery_area/ora10g/backupset/2008_12_06/o1_mf_ncsnf_tag20081206t201041_4mntz78s _.bkp
Control File INCLUDED:CKP scn:782019 CKP time:06-dec-08
SPFILE included:modification time:06-dec-08

BS (backupset), piece is a file, a BS contains multiple piece.

The default parameters in 3.rman can be done by show all;
To view (RMAN configuration parameters), we can use the BACKUP DATABASE command to replace these default values with a fixed value.

4. We can copy the backed-up files to the tape, then delete the backup files under the backup directory, if the next need to restore, as long as the file back to the backup directory to use it
5. View the backup information in the control file (because our backup is in Nocatalog mode), control file is in the/u01/oracle/oradata/ora10g directory, because control file is a binary file , to view the contents of the control file, use strings Control03.ctl to find information about the Rman backup in Control03.ctl


====================0-Level Incremental backup ===============

Concept: Full backup and Level 0 incremental backups. Full backup and Level 0 incremental backups are almost the same. The only difference is that level 0 incremental backups can be the basis for incremental backups, and full backups cannot be the basis for incremental backups. The rest is in full agreement.

1.backup Incremental Level=0 (leve 0) database; (Backup with an increment of 0)
2.backup Incremental Level 1 (level=1) database; (Incremental 1 backup)

In the above backup, we backed up datafile,controlfile and parameter file. Files not backed up have archived logs, redo logs, and password files are not backed up. password files do not need to be backed up, we use ORAPW to create a

The new password file. Rman cannot back up redo log file in Nocatalog mode


=================== backup Archivelog in Nocatalog mode =================

Command: Backup database plus archivelog Delete input meaning delete the Archivelog file after the backup is complete, this option is not available, this command can also be used with backup Incremental level=0 (1,2 ...) To make a backup)


======================= Backup Table Space ====================

Backup Tablespace tablespacename

If we don't know the name of Tablespace, in Rman, you can view the name of the table space by using the statement Schema command.

Man> a schema;
The database schema of the

List of Permanent datafiles
===========================
File Size (MB) tablespace RB segs datafile Name
---- -------- -------------------- ------- ------------------------
1 SYSTEM * * */HOME/ORACLE/ORADATA/ORA10G/SYSTEM01.DBF
2 UNDOTBS1 * * */HOME/ORACLE/ORADATA/ORA10G/UNDOTBS01.DBF
3 Sysaux * * */HOME/ORACLE/ORADATA/ORA10G/SYSAUX01.DBF
4 5 USERS * * */HOME/ORACLE/ORADATA/ORA10G/USERS01.DBF
5 Perfstat * * */HOME/ORACLE/ORADATA/ORA10G/PERFSTAT.DBF

List of temporary Files
=======================
File Size (MB) tablespace Maxsize (MB) tempfile Name
---- -------- -------------------- ----------- --------------------
1 TEMP 32767/home/oracle/oradata/ora10g/temp01.dbf

======================== Backup control File ====================

Backup Current Controlfile

Backup database include current Controlfile

======================== Backup Mirror ========================

There are two ways in the backup of Rman: Backup set (backupset) and backup mirror (image copies). A mirrored backup is primarily a copy of a file: Copy datafile ...

We are in Rman>report schema;

The database schema of the

List of Permanent datafiles
===========================
File Size (MB) tablespace RB segs datafile Name
---- -------- -------------------- ------- ------------------------
1 SYSTEM * * */HOME/ORACLE/ORADATA/ORA10G/SYSTEM01.DBF
2 UNDOTBS1 * * */HOME/ORACLE/ORADATA/ORA10G/UNDOTBS01.DBF
3 Sysaux * * */HOME/ORACLE/ORADATA/ORA10G/SYSAUX01.DBF
4 5 USERS * * */HOME/ORACLE/ORADATA/ORA10G/USERS01.DBF
5 Perfstat * * */HOME/ORACLE/ORADATA/ORA10G/PERFSTAT.DBF

List of temporary Files
=======================
File Size (MB) tablespace Maxsize (MB) tempfile Name
---- -------- -------------------- ----------- --------------------
1 TEMP 32767/home/oracle/oradata/ora10g/temp01.dbf

Rman>copy datafile 5 to '/u01/rmanbak/tbso1bak.dbf ';(copy 5 corresponding schme:perfstat.dbf)

It will use TBS as a copy. We use list backupset to see that we are not able to view the tbs01bak.dbf ' that we just backed up because it's not backupset. We can use list copy to view the files we just backed up.


======================= single command and Batch command =================

Single command: Backup database;

Batch command:

Rman> run{
2> Allocate channel CHA1 type disk;
3> Backup
4> format '/u01/rmanbak/full_%t '
5> tag full-backup//tag can be conveniently, okay
6> database;
7> release channel CHA1;
8>}

There are 3 commands in this run, separated by semicolons.

Format
%c: Number of copies of the backup slice (numbered starting from 1);
%d: database name;
%d: Days in the month (DD);
%m: The Month in the year (MM);
%F: A unique name based on dbid, this form of c-xxx-yyyymmdd-qq, where xxx bit the database DBID,YYYYMMDD for the date, QQ is a 1-256 sequence;
%n: The name of the database and will be populated with x characters on the right side to keep the length 8;
%u: is a 8-character name that consists of a backup set number and a build time compression. %u allows you to generate a unique name for each backup set;
%p: The number of the backup slice that represents the backup set, numbered from 1;
%u: is the abbreviated form of%u_%p_%c, which can be used to generate a unique name for each backup fragment (both disk files), which is the most commonly used naming method;
%t: Backup set timestamp;
%T: Month and day format (YYYYMMDD);

The concept of channel: A channel is a connection between Rman and the target database, the "Allocate channel" command starts a server process in the target database, and the server process must be defined to perform backup and restore operations

Type of I/O used

Channel control commands can be used to:
Controlling the OS resources used by Rman
Influence degree of parallelism
Specify the throttling value for I/O bandwidth (set limit read rate parameter)
Specify a limit on the size of the backup slice (set limit Kbytes)
Specifies the limit value for the currently open file (set limit maxopenfiles)


=================================rman Typical backup solution for one week ============================

1. Sunday Evening-level 0 Backup performed (full backup)
2. Monday Evening-level 2 backup performed
3. Tuesday Evening-level 2 backup performed
4. Wednesday evening-level 1 Backup performed
5. Thursday Evening-level 2 backup performed
6. Friday Evening-level 2 backup performed
7. Saturday Evening-level 2 backup performed


If Tuesday needs to be restored, just 1+2,
If Thursday needs to be restored, just 1+4,
If Friday needs to be restored, just 1+4+5,
If Saturday needs to be restored, only 1+4+5+6 will be needed.

Automatic backup: Backup Scripts +crontab
Bakl0
Bakl1
Bakl2

Execute script:
Rman Target/msglog=bakl0.log cmdfile=bakl0 (/indicates the target database to be connected, Msglog represents the log file, Cmdfile represents the script file)
Rman Target/msglog=bakl1.log CMDFILE=BAKL1
Rman Target/msglog=bakl2.log CMDFILE=BAKL2

Example: Rman target system/oracle@ora10g (/) Msglog=/u01/rmanbak/bakl1.log cmdfile=/u01/rmanbak/bakl0


Complete command:/u01/oracle/product/10.2.0/bin/rman target system/oracle@ora10g (/) Msglog=/u01/rmanbak/bakl1.log cmdfile=/ U01/rmanbak/bakl0


Put the backup script under the/u01/rmanbak/script directory, the VI bakl0,bakl0 content is:

run{
Allocate channel CHA1 type disk;
Backup
Incremental Level 0
Format '/u01/rmanbak/inc0_%u_%t ' (U denotes unique ID, big T is date, small T is time)
Tag monday_inc0//tag can be by the way, okay
Database
Release channel CHA1;
}
, a similar script can be written bakl1,bakl2.


Automatic backup
Crontab
CRONTAB-E-u Oracle (change command means to edit a timed execution of an Oracle user (-e,edit-u oracle,oracle user))

Timesharing Week (0 delegates Sunday)
0 Rman Target/msglog=bakl0.log cmdfile=bakl0 (23:45 of Sunday will execute the command as an Oracle user)
* 1 Rman target/msglog=bakl2.log CMDFILE=BAKL2
* 2 Rman Target/msglog=bakl2.log CMDFILE=BAKL2
* 3 Rman Target/msglog=bakl1.log CMDFILE=BAKL1
* 4 Rman Target/msglog=bakl2.log CMDFILE=BAKL2
* 5 Rman Target/msglog=bakl2.log CMDFILE=BAKL2
* 6 Rman Target/msglog=bakl2.log CMDFILE=BAKL2

Then start crontab and start the crontab command:
Root> Service Crond Restart

=======================rman Recovery ================

In a catalog mode, the backed-up information is stored in the Controlfile file, and if the Controlfile file is destroyed, it cannot be recovered.
Use the controlfile to automatically back up when you are backing up

Rman>show all;
Using target database control file instead of recovery catalog
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY to redundancy 1; # Default
CONFIGURE BACKUP optimization off; # Default
CONFIGURE DEFAULT DEVICE TYPE to DISK; # Default
CONFIGURE Controlfile autobackup off; # Default
CONFIGURE controlfile autobackup FORMAT for DEVICE TYPE DISK to '%F '; # Default
CONFIGURE DEVICE type DISK PARALLELISM 1 BACKUP type to backupset; # Default
CONFIGURE datafile BACKUP copies for DEVICE TYPE DISK to 1; # Default
CONFIGURE Archivelog BACKUP copies for DEVICE TYPE DISK to 1; # Default
CONFIGURE maxsetsize to unlimited; # Default
CONFIGURE encryption for DATABASE off; # Default
CONFIGURE encryption algorithm ' AES128 '; # Default
CONFIGURE archivelog deletion POLICY to NONE; # Default
CONFIGURE SNAPSHOT controlfile NAME to '/home/oracle/product/10.20/dbs/snapcf_ora10g.f '; # Default

Wherein configure Controlfile autobackup off; Controlfile is not autobackup, we need to run the following command to automatically back up Controlfile
Rman> CONFIGURE controlfile autobackup on;

Rman> Show All;

To manually back up control files:
Backup Current Controlfile


DBID represents an ID of the database that will be used in the future to restore SPFile and controlfile.
Rman> Connect Target/
Connected to target database:ora10g (dbid=3988862108)
This dbid=3988862108

rman> list backup; View previously backed up information
Rman>delete backupset 24;//24 Representative Backupset's number
Rman>backup format '/u01/rmanbak/full_%t_%u.bak ' database plus archivelog; (Make a full backup)

Verify Backup:
Rman> Validate Backupset 3; 3 represents Backupset's number

Password file loss (not part of Rman backup), we just need to use a single command to rebuild the file:
ORAPW File=orapwsid Password=pass entries=5; Path to password file:/u01/oracle/product/10.20/db_1/dbs directory
Oracle> Cd/u01/oracle/product/10.20/db_1/dbs
oracle> RM orapwora10g (file deletion, impersonation lost)
oracle> orapwd file=orapwora10g password=oracle entries=5 (re-establishing a file), entries meaning (maximum number of DBA users is 5)

SPFile Missing:
Startup Nomount;
Set dbid 3988862108;
Restore SPFile from


This article is from CSDN Blog, reproduced please indicate the source: http://blog.csdn.net/tianlesoftware/archive/2009/10/20/4699320.aspx

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.