RMAN常用設定[final]

tolywang發表於2010-09-28

 

1. 登陸RMAN, 不做介紹。


2. 常用命令


① 要使用作業系統命令:

RMAN> host;

Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\wangxiaoqi>

與SqlPlus中不同的是,RMAN中host後面必須加“;”

② 使用SQL命令:

RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG ALL';

但是使用SQL命令的限制比較多,主要是針對資料庫級的操作,很多的SQL語句都是無法使用的
因此最好的方法是先host登入到OS,再sqlplus進入SQL:

RMAN> host;

Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\wangxiaoqi>sqlplus wangxiaoqi/wangxiaoqi

SQL*Plus: Release 9.2.0.1.0 - Production on Thu Sep 18 14:30:03 2008

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production

SQL>


3、 首先列出所有指標:

RMAN> show all;
using target database controlfile 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; # 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 SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\ORA92\DATABASE\SNCFDODO.ORA';# default


4、 配置自動通道數:

RMAN> show device type;

RMAN configuration parameters are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default

RMAN> configure device type disk parallelism 2; --表示並行數

new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

 指定在以後的備份與恢復中,將採用並行度為2,同時開啟2個通道進行備份與恢復,當然也可以在run中指定通道來決定備份與恢復的並行程度。並行的數目決定了開啟通道的個數。如果指定了通道配置,將採用指定的通道,如果沒有指定通道,將採用預設通道配置。有點兒繞是吧,我來給你白話一把。


 預設情況下,自動分配通道的並行度為1,如果你透過設定PARALLELISM設定了並行通道為2,那麼在run塊中,如果你沒有單獨透過ALLOCATE CHANNEL命令指定通道,它會預設使用2條並行通道,如果你在run命令塊中指定了數個ALLOCATE CHANNEL,那麼rman在執行備份命令時會以你設定的channel為準,而不管configure中配置了多少個並行通道。需要注意的一點是,在backup命令中有一個FILESPERSET引數,該引數是指rman建立的每個備份集中所能包含的備份片段(即磁碟檔案)的最大數,該引數預設值為64,如果在執行backup命令時沒有指定該引數值,那麼rman會僅使用第一個通道來執行備份,其它通道將處於空閒狀態。關於通道數與FILESPERSET值之間也有一個大小關係,邏輯稍顯複雜這些就不多廢話了,總之一條,filesperset值不要小於你設定的通道數。

RMAN> show device type;

RMAN configuration parameters are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

若要清除對通道數的設定(其它引數同):

RMAN> configure device type disk clear;

old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

 

5、制定自動通道預設裝置:

RMAN> show default device type;

RMAN configuration parameters are:
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default

RMAN> configure default device type to sbt; --磁帶備份

new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure default device type clear; --還原預設設定

old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
RMAN configuration parameters are successfully reset to default value
starting full resync of recovery catalog
full resync complete

 

6、配置磁碟:

RMAN> show channel;

RMAN configuration parameters are:
RMAN configuration has no stored or default parameters

RMAN> configure channel device type disk format 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';

new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure channel 2 device type disk format 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';

new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> show channel;

RMAN configuration parameters are:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';

注:%t代替時間戳;%s代替備份組號;%p代替備份片號

取消:

RMAN> configure channel 2 device type disk clear;

old RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';
old RMAN configuration parameters are successfully deleted
starting full resync of recovery catalog
full resync complete

 

7、控制檔案配置:

啟動控制檔案的自動備份:

RMAN> configure controlfile autobackup on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> show controlfile autobackup;

RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

設定控制檔案、伺服器引數檔案備份檔案格式路徑:

RMAN> configure controlfile autobackup format for device type disk to 'D:\oracle
\oradata\dodo\rmanback\ctl_%F'; --F必須大寫

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\oracle\orada
ta\dodo\rmanback\ctl_%F';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

 

8、儲存策略:

儲存策略分兩種

時間策略:決定至少有一個備份能恢復到指定的日期

RMAN> configure retention policy to recovery window of 3 days;

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

注:保證至少有一個備份能恢復到3天前的時間點上,之前備份標註為obsolete

冗餘策略:決定至少有幾個冗餘的備份:
RMAN> configure retention policy to redundancy 3;

old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

注:至少需要有3個冗餘備份,若多於3個,則以前備份標記為obsolete

取消策略:

RMAN> configure retention policy to none;

檢視策略:

RMAN> show retention policy

RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

注:可以用 RMAN> report obsolete; 來查詢當前的obsolete備份。


9、備份最佳化設定:

開啟備份最佳化:
RMAN> CONFIGURE BACKUP OPTIMIZATION ON;

關閉備份最佳化:
RMAN> CONFIGURE BACKUP OPTIMIZATION OFF;


具體最佳化機制比較複雜,需要注意以下兩點:
①type只能選一種,不能disk和sbt都選
②BACKUP DATABASE或BACKUP ARCHIVELOG命令中帶有ALL或LIKE引數

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-675024/,如需轉載,請註明出處,否則將追究法律責任。

相關文章