一、如何创建recovery catlog
dbca-->catdb
在catdb建立表空间-->catlog owner的默认永久表空间。
export ORACLE_SID=catdb
sqlplus / as sysdba
CREATE TABLESPACE rcat_ts DATAFILE '/u01/app/oracle/rcat_ts01.dbf' SIZE 15M;
rcat_ts 存储从控制文件复制过来的信息
CREATE USER rcowner IDENTIFIED BY oracle
TEMPORARY TABLESPACE temp
DEFAULT TABLESPACE rcat_ts
QUOTA UNLIMITED ON rcat_ts;
授权:RECOVERY_CATALOG_OWNER
grant RECOVERY_CATALOG_OWNER to rcowner ;
用catalog owner连接
本地:export ORACLE_SID=catdb
rman catalog rcowner/oracle
或者:rman catalog rcowner/oracle@catdb
创建catalog
create catalog ;
成功后执行
RMAN> list incarnation;
没有结果:当前catalog没有数据库注册
连接目标数据库和catalog数据库
rman target sys/oracle@orcl
RMAN> connect catalog rcowner/oracle@catdb
或者
rman target sys/oracle@orcl catalog rcowner/oracle@catdb
连接目标数据库orcl ,catalog数据库 catdb
成功连接目标和catalog后使用注册
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
117 134 ORCL 1328805276 PARENT 1 13-AUG-09
117 118 ORCL 1328805276 CURRENT 754488 03-DEC-12
rman target sys/oracle@orcl catalog rcowner/oracle@catdb
RMAN> unregister database ;
database name is "ORCL" and DBID is 1336315545
Do you really want to unregister the database (enter YES or NO)? YES
RMAN> list incarnation;
二、管理catlog
1、将额外的备份文件加入catlog
catlog backuppiece '/u01/app/oracle/user04.bak'
catlog start with '/u01/app/oracle' (目录下的所有备份文件加入)
2、同步catlog信息
resync catlog
3、存储脚本
catlog数据库储存的脚本可以运行在所有的已经注册的数据库上
脚本类型
create script scriptname
{
<rman command>
}
CREATE SCRIPT datafile_4_backup
COMMENT 'only backup datafile 4'
{
BACKUP datafile 4;
}
create glocal script scriptname
{
<rman command>
}
CREATE GLOBAL SCRIPT datafile_4_backup
COMMENT 'only backup datafile 4'
{
BACKUP datafile 4;
}
利用已经存在的脚本创建:
CREATE SCRIPT full_backup
FROM FILE '/tmp/my_script_file.txt';
替换脚本:
REPLACE GLOBAL SCRIPT global_full_backup
COMMENT 'A script for full backup to be used with any database'
{
BACKUP AS BACKUPSET DATABASE PLUS ARCHIVELOG;
}
运行脚本:
RUN
{
EXECUTE SCRIPT full_backup;
}
RUN
{
EXECUTE GLOBAL SCRIPT global_full_backup;
}
打印脚本:print global script names
PRINT SCRIPT full_backup
TO FILE '/tmp/my_script_file.txt';
删除脚本:delete script scriptname
显示所有的本地脚本:list script names
显示所有的全局脚本:list global script names
显示所有的基本:LIST ALL SCRIPT NAMES;
转载于:https://blog.51cto.com/carefree/1156612