ITPub博客

首页 > 数据库 > Oracle > 恢复目录(catalog)使用

恢复目录(catalog)使用

Oracle 作者:lllllcheng 时间:2016-02-27 16:40:28 0 删除 编辑
恢复目录适合生产环境的数据库比较多这样便于管理。单个数据库的话还要管理恢复目录就没必要了,当然注册了恢复目录也可以不选用。
环境:同一台机器两个数据库(enmoedu和cc)
1、创建恢复目录所有者默认表空间
SQL> create tablespace sy datafile '/u01/app/oracle/oradata/CC/sy01.dbf' size 50M;

Tablespace created.


2、创建恢复目录所有者
SQL> create user dd identified by dd temporary tablespace temp default tablespace sy quota unlimited on sy;

User created.
SQL> grant connect ,resource,recovery_catalog_owner to dd;

Grant succeeded.
3、创建恢复目录
[oracle@host9 ~]$ ramn catalog dd/dd@cc
bash: ramn: command not found
[oracle@host9 ~]$ rman catalog dd/dd@cc

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 16 23:43:10 2016

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

connected to recovery catalog database

RMAN> create catalog;

recovery catalog created

RMAN> exit


Recovery Manager complete.
4、注册目标数据库
1)在恢复目录中注册数据库
[oracle@host9 ~]$ rman target sys/oracle@PROD catalog dd/dd@cc

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 16 23:45:24 2016

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

connected to target database: ENMOEDU (DBID=160261980)
connected to recovery catalog database

RMAN> register database;

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

RMAN> exit


Recovery Manager complete.
2)查看已注册的数据库
[oracle@host9 ~]$ sqlplus dd/dd@cc

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 16 23:46:20 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from rc_database;

    DB_KEY  DBINC_KEY        DBID NAME      RESETLOGS_CHANGE# RESETLOGS
---------- ---------- ---------- -------- ----------------- ---------
     1        2  160261980 ENMOEDU         925702 14-JAN-16

3)从恢复目录中注销目标数据库
[oracle@host9 ~]$ rman target sys/oracle@PROD catalog dd/dd@cc

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 16 23:47:40 2016

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

connected to target database: ENMOEDU (DBID=160261980)
connected to recovery catalog database

RMAN> unregister database;

database name is "ENMOEDU" and DBID is 160261980

Do you really want to unregister the database (enter YES or NO)? yes
database unregistered from the recovery catalog

RMAN> exit


Recovery Manager complete.
[oracle@host9 ~]$ sqlplus dd/dd@cc

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 16 23:49:05 2016

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from rc_databse;
select * from rc_databse
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> select * from database;
select * from database
              *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> !
5、将其他备份导入到恢复目录
[oracle@host9 ~]$ rman target sys/oracle@PROD catalog dd/dd@cc

Recovery Manager: Release 11.2.0.4.0 - Production on Sat Jan 16 23:54:38 2016

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

connected to target database: ENMOEDU (DBID=160261980)
connected to recovery catalog database

RMAN> catalog backuppiece '/u01/app/oracle/fast_recovery_area/PROD/backupset/2016_01_16/o1_mf_ncnnf_TAG20160116T225555_c9npjd0q_.bkp';

cataloged backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/PROD/backupset/2016_01_16/o1_mf_ncnnf_TAG20160116T225555_c9npjd0q_.bkp RECID=6 STAMP=901324605

RMAN> catalog recovery area noprompt; 如果使用了快速恢复区,可以使用这个命令一次完成导入。

searching for all files in the recovery area
no files found to be unknown to the database

List of files in Recovery Area not managed by the database
==========================================================
File Name: /u01/app/oracle/fast_recovery_area/PROD/control02.ctl
  RMAN-07526: Reason: File is not an Oracle Managed File

number of files not managed by recovery area is 1, totaling 9.56MB

6、备份导入恢复目录后应该备份恢复目录
Recovery Manager complete.
[oracle@host9 ~]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Jan 17 00:02:39 2016

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

connected to target database: ENMOEDU (DBID=160261980)

RMAN> backup database plus archivelog;


