oracle_backup

Physical backups are the foundation of any sound backup and recovery strategy.
Logical backups are a useful supplement to physical backups in many circumstances
but are not sufficient protection against data loss without physical backups.


only the following typically require DBA intervention and
data recovery: media failure, user errors, and application errors.

Incremental backups
An incremental backup stores only blocks changed since a previous backup.
Thus, they provide more compact backups and faster recovery, thereby reducing
the need to apply redo during datafile media recovery. If you enable block
change tracking, then you can improve performance by avoiding full scans of
every input datafile. You use the BACKUP INCREMENTAL command to perform
incremental backups.
■ Block media recovery
You an repair a datafile with only a small number of corrupt data blocks without
taking it offline or restoring it from backup. You use the RECOVER command to
perform. block media recovery.
■ Unused block compression
In unused block compression, RMAN can skip data blocks that have never been
used and, in some cases, used blocks that are currently unused.
■ Binary compression
A binary compression mechanism integrated into Oracle Database reduces the
size of backups.
■ Encrypted backups
RMAN uses backup encryption capabilities integrated into Oracle Database to
store backup sets in an encrypted format. To create encrypted backups on disk, the
database must use the Advanced Security Option. To create encrypted backups
directly on tape, RMAN must use the Oracle Secure Backup SBT interface, but
does not require the Advanced Security Option.

The logical-level flashback features of Oracle
do not depend on RMAN and are available whether or not RMAN is part of your
backup strategy.

开启rman

% rman TARGET / # operating system authentication
% rman TARGET SYS@prod NOCATALOG # RMAN prompts for SYS password
% rman TARGET / CATALOG rco@catdb # RMAN prompts for rco password

指定rman的输出位置(例如日志)

在打开rman的命令后面加入LOG /tmp/rman.log

例如:% rman TARGET SYS@prod  log E:\app\lily\oradata\rmanlog\rman.log

both input and output : % rman | tee rman.log

If you are going to use RMAN to connect to an unmounted database and mount the
database later while RMAN is still connected, then set the NLS_LANG environment
variable so that it also specifies the character set used by the database.

CHECKSYNTAX用于不执行,检查语法是否有错误

you must grant the RECOVERY_CATALOG_OWNER role to the catalog schema owner

You must use a password file if you are
connecting remotely as SYSDBA with a net service name.

Connecting to Target and Catalog Databases from the System Prompt
% rman TARGET SYS@prod CATALOG rco@catdb

rco是有recover_catalog_owner角色的用户,catdb是recovery catalog database

RMAN> CONNECT TARGET /
RMAN> CONNECT CATALOG rco@catdb

RMAN> CONNECT TARGET /
RMAN> CONNECT AUXILIARY SYS@aux

Diagnosing Recovery Catalog Connection Problems
When RMAN connects to the recovery catalog database, it does not use the SYSDBA
privilege. So, when you are using SQL*Plus to diagnose connection problems to the
recovery catalog database, you must enter the database connect string exactly as it was
entered into RMAN. Do not specify AS SYSDBA.

% rman PIPE abc TARGET /
RMAN opens the two pipes in the target database: ORA$RMAN_ABC_IN, which RMAN
uses to receive user commands, and ORA$RMAN_ABC_OUT, which RMAN uses to send
all output back to RMAN. All messages on both the input and output pipes are of type

DBMS_PIPE.CREATE_PIPE.(if it does not already exist
under the name ORA$RMAN_pipe_IN)

% rman PIPE abc TARGET / TIMEOUT 60

input pipe
by using DBMS_PIPE.PACK_MESSAGE and DBMS_PIPE.SEND_MESSAGE

output pipe by using DBMS_PIPE.RECEIVE_
MESSAGE and DBMS_PIPE.UNPACK_MESSAGE.
VARCHAR2.

Note: If multiple RMAN sessions can run against the target
database, then you must use unique pipe names for each RMAN
session. The DBMS_PIPE.UNIQUE_SESSION_NAME function is one
method that you can use to generate unique pipe names.

To show the current configuration for a database:show all

Optionally, use the CONFIGURE ... CLEAR command to return any
configuration to its default value,

Commands to Configure the Default Device Type

CONFIGURE DEFAULT DEVICE TYPE TO DISK

CONFIGURE DEFAULT DEVICE TYPE TO SBT

