0% found this document useful (0 votes)
14 views

ASM Lab Manual Guide

Uploaded by

Gaurav Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

ASM Lab Manual Guide

Uploaded by

Gaurav Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Oracle 11g:

ASM Administration
Lab Practice Guide
1. Installation of Grid Infrastructure & ASM

1. Performing Pre-installation Tasks for Oracle Grid Infrastructure


A. Pre-requisite checks:
1) To check the IP address of node.
# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:74:C5:58
inet addr:192.168.56.10 Bcast:192.168.56.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2392186 errors:0 dropped:0 overruns:0 frame:0
TX packets:212596 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3541584221 (3.2 GiB) TX bytes:19965359 (19.0 MiB)

2) Check the number of disks you have and their sizes.


To view disks from common storage
# fdisk –l /dev/sd*
/dev/sda
/dev/sdb

B. Create logical partitions on extended partition:


Use the "fdisk" command to create the logical partition disks under /dev/sdb from sdb5 to sdb9. The
following output shows the expected fdisk output for the sdb disk.
# fdisk /dev/sdb

Command (m for help): n


Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610

Command (m for help): n


Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +2G
Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (245-2610, default 245):
Using default value 245
Last cylinder or +size or +sizeM or +sizeK (245-2610, default 2610): +2G

Command (m for help): n


Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (489-2610, default 489):
Using default value 489
Last cylinder or +size or +sizeM or +sizeK (489-2610, default 2610): +2G

Like this, create all partitions with size of 2GB and last save the changes by typing “w”.

Command (m for help):w -- (to save the changes)

Check that the expected partitions exist. Partitions named /dev/sdb5, /dev/sdb6, and others should exist.
Check by using
# cat /proc/partitions

If required, execute the below command 2-3 times and check again.
# partx -a /dev/sdb -- ( try executing 2-3 times)
# fdisk –l
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 5 Extended
/dev/sdb5 1 244 1959867 83 Linux
/dev/sdb6 245 488 1959898+ 83 Linux
/dev/sdb7 489 732 1959898+ 83 Linux
/dev/sdb8 733 976 1959898+ 83 Linux
/dev/sdb9 977 1220 1959898+ 83 Linux
/dev/sdb10 1221 1464 1959898+ 83 Linux
/dev/sdb11 1465 1708 1959898+ 83 Linux
/dev/sdb12 1709 1952 1959898+ 83 Linux
/dev/sdb13 1953 2196 1959898+ 83 Linux
/dev/sdb14 2197 2440 1959898+ 83 Linux
/dev/sdb15 2441 2610 1365493+ 83 Linux

NOTE: Above you’ll see all 11 partitions created, but the last sdb15 is with less size.

C. Creating Groups, Users, Directories & setting permissions.


1) Setting up required groups and users:
# groupadd -g 501 oinstall
# groupadd -g 502 dba
# groupadd -g 503 oper
# groupadd -g 504 asmdba
# groupadd -g 505 asmoper
# groupadd -g 506 asmadmin
# useradd -u 501 -g oinstall -G dba,oper,asmdba oracle
# passwd oracle ( enter password: oracle )
# useradd -u 502 -g oinstall -G dba,asmoper,asmdba,asmadmin grid
# passwd grid (enter password: grid )

2) As the root user, create the oracle user directories.


# mkdir -p /u01/app/oracle/product/11.2.0
# chown -R grid:oinstall /u01
# chmod -R 775 /u01/app/oracle
# chown -R oracle:oinstall /u01/app/oracle

D. Editing Operating System settings to support GI Installation.


1) edit in /etc/security/limits.conf using vi command.
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 4096
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 4096
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768

2) Set the kernel parameters in /etc/sysctl.conf


fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

Run the following command to change the current kernel parameters.


# /sbin/sysctl –p

3) Install the following packages if they are not already present.


From Oracle Linux 5 DVD
# cd /media/cdrom/Server
rpm -Uvh binutils-2.*
rpm -Uvh compat-libstdc++-33*
rpm -Uvh compat-libstdc++-33*.i386.rpm
rpm -Uvh elfutils-libelf*
rpm -Uvh gcc-4.*
rpm -Uvh gcc-c++-4.*
rpm -Uvh glibc-2.*
rpm -Uvh glibc-common-2.*
rpm -Uvh glibc-devel-2.*
rpm -Uvh glibc-headers-2.*
rpm -Uvh ksh*
rpm -Uvh libaio-0.*
rpm -Uvh libaio-devel-0.*
rpm -Uvh libgomp-4.*
rpm -Uvh libgcc-4.*
rpm -Uvh libstdc++-4.*
rpm -Uvh libstdc++-devel-4.*
rpm -Uvh make-3.*
rpm -Uvh sysstat-7.*
rpm -Uvh unixODBC-2.*
rpm -Uvh unixODBC-devel-2.*
rpm -Uvh numactl-devel-*
rpm –Uvh oracleasm-support*
rpm –Uvh oracleasm-2.6.18-274.el5-2*

