ORACLE12C归档模式下RMAN全数据库备份
--首先,确认当前模式,为归档模式
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/archivelog/
Oldest online log sequence 15
Next log sequence to archive 17
Current log sequence 17
...
以系统备份的角色,登录rman工具,DBID号最好保留记录,以后在特定情况下恢复数据库可能用得到(例如用rman全数据库备份,然后rman恢复到异机,就是非本机)
[oracle@host01 archivelog]$ rman target "'/ as sysbackup'"
Recovery Manager: Release 18.0.0.0.0 - Production on Mon Jan 18 21:27:06 2021
Version 18.3.0.0.0
Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1535621266) #DBID号非常重要,最好单独记录下来
...
--进行全数据库的备份
当前数据库不用关闭,直接热备
RMAN> backup database plus archivelog;
...
Starting backup at 18-JAN-21 #开始归档日志文件的备份(seq14-15)
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=79 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=14 RECID=16 STAMP=1062185952
input archived log thread=1 sequence=15 RECID=17 STAMP=1062192475
channel ORA_DISK_1: starting piece 1 at 18-JAN-21
channel ORA_DISK_1: finished piece 1 at 18-JAN-21
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_18/o1_mf_annnn_TAG20210118T212757_j0c36z0g_.bkp tag=TAG20210118T212757 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished backup at 18-JAN-21 #完成归档日志文件的备份(seq14-15)
...
Starting backup at 18-JAN-21 #开始数据文件备份
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=00001 name=/u01/app/oracle/oradata/ORCL/system01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/ORCL/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/ORCL/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oracle/oradata/ORCL/users01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/ORCL/noarchivetest.dbf
channel ORA_DISK_1: starting piece 1 at 18-JAN-21
channel ORA_DISK_1: finished piece 1 at 18-JAN-21
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_18/o1_mf_nnndf_TAG20210118T212816_j0c37l4v_.bkp tag=TAG20210118T212816 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:22
Finished backup at 18-JAN-21 #完成数据文件备份
...
Starting backup at 18-JAN-21 #开始归档日志文件的备份(seq16)
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=16 RECID=18 STAMP=1062192759
channel ORA_DISK_1: starting piece 1 at 18-JAN-21
channel ORA_DISK_1: finished piece 1 at 18-JAN-21
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_18/o1_mf_annnn_TAG20210118T213240_j0c3hr5o_.bkp tag=TAG20210118T213240 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 18-JAN-21 #完成归档日志文件的备份(seq16)
...
Starting Control File and SPFILE Autobackup at 18-JAN-21 #开始控制文件和参数文件的备份
piece handle=/u01/app/oracle/fast_recovery_area/ORCL/ORCL/autobackup/2021_01_18/o1_mf_s_1062192761_j0c3hthv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 18-JAN-21 #完成了控制文件和参数文件的备份
...
--查看备份集,BS Key1和2 是非归档模式下的rman备份(冷备),3到6是归档模式下的备份,也就是上面操作的备份文件(热备)
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 1.22G DISK 00:02:46 17-JAN-21
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20210117T182716
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_17/o1_mf_nnndf_TAG20210117T182716_j084850o_.bkp
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 2019591 17-JAN-21 NO /u01/app/oracle/oradata/ORCL/system01.dbf
3 Full 2019591 17-JAN-21 NO /u01/app/oracle/oradata/ORCL/sysaux01.dbf
4 Full 2019591 17-JAN-21 NO /u01/app/oracle/oradata/ORCL/undotbs01.dbf
5 Full 2019591 17-JAN-21 NO /u01/app/oracle/oradata/ORCL/noarchivetest.dbf
7 Full 2019591 17-JAN-21 NO /u01/app/oracle/oradata/ORCL/users01.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 10.20M DISK 00:00:01 17-JAN-21
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20210117T183018
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/ORCL/autobackup/2021_01_17/o1_mf_s_1062095142_j084fvvy_.bkp
SPFILE Included: Modification time: 17-JAN-21
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 2019591 Ckp time: 17-JAN-21
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
3 100.02M DISK 00:00:08 18-JAN-21
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20210118T212757
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_18/o1_mf_annnn_TAG20210118T212757_j0c36z0g_.bkp
List of Archived Logs in backup set 3
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 14 2323212 17-JAN-21 2377530 18-JAN-21
1 15 2377530 18-JAN-21 2382029 18-JAN-21
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 1.24G DISK 00:04:11 18-JAN-21
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20210118T212816
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_18/o1_mf_nnndf_TAG20210118T212816_j0c37l4v_.bkp
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 2382053 18-JAN-21 NO /u01/app/oracle/oradata/ORCL/system01.dbf
3 Full 2382053 18-JAN-21 NO /u01/app/oracle/oradata/ORCL/sysaux01.dbf
4 Full 2382053 18-JAN-21 NO /u01/app/oracle/oradata/ORCL/undotbs01.dbf
5 Full 2382053 18-JAN-21 NO /u01/app/oracle/oradata/ORCL/noarchivetest.dbf
7 Full 2382053 18-JAN-21 NO /u01/app/oracle/oradata/ORCL/users01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
5 24.50K DISK 00:00:00 18-JAN-21
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20210118T213240
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/2021_01_18/o1_mf_annnn_TAG20210118T213240_j0c3hr5o_.bkp
List of Archived Logs in backup set 5
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 16 2382029 18-JAN-21 2382159 18-JAN-21
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
6 Full 10.20M DISK 00:00:01 18-JAN-21
BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20210118T213241
Piece Name: /u01/app/oracle/fast_recovery_area/ORCL/ORCL/autobackup/2021_01_18/o1_mf_s_1062192761_j0c3hthv_.bkp
SPFILE Included: Modification time: 18-JAN-21
SPFILE db_unique_name: ORCL
Control File Included: Ckp SCN: 2382172 Ckp time: 18-JAN-21
...
--最后在系统终端用系统命令再次确认备份文件
[oracle@host01 trace]$ cd /u01/app/oracle/fast_recovery_area/ORCL/ORCL/backupset/
[oracle@host01 backupset]$ ls
2021_01_17 2021_01_18
[oracle@host01 backupset]$ cd 2021_01_18
[oracle@host01 2021_01_18]$ ls #存放数据文件和归档日志
o1_mf_annnn_TAG20210118T212757_j0c36z0g_.bkp o1_mf_annnn_TAG20210118T213240_j0c3hr5o_.bkp o1_mf_nnndf_TAG20210118T212816_j0c37l4v_.bkp
[oracle@host01 2021_01_18]$ cd /u01/app/oracle/fast_recovery_area/ORCL/ORCL/
[oracle@host01 ORCL]$ ls
archivelog autobackup backupset onlinelog
[oracle@host01 ORCL]$ cd autobackup
[oracle@host01 autobackup]$ ls
2021_01_17 2021_01_18
[oracle@host01 autobackup]$ cd 2021_01_18
[oracle@host01 2021_01_18]$ ls #存放控制文件和参数文件
o1_mf_s_1062192761_j0c3hthv_.bkp
[oracle@host01 2021_01_18]$ cd /u01/app/oracle/fast_recovery_area/ORCL/ORCL/
[oracle@host01 ORCL]$ ls
archivelog autobackup backupset onlinelog
[oracle@host01 ORCL]$ cd onlinelog/
[oracle@host01 onlinelog]$ ls
[oracle@host01 onlinelog]$ cd ..
[oracle@host01 ORCL]$ ls
archivelog autobackup backupset onlinelog
[oracle@host01 ORCL]$ cd archivelog/
[oracle@host01 archivelog]$ ls
2021_01_16 2021_01_17 2021_01_18
[oracle@host01 archivelog]$ cd 2021_01_18
[oracle@host01 2021_01_18]$ ls
[oracle@host01 2021_01_18]$ cd ..
[oracle@host01 archivelog]$ ls
2021_01_16 2021_01_17 2021_01_18
[oracle@host01 archivelog]$ cd 2021_01_17
[oracle@host01 2021_01_17]$ ls
[oracle@host01 2021_01_17]$
end
对于数据库备份与还原这一部分理解或许有些帮助,供参考。
结合之前整理的非归档模式的实验,归档模式下备份的信息正好可以互相做个对比
整理的有点乱,主要是看看实际操作时的相关信息。知识点还是要看老师的PPT和视频。抛砖引玉~大家有操作中的体会也可以共同讨论~
--本资料由同学【星动行働】制作整理
Tag: Oracle Oracle备份 Oracle恢复