rman之建立恢復目錄筆記

xfhuangfu發表於2015-07-04
晚上做了一下建立恢復目錄的實驗,整理了一下,供自己以後參考

環境:
源庫:oracle10gr2     源OS:rhelas4    源sid=ora10    源庫ip=192.168.1.200
目標庫: oracle10gr2   目地OS:rhelas4     目的sid=ora10hha    目的庫ip=192.168.1.10

實驗目的:

要將源庫192.168.1.200 上的資料檔案、控制檔案以及日誌檔案備份到 目的庫192.168.1.10上,以便源庫出現問題時,可以透過
備份目錄恢復。

實驗準備:

1:在虛擬機器上安裝好兩個redhat系統,源庫ip=192.168.1.200,目的庫ip=192.168.1.10
並分別建立好兩個庫,一個ora10庫 , 一個orahha庫
同時關閉兩個redhat系統上的防火牆,確保這兩個OS都可以相互ping通

2:在目的庫(192.168.1.10)上透過圖形化介面執行netca命令,配置好監聽,配置好的listener.ora 如下

ora10hha =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
3:在源庫(192.168.1.200)上透過圖形化介面執行netca命令,配置好tnsname.ora ,配置好的內容如下:

ORA10HHA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ora10hha)
    )
  )

4:在源庫(192.168.1.200)上執行客戶端到伺服器端的連線是不是正常:

[oracle@sphost admin]$ tnsping ORA10HHA
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 03-MAY-2011 23:22:19
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
Used parameter files:
/home/oracle/10.2.0/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ora10hha)))
OK (80 msec)
[oracle@sphost admin]$

ok,這樣就可以透過網路連線到目的庫上了。

5:在源庫(192.168.1.200)上執行

[oracle@sphost admin]$ sqlplus sys/sysdba@ORA10HHA as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 3 23:26:18 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>

6:在源庫(192.168.1.200)上建立表空間,用於存放恢復目錄資料,
並建立使用者,該使用者是恢復目錄的擁有者;同時給使用者授予查詢、維護恢復目錄的許可權

SQL> create tablespace tbs_catalog datafile '/home/oracle/oradata/catalog.dbf' size 1G;  
Tablespace created.


SQL> create user rman identified by rman temporary tablespace temp default tablespace tbs_catalog quota unlimited on tbs_catalog;
User created.


SQL> grant connect,resource,recovery_catalog_owner to rman;
Grant succeeded.
SQL>


7:啟動rman
oracle@sphost admin]$rman

一定要注意:如果此處輸入rman後,一直沒有反應,那麼就執行如下命令:

[oracle@sphost admin]$ export PATH=$ORACLE_HOME/binPATH:.
[oracle@sphost admin]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 3 23:38:10 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
RMAN>

8:以使用者rman身份連線到恢復目錄所在的資料庫中

RMAN> connect catalog rman@ORA10HHA
recovery catalog database Password:
connected to recovery catalog database
RMAN>

當然,在這裡我的恢復目錄是已經建立好了的,如果還沒有建立的話,在執行這條命令後,顯示如下:
recovery catalog database Password:
connected to recovery catalog database
recovery catalog is not installed

9:因此要建立恢復目錄

在這裡一定要注意,建立的恢復目錄名一定要和剛建立的表空間名字一直,否則無效。如下:

RMAN> connect catalog rman@ORA10HHA
recovery catalog database Password:
connected to recovery catalog database
RMAN> create catalog tablespace tt;
ORACLE error from recovery catalog database: ORA-00959: tablespace 'TT' does not exist
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06433: error installing recovery catalog
RMAN> create catalog tablespace tbs_catalog;
recovery catalog created
RMAN> exit

10:測試恢復目錄是否建立成功。

[oracle@sphost ~]$ sqlplus sys/sysdba@ORA10HHA as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 3 22:48:23 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> connect rman@ORA10HHA
Enter password:
Connected.
SQL> set linesize 2000;
SQL> select table_name from user_tables;
TABLE_NAME
------------------------------------------------------------
DB
NODE
CONF
DBINC
CKP
TS
TSATT
DF
DFATT
TF
TFATT
TABLE_NAME
------------------------------------------------------------
OFFR
RR
RT
ORL
RLH
AL
BS
BP
BCF
CCF
XCF
TABLE_NAME
------------------------------------------------------------
BSF
BDF
CDF
XDF
BRL
BCB
CCB
SCR
SCRL
CONFIG
XAL
TABLE_NAME
------------------------------------------------------------
RSR
FB
ROUT
RCVER
37 rows selected.

如果這些表不存在,則表示恢復目錄沒有建立成功。


11.將資料庫註冊到恢復目錄

[oracle@catalog ~]$ rman
Recovery Manager: Release 10.2.0.1.0 - Production on Tue May 3 21:23:52 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
RMAN> connect target ora10;    ////連線到源庫
target database Password:
connected to target database: ORA10HHA (DBID=3339398398)
RMAN> connect catalog rman@ORA10HHA   ////連線到恢復目錄,感覺這邊隨意輸入任何密碼都是可以的
recovery catalog database Password:
connected to recovery catalog database
RMAN> register database;          ///  把源資料庫的資訊註冊到恢復目錄中
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
RMAN> exit

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

相關文章