After the storage administrator provides you with the disk for the database and presents the disk to the server, you want to stamp the disks as ASMLIB disks using the oracleasm command. All options to the oracleasm script that are not read-only actions require root privileges to execute. Such options include commands to configure, create, delete, and rename.
Example 1: Check oracleasm status
Before we can start using orale ASM, the oracleasm module must be loaded and psuedo filesystem /dev/oracleasm must be mounted. The oracleasm enable command simply writes to the configuration file to autostart ASMLIB. You can disable ASMLIB as part of the reboot process by using the oracleasm disable command. To check the status of both use the below command:
# oracleasm status Checking if ASM is loaded: yes Checking if /dev/oracleasm is mounted: yes
Example 2: Scan ASM disks
When you have create new asmdisk on one of cluster node, you need to scan disks on other nodes. For example:
At Node 1
[[email protected] ~]# oracleasm createdisk DATA1 /dev/sdd1 Writing disk header: done Instantiating disk: done
[[email protected] ~]# oracleasm createdisk DATA2 /dev/sde1 Writing disk header: done Instantiating disk: done
[[email protected] ~]# oracleasm listdisks DATA1 DATA2
At Node 2
At first there will not be any disk discovered on the 2nd node of the RAC. For example:
[[email protected] ~]# oracleasm listdisks (There are no ASM disks)
After scanning the disk, you shall see 2 new disks getting “Instantiating” on 2nd node as well.
[[email protected] ~]# oracleasm scandisks Reloading disk partitions: done Cleaning any stale ASM disks… Scanning system for ASM disks… Instantiating disk “DATA1” Instantiating disk “DATA2”
Example 3: Determine if a disk belongs to Oracle ASMlib
You can read a disk header using “oracleasm querydisk” command and determine if the disk belongs to ASM or not. For example:
# oracleasm querydisk /dev/sde1 Device “/dev/sde1” is marked an ASM disk with the label “DATA2” ### this belongs to ASMLIB
# oracleasm querydisk /dev/sdb1 Device “/dev/sdb1” is not marked as an ASM disk ### this does’nt belong to ASMLIB
Example 4: Check ASM Disk Group device path name
To get the absolute device path for the disks used while creating an ASM disk, we can use the below command:
# oracleasm querydisk -p VOTEDISK1 Disk “VOTEDISK1″ is a valid ASM disk /dev/sdc1: LABEL=”VOTEDISK1″ TYPE=”oracleasm”
As you can see /dev/sdc1 is the absolute device path for the ASM disk with label “VOTEDISK1”.
Example 5. Rename ASM Disk
Sometime you may want to rename a ASM disk label. “oracleasm renamedisk” does the job of renaming the ASM disk label as well as re-instatiating the disks on the same node where rename was performed. It also removed the old ASM disk label while doing so. For example:
# oracleasm renamedisk -f VOTEDISK1 OCRVOTEDISK1 Instantiating disk “OCRVOTEDISK1”: done Writing disk header: done Removing old ASM disk “VOTEDISK1”: done # oracleasm renamedisk -f VOTEDISK2 OCRVOTEDISK2 Instantiating disk “OCRVOTEDISK2”: done Writing disk header: done Removing old ASM disk “VOTEDISK2”: done # oracleasm renamedisk -f VOTEDISK3 OCRVOTEDISK3 Instantiating disk “OCRVOTEDISK3”: done Writing disk header: done Removing old ASM disk “VOTEDISK3”: done # oracleasm renamedisk -f DATADISK1 DBDATADISK1 Instantiating disk “DBDATADISK1”: done Writing disk header: done Removing old ASM disk “DATADISK1”: done
# oracleasm listdisks DBDATADISK1 OCRVOTEDISK1 OCRVOTEDISK2 OCRVOTEDISK3
Example 5: Re-instantiating ASM Disks at another of RAC nodes after renaming disks
When you rename the disk on one node of the RAC, you will have to rescan the devices again on the other nodes of the RAC. This will re-instatiate the ASM disks and cleanup the old ASM disk labels. For example:
# oracleasm scandisks Reloading disk partitions: done Cleaning any stale ASM disks… Cleaning disk “DATADISK1” Cleaning disk “VOTEDISK1” Cleaning disk “VOTEDISK2” Cleaning disk “VOTEDISK3” Scanning system for ASM disks… Instantiating disk “DBDATADISK1” Instantiating disk “OCRVOTEDISK1” Instantiating disk “OCRVOTEDISK2” Instantiating disk “OCRVOTEDISK3”
Example 6: Delete/Unmark ASM labels
Theoracleasm deletedisk command deletes the disk label that identifies the disk as the ASMLIB disk.
# oracleasm deletedisk DBDATADISK1 Removing ASM disk "DBDATADISK1": [ OK ]