E. Creating ASM disks


As root, execute the oracleasm configure –i command to configure the Oracle ASM library
driver. The owner should be grid and the group should be asmadmin. Make sure that the driver loads
and scans disks on boot.

# oracleasm configure -i
Configuring the Oracle ASM library driver.
Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done

Create the ASM disks needed for the practices.


# oracleasm init
# oracleasm createdisk ASMDISK01 /dev/sdb5
# oracleasm createdisk ASMDISK02 /dev/sdb6
# oracleasm createdisk ASMDISK03 /dev/sdb7
# oracleasm createdisk ASMDISK04 /dev/sdb8
# oracleasm createdisk ASMDISK05 /dev/sdb9
# oracleasm createdisk ASMDISK06 /dev/sdb10
# oracleasm createdisk ASMDISK07 /dev/sdb11
# oracleasm createdisk ASMDISK08 /dev/sdb12
# oracleasm createdisk ASMDISK09 /dev/sdb13
# oracleasm createdisk ASMDISK10 /dev/sdb14

Perform an oracleasm listdisks command to make sure all the disks have been configured.

# oracleasm listdisks
ASMDISK01
ASMDISK02
ASMDISK03
ASMDISK04
ASMDISK05
ASMDISK06
ASMDISK07
ASMDISK08
ASMDISK09
ASMDISK10

II. Grid Infrastructure Software Installation:


Connect to vncserver as grid user to start installation
# su - grid
$ vncserver :1
password : grid
Login to server using VNC session and start the installation. The grid software is present in stage
directory.
Use vnc viewer and enter : 192.168.56.10:1

$ cd /stage/grid
Run the runinstaller to start the installation

$ ./runInstaller
1) Installation Type : Select Install and Configure Grid Infrastructure for a Standalone Server, click next
2) Product Languages: Move sure you have selected English language. Click Next.
3) Create ASM diskgroup:
 Disk Group name DATA
 Set Redundancy to External
 To select the disks, click on change discovery path and enter : /dev/oracleasm/disks
 select ASMDISK01, ASMDISK02, ASMDISK03
 Click Next
4) ASM Password :
 Select 'Use same passwords for these accounts'
 Enter your password : oracle_4U
 Confirm the password
 Click Next
5) Operating Sytem groups: Keep the default groups (asmdba, asmoper, asmadmin) and click next.
6) Installation Location:
 Set the Software Location to /u01/app/oracle/grid
 Set the Oracle Base to /u01/app/oracle
 Click Next
7) Create Inventory: /u01/app/oraInventory
8) Prerequisite Checks: Prerequisite Check page appears and completes the checks.
9) Summary: On the Summary page, the installation settings are shown. Click Finish to complete the
installation.
10) Setup : The setup page shows the install progress.
11) Execute configuration scripts as root user.
12) Finish: When the Finish page appears, with the message "The installation of Oracle Grid Infrastructure
for single Server was successful", click Close
2. Managing ASM Instance

You can administer Oracle ASM initialization parameter files with SQL*Plus, Oracle Enterprise Manager,
ASMCA, and ASMCMD commands.

1. To create or move an SPFILE in a disk group.


1) First check where is my current SPfile. ( by default it’s in ASM disk group)
After opening a terminal session, set the environment :
$ . oraenv
ORACLE_SID=[grid]? +ASM
TheOraclebaseforORACLE_HOME=/u01/app/oracle/product/11.2.0/dhbome_1is
/u01/app/ oracle/product/11.2.0/dhbome_1
$ sqlplus / as sysasm
SQL> show parameter spfile
$ asmcmd
ASMCMD> spget

2) Create a PFILE from spfile.


SQL> create pfile='$HOME/asmpfile.ora' from spfile;

3) Shutdown & start ASM Instance using PFILE.


SQL> shutdown abort
SQL> startup pfile='$HOME/asmpfile.ora';
SQL> show parameter spfile -- (no spfile is used )

4) Create an SPFILE in a disk group that has COMPATIBLE.ASM set to 11.2 with the SQL CREATE SPFILE
statement from the existing PFILE.
SQL> CREATE SPFILE = '+DATA/asm/spfileASM.ora'
FROM PFILE = '$HOME/asmpfile.ora';

The CREATE SPFILE statement also updates the Grid Plug and Play (GPnP) profile. You can check the
location of the Oracle ASM SPFILE in the GPnP profile with the ASMCMD spget command.

5) Now check about spfile.


$ asmcmd
ASMCMD> spget

6) Restart the Oracle ASM instance so that the instance reads the SPFILE from the new location.

2. Enquire about the Disk Group & ASM disks using SQLPlus
Connect to ASM instance as grid user.
$ sqlplus / as sysasm
Check the diskgroup’s information.
SQL> col name format a10
SQL> col path format a35
SQL> set line 150
SQL> col failgroup format a10
SQL> select group_number, name, sector_size, allocation_unit_size "AU",
state, type, total_mb
from v$asm_diskgroup;
NOTE: DATA Diskgroup is available with external redundancy option (type column value).

Check asm disk’s information.


SQL> select GROUP_NUMBER, DISK_NUMBER, name, path, MOUNT_STATUS,
HEADER_STATUS, MODE_STATUS, state, TOTAL_MB
from v$asm_disk
order by 1,2;

SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,


SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk;

Check the values like Redundancy, Failgroup, Sector_size, Total_MB, Free_MB & status for disk group# 1.

3. Changing parameters in ASM spfile


SQL> show parameter ASM_POWER_LIMIT
NAME TYPE VALUE
------------------- ----------- ------------------
asm_power_limit integer 1

SQL> ALTER SYSTEM set ASM_POWER_LIMIT=3 SCOPE=BOTH;

SQL> show parameter ASM_POWER_LIMIT


NAME TYPE VALUE
------------------- ----------- ------------------
asm_power_limit integer 3

4. Querying ASM instance using ASMCMD utility


Asmcmd is a command line tool that can be used to manage ASM instance.
$ asmcmd

ASMCMD> du
du -- Total space in MB used by files.

ASMCMD> lsdg
State Type Rebal Sector Block AU Total_MB Free_MB
Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED EXTERN N 512 4096 1048576 1928 1867
0 0 N DATA/
lsdg - list information about a particular diskgroup or all mounted diskgroups.

ASMCMD> lsdsk -–statistics


ReadsWrite Read_Errs Write_Errs Read_time Write_Time
Bytes_Read Bytes_Written Voting_File Path
689310 0 0 324.968 74.8
103
664005 30048563 Y ORCL:ASMDISK01
632
102731 2
0 0 338.432 84.596
1096
743536 34666393 Y ORCL:ASMDISK02
128
634510 6
0 0 283.62 59.944
971
599138 24601139 Y ORCL:ASMDISK03
304
153 2
0 0 1 0
0
156876 0 N O ORCL:ASMDISK05
8

5. Starting and Stopping ASM Instance by Using ASMCMD


$ asmcmd
ASMCMD> shutdown
ASMCMD> shutdown –immediate
ASMCMD> shutdown --abort
ASMCMD> startup -–nomount /home/oracle/initASM.ora
ASMCMD> startup -mount

6. Drop and Re-create DATA diskgroup with NORMAL Redundancy:


1) We don’t have any other data except spfile in DATA diskgroup, so first create an pfile, then drop the
diskgroup, create new diskgroup with Normal redundancy, and create spfile into it.
SQL> show parameter spfile
NAME TYPE VALUE
------------------ ----------- -----------------
spfile string +DATA/asm/spfileasm.ora

SQL> create pfile='$HOME/initasm.ora'


from spfile='+DATA/asm/spfileasm.ora';

SQL> shutdown abort;


ASM instance shutdown

SQL> startup pfile='$HOME/initasm.ora';


ASM instance started
Total System Global Area 283930624 bytes
Fixed Size 2212656 bytes
Variable Size 256552144 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups mounted

SQL> drop diskgroup data;


drop diskgroup data
*
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15053: diskgroup "DATA" contains existing files

SQL> drop diskgroup data including contents;


Diskgroup dropped.

2) Use ASMCA graphical utility to create the new DATA diskgroup with NORMAL redundancy.

Start vncserver as grid user.


$ vncserver :1

Use vnc viewer and connect : 192.168.56.10:1 enter password : oracle


In the terminal window, set environment to +ASM using .oraenv

Invoke asmca in vnc viewer terminal session.


