In this article I will continue to explain Oracle Automatic Storage Management. Before reading this article, I suggest you read the previous article. “Oracle Automatic Storage Management -1”
When the Oracle ASM is used, the concept of Disk group enters our lives. As the name implies, we store our data in Disk Groups where one or more disks come together instead of a single disk.
As mentioned in the previous article, the ASM instance is different from the Oracle Database instances. When we query the smon process as follows, “+ ASM” instance is listed as an instance.
1 2 3 4 5 6 | oracle:deveci01:/home/users/oracle:>ps -ef |grep smon root 11731186 1 18 10:05:48 - 0:00 /u01/app/oracle/product/12.1.0/grid/bin/osysmond.bin oracle 12058826 1 0 10:06:56 - 0:00 ora_smon_DEVECI oracle 12976246 1 0 10:06:24 - 0:00 asm_smon_+ASM oracle 38338572 28049424 1 10:07:02 pts/0 0:00 grep smon |
To connect to ASM Instances we create an ASM Instance profile:
1 2 3 4 5 6 7 | oracle:deveci01:/home/users/oracle:> vi profile.12g.asm export ORACLE_HOME=/u01/app/oracle/product/12.1.0/grid export ORACLE_BASE=/u01/app/oracle export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH export ORACLE_SID=+ASM bash |
After creating as above, we can set the profile as follows and we can now connect to ASM:
1 | oracle:deveci01:/home/users/oracle:>. profile.12c.asm |
asmcmd is a tool that we perform and monitor many disk operations.
We can connect and see disk groups and sizes, free spaces etc with LSDG as follows:
1 2 3 4 5 6 7 8 9 10 11 | oracle:deveci:/home/users/oracle:>asmcmd 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 512000 510551 0 510551 0 N DATA/ MOUNTED EXTERN N 512 4096 4194304 204800 203272 0 203272 0 Y RECO/ ASMCMD> ASMCMD> cd DATA ASMCMD> ls -l Type Redund Striped Time Sys Name Y DEVECI/ |
We can also connect to ASM instances with “sqlplus / as sysasm
” command and perform similar operations with queries.
You can add and remove disks to the ASM disk groups as follows.
First set the ASM profile:
1 | oracle:deveci01:/home/users/oracle:>. profile.12c.asm |
Then we are connecting to the ASM Instance with the command “sqlplus / as sysasm”.
Run the following query to see disk groups in here:
1 2 3 4 5 6 7 8 9 10 | SQL> SELECT GROUP_NUMBER, NAME,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,TYPE TOTAL_MB,FREE_MB FROM V$ASM_DISKGROUP; GROUP_NUMBER NAME SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE TOTAL_ FREE_MB ------------ -------- ----------- ---------- -------------------- ----------- ------ ---------- 1 DATA 512 4096 1048576 CONNECTED EXTERN 355915 2 RECO 512 4096 1048576 CONNECTED EXTERN 721067 |
If an ASM Disk has been mapped to the operating system(this is a storage-side operation.), they will appear in the following query. HEADER_STATUS = CANDIDATE are disks that could not be added.
Disks with HEADER_STATUS value CANDIDATE are disks that are not mapped to the operating system.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | SQL> SELECT MOUNT_STATUS, HEADER_STATUS, MODE_STATUS, STATE, TOTAL_MB, FREE_MB, NAME, PATH, LABEL FROM V$ASM_DISK; MOUNT_S HEADER_STATU MODE_ST STATE TOTAL_MB FREE_MB NAME PATH LABEL ------- ------------ ------- -------- ---------- ---------- ----------- -------- ---------- CLOSED CANDIDATE ONLINE NORMAL 0 0 /dev/rhdisk38 CLOSED CANDIDATE ONLINE NORMAL 0 0 /dev/rhdisk39 CLOSED CANDIDATE ONLINE NORMAL 0 0 /dev/rhdisk40 CACHED MEMBER ONLINE NORMAL 102399 17756 DATA_0000 /dev/rhdisk10 CACHED MEMBER ONLINE NORMAL 102399 17795 DATA_0001 /dev/rhdisk11 CACHED MEMBER ONLINE NORMAL 102399 17787 DATA_0002 /dev/rhdisk12 |
If you re-create a diskgroup you can use the following commands:
1 2 3 | CREATE DISKGROUP RECO EXTERNAL REDUNDANCY DISK ‘/dev/mapper/asmtsk1’ NAME RECO_0001 SIZE 102399 M; ALTER DISKGROUP RECO REBALANCE POWER 10; |
1 2 3 4 5 6 7 | ALTER DISKGROUP RECO ADD DISK ‘/dev/mapper/asmtsk2’ NAME RECO_0002 SIZE 102399 M REBALANCE POWER 10; ALTER DISKGROUP RECO ADD DISK '/dev/mapper/asmtsk3' NAME RECO_0003 SIZE 102399 M REBALANCE POWER 10; ALTER DISKGROUP RECO ADD DISK '/dev/mapper/asmtsk4' NAME RECO_0004 SIZE 102399 M REBALANCE POWER 10; ALTER DISKGROUP RECO ADD DISK '/dev/mapper/asmtsk5' NAME RECO_0005 SIZE 102399 M REBALANCE POWER 10; |
If we created a new diskgroup on a 2-node RAC system, we should not forget to mount the diskgroup on the second node.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | SQL> select INST_ID,GROUP_NUMBER,NAME,STATE from GV$ASM_DISKGROUP; INST_ID GROUP_NUMBER NAME STATE ---------- ------------ ------- ------- 1 1 DATA MOUNTED 1 2 RECO MOUNTED 2 1 DATA MOUNTED 2 0 RECO DISMOUNTED SQL> alter diskgroup RECO mount; Diskgroup altered. SQL> select INST_ID,GROUP_NUMBER,NAME,STATE from GV$ASM_DISKGROUP; INST_ID GROUP_NUMBER NAME STATE ---------- ------------ ------ ----------- 1 1 DATA MOUNTED 1 2 RECO MOUNTED 2 1 DATA MOUNTED 2 2 RECO MOUNTED |
Add the /dev/rhdisk12 disk to the RECO disk group:
1 2 3 | SQL> ALTER DISKGROUP RECO ADD DISK '/dev/rhdisk38' NAME RECO_0010 SIZE 102399 M REBALANCE POWER 10; Diskgroup altered. |
We give the parallelism value of the rebalance operation and increase the speed of REBALANCE with the POWER parameter.
Set to 10 on busy systems can decrease performance in your databases.
If this parameter is not given, it takes the value of the ASM_POWER_LIMIT parameter by default.. ASM_POWER_LIMIT can take values from 0-11. The rebalance status can be monitored from the V$ASM_OPERATION
view.
If this parameter is not given, it takes the value of the ASM_POWER_LIMIT parameter by default.
1 2 3 4 5 6 7 8 | SQL> show parameter ASM_POWER_LIMIT NAME TYPE VALUE -------- ------- -------- asm_power_limit integer 1 SQL> select * from v$asm_operation; |
Apart from ASMCMD and sqlplus, you can also see disk groups and add and remove disk with asmca.
Add a disk with asmca:
A disk in the ASM disk group can be dropped as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | SQL> SELECT name, header_status, path FROM V$ASM_DISK; NAME HEADER_STATU PATH ----------- -------------- ---------- FORMER /dev/rhdisk18 FORMER /dev/rhdisk15 FORMER /dev/rhdisk16 FORMER /dev/rhdisk17 DATA_0000 MEMBER /dev/rhdisk10 DATA_0001 MEMBER /dev/rhdisk11 DATA_0002 MEMBER /dev/rhdisk12 DATA_0003 MEMBER /dev/rhdisk13 DATA_0004 MEMBER /dev/rhdisk14 |
1 2 | SQL> alter diskgroup DATA drop disk DATA_0004; Diskgroup altered. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | The value of header_status in the dropped disk will be former. SQL> SELECT name, header_status, path FROM V$ASM_DISK; NAME HEADER_STATU PATH ----------- -------------- ---------- FORMER /dev/rhdisk18 FORMER /dev/rhdisk14 FORMER /dev/rhdisk15 FORMER /dev/rhdisk16 FORMER /dev/rhdisk17 DATA_0000 MEMBER /dev/rhdisk10 DATA_0001 MEMBER /dev/rhdisk11 DATA_0002 MEMBER /dev/rhdisk12 DATA_0003 MEMBER /dev/rhdisk13 |
If the RAC is a database, all nodes should be checked and the same status should be seen in other nodes.
Drop a disk with asmca: