Oracle11新特性——備份恢復功能增強(六)

yangtingkun發表於2007-12-01

打算寫一系列的文章介紹11g的新特性和變化。

Oracle11g在備份和恢復方面新增了很多的功能,無論是效能、功能性、安全性和可操作性方面都有了不同程度的提高。

這一篇介紹虛擬CATALOG

Oracle11新特性——備份恢復功能增強(一):http://yangtingkun.itpub.net/post/468/412991

Oracle11新特性——備份恢復功能增強(二):http://yangtingkun.itpub.net/post/468/414647

Oracle11新特性——備份恢復功能增強(三):http://yangtingkun.itpub.net/post/468/414834

Oracle11新特性——備份恢復功能增強(四):http://yangtingkun.itpub.net/post/468/414941

Oracle11新特性——備份恢復功能增強(五):http://yangtingkun.itpub.net/post/468/416015


Oracle11g新增了虛擬CATALOG的功能。可以將CATALOG中的不同資料庫的資訊授權給不同的使用者。

這樣一套CATALOG可以支援多個資料庫備份,同時保證多個資料庫不會訪問到不屬於自己資料庫的資訊,提高了系統的安全性。

先看看10g中註冊多個資料庫的情況:

SQL> CONN YANGTK/YANGTK@YTK102已連線。
SQL> CREATE USER CATA_LOG IDENTIFIED BY CATA_LOG DEFAULT TABLESPACE YANGTK;

使用者已建立。

SQL> GRANT CONNECT, RESOURCE TO CATA_LOG;

授權成功。

SQL> GRANT RECOVERY_CATALOG_OWNER TO CATA_LOG;

授權成功。

下面建立CATALOG並註冊第一個資料庫:

E:>rman target / catalog cata_log/cata_log

恢復管理器: Release 10.2.0.1.0 - Production on 星期日 12 2 00:41:16 2007

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

連線到目標資料庫: YTK102 (DBID=3695768905)連線到恢復目錄資料庫

RMAN> CREATE CATALOG;

恢復目錄已建立

RMAN> REGISTER DATABASE;

註冊在恢復目錄中的資料庫正在啟動全部恢復目錄的 resync完成全部 resync

下面註冊第二個:

E:>%ORACLE_HOME%/BIN/RMAN TARGET / CATALOG CATA_LOG/CATA_LOG@YTK102

恢復管理器: 版本9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

連線到目標資料庫: YTK92 (DBID=1285986946)連線到恢復目錄資料庫

RMAN> REGISTER DATABASE;

註冊在恢復目錄中的資料庫正在啟動全部恢復目錄的 resync完成全部 resync

所有註冊資料庫都是透過CATALOGOWNER CATA_LOG使用者執行的,因此透過CATA_LOG使用者訪問CATALOG可以看到所有註冊的資料庫資訊,這就存在的安全隱患。

SQL> CONN CATA_LOG/CATA_LOG@YTK102已連線。
SQL> SELECT * FROM RC_DATABASE;

DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- -------- ----------------- --------------
94 95 1285986946 YTK92 1 09-8
-07
1 2 3695768905 YTK102 547780 09-8
-07

而11g中的虛擬CATALOG則解決了這個問題。每個資料庫都可以使用自己的虛擬CATALOG帳號連線CATALOG,且這個帳號只能看到自己資料庫的資訊:

SQL> CONN YANGTK/yangtk@ORA11G已連線。
SQL> CREATE USER CATA_LOG IDENTIFIED BY CATA_LOG DEFAULT TABLESPACE YANGTK;

使用者已建立。

SQL> GRANT CONNECT, RESOURCE TO CATA_LOG;

授權成功。

SQL> GRANT RECOVERY_CATALOG_OWNER TO CATA_LOG;

授權成功。

首先仍然是建立CATALOGOWNER使用者,然後建立兩個虛擬CATALOG帳號:

SQL> CREATE USER CATALOG_11G IDENTIFIED BY CATALOG_11G DEFAULT TABLESPACE YANGTK;

使用者已建立。

SQL> GRANT CONNECT, RESOURCE TO CATALOG_11G;

授權成功。

SQL> GRANT RECOVERY_CATALOG_OWNER TO CATALOG_11G;

授權成功。

SQL> CREATE USER CATALOG_10G IDENTIFIED BY CATALOG_10G DEFAULT TABLESPACE YANGTK;

使用者已建立。

SQL> GRANT CONNECT, RESOURCE TO CATALOG_10G;

授權成功。

