catalog备份数据库及RMAN存储脚本

环境说明:


提前配置好两个库的监听与tnsnames.ora
IP:10.100.25.13 为目标数据库  
IP:10.100.25.14 为恢复目录数据库(catalog database)


以下操作全部都在恢复目录数据库下执行:


1.为恢复目录创建一个表空间,表空间名称是 catalogts。用户名是catalogdemo 密码是
oracle。给这个用户赋予恢复目录拥有者权限。


SQL> create tablespace catalogts datafile'/home/oracle/app/oradata/catalog01.dbf' size 50m autoextend on;


Tablespace created.


SQL> create user catalogdemo identified by oracle default tablespace catalogts quota unlimited on catalogts;


User created.


SQL> grant recovery_catalog_owner to catalogdemo;


Grant succeeded.




2.使用RMAN用catalogdemo用户连接到恢复目录数据库。在 catalogts 表空间中创建恢复目录。


[oracle@11g ~]$ rman catalog catalogdemo/oracle@10.100.25.14:1521/orcl


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 4 14:54:43 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to recovery catalog database


RMAN> create catalog tablespace catalogts;


recovery catalog created


3.使用RMAN,连接到目标数据库和恢复目录数据库。


[oracle@11g ~]$ rman target sys/oracle@10.100.25.13:1521/orcl catalog catalogdemo/oracle@10.100.25.14:1521/orcl


Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 4 14:56:21 2014


Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.


connected to target database: ORCL (DBID=1388303183)
connected to recovery catalog database


5.在恢复目录中注册目标数据库,执行resync catalog 命令来同步控制文件和恢复目录。


RMAN> register database;


database registered in recovery catalog
starting full resync of recovery catalog
full resync complete


RMAN> resync 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
------- ------- -------- ---------------- --- ---------- ----------
2       21      ORCL     1388303183       PARENT  1          15-AUG-09
2       4       ORCL     1388303183       CURRENT 945184     09-OCT-14




RMAN> backup database;


Starting backup at 04-DEC-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=52 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oradata/orcl/ogg01.dbf
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/home/oracle/app/oradata/orcl/tbtb01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/15ppb1kf_1_1 tag=TAG20141204T151527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:38
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/16ppb1pd_1_1 tag=TAG20141204T151527 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-DEC-14


——————————————————————————————————————————————————
--  检查备份是否存在于目标数据库相应位置    (目标数据库执行)


[oracle@11g dbs]$ pwd
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@11g dbs]$ ll
total 1200476
-rw-r-----. 1 oracle oinstall 1209679872 Dec  4 15:17 15ppb1kf_1_1
-rw-r-----. 1 oracle oinstall    9830400 Dec  4 15:18 16ppb1pd_1_1




——————————————————————————————————————————————————










catalog RMAN存储脚本


脚本的分类
    local : 在rman连接的目标数据库下创建的脚本,此类脚本仅仅适用于当前目标数据库。即是针对特定的数据库创建的rman脚本
    global : 能够在恢复目录注册的任意目标数据库中执行
    如:create global script XXXX comment 'A script for full backup to be used with any database' {。。。。}


a:  创建rman本地存储脚本
RMAN> create script whole_backup { backup database; }


created script whole_backup


b:执行rman本地存储脚本
RMAN> run { execute  script whole_backup; }


executing script: whole_backup


Starting backup at 04-DEC-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/home/oracle/app/oradata/orcl/ogg01.dbf
input datafile file number=00001 name=/home/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00002 name=/home/oracle/app/oradata/orcl/sysaux01.dbf
input datafile file number=00005 name=/home/oracle/app/oradata/orcl/tbtb01.dbf
input datafile file number=00003 name=/home/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/home/oracle/app/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/17ppb2rh_1_1 tag=TAG20141204T153617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:56
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-DEC-14
channel ORA_DISK_1: finished piece 1 at 04-DEC-14
piece handle=/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/18ppb34q_1_1 tag=TAG20141204T153617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 04-DEC-14


c:  查看当前恢复目录内的脚本
list [global | all] script names
       
RMAN> list script names;


d:  更新脚本
    replace [global] script scrip_name {....}
    replace [global] script script_name from file '<dir>'  --从文件更新脚本


RMAN> replace  script whole_backup { allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog  delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2; }2> 3> 4> 5> 6> 7> 


replaced script whole_backup


e:  查看脚本内容
RMAN> print script whole_backup;


printing stored script: whole_backup
{ allocate channel ch1 type disk;
allocate channel ch2 type disk;
backup incremental level 0 database plus archivelog  delete input
format '/home/oracle/rmanbak/db_%d_%U'
tag=db_inc_0;
release channel ch1;
release channel ch2; }


f: 删除脚本
delete [global] script script_name


OK,转载请标明出处。

posted on 2017-01-04 22:18  张冲andy  阅读(455)  评论(0编辑  收藏  举报

导航