1
. set database to archivelog mode
Sql代码
SQL> shutdown immediate;
Databaseclosed.
Databasedismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System GlobalArea 251658240 bytes
Fixed Size1248356 bytes
Variable Size83887004 bytes
DatabaseBuffers 159383552 bytes
Redo Buffers 7139328 bytes
Databasemounted.
SQL> alterdatabasearchivelog;
Databasealtered.
SQL> alterdatabaseopen;
Databasealtered.
SQL> archive log list;
Databaselog mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence1319
Nextlogsequencetoarchive 1321
Currentlogsequence1321SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 251658240 bytes
Fixed Size 1248356 bytes
Variable Size 83887004 bytes
Database Buffers 159383552 bytes
Redo Buffers 7139328 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1319
Next log sequence to archive 1321
Current log sequence 1321
2
. define flash recovery area
Sql代码
SQL>altersystemsetdb_recovery_file_dest='D:\oracle\flash_recovery_area'scope=both;
System altered.
SQL> altersystemsetdb_recovery_file_dest_size=15G scope=both;
System altered.SQL> alter system set db_recovery_file_dest='D:\oracle\flash_recovery_area' scope=both;
System altered.
SQL> alter system set db_recovery_file_dest_size=15G scope=both;
System altered.
Oracle will use Oracle Managed File (OMF) for the flash recovery
area. The free space in recovery area can be checked using OEM: All
Metrics -> Recovery Area, or query vflash_recovery_area_usage view.
To get more free space, you can use the following command to backup and
then delete all the archived log files.
Sql代码
RMAN> backup archivelogalldeleteallinput;RMAN> backup archivelog all delete all input;
3
. define multiple archived log destinations
Sql代码
SQL>altersystemsetlog_archive_dest_1='location=use_db_recovery_file_dest'scope=both;
System altered.
SQL> altersystemsetlog_archive_dest_2='location=D:\oracle\archivelog_area1'scope=both;
System altered.SQL> alter system set log_archive_dest_1='location=use_db_recovery_file_dest' scope=both;
System altered.
SQL> alter system set log_archive_dest_2='location=D:\oracle\archivelog_area1' scope=both;
System altered.
4
. CONTROL_FILE_RECORD_KEEP_TIME
This parameter specify the minimum days the RMAN information is
stored in the control file before overwritten. The default value is 7
days. When using catalog, a smaller value should be chosen.
5
. starting RMAN
Sql代码
rman target /
rman target / nocatalog
rman target sys/change_on_install@orcl
rman target sys/change_on_install@orcl catalog rman/rman@catdb
rman target sys/change_on_install log=xxx.log append
rman target sys/change_on_install cmdfile=xxx.rcvrman target /
rman target / nocatalog
rman target sys/change_on_install@orcl
rman target sys/change_on_install@orcl catalog rman/rman@catdb
rman target sys/change_on_install log=xxx.log append
rman target sys/change_on_install cmdfile=xxx.rcv
6
. RMAN persistent settings
6.1 display settings
Sql代码
RMAN> showall;
RMAN> show controlfile autobackup;
RMAN> show retention policy;RMAN> show all;
RMAN> show controlfile autobackup;
RMAN> show retention policy;
6.2 configure settings
Sql代码
RMAN> configure retention policytorecovery windowof7 days;
RMAN> configure backup optimization on;
RMAN> configure defaultdevice typetodisk;
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format fordevice type diskto'%F';
RMAN> configure device type disk backup type tocompressed backupset parallelism 1;
RMAN> configure datafile backup copies fordevice type diskto1;
RMAN> configure archivelog backup copies fordevice type diskto1;
RMAN> configure channel device type disk maxpiecesize 1 G;
RMAN> configure maxsetsize tounlimited;
RMAN> configure encryption fordatabaseoff;
RMAN> configure encryption algorithm 'AES128';
RMAN> configure archivelog deletion policy tonone;
RMAN> configure snapshot controlfile nameto'D:\oracle\flash_recovery_area\sncfepcit.ora';RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure backup optimization on;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type disk to '%F';
RMAN> configure device type disk backup type to compressed backupset parallelism 1;
RMAN> configure datafile backup copies for device type disk to 1;
RMAN> configure archivelog backup copies for device type disk to 1;
RMAN> configure channel device type disk maxpiecesize 1 G;
RMAN> configure maxsetsize to unlimited;
RMAN> configure encryption for database off;
RMAN> configure encryption algorithm 'AES128';
RMAN> configure archivelog deletion policy to none;
RMAN> configure snapshot controlfile name to 'D:\oracle\flash_recovery_area\sncfepcit.ora';
If the control file autobackup is enabled, then RMAN automatically
backs up the control file and spfile in one of two circumstances:
- A successful backup is recorded in the RMAN repository
- A structural change to the database affects the contents of the control file
Control file autobackups are stored in the flash recovery area, unless otherwise specified.
6.3 reset settings to default value
Sql代码
RMAN> configure controlfile autobackup clear;
RMAN> configure retention policy clear;RMAN> configure controlfile autobackup clear;
RMAN> configure retention policy clear;
7. RMAN commands
7.1 backup commands
Sql代码
RMAN> backupdatabase;
RMAN> backup copy ofdatabase;
RMAN> backup ascompressed backupsetdatabase;
RMAN> backup asbackupset format''/BACKUP/df_%d_%s_%p.bus' tablespace users;
RMAN> backup databaseplus archivelogdeleteallinput;
RMAN> backup archivelog fromsequence=234deleteinput;
RMAN> backup tag='month_full_backup'datafile 1, 2, 3, 4;
RMAN> backup incremental level0database;
RMAN> backup incremental level1database;
RMAN> backup incremental level1 cumulativedatabase;
RMAN> run {
2> allocate channel c1 device type sbt;
3> allocate channel c2 device type sbt;
4> allocate channel c3 device type sbt;
5> backup incremental level= 0
6> format '/disk1/backup/df_%d_%s_%p.bak'
7> (datafile 1,4,5 channel c1)
8> (datafile 2,3,9 channel c2)
9> (datafile 6,7,8 channel c3);
10> altersystem archive logcurrent;
11> }RMAN> backup database;
RMAN> backup copy of database;
RMAN> backup as compressed backupset database;
RMAN> backup as backupset format ''/BACKUP/df_%d_%s_%p.bus' tablespace users;
RMAN> backup database plus archivelog delete all input;
RMAN> backup archivelog from sequence=234 delete input;
RMAN> backup tag='month_full_backup' datafile 1, 2, 3, 4;
RMAN> backup incremental level 0 database;
RMAN> backup incremental level 1 database;
RMAN> backup incremental level 1 cumulative database;
RMAN> run {
2> allocate channel c1 device type sbt;
3> allocate channel c2 device type sbt;
4> allocate channel c3 device type sbt;
5> backup incremental level = 0
6> format '/disk1/backup/df_%d_%s_%p.bak'
7> (datafile 1,4,5 channel c1)
8> (datafile 2,3,9 channel c2)
9> (datafile 6,7,8 channel c3);
10> alter system archive log current;
11> }
7.2 block change tracking
Sql代码
SQL>alterdatabaseenable block change tracking using file''/mydir/rman_change_track.f' reuse;
SQL> alterdatabasedisable block change tracking;SQL> alter database enable block change tracking using file ''/mydir/rman_change_track.f' reuse;
SQL> alter database disable block change tracking;
7.3 incrementally updating backups
Sql代码
RMAN> backupascopy incrementallevel0 datafile 1 tag'basecopy';
RMAN> backup incremental level1forrecoverofcopywithtag'basecopy'datafile 1;
RMAN> recover copy ofdatafile 1withtag'basecopy';RMAN> backup as copy incremental level 0 datafile 1 tag 'basecopy';
RMAN> backup incremental level 1 for recover of copy with tag 'basecopy' datafile 1;
RMAN> recover copy of datafile 1 with tag 'basecopy';
7.4 list commands
Sql代码
RMAN> list backupofdatabasesummary;
RMAN> list backup oftablespace system summary;
RMAN> list backup ofdatafile {n|'file_name'} summary;
RMAN> list backup ofdatabaseby{file|backup};
RMAN> list copy ofdatabase;RMAN> list backup of database summary;
RMAN> list backup of tablespace system summary;
RMAN> list backup of datafile {n|'file_name'} summary;
RMAN> list backup of database by {file|backup};
RMAN> list copy of database;
7.5 report commands
Sql代码
RMAN> reportschema;
RMAN> report need backup incremental 0 database;
RMAN> report need backup days 3;
RMAN> report need backup redundancy 2;
RMAN> report need backup recovery window of3 days;
RMAN> report obsolete redundancy 2;
RMAN> report obsolete recovery window of3 days;RMAN> report schema;
RMAN> report need backup incremental 0 database;
RMAN> report need backup days 3;
RMAN> report need backup redundancy 2;
RMAN> report need backup recovery window of 3 days;
RMAN> report obsolete redundancy 2;
RMAN> report obsolete recovery window of 3 days;
7.6 delete commands
Java代码
RMAN> delete noprompt expired copy;
RMAN> delete noprompt expired backup;
RMAN> delete noprompt obsolete;
RMAN> delete obsolete redundancy 2;
RMAN> delete obsolete recovery window of 3days;
RMAN> delete backupset 4;RMAN> delete noprompt expired copy;
RMAN> delete noprompt expired backup;
RMAN> delete noprompt obsolete;
RMAN> delete obsolete redundancy 2;
RMAN> delete obsolete recovery window of 3 days;
RMAN> delete backupset 4;
8. RMAN v$ views
Java代码
V$ARCHIVED_LOG
V$BACKUP_CORRUPTION
V$BACKUP_DEVICE
V$BACKUP_FILES
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$BACKUP_SPFILE
V$COPY_CORRUPTION
V$RMAN_CONFIGURATIONcome from :**.com/blog/344903