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,轉載請標明出處。
提前配置好兩個庫的監聽與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,轉載請標明出處。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31383567/viewspace-2131919/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- RMAN備份 建立catalog資料庫資料庫
- 基於catalog 建立RMAN儲存指令碼指令碼
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- RMAN全庫備份指令碼指令碼
- 資料庫備份指令碼資料庫指令碼
- 【備份恢復】RMAN catalog 恢復目錄資料庫資料庫
- rman儲存指令碼指令碼
- rman 備份指令碼指令碼
- rman備份指令碼指令碼
- 中小型資料庫 RMAN CATALOG 備份恢復方案(二)資料庫
- 中小型資料庫 RMAN CATALOG 備份恢復方案(一)資料庫
- 資料庫全備份指令碼資料庫指令碼
- RMAN相容性、控制檔案自動備份、儲存時間、備份策略、備份指令碼(二)指令碼
- rman備份和增量備份指令碼指令碼
- rman 全備份指令碼指令碼
- rman增量備份指令碼指令碼
- windows rman備份指令碼Windows指令碼
- RMAN常用備份指令碼指令碼
- oracle RMAN備份指令碼Oracle指令碼
- 【RMAN】catalog資料庫資料庫
- 《mysql資料庫備份小指令碼》MySql資料庫指令碼
- 使用RMAN備份資料庫資料庫
- Mysqldump備份說明及資料庫備份指令碼分享-運維筆記MySql資料庫指令碼運維筆記
- 【RMAN】使用恢復目錄catalog備份目標資料庫的演示資料庫
- [Oracle] rman備份指令碼(2)Oracle指令碼
- 使用rman備份的指令碼指令碼
- oracle rman備份指令碼收集Oracle指令碼
- Windows下RMAN備份指令碼Windows指令碼
- RMAN備份Shel指令碼示例指令碼
- Rman備份的shell指令碼指令碼
- MySQL資料庫備份的shell指令碼MySql資料庫指令碼
- Oracle多例項資料庫備份指令碼Oracle資料庫指令碼
- 《mysql資料庫備份小指令碼》(轉)MySql資料庫指令碼
- 簡單的備份資料庫指令碼資料庫指令碼
- mysqldump來備份MYSQL資料庫(指令碼)MySql資料庫指令碼
- 利用RMAN備份重建資料庫資料庫
- RMAN備份恢復——備份集儲存位置改變
- MOGDB/openGauss資料庫gs_dump備份指令碼及清理資料庫指令碼