oracle 备份恢复篇(六)---基于12c的pdb备份与恢复
原创
©著作权归作者所有:来自51CTO博客作者kingle_work的原创作品,请联系作者获取转载授权,否则将追究法律责任
一,备份前提描述
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /orcl/app/oracle/oradata/orcl/archivelog
Oldest online log sequence 280
Next log sequence to archive 282
Current log sequence 282
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /orcl/app/oracle/fast_recovery_area/orcl --恢复区地址
db_recovery_file_dest_size big integer 1G
db_unrecoverable_scn_tracking boolean TRUE
recovery_parallelism integer 0
remote_recovery_file_dest string
SQL>
alter database archielog --开启归档日志
alter database open 开启数据库
alter system set db_recovery_file_dest_size=20G; 闪回恢复区大小
alter system set db_recovery_file_dest='/orcl/app/oracle/fast_recovery_area/orcl';
二,生成备份
[oracle@node12c01 ~]$ rman target /
Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 12 05:29:33 2019
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1532278336)
RMAN> report schema --以列出数据库中的表空间和文件信息等,在12c的输出中,临时表空间作为一个独立的信息部分被显示出来:
2> ;
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name NODE12C01
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 830 SYSTEM YES /orcl/app/oracle/oradata/orcl/system01.dbf
3 970 SYSAUX NO /orcl/app/oracle/oradata/orcl/sysaux01.dbf
4 70 UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/undotbs01.dbf
5 250 PDB$SEED:SYSTEM NO /orcl/app/oracle/oradata/orcl/pdbseed/system01.dbf
6 330 PDB$SEED:SYSAUX NO /orcl/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf
7 5 USERS NO /orcl/app/oracle/oradata/orcl/users01.dbf
8 100 PDB$SEED:UNDOTBS1 NO /orcl/app/oracle/oradata/orcl/pdbseed/undotbs01.dbf
9 260 ORCLPDB:SYSTEM YES /orcl/app/oracle/oradata/orcl/orclpdb/system01.dbf
10 430 ORCLPDB:SYSAUX NO /orcl/app/oracle/oradata/orcl/orclpdb/sysaux01.dbf
11 100 ORCLPDB:UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/orclpdb/undotbs01.dbf
12 5 ORCLPDB:USERS NO /orcl/app/oracle/oradata/orcl/orclpdb/users01.dbf
13 250 HRPDB:SYSTEM YES /orcl/app/oracle/oradata/orcl/hrpdb/system01.dbf
14 350 HRPDB:SYSAUX NO /orcl/app/oracle/oradata/orcl/hrpdb/sysaux01.dbf
15 100 HRPDB:UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/hrpdb/undotbs01.dbf
16 250 SALESPDB:SYSTEM YES /orcl/app/oracle/oradata/orcl/salespdb/system01.dbf
17 350 SALESPDB:SYSAUX NO /orcl/app/oracle/oradata/orcl/salespdb/sysaux01.dbf
18 100 SALESPDB:UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/salespdb/undotbs01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 131 TEMP 32767 /orcl/app/oracle/oradata/orcl/temp01.dbf
2 64 PDB$SEED:TEMP 32767 /orcl/app/oracle/oradata/orcl/pdbseed/temp012019-04-02_03-07-18-378-AM.dbf
3 129 ORCLPDB:TEMP 32767 /orcl/app/oracle/oradata/orcl/orclpdb/temp01.dbf
4 64 HRPDB:TEMP 32767 /orcl/app/oracle/oradata/orcl/hrpdb/temp012019-04-02_03-07-18-378-AM.dbf
5 64 SALESPDB:TEMP 32767 /orcl/app/oracle/oradata/orcl/salespdb/temp012019-04-02_03-07-18-378-AM.dbf
RMAN> backup pluggable database orclpdb,salespdb; --支持对单个或者多个PDB文件的备份
Starting backup at 12-APR-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=271 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=00010 name=/orcl/app/oracle/oradata/orcl/orclpdb/sysaux01.dbf
input datafile file number=00009 name=/orcl/app/oracle/oradata/orcl/orclpdb/system01.dbf
input datafile file number=00011 name=/orcl/app/oracle/oradata/orcl/orclpdb/undotbs01.dbf
input datafile file number=00012 name=/orcl/app/oracle/oradata/orcl/orclpdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_69_1.bkp tag=TAG20190412T053110 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=/orcl/app/oracle/oradata/orcl/salespdb/sysaux01.dbf
input datafile file number=00016 name=/orcl/app/oracle/oradata/orcl/salespdb/system01.dbf
input datafile file number=00018 name=/orcl/app/oracle/oradata/orcl/salespdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_70_1.bkp tag=TAG20190412T053110 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 12-APR-19
Starting Control File and SPFILE Autobackup at 12-APR-19
piece handle=/orcl/app/oracle/fast_recovery_area/orcl/NODE12C01/autobackup/2019_04_12/o1_mf_s_1005370293_gc0pqo9m_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-APR-19
RMAN> backup pluggable database "CDB$ROOT"; --备份CDB根即下面所有的PDB
Starting backup at 12-APR-19
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=00003 name=/orcl/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/orcl/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/orcl/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00007 name=/orcl/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_72_1.bkp tag=TAG20190412T053207 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 12-APR-19
Starting Control File and SPFILE Autobackup at 12-APR-19
piece handle=/orcl/app/oracle/fast_recovery_area/orcl/NODE12C01/autobackup/2019_04_12/o1_mf_s_1005370334_gc0prz1p_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-APR-19
RMAN> backup database root; -- 只备份CDB数据库需要具有SYSDBA或SYSBACKUP权限用户连接到CDB的root环境下,执行backupdatabase root命令即可完成对CDB的备份
Starting backup at 12-APR-19
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=00003 name=/orcl/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/orcl/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/orcl/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00007 name=/orcl/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_74_1.bkp tag=TAG20190412T053852 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 12-APR-19
Starting Control File and SPFILE Autobackup at 12-APR-19
piece handle=/orcl/app/oracle/fast_recovery_area/orcl/NODE12C01/autobackup/2019_04_12/o1_mf_s_1005370739_gc0q5nhk_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-APR-19
RMAN> backup database; -- 备份所有
Starting backup at 12-APR-19
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=00003 name=/orcl/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00001 name=/orcl/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00004 name=/orcl/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00007 name=/orcl/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_76_1.bkp tag=TAG20190412T054009 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=/orcl/app/oracle/oradata/orcl/orclpdb/sysaux01.dbf
input datafile file number=00009 name=/orcl/app/oracle/oradata/orcl/orclpdb/system01.dbf
input datafile file number=00011 name=/orcl/app/oracle/oradata/orcl/orclpdb/undotbs01.dbf
input datafile file number=00012 name=/orcl/app/oracle/oradata/orcl/orclpdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_77_1.bkp tag=TAG20190412T054009 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=/orcl/app/oracle/oradata/orcl/hrpdb/sysaux01.dbf
input datafile file number=00013 name=/orcl/app/oracle/oradata/orcl/hrpdb/system01.dbf
input datafile file number=00015 name=/orcl/app/oracle/oradata/orcl/hrpdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_78_1.bkp tag=TAG20190412T054009 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=/orcl/app/oracle/oradata/orcl/salespdb/sysaux01.dbf
input datafile file number=00016 name=/orcl/app/oracle/oradata/orcl/salespdb/system01.dbf
input datafile file number=00018 name=/orcl/app/oracle/oradata/orcl/salespdb/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_79_1.bkp tag=TAG20190412T054009 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
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=/orcl/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/orcl/app/oracle/oradata/orcl/pdbseed/system01.dbf
input datafile file number=00008 name=/orcl/app/oracle/oradata/orcl/pdbseed/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 12-APR-19
channel ORA_DISK_1: finished piece 1 at 12-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_80_1.bkp tag=TAG20190412T054009 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 12-APR-19
Starting Control File and SPFILE Autobackup at 12-APR-19
piece handle=/orcl/app/oracle/fast_recovery_area/orcl/NODE12C01/autobackup/2019_04_12/o1_mf_s_1005370833_gc0q8log_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 12-APR-19
using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name NODE12C01
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 830 SYSTEM YES /orcl/app/oracle/oradata/orcl/system01.dbf
3 1070 SYSAUX NO /orcl/app/oracle/oradata/orcl/sysaux01.dbf
4 70 UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/undotbs01.dbf
5 250 PDB$SEED:SYSTEM NO /orcl/app/oracle/oradata/orcl/pdbseed/system01.dbf
6 330 PDB$SEED:SYSAUX NO /orcl/app/oracle/oradata/orcl/pdbseed/sysaux01.dbf
7 5 USERS NO /orcl/app/oracle/oradata/orcl/users01.dbf
8 100 PDB$SEED:UNDOTBS1 NO /orcl/app/oracle/oradata/orcl/pdbseed/undotbs01.dbf
9 260 ORCLPDB:SYSTEM YES /orcl/app/oracle/oradata/orcl/orclpdb/system01.dbf
10 470 ORCLPDB:SYSAUX NO /orcl/app/oracle/oradata/orcl/orclpdb/sysaux01.dbf
11 100 ORCLPDB:UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/orclpdb/undotbs01.dbf
12 5 ORCLPDB:USERS NO /orcl/app/oracle/oradata/orcl/orclpdb/users01.dbf
13 250 HRPDB:SYSTEM YES /orcl/app/oracle/oradata/orcl/hrpdb/system01.dbf
14 350 HRPDB:SYSAUX NO /orcl/app/oracle/oradata/orcl/hrpdb/sysaux01.dbf
15 100 HRPDB:UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/hrpdb/undotbs01.dbf
16 250 SALESPDB:SYSTEM YES /orcl/app/oracle/oradata/orcl/salespdb/system01.dbf
17 350 SALESPDB:SYSAUX NO /orcl/app/oracle/oradata/orcl/salespdb/sysaux01.dbf
18 100 SALESPDB:UNDOTBS1 YES /orcl/app/oracle/oradata/orcl/salespdb/undotbs01.dbf
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1 131 TEMP 32767 /orcl/app/oracle/oradata/orcl/temp01.dbf
2 64 PDB$SEED:TEMP 32767 /orcl/app/oracle/oradata/orcl/pdbseed/temp012019-04-02_03-07-18-378-AM.dbf
3 129 ORCLPDB:TEMP 32767 /orcl/app/oracle/oradata/orcl/orclpdb/temp01.dbf
4 64 HRPDB:TEMP 32767 /orcl/app/oracle/oradata/orcl/hrpdb/temp012019-04-02_03-07-18-378-AM.dbf
5 64 SALESPDB:TEMP 32767 /orcl/app/oracle/oradata/orcl/salespdb/temp012019-04-02_03-07-18-378-AM.dbf
RMAN> backup tablespace HRPDB:SYSTEM; 单独备份表空间
Starting backup at 15-APR-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=276 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=00013 name=/orcl/app/oracle/oradata/orcl/hrpdb/system01.dbf
channel ORA_DISK_1: starting piece 1 at 15-APR-19
channel ORA_DISK_1: finished piece 1 at 15-APR-19
piece handle=/home/oracle/dgback/ORCL_1532278336_82_1.bkp tag=TAG20190415T050535 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 15-APR-19
Starting Control File and SPFILE Autobackup at 15-APR-19
piece handle=/orcl/app/oracle/fast_recovery_area/orcl/NODE12C01/autobackup/2019_04_15/o1_mf_s_1005627936_gc8lc1of_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 15-APR-19
三,恢复
recover pluggable database SALESPDB; 恢复单个PDB