Oracle 12c ASM Disk Groups Backup & Restore Example
SQL> conn sys@pdb1 as sysdba
Enter password:
Connected.
SQL> show con_name
CON_NAME
------------------------------
PDB1
Create a Tablespace Named DATA2_TBS In Disk Group DATA2:
SQL> create tablespace DATA2_TBS datafile '+DATA2' SIZE 10M autoextend on next 1 M;
Tablespace created.
SQL> select file_name from dba_data_files where tablespace_name = 'DATA2_TBS';
FILE_NAME
--------------------------------------------------------------------------------
+DATA2/CDBRAC/426B78A071E83DCAE0530B0AA8C04DB5/DATAFILE/data2_tbs.256.930739747
1 row selected.
Insert test data to DATA2 tablespace
SQL> conn testuser@pdb1
Enter password:
Connected.
SQL> create table test_data
2 (c1 number(10)) tablespace DATA2_TBS;
Table created.
SQL> insert into test_data(c1)
2 select rownum from dual
3 connect by level <=10;
10 rows created.
SQL> commit;
Commit complete.
SQL> select * from test_data;
C1
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
Perform RMAN Full Database Backup: (skip the details)
[oracle@rac12c01 ~]$ rman target /
Recovery Manager: Release 12.1.0.2.0 - Production on Fri Dec 16 11:46:20 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDBRAC (DBID=414791675)
RMAN> backup database plus archivelog;
……
……
……
Backup All ASM Disk Groups:
[oracle@rac12c01 ~]$ grid_env
[oracle@rac12c01 ~]$ asmcmd md_backup /backup/dgbackup_20161216
Bring The Tablespace DATA2_TBS Offline:
SQL> conn sys@pdb1 as sysdba
Enter password:
Connected.
SQL> alter tablespace DATA2_TBS offline;
Tablespace altered.
SQL> exit
Deliberately Dismount and Drop the disk group DATA2:
[oracle@rac12c01 ~]$ grid_env
[oracle@rac12c01 backup]$ sqlplus "/ as sysasm"
SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 6 13:56:47 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
SQL> select group_number,name,state from v$asm_diskgroup order by 1;
GROUP_NUMBER NAME STATE
----------------------- ------------------------------ -------------------------------
1 DATA2 MOUNTED
2 DATA MOUNTED
SQL> alter diskgroup DATA2 dismount force;
Diskgroup altered.
SQL> select group_number,name,state from v$asm_diskgroup order by 1;
GROUP_NUMBER NAME STATE
----------------------- --------------- -------------------------------
0 DATA2 DISMOUNTED
2 DATA MOUNTED
SQL> drop diskgroup DATA2 force including contents;
Diskgroup dropped.
SQL> select group_number,name,state from v$asm_diskgroup order by 1;
GROUP_NUMBER NAME STATE
----------------------- ------------------------------ -------------------------------
2 DATA MOUNTED
SQL> exit
[oracle@rac12c01 ~]$ db_env
[oracle@rac12c01 ~]$ sqlplus testuser@pdb1
SQL*Plus: Release 12.1.0.2.0 Production on Fri Dec 16 12:08:01 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Enter password:
Last Successful login time: Fri Dec 16 2016 10:51:00 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> select * from test_data;
select * from test_data
*
ERROR at line 1:
ORA-00376: file 16 cannot be read at this time
ORA-01110: data file 16:
'+DATA2/CDBRAC/426B78A071E83DCAE0530B0AA8C04DB5/DATAFILE/data2_tbs.256.930739747
ERROR at line 1:
ORA-00376: file 16 cannot be read at this time
ORA-01110: data file 16:
'+DATA2/CDBRAC/426B78A071E83DCAE0530B0AA8C04DB5/DATAFILE/data2_tbs.256.930739747
SQL> exit
''
Perform ASM Disk Group Restoration On The Disk Group DATA2:
[oracle@rac12c01 ~]$ grid_env
[oracle@rac12c01 ~]$ asmcmd md_restore --full -G DATA2 /backup/dgbackup_20161216
Current Diskgroup metadata being restored: DATA2
Diskgroup DATA2 created!
System template INCR XTRANSPORT BACKUPSET modified!
System template VOTINGFILE modified!
System template FLASHBACK modified!
System template ARCHIVELOG modified!
System template OCRFILE modified!
System template ASMPARAMETERFILE modified!
System template FLASHFILE modified!
System template PARAMETERFILE modified!
System template ONLINELOG modified!
System template BACKUPSET modified!
System template KEY_STORE modified!
System template DATAGUARDCONFIG modified!
System template XTRANSPORT modified!
System template XTRANSPORT BACKUPSET modified!
System template TEMPFILE modified!
System template DATAFILE modified!
System template DUMPSET modified!
System template CHANGETRACKING modified!
System template AUDIT_SPILLFILES modified!
System template CONTROLFILE modified!
System template AUTOBACKUP modified!
System template AUTOLOGIN_KEY_STORE modified!
Directory +DATA2/CDBRAC re-created!
Directory +DATA2/CDBRAC/426B78A071E83DCAE0530B0AA8C04DB5 re-created!
Directory +DATA2/CDBRAC/426B78A071E83DCAE0530B0AA8C04DB5/DATAFILE re-created!
[oracle@rac12c01 ~]$ asmcmd lsdg
Restore and Recover the Missing Data File:
[oracle@rac12c01 ~]$ db_env
[oracle@rac12c01 ~]$ rman target sys@pdb1
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Dec 6 14:17:33 2016
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
target database Password:
connected to target database: CDBRAC (DBID=414791675)
RMAN> restore datafile 16;
RMAN> recover datafile 16;
RMAN> alter tablespace DATA2_TBS online;
Check the recovered data:
RMAN> select * from testuser.test_data;
C1
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected
留言列表