ASM Lab Manual Guide
ASM Lab Manual Guide
ASM Administration
Lab Practice Guide
1. Installation of Grid Infrastructure & ASM
Like this, create all partitions with size of 2GB and last save the changes by typing “w”.
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.
# 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
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
$ 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.
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.
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 the values like Redundancy, Failgroup, Sector_size, Total_MB, Free_MB & status for disk group# 1.
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.
2) Use ASMCA graphical utility to create the new DATA diskgroup with NORMAL redundancy.
3) Now create SPFILE into DATA diskgroup & bounce the ASM Instance. (putty terminal can be used)
NOTE: you can bounce your ASM using ASMCMD utility too.
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
NOTE: DATA Diskgroup is available with external redundancy option (type column value).
Check the values like Redundancy, Failgroup, Sector_size, Total_MB, Free_MB & status for disk group# 1.
You should now have a single directory called "database" containing installation files.
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
Node Selection
Select, Single instance database installation, next
Product languages
English is default selected, click next
Privileged OS groups
Default settings – dba, oper,
Next
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.
Check the values like Redundancy, Failgroup, Total_MB, Free_MB, HOT_used, Cold_Used values.
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;
Note: you can monitor data moment from column COLD_USED_MB. Each FAILGROUP name is same as Disk
NAME columns.
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;
Note: you can monitor data moment from column COLD_USED_MB and 3 arb process running.
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.
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;
7. Dropping a diskgroup
ASMCMD> help dropdg
ASMCMD> dropdg FG_DATA –r
-r option for including contents
4. Administering ASM Files, Directories and
Templates
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
ASMCMD> cd +DATA
ASMCMD> ls
ASM/
ORADATA/
ORCL/
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
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
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
ASMCMD> cd +DATA/ORADATA
ASMCMD> ls
data_ts02.dbf
example_01.dbf
users01.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 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 )
RELATED VIEWS:
V$ASM_ALIAS
V$ASM_FILE
V$ASM_TEMPLATE