ASM


/*Init parameters of ASM instance*/
 
 INSTANCE_TYPE -- must be ASM
 ASM_POWER_LIMIT -- [1-10]
 ASM_DISKSTRING
 ASM_DISKGROUPS
 
 Css should be up and running for synchronizing db instance and asm instance
 -- crsctl check cssd
 
 -- insufficient number of failure groups or disks running out of disk space
 select redundancy_lowered from v$asm_file;
 -- free_mb . required_mirror_free_mb = 2 * usable_file_mb
 select required_mirror_free_mb, usable_file_mb from v$asm_diskgroup;
 
 creating diskgroup
 -- disk names are available in v$asm_disk view
 -- set ORACLE_SID and ORACLE_HOME for asm instance

 sqlplus /nolog
SQL> connect / as sysdba
 startup nomount;
 create diskgroup <disk_group_name> normal|high|external redundancy [force|noforce]
 [failgroup <failgroupname>] DISK
 e<disk name>' [NAME <diskname>],
 e<disk name>'
 [failgroup <failgroupname> DISK
 e<disk name>',
 e<disk name>']
 
 alter diskgroup <disk_group_name> add disk
 'disk_name' NAME diska1,
 'disk_name' NAME diska2,
 'disk_name[5678]',
 'disk_name*' [FORCE]
 [REBALANCE POWER 5 WAIT|NOWAIT]
 
 alter diskgroup <disk_group_name> drop disk <disk_name>
 
 alter diskgroup <disk_group_name> resize disks [in failgroup
 <failgroupname> [size 100M]]
 
 alter diskgroup <disk_group_name> rebalance [WAIT|NOWAIT] [POWER n];
 select * from v$asm_operation;
 
 alter diskgroup <disk_group_name>|ALL MOUNT | DISMOUNT;
 alter diskgroup <disk_group_name> check [REPAIR|NOREPAIR] all;
 
 drop diskgroup <disk_group_name> INCLUDING | EXCLUDING contents;
 alter diskgroup <disk_group_name> add directory
 '+<disk_group_name>/<dir_name>/..';
 alter diskgroup <disk_group_name> rename directory '<dir1>' to '<dir2>';
 alter diskgroup <disk_group_name> drop directory '<dir_name>';
 alter diskgroup <disk_group_name> add alias '..' FOR '..';
 select * from v$asm_alias;
alter diskgroup <disk_group_name> drop file ‘..’;
select software_version, compatible_version from v$asm_client;
-- fully qualified asm filename
+group/dbname/file_type/file_type_tag.file.incarnation
+dgroup2/sample/controlfile/Current.256.541956473

-- numeric asm filename
+group.file.incarnation
+dgroup2.257.541956473

-- incomplete ASM filenames
-- asm creates the unique filename
alter system set db_create_file_dest=’+diskgroup1’;

-- if you want asm to be default destination set the following init parameters
DB_CREATE_FILE_DEST
DB_CREATE_ONLINE_LOG_DEST_n
DB_RECOVERY_FILE_DEST
CONTROL_FILES
LOG_ARCHIVE_DEST_n
LOG_ARCHIVE_DEST
STANDBY_ARCHIVE_DEST
LARGE_POOL_SIZE – minimum 1mb

-- Using an ASM Filename in a SQL Statement: Example
CREATE TABLESPACE tspace2 DATAFILE '+dgroup2' SIZE 200M AUTOEXTEND ON;

-- Creating a Database in ASM
DB_CREATE_FILE_DEST = '+dgroup1'
DB_RECOVERY_FILE_DEST = '+dgroup2'
DB_RECOVERY_FILE_DEST_SIZE = 10G

CREATE DATABASE sample;

--Creating a Tablespace in ASM
DB_CREATE_FILE_DEST = '+dgroup2'

CREATE TABLESPACE tspace2;

‐‐the file is not an Oracle‐managed file
CREATE UNDO TABLESPACE myundo
DATAFILE '+dgroup3(my_undo_template)/myfiles/my_undo_ts' SIZE 200M;
ALTER DISKGROUP dgroup3 DROP FILE '+dgroup3/myfiles/my_undo_ts';

--Adding New Redo Log Files
DB_CREATE_ONLINE_LOG_DEST_1 = '+dgroup1'
DB_CREATE_ONLINE_LOG_DEST_2 = '+dgroup2'
ALTER DATABASE ADD LOGFILE;

--Creating a Control File in ASM
--Noresetlogs example, script is from “alter database backup controlfile to trace”
CREATE CONTROLFILE REUSE DATABASE "SAMPLE" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 (
'+DGROUP1/db/onlinelog/group_1.258.541956457',
'+DGROUP2/db/onlinelog/group_1.256.541956473'
) SIZE 100M,
GROUP 2 (
'+DGROUP1/db/onlinelog/group_2.257.541956477',
'+DGROUP2/db/onlinelog/group_2.258.541956487'
) SIZE 100M
DATAFILE
'+DGROUP1/db/datafile/system.260.541956497',
'+DGROUP1/db/datafile/sysaux.259.541956511'
CHARACTER SET US7ASCII
;

--resetlogs example
CREATE CONTROLFILE REUSE DATABASE "SAMPLE" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 30
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 (
'+DGROUP1',
'+DGROUP2'
) SIZE 100M,
GROUP 2 (
'+DGROUP1',
'+DGROUP2'
) SIZE 100M
DATAFILE
'+DGROUP1/db/datafile/system.260.541956497',
'+DGROUP1/db/datafile/sysaux.259.541956511'
CHARACTER SET US7ASCII
;

-- system views
V$ASM_DISKGROUP
V$ASM_DISK
V$ASM_DISKGROUP_STAT
V$ASM_DISK_STAT
V$ASM_FILE
V$ASM_TEMPLATE
V$ASM_ALIAS
V$ASM_OPERATION
V$ASM_CLIENT
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: