【備份恢復】RMAN catalog 恢復目錄資料庫

不一樣的天空w發表於2016-10-16

MAN catalog恢復目錄:

當沒有恢復目錄的時候,RMAN相關的備份資訊,比如歸檔路徑、備份集路徑等均存在目標資料庫的控制檔案,但是控制檔案並不能無限增長,而且控制檔案也不僅僅是用來儲存與備份相關的資訊,因此RMAN也有一個專門存放備份資訊的地方。當待備份的資料庫註冊到恢復目錄之後,RMAN相關的資訊除了儲存在控制檔案中外(只儲存一部分),更加詳細的資訊就被存在恢復目錄中。

注意:不要將恢復目錄資料庫放到目標資料庫中。

1.1.   建立恢復目錄所有者預設表空間

SYS@ORA11GR2>create tablespace ts_catalog datafile '/u01/app/oracle/oradata/ORA11GR2/ts_catalog.dbf' size 15m;

 

Tablespace created.

1.2.   建立恢復目錄所有者

——建立使用者rcowner並授予RECOVERY_CATALOG_OWNER角色

SYS@ORA11GR2>create user rcowner identified by oracle temporary tablespace temp default tablespace ts_catalog quota unlimited on ts_catalog;

 

User created.

 

SYS@ORA11GR2>grant recovery_catalog_owner to rcowner;

 

Grant succeeded.

 

——回到作業系統建立本庫自己tnsnames.ora

[oracle@wang ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/

[oracle@wang admin]$ ls

listener.ora  samples  shrept.lst

[oracle@wang admin]$ vi tnsnames.ora

ora=

  (description=

   (address=(protocol=tcp)(host=wang)(port=1521))

   (connect_data=

   (service_name=ORA11GR2)))

"tnsnames.ora" [New] 5L, 118C written

[oracle@wang admin]$

——測試tns

[oracle@wang admin]$ tnsping ora

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 28-SEP-2016 23:35:29

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

Used parameter files:

Used TNSNAMES adapter to resolve the alias

Attempting to contact (description= (address=(protocol=tcp)(host=wang)(port=1521)) (connect_data= (service_name=ORA11GR2)))

OK (50 msec)

[oracle@wang admin]$

1.3.   建立恢復目錄

[oracle@wang admin]$ rman catalog rcowner/oracle@ora

(登入恢復目錄資料庫)

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Sep 28 23:38:37 2016

 

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

 

connected to recovery catalog database

 

——建立恢復目錄

RMAN> create catalog;

 

recovery catalog created

 

  create catalog的動作是在rcowner使用者下建立了恢復目錄相關的表,表的預設表空間使用的就是使用者的預設表空間,如果,相關表指定其他表空間,那麼在執行建立的時候加上指定表空間名稱create catalog tablespacets_name;

1.4.   註冊目標資料庫

1)   在恢復目錄中註冊目標資料庫

[oracle@wang ~]$ rman target / catalog rcowner/oracle@ora

(此步驟我是註冊本地的資料庫到恢復目錄中去)

【當要註冊目標資料庫到遠端恢復目錄中去時,1.要配置tns連線網路;2.執行rman target sys/oracle@ora11gr2 catalog rcowner/oracle@orcl,使用 RMAN  連線到目標資料庫(要註冊的資料庫)和恢復目錄資料庫以及註冊到遠端恢復目錄時,必須要加上賬號密碼,且要配置好本機及遠端的tns及別名】

 

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 29 06:47:48 2016

 

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

connected to target database: ORA11GR2 (DBID=237843809)

connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

2)   檢視已註冊的目標庫

[oracle@wang ~]$ sqlplus rcowner/oracle@ora

 

SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 29 06:56:22 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

 

RCOWNER@ora>select * from rc_database;

    DB_KEY  DBINC_KEY       DBID NAME     RESETLOGS_CHANGE# RESETLOGS_TIME

---------- ---------- ---------- -------- ----------------- -------------------

         1          2  237843809 ORA11GR2           1256742 2016-09-23 15:29:09

 

3)   從恢復目錄中登出目標資料庫

[oracle@wang ~]$ rman target / catalog rcowner/oracle@ora

 

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 29 06:59:32 2016

 

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

 

connected to target database: ORA11GR2 (DBID=237843809)

connected to recovery catalog database

 

RMAN> unregister database;

 

database name is "ORA11GR2" and DBID is 237843809

 

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

database unregistered from the recovery catalog

 

?——再次檢視已註冊的目標資料庫

[oracle@wang ~]$ sqlplus rcowner/oracle@ora

 

SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 29 07:01:40 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

 

RCOWNER@ora>select * from rc_database;

 

no rows selected(沒有已註冊的資料庫資訊)

1.5.   手動重新同步恢復目錄

1先要將目標資料庫與恢復目錄資料庫連線起來

[oracle@wang ~]$ rman target / catalog rcowner/oracle@ora

 

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 29 07:11:19 2016

 

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

 

connected to target database: ORA11GR2 (DBID=237843809)

connected to recovery catalog database

 

RMAN> register database;(註冊資料庫)

 

database registered in recovery catalog

starting full resync of recovery catalog

full resync complete

 

RMAN>

 

——檢視:

[oracle@wang ~]$ sqlplus rcowner/oracle@ora

SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 29 07:16:50 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

 

RCOWNER@ora>select * from rc_database;

 

    DB_KEY  DBINC_KEY       DBID NAME     RESETLOGS_CHANGE# RESETLOGS_TIME

---------- ---------- ---------- -------- ----------------- -------------------

       272        273  237843809 ORA11GR2           1256742 2016-09-23 15:29:09

2)手動重新同步恢復目錄:

RMAN> resync catalog;

 

starting full resync of recovery catalog

full resync complete

 


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

相關文章