Starting backup at 17-JAN-16
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=5 RECID=1 STAMP=901131695
input archived log thread=1 sequence=6 RECID=23 STAMP=901131731
input archived log thread=1 sequence=7 RECID=17 STAMP=901131731
input archived log thread=1 sequence=8 RECID=18 STAMP=901131731
input archived log thread=1 sequence=9 RECID=19 STAMP=901131731
input archived log thread=1 sequence=10 RECID=20 STAMP=901131731
input archived log thread=1 sequence=11 RECID=21 STAMP=901131731
input archived log thread=1 sequence=12 RECID=22 STAMP=901131731
input archived log thread=1 sequence=13 RECID=26 STAMP=901131731
input archived log thread=1 sequence=14 RECID=24 STAMP=901131731
input archived log thread=1 sequence=15 RECID=25 STAMP=901131731
input archived log thread=1 sequence=16 RECID=27 STAMP=901131731
input archived log thread=1 sequence=17 RECID=28 STAMP=901131731
input archived log thread=1 sequence=18 RECID=4 STAMP=901131695
input archived log thread=1 sequence=19 RECID=3 STAMP=901131695
input archived log thread=1 sequence=20 RECID=2 STAMP=901131695
input archived log thread=1 sequence=21 RECID=5 STAMP=901131695
input archived log thread=1 sequence=22 RECID=6 STAMP=901131695
input archived log thread=1 sequence=23 RECID=7 STAMP=901131695
input archived log thread=1 sequence=24 RECID=8 STAMP=901131695
input archived log thread=1 sequence=25 RECID=9 STAMP=901131696
input archived log thread=1 sequence=26 RECID=10 STAMP=901131696
input archived log thread=1 sequence=27 RECID=13 STAMP=901131696
input archived log thread=1 sequence=28 RECID=12 STAMP=901131696
input archived log thread=1 sequence=29 RECID=11 STAMP=901131696
input archived log thread=1 sequence=30 RECID=14 STAMP=901131696
input archived log thread=1 sequence=31 RECID=15 STAMP=901131696
input archived log thread=1 sequence=32 RECID=16 STAMP=901131698
input archived log thread=1 sequence=33 RECID=29 STAMP=901131731
input archived log thread=1 sequence=34 RECID=30 STAMP=901132090
input archived log thread=1 sequence=35 RECID=31 STAMP=901132090
input archived log thread=1 sequence=36 RECID=32 STAMP=901132167
input archived log thread=1 sequence=37 RECID=33 STAMP=901136793
input archived log thread=1 sequence=38 RECID=34 STAMP=901139311
input archived log thread=1 sequence=39 RECID=35 STAMP=901139315
input archived log thread=1 sequence=40 RECID=36 STAMP=901144816
input archived log thread=1 sequence=41 RECID=37 STAMP=901193321
input archived log thread=1 sequence=42 RECID=38 STAMP=901193324
input archived log thread=1 sequence=43 RECID=39 STAMP=901235706
input archived log thread=1 sequence=44 RECID=40 STAMP=901280070
input archived log thread=1 sequence=45 RECID=41 STAMP=901280073
input archived log thread=1 sequence=46 RECID=42 STAMP=901281704
input archived log thread=1 sequence=47 RECID=43 STAMP=901285469
input archived log thread=1 sequence=48 RECID=44 STAMP=901285473
input archived log thread=1 sequence=49 RECID=45 STAMP=901289280
input archived log thread=1 sequence=50 RECID=46 STAMP=901289284
input archived log thread=1 sequence=51 RECID=48 STAMP=901289701
input archived log thread=1 sequence=52 RECID=60 STAMP=901290291
input archived log thread=1 sequence=53 RECID=62 STAMP=901301449
input archived log thread=1 sequence=54 RECID=64 STAMP=901301453
input archived log thread=1 sequence=55 RECID=66 STAMP=901304493
input archived log thread=1 sequence=56 RECID=67 STAMP=901304497
input archived log thread=1 sequence=57 RECID=70 STAMP=901304857
input archived log thread=1 sequence=58 RECID=72 STAMP=901306745
input archived log thread=1 sequence=59 RECID=74 STAMP=901306749
input archived log thread=1 sequence=60 RECID=76 STAMP=901306764
input archived log thread=1 sequence=61 RECID=78 STAMP=901324975
channel ORA_DISK_1: starting piece 1 at 17-JAN-16
channel ORA_DISK_1: finished piece 1 at 17-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD/backupset/2016_01_17/o1_mf_annnn_TAG20160117T000255_c9ntfhpf_.bkp tag=TAG20160117T000255 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 17-JAN-16

Starting backup at 17-JAN-16
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=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/ts01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 17-JAN-16
channel ORA_DISK_1: finished piece 1 at 17-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD/backupset/2016_01_17/o1_mf_nnndf_TAG20160117T000258_c9ntfm0w_.bkp tag=TAG20160117T000258 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 17-JAN-16

Starting backup at 17-JAN-16
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=62 RECID=79 STAMP=901324993
channel ORA_DISK_1: starting piece 1 at 17-JAN-16
channel ORA_DISK_1: finished piece 1 at 17-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD/backupset/2016_01_17/o1_mf_annnn_TAG20160117T000313_c9ntg21g_.bkp tag=TAG20160117T000313 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 17-JAN-16

Starting Control File Autobackup at 17-JAN-16
piece handle=/u01/app/oracle/fast_recovery_area/PROD/autobackup/2016_01_17/o1_mf_n_901324995_c9ntg360_.bkp comment=NONE
Finished Control File Autobackup at 17-JAN-16

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

下一篇: dump表的数据块
请登录后发表评论 登录
全部评论

注册时间:2015-12-02

  • 博文量
    41
  • 访问量
    119980