Note that you can always override the default device by using the DEVICE TYPE
clause of the BACKUP command, as shown in the following examples:
BACKUP DEVICE TYPE sbt DATABASE;
BACKUP DEVICE TYPE DISK DATABASE;

RMAN can write an image copy only to disk, the backup type for tape can only be a backup set.

The following examples configure the backup type for disk backups to copies and
backup sets:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY; # image copies
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET; # uncompressed
The following examples configure compression for backup sets:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
CONFIGURE DEVICE TYPE sbt BACKUP TYPE TO COMPRESSED BACKUPSET;

if you use CONFIGURE CHANNEL to specify generic channel settings for a
device, any previous settings are discarded, even if the settings are not in conflict.

 

example, after the second CONFIGURE CHANNEL command, which specifies only the
FORMAT for configured disk channels, the MAXPIECESIZE for the disk channel is
returned to its default value:
CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2G;
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT /tmp/%U;

You can also specify an ASM disk location, as shown in the following example:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '+dgroup1';

Configuring Parallelism for an SBT Device
RMAN> CONFIGURE DEVICE TYPE sbt PARALLELISM 2;

If you manually allocate a channel during a job, then RMAN disregards any
configured channel settings.

You can enable the autobackup feature by running the following command:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
You can disable the feature by running the following command:
CONFIGURE CONTROLFILE AUTOBACKUP OFF;

controlfile foermat :c-IIIIIIIIII-YYYYMMDD-QQ, with the placeholders defined as follows:
■ IIIIIIIIII stands for the DBID.
■ YYYYMMDD is a time stamp of the day the backup is generated.
■ QQ is the hex sequence that starts with 00 and has a maximum of FF.c

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT
FOR DEVICE TYPE DISK TO '?/oradata/cf_%F';

set can also overide configure

The following example shows the channel syntax, where pathname is the absolute
filename of the library:
CONFIGURE CHANNEL DEVICE TYPE sbt
PARMS 'SBT_LIBRARY=pathname';

Linux and UNIX, the default library filename is $ORACLE_HOME/lib/libobk.so,
with the extension name varying according to platform. .so, .sl on HP-UX, .a on
AIX, and so on. On Windows the default library location is %ORACLE_
HOME%\bin\orasbt.dll.

Example 5–5 PARMS Setting for Oracle Secure Backup
CONFIGURE CHANNEL DEVICE TYPE 'SBT_TAPE'
PARMS 'ENV=(OB_MEDIA_FAMILY=datafile_mf)';

To test channel allocation on the media manager:
1. Start RMAN and connect to a target database and a recovery catalog (if used).
2. Run the ALLOCATE CHANNEL command with the PARMS required by your media
management software.
The following RUN command shows sample vendor-specific PARMS settings:
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS 'SBT_LIBRARY=/mydir/lib/libobk.so,
ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)';
}
3. Examine the RMAN output.

Example 5–6 Backing Up the Server Parameter File to Tape
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS 'SBT_LIBRARY=/mydir/lib/libobk.so,
ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)';
BACKUP SPFILE;
# If your database does not use a server parameter file, use:
# BACKUP CURRENT CONTROLFILE;
}

Example 5–7 Restoring the Server Parameter File from Tape
RUN
{ALLOCATE CHANNEL c1 DEVICE TYPE sbt
PARMS 'SBT_LIBRARY=/mydir/lib/libobk.so,
ENV=(OB_DEVICE=drive1,OB_MEDIA_FAMILY=datafile_mf)';
RESTORE SPFILE TO PFILE '/tmp/test_restore.f';
# If your database does not use a server parameter file, use:
# RESTORE CURRENT CONTROLFILE;
}

Optionally, check your channel configuration by running the following command:
SHOW CHANNEL FOR DEVICE TYPE sbt;

in an Oracle Real Application Clusters (Oracle RAC)
database, all instances must have the same values for these initialization parameters.

You must set DB_RECOVERY_FILE_DEST_SIZEbefore DB_
RECOVERY_FILE_DEST.

DB_RECOVERY_FILE_DEST_SIZE Yes

DB_RECOVERY_FILE_DEST Yes

DB_FLASHBACK_RETENTION_TARGET No

