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 asm ASM is running on wissem [oracle@wissem ~]$ [oracle@wissem ~]$ ps -edf | grep smon oracle 3178 1 0 Mar04 ? 00:00:19 asm_smon_+ASM oracle 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 /nolog SQL*Plus: Release 11.2.0.1.0 Production on Sat Mar 5 02:40:26 2011 Copyright (c) 1982, 2009, Oracle. All rights reserved. SQL> connect sys as sysdba Enter 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 bytes Fixed Size 1336232 bytes Variable Size 247467096 bytes Database Buffers 58720256 bytes Redo Buffers 6336512 bytes Database 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 sysasm SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 4 22:43:50 2011 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production With the Automatic Storage Management option SQL> 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 DISK5 7 rows selected. SQL> SQL> select NAME, TOTAL_MB, FREE_MB from V$ASM_DISKGROUP; NAME TOTAL_MB FREE_MB ------------------------------ ---------- ---------- DATA 4000 1068 INDX 0 0 DATA_REPORTING 2000 1898 SQL> |
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.744952855 SQL> 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.25 SQL> insert into reporting values (1, sysdate); 1 row created. Elapsed: 00:00:00.28 SQL> insert into reporting values (2, sysdate); 1 row created. Elapsed: 00:00:00.04 SQL> commit; Commit complete. Elapsed: 00:00:00.34 SQL> select * from reporting; ID REP_DATE ---------- ------------------- 1 05-03-2011 03:25:04 2 05-03-2011 03:25:22 Elapsed: 00:00:00.23 SQL> |
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 ~]$ asmcmd ASMCMD> 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_REPORTING Current alias directory path: ORAW/DATAFILE Current alias directory path: ORAW ASMCMD> |
No comments:
Post a Comment