$ asmca
 Click on create
 Disk group name : DATA
 Redundancy : Normal
 Select : ASMDISK1, ASMDISK2 & ASMDISK3 (whose header status is shown as FORMER)
 Click OK & close the VNC session as of now.

3) Now create SPFILE into DATA diskgroup & bounce the ASM Instance. (putty terminal can be used)

SQL> create spfile='+DATA/asm/spfileASM.ora'


from pfile='$HOME/initasm.ora';

NOTE: you can bounce your ASM using ASMCMD utility too.

[grid@asm1 ~]$ asmcmd


ASMCMD> shutdown --immediate
ASM diskgroups dismounted
ASM instance shutdown
Connected to an idle instance.

ASMCMD> startup
ASM instance started
Total System Global Area 283930624 bytes
Fixed Size 2212656 bytes
Variable Size 256552144 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted

4) Check you diskgroup & spfile status


SQL> show parameter pfile
NAME TYPE VALUE
---------------------- ----------- -------------------------
spfile string +DATA/asm/spfileasm.ora

Check the diskgroup’s information.


SQL> col name format a10
SQL> col path format a35
SQL> set line 150
SQL> col failgroup format a10

SQL> select group_number, name, sector_size, allocation_unit_size "AU",


state, type, total_mb
from v$asm_diskgroup;

NOTE: DATA Diskgroup is available with external redundancy option (type column value).

Check asm disk’s information.


SQL> select GROUP_NUMBER, DISK_NUMBER, name, path, MOUNT_STATUS,
HEADER_STATUS, MODE_STATUS, state, TOTAL_MB
from v$asm_disk
order by 1,2;

SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,


SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk;

Check the values like Redundancy, Failgroup, Sector_size, Total_MB, Free_MB & status for disk group# 1.

7. Create another diskgroup “FRA” for database files


Create FRA diskgroup using asmca from vnc viewer session.
Use vnc viewer and connect : 192.168.56.10:1 enter password : oracle
In the terminal window, set environment to +ASM using .oraenv

Invoke asmcmd in vnc viewer terminal session.


$ asmca
 Click on create
 Disk group name : FRA
 Redundancy : Normal
 Select : ASMDISK4, ASMDISK5 & ASMDISK6
 Click OK & close the VNC session as of now.

Check the new diskgroup status using the above views.


3. Installing Oracle Database Software

1. Download Oracle database software


Download the Oracle database 11.2.0.1 software from oracle.com for linux operating system & upload the
files in our VM using winscp into stage folder.
Unpack Files
# cd /stage
# unzip linux.x64_11gR2_database_1of2
# unzip linux.x64_11gR2_database_2of2

You should now have a single directory called "database" containing installation files.

2. Performing Pre-installation tasks


NOTE: Editing /etc/hosts file, Installing the required rpm’s, Kernel parameter settings, Security limits, Oracle
user & required directory structure was already got created while doing the Grid Infrastructure installation.

3. Installation the software


Log into the oracle user,and start vncserver
# su - oracle
$ vncserver :2
$ vncpasswd (enter: oracle)

Login using VNC viewer : 192.168.56.10:2 and enter oracle user password. Now open a terminal (if
required) and start the installation.
$ cd /stage
$ cd database
Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.
$ ./runInstaller

You can see the installation steps below.


Configure Security Updates
Uncheck, I wish to receive security updates, next
Email address not specified, click yes

Select Install Option


Select, Install database software only, next

Node Selection
Select, Single instance database installation, next

Product languages
English is default selected, click next

Select database Edition


Select, Enterprise edition, next
Specify Installation Location
Oracle Base : /u01/app/oracle
Software location: /u01/app/oracle/product/11.2.0/dbhome_1
Click next

Privileged OS groups
Default settings – dba, oper,
Next

Perform Prerequisite Checks

Summary
Click on Finish

NOTE: Installation starts, wait for some time. In the last, it will ask us to run a scripts as root user. Open
another terminal window as root user and execute those scripts.
# /u01/app/oracle/product/11.2.0/dbhome_2/root.sh
( just press enter for all the options )

On OUI window
Click next and close.
4. Creating a Database using DBCA

Database Configuration Assistant (DBCA) is a graphical mode of creating your database. Use the same VNC
viewer session of oracle user to create the database.

As an oracle user run the dbca command


$ cd /u01/app/oracle/product/11.2.0/dbhome_1/bin
$ ./dbca

Follow the steps mentioned below to create a database named DB11G.


