透過rman備份system系統表空間

skyin_1603發表於2016-10-31
rman備份工具是我們常用的備份工具。既然重要,那就是要求我們有明確性針對性的進行備份及其管理。
以下用簡單的例子講述以下rman引數的設定,並嘗試備份system系統表空間,然後檢視備份檔案的路徑。
提醒:做備份前,一定要確保資料庫是歸檔模式,這樣避免後面因為丟失系統資料檔案的部分而導致起不了庫。

---檢視資料庫到歸檔模式:
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     5
Current log sequence           7
SQL> 
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> 

---切換歸檔模式:
SQL> startup mount;
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2257840 bytes
Variable Size             541068368 bytes
Database Buffers          289406976 bytes
Redo Buffers                2371584 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Next log sequence to archive   8
Current log sequence           8
SQL> 

SQL> alter database open;
Database altered.

---開啟rman備份工具:
[oracle@enmo ~]$  rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Oct 31 22:36:37 2016
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: PROD (DBID=338469376)   #這裡顯示的是目標庫的資訊#

---檢視rman引數:
RMAN> show all; 
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name PROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD.f'; # default

---配置部分備份引數:
--設定備份檔案的存放路徑:
RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u01/app/backup/db_%U.rmn';

new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/backup/db_%U.rmn';
new RMAN configuration parameters are successfully stored

--開啟自動備份控制檔案與引數檔案:
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

---再次檢視rman引數:
RMAN configuration parameters for database with db_unique_name PROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u01/app/backup/db_%U.rmn';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_PROD.f'; # default
#其中有兩項的引數已經修改:

---測試恢復系統關鍵資料檔案:
---透過rman備份系統表空間:
RMAN> backup tablespace system;                  #只備份系統表空間

Starting backup at 31-OCT-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 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=/u01/app/oracle/oradata/PROD/system01.dbf
channel ORA_DISK_1: starting piece 1 at 31-OCT-16
channel ORA_DISK_1: finished piece 1 at 31-OCT-16
piece handle=/u01/app/backup/db_01rjp9rn_1_1.rmn tag=TAG20161031T224511 comment=NONE     #系統表空間備份的控制程式碼
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:38
Finished backup at 31-OCT-16


Starting Control File and SPFILE Autobackup at 31-OCT-16                #因為上面已經設定自動備份控制檔案
piece handle=/u01/app/oracle/fast_recovery_area/PROD/autobackup/2016_10_31/o1_mf_s_926722009_d1gpbvth_.bkp comment=NONE  
#控制檔案以及引數引數檔案備份的控制程式碼

Finished Control File and SPFILE Autobackup at 31-OCT-16
#備份完成。

---檢視兩個生成的備份檔案:
--system表空間的備份檔案:
[oracle@enmo backup]$ ls
db_01rjp9rn_1_1.rmn
[oracle@enmo backup]$ ll
total 660032
-rw-r----- 1 oracle oinstall 675209216 Oct 31 22:46 db_01rjp9rn_1_1.rmn
[oracle@enmo backup]$ 
--控制檔案與引數檔案的備份檔案:
[oracle@enmo backup]$ cd /u01/app/oracle/fast_recovery_area/PROD/
[oracle@enmo PROD]$ ls
autobackup  control02.ctl  onlinelog
[oracle@enmo PROD]$ 
[oracle@enmo PROD]$ cd autobackup/
[oracle@enmo autobackup]$ ls
2016_10_31
[oracle@enmo autobackup]$ ll
total 4
drwxr-x--- 2 oracle oinstall 4096 Oct 31 22:46 2016_10_31
[oracle@enmo autobackup]$ 

系統表空間rman備份已完成。

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

相關文章