Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
-------------------------------------- * An Oracle file system, built specifically for database related files.
-- * Can be used for single or multiple instance architecture (RAC).
-(Eliminates the need for third party Clustered File System)
-- * Enables storage solutions such as Striping & Mirroring (for performance & Survivability)
-- * Stripes and Mirrors at file level (as opposed to volume level)
-- Files are striped more efficiently.
-- Mirroring can be enabled for specific files only, at different levels.
-- * Each DB can have both ASM and regular files. (Can also migrate some files to ASM)
-- * ASM can store all Oracle file types. (Not just Data Files).
ASM Advantages
-------------------------------------- 1. it is aware of the nature of Oracle database files. This means it can make
-- more intelligent decisions about how to manage the files than a third-party product.
-- 2. ASM can handle files individually, whereas all other LVMs work at the
-- volume level: they are not aware of the files within the volume. So with a third-party
-- LVM, you have to specify RAID attributes per volume.
-- ASM can specify the attributes per file, so you can for instance have three-way
-- mirroring for your SYSTEM tablespace datafiles but no mirroring at all for your
-- temporary tablespaces tempfiles, all within the same logical volume.
---
* 10g: 1MB
* 11g: Determined at DG creation. (1MB, 2, 4, 8, 16, 32, 64MB)
ATTRIBUTES (FINE);
ALTER DISKGROUP dg2 MODIFY TEMPLATE DATAFILE
ATTRIBUTES (COARSE);
Select * From V$ASM_TEMPLATE
WHERE name = ('DATAFILE', 'ONLINELOG')
AND group_number = 2
Disk Group Dynamic Rebalancing
-------------------------------------- * ASM performs automatic rebalancing online whenever we add / remove disks from a
DG.
-- * ASM_POWER_LIMIT:
-- - Controls IO overhead during rebalancing.
-- - Values are between 1 and 11. (Minimum overhead (1) .. Minumum time (11))
-- - The higher the limit, the faster rebalancing will complete.
-- - Lower values will take longer, but consume fewer processing and I/O resources.
show parameter ASM_POWER_LIMIT
ASM Mirroring & Failure Groups
-------------------------------------- * ASM can protect our files from media failures (disk / disk-controller crash)
--- * Mirroring:
-- - Applied at Extent (AU) level (Not at file or disk level).
-- - When an AU is allocated to a file on a specific disk,
-a mirrored AU is also allocated on another disk in the SAME Disk Group.
-- - Therefore, if a disk is lost, we can restore its contents
-from other disks on its Disk Group.
-- * Failure Group:
-- - A failure group is a subset of the disks in a disk group,
-which could fail at the same time because they share hardware.
-(For example, disks that share the same disk controller)
-- - By default, each ASM disk belongs to his own Failure Group (FG).
-- - However, we can group a few disks in a DG to a single Failure Group.
-- - When an AU is allocated on a FG disk, a mirrored AU is also allocated
-on ANOTHER Failure Group in the SAME Disk Group.
-- - Therefore, if a Failure Group is lost, we can restore its contents
-from other disks on its Disk Group.
-- * types or mirroring:
-1. External Redundancy - No mirroring or FGs. (When using an external tool for -protection).
-2. Normal Redundancy - Two-way mirroring. (Two copies)
-3. High Redundancy
- Triple-mirroring. (Three copies)
DROP DISKGROUP DG2 INCLUDING CONTENTS;
--
SELECT file_number, name, CASE ALIAS_DIRECTORY WHEN 'Y' THEN 'Directory' ELSE
'File' END Type
FROM v$asm_alias
ORDER BY type, file_number;
SYSASM
-------------------------------------- * Meant for ASM management. (Separate from SYSDBA for security)
-- * As ASM has no Data Dictionary, users are authenticated via OS or password-file.
-- * SYSOPER, enables basic administration, but not CREATE/ALTER/DROP DGs.
-(Startup/Shutdown, Mount/Dismount, Rebalance, Online/Offline disk, v$ASM_*)
-- * SYSDBA enables all SYSASM privs, but will be limited in the future.
-- * Via OEM (Only if connected via SYSASM):
-- ASM => Users => Create/Edit/Delete
-- (Connecting as SYSASM: Preferences => Preferred Credentials => ASM:Set Credentials
=> Specify...
-- In CMD:
SET ORACLE_SID=+ASM
sqlplus /nolog
conn / as sysasm
SELECT GROUP_NUMBER, NAME, TOTAL_MB
FROM v$asm_diskgroup;
-- Or:
CREATE USER asm_mgr IDENTIFIED BY asm_mgr;
GRANT SYSASM TO asm_mgr;
SELECT * FROM v$pwfile_users;
conn asm_mgr/asm_mgr AS SYSASM
set oracle_sid=+ASM
sqlplus / as sysasm
col name for a10
col path for a30
SELECT GROUP_NUMBER, NAME, STATE, TYPE, TOTAL_MB
FROM V$ASM_DISKGROUP
ORDER BY 1;
SELECT GROUP_NUMBER "DG#", DISK_NUMBER "DSK#", NAME, FAILGROUP, PATH, OS_MB,
TOTAL_MB, FREE_MB
FROM v$asm_disk;
CREATE DG
------------------------ * We can optionally name and size each disk.
-- (Otherwise a system generated name is given, and ASM determines its size
automatically)
-- * FORCE - Move the disk from another DG to this one.
CREATE DISKGROUP DG2
NORMAL REDUNDANCY
DISK
'//./ORCLDISKDATA3'
'//./ORCLDISKDATA4'
'//./ORCLDISKDATA5'
'//./ORCLDISKDATA6'
NAME
NAME
NAME
NAME
DG2_0,
DG2_1,
DG2_2,
DG2_3;
DROP DG
------------------------ * INCLUDING CONTENTS - Must be specified if it contains files.
-- * The DG must be mounted, and its files inactive.
-- * The header of each disk is formatted, so it will be available
-to other DGs or to the OS.
DROP DISKGROUP DG2 INCLUDING CONTENTS;
Adding disks to a DG
------------------------------ * Disks are added and Rebalaced online while data is fully accessible.
-- * The rebalancing load is determined according to ASM_POWER_LIMIT.
SELECT GROUP_NUMBER "DG#", DISK_NUMBER "DSK#", NAME, FAILGROUP, PATH, OS_MB,
TOTAL_MB, FREE_MB
FROM v$asm_disk
WHERE group_number=0
ORDER BY path;
-- Add two disks to a "DG1":
ALTER DISKGROUP DG1 ADD DISK
'//./ORCLDISKDATA3' NAME DG1_3,
'//./ORCLDISKDATA4' NAME DG2_4;
-- Special discovery characters can be used to add a group of disks.
ALTER DISKGROUP DG1 ADD DISK '//./ORCLDISKDATA*';
ASM DG Compatability
------------------------------- * Determines which Oracle version can run the ASM or work with him.
-- * Determined at Disk Group level.
-- * Two types:
-- 1. RDBMS Compatibility (Compatible.RDBMS)
-- Refers to the regular instances which work with the ASM.
-- The compatability version of the instance must be equal or higher.
-- Determines the format of the massages between the ASM and the regular instance.
-- ASM can operate with instances of different compatability versions.
-- 2. ASM Compatability (Compatible.ASM)
-- The compatability version of the ASM instance (ASM Metadata).
-- Must be greater or equal to the RDBMS comp. of the FG.
------------------------------- ASM DG Attributes
------------------------------- * We can specify DG attributes when creating and altering the DG in the ATTRIBUTE
clause.
-- - AU_SIZE (C)
- Allocation Unit size (1MB ,2, 4, 8, 16, 32, 64MB)
-- - COMPATIBLE.RDBMS (AC) - Minimal Oracle version for the regular instances using the
DG.
-- - COMPATIBLE.ASM (AC) - Minimal Oracle version for the ASM instance mounting the
DG.
-- - DISK_REPAIR_TIME (AC) - Length of time before removing a disk once OFFLINE
-- - TEMPLATE.t-name.REDUNDANCY (A) - Redundancy level of a specifid template.
-(UNPROTECTED / MIRROR / HIGH)
-- - TEMPLATE.t-name.STRIPE (A) - Striping attribute of specified template. (COARSE /
FINE)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = OWNER-3WSG9BKMD)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = +ASM)
)
)
*/
DG#
---------1
1
0
0
PATH
-------------------------------------------------\\.\ORCLDISK_LABEL_E
\\.\ORCLDISK_LABEL_F
\\.\ORCLDISK_LABEL_G
\\.\ORCLDISK_LABEL_H
SYS@ASM>
SYS@ASM> -- DG#=0 means that specific path does not have any Disk Group
SYS@ASM>
SYS@ASM> -- Join:
SYS@ASM> SELECT GROUP_NUMBER, dg.name, SUM(d.TOTAL_MB) AS "Size", COUNT(*) AS
"Disks"
2 FROM v$asm_diskgroup dg JOIN v$asm_disk d
3 USING (GROUP_NUMBER)
4 GROUP BY GROUP_NUMBER, dg.name ;
GROUP_NUMBER NAME
Size
Disks
------------ ------------------------------ ---------- ---------1 DG1
9998
2
SYS@ASM>
SYS@ASM> -- Create a new disk group DG2:
SYS@ASM> CREATE DISKGROUP DG2
2 DISK
3 '\\.\ORCLDISK_LABEL_G' NAME DG2_0,
4 '\\.\ORCLDISK_LABEL_H' NAME DG2_1 ;
Diskgroup created.
SYS@ASM> -- See available disks:
SYS@ASM> SELECT GROUP_NUMBER "DG#", PATH
2 FROM v$asm_disk
3 ORDER BY path;
DG#
---------1
1
2
2
PATH
-------------------------------------------------\\.\ORCLDISK_LABEL_E
\\.\ORCLDISK_LABEL_F
\\.\ORCLDISK_LABEL_G
\\.\ORCLDISK_LABEL_H
SYS@ASM>
SYS@ASM> -- DROP DISKGROUP DG2;
SYS@ASM>
SYS@ASM> ------------------------------------SYS@ASM> -- Create a tablespace with ASM file
SYS@ASM> -- (Performed in the DB instance)
SYS@ASM> ------------------------------------SYS@ASM>
SYS@ASM> conn sys/oracle@orcl as sysdba
Connected.
SYS@orcl>
SYS@orcl> CREATE TABLESPACE ASM_TBS
2
DATAFILE '+DG2/asm_tbs01.dbf' SIZE 100M;
Tablespace created.
SYS@orcl> SELECT name FROM v$datafile;
NAME
------------------------------------------------------------------------------C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
C:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBF
+DG2/asm_tbs01.dbf
6 rows selected.
SYS@orcl>
SYS@orcl> -SYS@orcl>
SYS@orcl>
SYS@orcl> -- *
can be done by
SYS@orcl> -SYS@orcl> -- *
SYS@orcl> -ASM => STARTUP
SYS@orcl> -- *
SYS@orcl>
NAME
STRIPE REDUND
------------------------------ -----PARAMETERFILE
COARSE
ASMPARAMETERFILE
COARSE
ASMPARAMETERBAKFILE
COARSE
-----MIRROR
MIRROR
MIRROR
1
1
1
1
1
1
1
1
DUMPSET
CONTROLFILE
FLASHFILE
ARCHIVELOG
ONLINELOG
DATAFILE
TEMPFILE
BACKUPSET
COARSE
FINE
COARSE
COARSE
COARSE
COARSE
COARSE
COARSE
MIRROR
HIGH
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
GROUP_NUMBER
-----------1
1
1
1
1
1
1
1
2
2
2
NAME
STRIPE REDUND
------------------------------ -----AUTOBACKUP
COARSE
XTRANSPORT
COARSE
CHANGETRACKING
COARSE
FLASHBACK
COARSE
DATAGUARDCONFIG
COARSE
OCRFILE
COARSE
OCRBACKUP
COARSE
ASM_STALE
COARSE
PARAMETERFILE
COARSE
ASMPARAMETERFILE
COARSE
ASMPARAMETERBAKFILE
COARSE
-----MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
HIGH
MIRROR
MIRROR
MIRROR
GROUP_NUMBER
-----------2
2
2
2
2
2
2
2
2
2
2
NAME
STRIPE REDUND
------------------------------ -----DUMPSET
COARSE
CONTROLFILE
FINE
FLASHFILE
COARSE
ARCHIVELOG
COARSE
ONLINELOG
COARSE
DATAFILE
COARSE
TEMPFILE
COARSE
BACKUPSET
COARSE
AUTOBACKUP
COARSE
XTRANSPORT
COARSE
CHANGETRACKING
COARSE
-----MIRROR
HIGH
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
MIRROR
GROUP_NUMBER
-----------2
2
2
2
2
NAME
STRIPE REDUND
------------------------------ -----FLASHBACK
COARSE
DATAGUARDCONFIG
COARSE
OCRFILE
COARSE
OCRBACKUP
COARSE
ASM_STALE
COARSE
-----MIRROR
MIRROR
MIRROR
MIRROR
HIGH
38 rows selected.
SYS@orcl>
SYS@orcl>
SYS@orcl>
SYS@orcl>
SYS@orcl>
SYS@orcl>
disks.
SYS@orcl>
S NAME
PRIM MIRR
- ------------------------------ ---Y ONLINELOG
COLD
Y DATAFILE
COLD
NAME
STRIPE REDUND
------------------------------ ------ -----ONLINELOG
FINE
MIRROR
DATAFILE
COARSE MIRROR
SYS@orcl>
SYS@orcl> CONN /@ASM AS SYSASM
SYS@ASM> DROP DISKGROUP DG2 INCLUDING CONTENTS;
ASM Mirroring & Failure Groups
--------------------------------------------------------------------------------------------- * ASM can protect our files from media failures (disk / disk-controller
crash)
--
-- * Mirroring:
-- Applied at
-- When an AU
also allocated on
-- Therefore,
disks on its Disk
-- * Failure Group:
-- A failure group is a subset of the disks in a disk group, which could
fail at the same time because they share hardware. (For example, disks that
share the same disk controller)
-- By default, each ASM disk belongs to his own Failure Group (FG).
-- However, we can group a few disks in a DG to a single Failure Group.
-- When an AU is allocated on a FG disk, a mirrored AU is also allocated
on ANOTHER Failure Group in the SAME Disk Group.
-- Therefore, if a Failure Group is lost, we can restore its contents from
other disks on its Disk Group.
-- *
types or mirroring:
-1. External Redundancy - No mirroring or FGs. (When using an external
tool for protection).
-2. Normal Redundancy
- Two-way mirroring.
(Two copies)
-3. High Redundancy
- Triple-mirroring.
(Three copies)
SYS@ASM> col path for a50
SYS@ASM> -- See available disks:
SYS@ASM> SELECT GROUP_NUMBER "DG#", PATH
2 FROM v$asm_disk
3 ORDER BY path;
DG#
---------1
1
0
0
PATH
-------------------------------------------------\\.\ORCLDISK_LABEL_E
\\.\ORCLDISK_LABEL_F
\\.\ORCLDISK_LABEL_G
\\.\ORCLDISK_LABEL_H
Diskgroup created.
SYS@ASM> SELECT GROUP_NUMBER "DG#", DISK_NUMBER "DSK#", NAME, FAILGROUP
2 FROM v$asm_disk;
DG#
DSK# NAME
FAILGROUP
---------- ---------- ---------- ----------2
0 DG2_0000
DG2_0000
2
1 DG2_0001
DG2_0001
1
0 DG1_0000
DG1_0000
1
1 DG1_0001
DG1_0001