1) On welcome page, click next
2) Select Create database, click next
3) Select general purpose and click next
4) Give global database name and sid as ORCL
5) Select configure enterprise manager, and select configure database control for local management
Go to Automatic Maintenance Task tab : uncheck maintenance task, click next
6) Select use same administrative passwords for all accounts, enter oracle_4U, click next
7) Select source type : Automatic Storage Management
Select Oracle managed files : Browse, select +DATA, then click next.
8) Specify ASM-SYS password same as you mentioned above, enter oracle_4U, click OK
9) Select checkbox for flash recovery area and select +FRA using browse, click next
10) If you get any popup saying not enough free space, click yes and continue
11) Select sample schemas option and click next.
12) Memory Management : Use typical option and set memary equal to 507M,
Select Character set tab, select use UNICODE, then click next
13) Database Storage - Location of Control file, size of redo and Datafiles. Click next
14) Creation Options : Select create database
15) Database Creation complete click exit, then finish.
3. Administrating ASM Diskgroups

1. Check DATA & FRA diskgroup’s information connecting to ASM Instance.


$ sqlplus / sysasm
SQL> col name format a10
SQL> col path format a35
SQL> set line 150
SQL> col failgroup format a10
SQL> select group_number, name, sector_size, allocation_unit_size "AU",
state, type, total_mb
from v$asm_diskgroup;

Check asm disk’s information.


SQL> select GROUP_NUMBER, DISK_NUMBER, name, path, MOUNT_STATUS,
HEADER_STATUS, MODE_STATUS, state, TOTAL_MB
from v$asm_disk
order by 1,2;

SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,


SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk order by 1;

Check the values like Redundancy, Failgroup, Total_MB, Free_MB, HOT_used, Cold_Used values.

Check the Diskgroup Attributes for Disk Repair Time.


SQL> select * from v$asm_attribute where name in ('disk_repair_time');
NAME VALUE GROUP_NUMBER Attr_Indx Attr_Inc READ_ON SYSTEM_
---------------- ------ ------------ --------- --------- ------- -------
disk_repair_time 3.6h 1 0 1 N Y
disk_repair_time 3.6h 2 0 1 N Y

2. Add a Disk to DATA diskgroup & check Rebalance operation


Window1:
Check the data striping across all the 3 disks in DATA diskgroup.
SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,
SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk
WHERE GROUP_NUMBER=1
order by 1;

Window2:
Add ASMDISK7 to DATA diskgroup using below command, and immediately continue with next Window1
commands
SQL> ALTER DISKGROUP DATA ADD DISK ’/dev/oracleasm/disks/ASMDISK07’;
Window1:
Check the data rebalancing in the new disk added & check the operation. (repeat the commands till the
rebalance ends)
SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,
SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk
WHERE GROUP_NUMBER=1
order by 1;

SQL> select * from v$asm_operation;

Note: you can monitor data moment from column COLD_USED_MB. Each FAILGROUP name is same as Disk
NAME columns.

3. Delete the asmdisk using power limit option


Window1:
Check the data striping across all the 4 disks in DATA diskgroup.
SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,
SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk
WHERE GROUP_NUMBER=1
order by 1;

Window2:
Delete DATA_0003 disk. Because of wait option, this statement runs with a rebalance power of 3, and does
not return until the rebalance operation is complete. ( immediately continue with next Window1 command )
SQL> ALTER DISKGROUP DATA DROP DISK DATA_0003 rebalance power 3 wait;

Window1:
Check the data rebalancing again (repeat the commands till the rebalance ends)
SQL> select GROUP_NUMBER, DISK_NUMBER, name, REDUNDANCY, FAILGROUP,
SECTOR_SIZE, TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk
WHERE GROUP_NUMBER=1
order by 1;

SQL> select * from v$asm_operation;


SQL> !ps –ef | grep arb

Note: you can monitor data moment from column COLD_USED_MB and 3 arb process running.

Check ASMDISK07 information, Header_Status column will show you FORMER.


SQL> select GROUP_NUMBER, DISK_NUMBER, name, path, MOUNT_STATUS,
HEADER_STATUS, MODE_STATUS, state, TOTAL_MB
from v$asm_disk
order by 1,2;
4. Create a new diskgroup specifying FAILGROUP keyword
SQL> CREATE DISKGROUP FG_DATA NORMAL REDUNDANCY
FAILGROUP FG1
DISK '/dev/oracleasm/disks/ASMDISK07',
'/dev/oracleasm/disks/ASMDISK08'
FAILGROUP FG2
DISK '/dev/oracleasm/disks/ASMDISK09',
'/dev/oracleasm/disks/ASMDISK10'
ATTRIBUTE 'COMPATIBLE.ASM'='11.2';