SQL> GRANT RECOVERY_CATALOG_OWNER TO CATALOG_10G;

授權成功。

下面首先註冊兩個資料庫:

[oracle@yangtk ~]$ rman target / catalog cata_log/CATA_LOG

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Nov 5 08:57:22 2007

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

connected to target database: ORA11G (DBID=4026820313)
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.

下面註冊第二個資料庫:

E:>RMAN TARGET / CATALOG CATA_LOG/CATA_LOG@ORA11G

恢復管理器: Release 10.2.0.1.0 - Production on 星期日 12 2 10:21:27 2007

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

連線到目標資料庫: YTK102 (DBID=3695768905)連線到恢復目錄資料庫

RMAN> REGISTER DATABASE;

註冊在恢復目錄中的資料庫正在啟動全部恢復目錄的 resync完成全部 resync

RMAN> EXIT

恢復管理器完成。

下面給兩個虛擬帳號授權:

[oracle@yangtk ~]$ rman catalog cata_log/CATA_LOG

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Nov 5 03:49:46 2007

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

connected to recovery catalog database

RMAN> create catalog;

recovery catalog created

RMAN> grant catalog for database 4026820313 to catalog_11g;

Grant succeeded.

RMAN> grant register database to catalog_11g;

Grant succeeded.

RMAN> grant catalog for database 3695768905 to catalog_10g;

Grant succeeded.

對於已經存在的CATALOG,可以透過GRANT CATALOG的方式給虛擬CATALOG使用者授權,這裡可以使用DBID也可以使用DBNAME

也可以將REGISTER DATABASE的許可權授權給虛擬使用者。

[oracle@yangtk ~]$ rman target / catalog catalog_11g/CATALOG_11G

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Nov 5 03:58:02 2007

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

connected to target database: ORA11G (DBID=4026820313)
connected to recovery catalog database

RMAN> create virtual catalog;

found eligible base catalog owned by CATA_LOG
created virtual catalog against base catalog owned by CATA_LOG

RMAN> exit


Recovery Manager complete.
[oracle@yangtk ~]$ rman catalog catalog_10g/CATALOG_10G

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Nov 5 09:03:25 2007

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

connected to recovery catalog database

RMAN> create virtual catalog;

found eligible base catalog owned by CATA_LOG
created virtual catalog against base catalog owned by CATA_LOG

RMAN> exit


Recovery Manager complete.

登陸兩個虛擬CATALOG帳號,可以看到各自的資料庫資訊:

SQL> CONN CATALOG_11G/CATALOG_11G@ORA11G已連線。
SQL> SELECT * FROM RC_DATABASE;

DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- -------- ----------------- --------------
1 2 4026820313 ORA11G 1 14-8
-07

SQL> CONN CATALOG_10G/CATALOG_10G@ORA11G已連線。
SQL> SELECT * FROM RC_DATABASE;

DB_KEY DBINC_KEY DBID NAME RESETLOGS_CHANGE# RESETLOGS_TIME
---------- ---------- ---------- -------- ----------------- --------------
377 378 3695768905 YTK102 547780 09-8
-07

11grman可以直接使用建立好的虛擬CATALOG

[oracle@yangtk ~]$ rman target / catalog catalog_11g/CATALOG_11G

Recovery Manager: Release 11.1.0.6.0 - Production on Mon Nov 5 09:23:02 2007

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

connected to target database: ORA11G (DBID=4026820313)
connected to recovery catalog database

RMAN> backup tablespace system;

Starting backup at 05-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=129 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=00001 name=/data/oracle/oradata/ora11g/ORA11G/datafile/o1_mf_system_3d3795py_.dbf
channel ORA_DISK_1: starting piece 1 at 05-NOV-07
channel ORA_DISK_1: finished piece 1 at 05-NOV-07
piece handle=/data1/backup/0uj0997v_1_1 tag=TAG20071105T092311 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:16
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 05-NOV-07
channel ORA_DISK_1: finished piece 1 at 05-NOV-07
piece handle=/data1/backup/0vj099aj_1_1 tag=TAG20071105T092311 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 05-NOV-07

而10g不能直接使用,即使根據文件的描述,使用虛擬CATALOG執行下面的步驟:

SQL> CONN CATALOG_10G/CATALOG_10G@ORA11G已連線。
SQL> EXEC CATA_LOG.DBMS_RCVCAT.CREATE_VIRTUAL_CATALOG

PL/SQL 過程已成功完成。

使用虛擬CATALOG執行備份仍然報錯。

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

相關文章