11gR2 ASM – Inside story – Part2 - 1 (Diskgroup restore)
Introduction
In the previous post of “11gR2 ASM – Inside story – Part1″, we have seen how to install grid infrastructure for standalone server and how to setup and configure an ASM instance.
In this Part2 of the story, we will see how to restore a diskgroup after a failure.
In the previous post of “11gR2 ASM – Inside story – Part1″, we have seen how to install grid infrastructure for standalone server and how to setup and configure an ASM instance.
In this Part2 of the story, we will see how to restore a diskgroup after a failure.
Oracle ASM disk and diskgroup
According to the , Oracle documentation. these are the definitions of ASM disk and ASM diskgroup;
1- Oracle ASM Disks: An Oracle ASM disk is a storage device that is provisioned to an Oracle ASM disk group. An Oracle ASM disk can be a physical disk or partition, a Logical Unit Number (LUN) from a storage array, a logical volume, or a network-attached file.
Oracle ASM disks can be added or dropped from a disk group while the database is running. When you add a disk to a disk group, you either assign a disk name or the disk is given an Oracle ASM disk name automatically.
According to the , Oracle documentation. these are the definitions of ASM disk and ASM diskgroup;
1- Oracle ASM Disks: An Oracle ASM disk is a storage device that is provisioned to an Oracle ASM disk group. An Oracle ASM disk can be a physical disk or partition, a Logical Unit Number (LUN) from a storage array, a logical volume, or a network-attached file.
Oracle ASM disks can be added or dropped from a disk group while the database is running. When you add a disk to a disk group, you either assign a disk name or the disk is given an Oracle ASM disk name automatically.
2- Oracle ASM Disk Groups: An Oracle ASM disk group is a collection of Oracle ASM disks managed as a logical unit. The data structures in a disk group are self-contained and consume some disk space in a disk group.
Within a disk group, Oracle ASM exposes a file system interface for Oracle database files. The content of files that are stored in a disk group are evenly distributed, or striped, to eliminate hot spots and to provide uniform performance across the disks. The performance is comparable to the performance of raw devices.
Within a disk group, Oracle ASM exposes a file system interface for Oracle database files. The content of files that are stored in a disk group are evenly distributed, or striped, to eliminate hot spots and to provide uniform performance across the disks. The performance is comparable to the performance of raw devices.
ASMCMD:
The asmcmd utility is a command line tool that helps you to manage and list files and directories within an ASM diskgroup.
This utility provides ASM metadata backup and restore functionality through the md_backup and md_restore commands.
ASM instance does not store data. ASM instance maintains the storage metadata such as disks, diskgroups, directories, ASM operations , etc…This means that when you lose a disk, or when a disk crash, you can use RMAN to restore the database itself but not the ASM metadata. The md_backup and md_restore commands let you backup and restore the ASM metadata.
In the previous Oracle version 10g, the only way to restore the ASM metadata was to manually create ALL ASM diskgroups and directories.
In the following section, we are going to simulate a diskgroup loss and I will show you how to restore it, without losing any data.
The asmcmd utility is a command line tool that helps you to manage and list files and directories within an ASM diskgroup.
This utility provides ASM metadata backup and restore functionality through the md_backup and md_restore commands.
ASM instance does not store data. ASM instance maintains the storage metadata such as disks, diskgroups, directories, ASM operations , etc…This means that when you lose a disk, or when a disk crash, you can use RMAN to restore the database itself but not the ASM metadata. The md_backup and md_restore commands let you backup and restore the ASM metadata.
In the previous Oracle version 10g, the only way to restore the ASM metadata was to manually create ALL ASM diskgroups and directories.
In the following section, we are going to simulate a diskgroup loss and I will show you how to restore it, without losing any data.
The demonstration
First of all, let’s check the status of ASM instance, if it’s running or not:
1
2
3
4
5
6
| [oracle@wissem ~]$ srvctl status asmASM is running on wissem[oracle@wissem ~]$ [oracle@wissem ~]$ ps -edf | grep smonoracle 3178 1 0 Mar04 ? 00:00:19 asm_smon_+ASMoracle 5440 1 0 Mar04 ? 00:00:20 ora_smon_ORAW |
in the case the ASM and database instance are not running, you must startup them.
Then, let’s configure the flash recovery area and put the database in archive log mode.
Then, let’s configure the flash recovery area and put the database in archive log mode.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| [oracle@wissem ~]$ source .bash_profile[oracle@wissem ~]$ sqlplus /nologSQL*Plus: Release 11.2.0.1.0 Production on Sat Mar 5 02:40:26 2011Copyright (c) 1982, 2009, Oracle. All rights reserved.SQL> connect sys as sysdbaEnter password: Connected.SQL> SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 4G SCOPE=BOTH;System altered.SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/admin/ORAW/fra' scope=BOTH;System altered.SQL> SQL> shutdown immediate; Database closed.Database dismounted.ORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 313860096 bytesFixed Size 1336232 bytesVariable Size 247467096 bytesDatabase Buffers 58720256 bytesRedo Buffers 6336512 bytesDatabase mounted.SQL> alter database archivelog;Database altered.SQL> alter database open;Database altered.SQL> |
Create a new diskgroup, we name it DATA_REPORTING:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| [oracle@wissem ~]$ export ORACLE_SID=+ASM[oracle@wissem ~]$ export ORACLE_HOME=$GRID_HOME[oracle@wissem ~]$ sqlplus / as sysasmSQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 4 22:43:50 2011Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionWith the Automatic Storage Management optionSQL> CREATE DISKGROUP DATA_REPORTING NORMAL REDUNDANCY DISK 2 '/dev/raw/raw5' name disk5 , 3 '/dev/raw/raw6' name disk6 force;Diskgroup created.SQL> SQL> select GROUP_NUMBER, NAME from V$ASm_DISK;GROUP_NUMBER NAME------------ ------------------------------ 0 1 DISK4 1 DISK3 1 DISK2 1 DISK1 2 DISK6 2 DISK57 rows selected.SQL> SQL> select NAME, TOTAL_MB, FREE_MB from V$ASM_DISKGROUP;NAME TOTAL_MB FREE_MB------------------------------ ---------- ----------DATA 4000 1068INDX 0 0DATA_REPORTING 2000 1898SQL> |
We create a new tablespace named “DATA_REPORTING”:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
| SQL> create tablespace data_reporting datafile '+DATA_REPORTING';Tablespace created.SQL> select NAME from v$datafile;NAME--------------------------------------------------------------------------------+DATA/oraw/datafile/system.256.744936879+DATA/oraw/datafile/sysaux.257.744936887+DATA/oraw/datafile/undotbs1.258.744936889+DATA/oraw/datafile/users.259.744936891+DATA_REPORTING/oraw/datafile/data_reporting.256.744952855SQL> SQL> create table reporting(ID NUMBER , REP_DATE DATE) TABLESPACE DATA_REPORTING;Table created.SQL> set timi on SQL> alter session set NLS_DATE_FORMAT='DD-MM-YYYY HH24:MI:SS';Session altered.Elapsed: 00:00:00.25SQL> insert into reporting values (1, sysdate);1 row created.Elapsed: 00:00:00.28SQL> insert into reporting values (2, sysdate);1 row created.Elapsed: 00:00:00.04SQL> commit;Commit complete.Elapsed: 00:00:00.34SQL> select * from reporting; ID REP_DATE---------- ------------------- 1 05-03-2011 03:25:04 2 05-03-2011 03:25:22Elapsed: 00:00:00.23SQL> |
We backup the ASM diskgroup DATA_REPORTING metadata with md_backup command:
1
2
3
4
5
6
7
8
9
10
11
12
13
| [oracle@wissem ~]$ cd /home/oracle[oracle@wissem ~]$ source .bash_profile[oracle@wissem ~]$ export ORACLE_SID=+ASM[oracle@wissem ~]$ export ORACLE_HOME=$GRID_HOME[oracle@wissem ~]$ export PATH=$ORACLE_HOME:$PATH[oracle@wissem ~]$ asmcmdASMCMD> ASMCMD> md_backup -b /tmp/asmbkp_data_reporting -G 'DATA_REPORTING'WARNING:option 'b' is deprecated for 'md_backup'Disk group metadata to be backed up: DATA_REPORTINGCurrent alias directory path: ORAW/DATAFILECurrent alias directory path: ORAWASMCMD> |
No comments:
Post a Comment