Check the disks & diskgroup’s information


$ sqlplus / sysasm
SQL> col name format a10
SQL> col path format a35
SQL> set line 150
SQL> col failgroup format a10

SQL> select group_number, name, sector_size, allocation_unit_size "AU",


state, type, total_mb
from v$asm_diskgroup;
SQL> select GROUP_NUMBER, DISK_NUMBER, NAME,PATH, FAILGROUP,
MODE_STATUS, STATE, TOTAL_MB
from v$asm_disk
order by 1,2;

SQL> select GROUP_NUMBER, DISK_NUMBER, name, FAILGROUP, PATH,


TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk order by 1;

Check the values like Redundancy, Failgroup, Total_MB, Free_MB, HOT_used, Cold_Used values.

Note: you see that FG1 & FG2 having 2 asm disks each.

5. ADDING & DROPPING disks in FAILGROUP


SQL> select GROUP_NUMBER, DISK_NUMBER, name, path, FAILGROUP,
MODE_STATUS, state, TOTAL_MB
from v$asm_disk
order by 1,2;

SQL> ALTER DISKGROUP fg_data DROP DISK FG_DATA_0001;

NOTE: now /dev/oracleasm/disks/ASMDISK08 became former disk.

Add this disk back in the failgroup and delete another disk from FG2 in a single operation.
SQL> ALTER DISKGROUP FG_DATA
add failgroup FG1
disk '/dev/oracleasm/disks/ASMDISK08'
drop disk FG_DATA_0003;
SQL> select GROUP_NUMBER, DISK_NUMBER, name, FAILGROUP, PATH,
TOTAL_MB, FREE_MB, HOT_USED_MB, COLD_USED_MB
from v$asm_disk order by 1;

6. Checking the consistency of diskgroup metadata


SQL> ALTER DISKGROUP DATA CHECK [REPAIR | NOREPAIR];

7. Dismount & Mounting a diskgroup


SQL> ALTER DISKGROUP FG_DATA dismount; (or)
ASMCMD> dismount FG_DATA

ASMCMD> mount FG_DATA (or)


SQL> ALTER DISKGROUP FG_DATA mount;

7. Dropping a diskgroup
ASMCMD> help dropdg
ASMCMD> dropdg FG_DATA –r
-r option for including contents
4. Administering ASM Files, Directories and
Templates

1. Check database files, directory structure & file naming format


As oracle user on database :
SQL> select name from v$datafile;
NAME
---------------------------------------------
+DATA/orcl/datafile/system.256.909596003
+DATA/orcl/datafile/sysaux.257.909596005
+DATA/orcl/datafile/undotbs1.258.909596007
+DATA/orcl/datafile/users.259.909596007
+DATA/orcl/datafile/example.265.909596221

SQL> select group#, member from v$logfile order by 1


GROUP# MEMBER
---------- ---------------------------------------------
1 +DATA/orcl/onlinelog/group_1.261.909596165
1 +FRA/orcl/onlinelog/group_1.257.909596171
2 +DATA/orcl/onlinelog/group_2.262.909596177
2 +FRA/orcl/onlinelog/group_2.258.909596183
3 +DATA/orcl/onlinelog/group_3.263.909596189
3 +FRA/orcl/onlinelog/group_3.259.909596195

As grid user :
[grid@asm13 ~]$ . oraenv
ORACLE_SID = [+ASM] ?
The Oracle base for ORACLE_HOME=/u01/app/oracle/grid is /u01/app/oracle
[grid@asm13 ~]$
[grid@asm13 ~]$ asmcmd
ASMCMD> ls
DATA/
FRA/
ASMCMD> cd DATA
ASMCMD> ls
ASM/
ORCL/

ASMCMD> cd ORCL
ASMCMD> ls
CONTROLFILE/
DATAFILE/
ONLINELOG/
PARAMETERFILE/
TEMPFILE/
spfileORCL.ora

ASMCMD> cd DATAFILE
ASMCMD> ls
EXAMPLE.265.909596221
SYSAUX.257.909596005
SYSTEM.256.909596003
UNDOTBS1.258.909596007
USERS.259.909596007

2. Create a new directory in the existing diskgroup


SQL> ALTER DISKGROUP DATA ADD DIRECTORY '+DATA/ORADATA';
( or )
ASMCMD> mkdir +DATA/oradata

Now verify the directory creation thru asmcmd