Run the BACKUP INCREMENTAL command.
The following example creates a level 0 incremental backup to serve as a base for
an incremental backup strategy:
BACKUP INCREMENTAL LEVEL 0 DATABASE;
The following example creates a level 1 cumulative incremental backup:
BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;
The following example creates a level 1 differential incremental backup:
BACKUP INCREMENTAL LEVEL 1 DATABASE;

RECOVER COPY OF DATABASE
WITH TAG 'incr_update';
BACKUP
INCREMENTAL LEVEL 1
FOR RECOVER OF COPY WITH TAG 'incr_update'
DATABASE;

You can use the VALIDATE command to confirm that all database files exist, are in
their correct location, and are free of physical corruption. The CHECK LOGICAL option
also checks for logical block corruption.

Run the LIST BACKUP and LIST COPY commands to display information about
backups and datafile copies listed in the repository.

Option Example Explanation
BY BACKUP LIST BACKUP OF
DATABASE BY BACKUP
Organizes the output by backup set. This is the
default mode of presentation.
BY FILE LIST BACKUP BY FILE Lists the backups according to which file was
backed up.
SUMMARY LIST BACKUP SUMMARY Displays summary output. By default, the output
is VERBOSE.

EXPIRED LIST EXPIRED
COPY
Lists backups that are recorded in the RMAN repository
but that were not present at the expected location on disk
or tape during the last CROSSCHECK command. An
expired backup may have been deleted by an operating
system utility.
RECOVERABLE LIST BACKUP
RECOVERABLE
Lists datafile backups or copies that have status
AVAILABLE in the RMAN repository and that can be

REPORT Options
Option Example Explanation
NEED BACKUP REPORT NEED
BACKUP
DATABASE
Shows which files need backing up under current
retention policy. Use optional REDUNDANCY and
RECOVERY WINDOW parameters to specify different
criteria.
OBSOLETE REPORT
OBSOLETE
Lists backups that are obsolete under the configured
backup retention policy. Use the optional
REDUNDANCY and RECOVERY WINDOW parameters to
override the default.

SCHEMA REPORT SCHEMA Reports the tablespaces and datafiles in the database
at the current time (default) or a different time.
UNRECOVERABLE REPORT
UNRECOVERABLE
Lists all datafiles for which an unrecoverable
operation has been performed against an object in
the datafile since the last backup of the datafile.

CROSSCHECK BACKUP;
CROSSCHECK COPY;

DELETE OBSOLETE;
restored and recovered.

LIST BACKUP OF DATABASE;
LIST COPY OF DATAFILE 1, 2;
LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 10;
LIST BACKUPSET OF DATAFILE 1;

You can run the LIST FAILURE command to show all known failures. If failures exist,
then run the ADVISE FAILURE command in the same session to determine manual
and automated repair options.

After running LIST FAILURE and ADVISE FAILURE in an RMAN session, you can
run REPAIR FAILURE to execute a repair option.

FLASHBACK DATABASE TO SCN 861150;
FLASHBACK DATABASE
TO RESTORE POINT BEFORE_CHANGES;
FLASHBACK DATABASE TO TIME
"TO_DATE('06/20/07','MM/DD/YY')";

To preview a database restore and recovery: RESTORE DATABASE PREVIEW SUMMARY;

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';

SET NEWNAME FOR DATAFILE '/disk1/oradata/prod/users01.dbf'
TO '/disk2/users01.dbf';
RESTORE TABLESPACE users;
SWITCH DATAFILE ALL; # update control file with new filenames
RECOVER TABLESPACE users;

RMAN> SQL 'ALTER TABLESPACE users ONLINE';

The following RMAN command recovers all corrupted blocks:
RMAN> RECOVER CORRUPTION LIST;
You can also recover individual blocks, as shown in the following example:
RMAN> RECOVER DATAFILE 1 BLOCK 233, 235 DATAFILE 2 BLOCK 100 TO 200;

SBT devices are tape
libraries and tape drives.

For
the BACKUP command, RMAN allocates only the type of channel required to back up
to the specified media. For the RESTORE command and RMAN maintenance
commands, RMAN allocates all necessary channels for the device types required to
execute the command.

Each channel may back up more than one file, but unless a
multisection backup is performed, no file is backed up by more than one channel.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25155154/viewspace-687971/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25155154/viewspace-687971/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值