rman的简单使用: catalog的建立全备份保留备份策略删除过期备份
查看当前数据库的数据文件
SQL> select name from V$datafile;
NAME
/oracle/oraclei/oradata/testmysiteok/systemdbf
/oracle/oraclei/oradata/testmysiteok/undotbsdbf
/oracle/oraclei/oradata/testmysiteok/cwmlitedbf
/oracle/oraclei/oradata/testmysiteok/drsysdbf
/oracle/oraclei/oradata/testmysiteok/exampledbf
/oracle/oraclei/oradata/testmysiteok/indxdbf
/oracle/oraclei/oradata/testmysiteok/odmdbf
/oracle/oraclei/oradata/testmysiteok/toolsdbf
/oracle/oraclei/oradata/testmysiteok/usersdbf
/oracle/oraclei/oradata/testmysiteok/xdbdbf
/oracle/oradata/webdb_filedbf
NAME
/oracle/oradata/webdb_filedbf
/oracle/oradata/webdb_filedbf
/oracle/oradata/webdb_filedbf
rows selected
建立catalog表空间为back_up
SQL> create tablespace back_up datafile /oracle/oradata/catalogdbf size m;
Tablespace created
建立rman用户密码为rmanrman默认的表空间为back_up使用临时表空间temp
SQL> create user rman identified by rman default tablespace back_up temmporary tablespace temp;
create user rman identified by rman default tablespace back_up temmporary tablespace temp
*
ERROR at line :
ORA: missing or invalid option
SQL> create user rman identified by rman default tablespace back_up temporary tablespace temp;
User created
给rman用户授权
SQL> grant connectresourcerecovery_catalog_owner to rman;
Grant succeeded
SQL> quit
Disconnected from Oraclei Enterprise Edition Release bit Production
With the Partitioning OLAP and Oracle Data Mining options
JServer Release Production
连接或者创建catalog到表空间 back_up
bash$ rman
Recovery Manager: Release bit Production
Copyright (c) Oracle CorporationAll rights reserved
RMAN> connect catalog rman/rman;
connected to recovery catalog database
recovery catalog is not installed
RMAN> create catalog tablespace backup;
RMAN: ===========================================================
RMAN: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN: ===========================================================
RMAN: error encountered while parsing input commands
RMAN: syntax error: found backup: expecting one of: doublequotedstring identifier singlequotedstring
RMAN: at line column file: standard input
RMAN: ===========================================================
RMAN: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN: ===========================================================
RMAN: error encountered while parsing input commands
RMAN: syntax error: found ;: expecting one of: allocate alter backup beginline blockrecover catalog change connect copy create crosscheck configure duplicate debug delete drop exit endinline host { library list mount open print quit recover register release replace report renormalize reset restore resync rman run rpctest set setlimit sql spool startup shutdown send show test upgrade validate
RMAN: at line column file: standard input
RMAN> create catalog tablespace back_up;
recovery catalog created
RMAN> quit
Recovery Manager complete
连接到sid 为testmysiteok的 catalog上 并注册testmysiteok数据库
bash$ rmantarget testmysiteok catalog rman/rman
Recovery Manager: Release bit Production
Copyright (c) Oracle CorporationAll rights reserved
target database Password:
connected to target database: testmysiteOK (DBID=)
connected to recovery catalog database
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
全备份testmysiteok数据库
RMAN> backup full tag testmysiteok format /data/ora_backup/testmysiteok_%u_%s_%p database;
Starting backup at AUG
allocated channel: ORA_DISK_
channel ORA_DISK_: sid= devtype=DISK
channel ORA_DISK_: starting full datafile backupset
channel ORA_DISK_: specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/systemdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/undotbsdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/exampledbf
input datafile fno= name=/oracle/oradata/webdb_filedbf
input datafile fno= name=/oracle/oradata/webdb_filedbf
input datafile fno= name=/oracle/oradata/webdb_filedbf
input datafile fno= name=/oracle/oradata/webdb_filedbf
input datafile fno= name=/oracle/oradata/catalogdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/xdbdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/indxdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/usersdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/cwmlitedbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/drsysdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/odmdbf
input datafile fno= name=/oracle/oraclei/oradata/testmysiteok/toolsdbf
channel ORA_DISK_: starting piece at AUG
channel ORA_DISK_: finished piece at AUG
piece handle=/data/ora_backup/testmysiteok_grgroc__ comment=NONE
channel ORA_DISK_: backup set complete elapsed time: ::
Finished backup at AUG
设置保留最近的次备份
RMAN> configure retention policy to redundancy ;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY ;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY ;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
查看过期的备份
RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy
Report of obsolete backups and copies
Type KeyCompletion TimeFilename/Handle
Backup Set OCT
Backup Piece OCT/oracle/testmysiteokdbf
Archive LogSEP/oracle/OraHome/dbs/arch_dbf
查看所有备份
RMAN> list backup;
删除过期备份
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy
using channel ORA_DISK_
Deleting the following obsolete backups and copies:
Type KeyCompletion TimeFilename/Handle
Backup Set OCT
Backup Piece OCT/oracle/testmysiteokdbf
Archive LogSEP/oracle/OraHome/dbs/arch_dbf
Do you really want to delete the above objects (enter YES or NO)? y
deleted backup piece
backup piece handle=/oracle/testmysiteokdbf recid= stamp=
Deleted objects