ASMCMD> cd +DATA
ASMCMD> ls
ASM/
ORADATA/
ORCL/

3. Create a new tablespace using this oradata directory & verify


SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.256.909596003
+DATA/orcl/datafile/sysaux.257.909596005
+DATA/orcl/datafile/undotbs1.258.909596007
+DATA/orcl/datafile/users.259.909596007
+DATA/orcl/datafile/example.265.909596221

SQL> create tablespace DATA_TS


datafile '+DATA/ORADATA/data_ts01.dbf' size 5m;

SQL> select name from v$datafile;


NAME
--------------------------------------------------------------------------------
+DATA/orcl/datafile/system.256.909596003
+DATA/orcl/datafile/sysaux.257.909596005
+DATA/orcl/datafile/undotbs1.258.909596007
+DATA/orcl/datafile/users.259.909596007
+DATA/orcl/datafile/example.265.909596221
+DATA/oradata/data_ts01.dbf

ASMCMD> cd +DATA/ORADATA
ASMCMD> ls -l
Type Redund Striped Time Sys Name
N data_ts01.dbf => +DATA/ORCL/DATAFILE/DATA_TS.267.910302791

NOTE: It created an alias in your specified directory (oradata) but the actual file got created in the default
location under DATAFILE folder.
ASMCMD> cd +DATA/ORCL/DATAFILE

ASMCMD> pwd
+DATA/ORCL/DATAFILE

ASMCMD> ls
DATA_TS.267.910302791
EXAMPLE.265.909596221
SYSAUX.257.909596005
SYSTEM.256.909596003
UNDOTBS1.258.909596007
USERS.259.909596007
ASMCMD> ls -l
Type Redund Striped Time Sys Name
DATAFILE MIRROR COARSE APR 27 21:00:00 Y DATA_TS.267.910302791
DATAFILE MIRROR COARSE APR 27 21:00:00 Y EXAMPLE.265.909596221
DATAFILE MIRROR COARSE APR 27 21:00:00 Y SYSAUX.257.909596005
DATAFILE MIRROR COARSE APR 27 21:00:00 Y SYSTEM.256.909596003
DATAFILE MIRROR COARSE APR 27 21:00:00 Y UNDOTBS1.258.909596007
DATAFILE MIRROR COARSE APR 27 21:00:00 Y USERS.259.909596007

NOTE: to know more option with ls command in asmcmd type,


ASMCMD> help ls

Try other options too:


ASMCMD> ls -s
Block_Size Blocks Bytes Space Name
8192 641 5251072 12582912 DATA_TS.267.910302791
8192 12801 104865792 214958080 EXAMPLE.265.909596221
8192 66561 545267712 1095761920 SYSAUX.257.909596005
8192 87041 713039872 1431306240 SYSTEM.256.909596003
8192 12801 104865792 214958080 UNDOTBS1.258.909596007
8192 641 5251072 12582912 USERS.259.909596007

4. Creating an Alias for an existing database file.


Aliases allow you to reference ASM files using user-friendly names, rather than the fully qualified ASM
filenames.
SQL> select name from v$datafile;
NAME
---------------------------------------------------
+DATA/orcl/datafile/system.256.909596003
+DATA/orcl/datafile/sysaux.257.909596005
+DATA/orcl/datafile/undotbs1.258.909596007
+DATA/orcl/datafile/users.259.909596007
+DATA/orcl/datafile/example.265.909596221
+DATA/oradata/data_ts01.dbf

SQL> alter diskgroup DATA


ADD ALIAS '+DATA/ORADATA/example_01.dbf'
FOR '+DATA/orcl/datafile/example.265.909596221';
( or )
ASMCMD> mkalias +DATA/orcl/datafile/example.265.909596221
+DATA/ORCL/oradata/example_01.dbf
(execute the above command in single line)

ASMCMD> cd +DATA/oraDATA
ASMCMD> pwd
+DATA/oraDATA
ASMCMD> ls -l
Type Redund Striped Time Sys Name
N data_ts01.dbf =>
+DATA/ORCL/DATAFILE/DATA_TS.267.910302791
N example_01.dbf =>
+DATA/ORCL/DATAFILE/EXAMPLE.265.909596221

5. Renaming Datafile name to Alias name


SQL> select tablespace_name, file_name from dba_data_files;

TABLESPACE_N FILE_NAME
------------ ---------------------------------------------
USERS +DATA/orcl/datafile/users.259.909596007
UNDOTBS1 +DATA/orcl/datafile/undotbs1.258.909596007
SYSAUX +DATA/orcl/datafile/sysaux.257.909596005
SYSTEM +DATA/orcl/datafile/system.256.909596003
EXAMPLE +DATA/orcl/datafile/example.265.909596221
DATA_TS +DATA/oradata/data_ts01.dbf

ASMCMD> cd +DATA/oraDATA
ASMCMD> pwd
+DATA/oraDATA
ASMCMD> ls -l
Type Redund Striped Time Sys Name
N data_ts01.dbf =>
+DATA/ORCL/DATAFILE/DATA_TS.267.910302791
N example_01.dbf =>
+DATA/ORCL/DATAFILE/EXAMPLE.265.909596221

SQL> alter tablespace EXAMPLE offline;


Tablespace altered.

SQL> alter database rename file '+DATA/orcl/datafile/example.265.909596221'


to '+DATA/ORADATA/example_01.dbf';
Database altered.

SQL> alter tablespace EXAMPLE online;


Tablespace altered.
SQL> select name from v$datafile;
NAME
-------------------------------------------------
+DATA/orcl/datafile/system.256.909596003
+DATA/orcl/datafile/sysaux.257.909596005
+DATA/orcl/datafile/undotbs1.258.909596007
+DATA/orcl/datafile/users.259.909596007
+DATA/oradata/example_01.dbf
+DATA/oradata/data_ts01.dbf

6. Renaming & Dropping Alias


SQL> select tablespace_name, file_name from dba_data_files;
TABLESPACE_N FILE_NAME
------------ ---------------------------------------------
USERS +DATA/orcl/datafile/users.259.909596007
UNDOTBS1 +DATA/orcl/datafile/undotbs1.258.909596007
SYSAUX +DATA/orcl/datafile/sysaux.257.909596005
SYSTEM +DATA/orcl/datafile/system.256.909596003
EXAMPLE +DATA/oradata/example_01.dbf
DATA_TS +DATA/oradata/data_ts01.dbf

ASMCMD> cd +DATA/ORADATA
ASMCMD> ls
data_ts02.dbf
example_01.dbf
users01.dbf

Now rename the alias & check :


SQL> alter diskgroup data
RENAME ALIAS '+DATA/oradata/data_ts01.dbf'
TO '+DATA/oradata/data_ts02.dbf';
Diskgroup altered.

SQL> select tablespace_name, file_name from dba_data_files;


TABLESPACE_N FILE_NAME
------------ ---------------------------------------------
USERS +DATA/orcl/datafile/users.259.909596007
UNDOTBS1 +DATA/orcl/datafile/undotbs1.258.909596007
SYSAUX +DATA/orcl/datafile/sysaux.257.909596005
SYSTEM +DATA/orcl/datafile/system.256.909596003
EXAMPLE +DATA/oradata/example_01.dbf
DATA_TS +DATA/oradata/data_ts01.dbf

ASMCMD> cd +DATA/ORADATA
ASMCMD> ls
data_ts02.dbf
example_01.dbf
users01.dbf
NOTE: Only Alias got renamed in the directory, but not your datafile name in database & your database file is
still pointing to data_ts01.dbf name. (to get it reflected you need to perform the above rename datafile
command)

Now bounce you database & check for any errors:


SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 609624064 bytes
Fixed Size 2215784 bytes
Variable Size 419430552 bytes
Database Buffers 184549376 bytes
Redo Buffers 3428352 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '+DATA/oradata/data_ts01.dbf'

Now remove the data_ts02.dbf alias and create a new with actual name in database
ASMCMD> rmalias data_ts02.dbf
ASMCMD> mkalias +DATA/ORCL/DATAFILE/DATA_TS.267.910302791
+DATA/ORADATA/data_ts01.dbf
( type the above command in single line )

Now startup your database and check:


SQL> alter database open;
Database altered.

SQL> select tablespace_name, file_name from dba_data_files;


TABLESPACE_N FILE_NAME
------------ ---------------------------------------------
USERS +DATA/orcl/datafile/users.259.909596007
UNDOTBS1 +DATA/orcl/datafile/undotbs1.258.909596007
SYSAUX +DATA/orcl/datafile/sysaux.257.909596005
SYSTEM +DATA/orcl/datafile/system.256.909596003
EXAMPLE +DATA/oradata/example_01.dbf
DATA_TS +DATA/oradata/data_ts01.dbf

RELATED VIEWS:

V$ASM_ALIAS
V$ASM_FILE
V$ASM_TEMPLATE

You might also like