Oracle Automatic Storage Management ( ASM ) Add Disk and Drop Disk Operations in Oracle ASM

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.

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, create an ASM Instance profile as follows.

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:

oracle:deveci01:/home/users/oracle:> . profile.12c.asm

Or you can set ASM Instance profile as follows.

oracle:deveci01:/home/users/oracle:>  . oraenv
ORACLE_SID = [oracle] ? +ASM
The Oracle base has been set to /u01/app/oracle
[oracle@deveci ~]# 

asmcmd is a tool that we perform and monitor many disk operations.

 We can connect and list disk groups and sizes, free spaces etc with LSDG command as follows.

 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:

oracle:deveci01:/home/users/oracle:> . profile.12c.asm

Or you can set ASM Instance profile as follows.

oracle:deveci01:/home/users/oracle:>  . oraenv
ORACLE_SID = [oracle] ? +ASM
The Oracle base has been set to /u01/app/oracle
[oracle@deveci ~]#

Then we are connecting to the ASM Instance with the command “sqlplus / as sysasm”.

 Run the following query to see disk groups in here:

 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.

 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.

Firstly create this group, then add disks to disk group as follows.

CREATE DISKGROUP RECO EXTERNAL REDUNDANCY DISK '/dev/mapper/asmtsk1' NAME RECO_0001 SIZE 102399 M;


ALTER DISKGROUP RECO REBALANCE POWER 10;
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.

 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:

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.

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 utility.

Add a disk with asmca:

A disk in the ASM disk group can be dropped as follows:

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
SQL> alter diskgroup DATA drop disk DATA_0004;
Diskgroup altered.

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:

Marius Catalin

Oracle database administrator / administrador dba

2 年

Hello Srinivasulu! I have a question please. I have a diskgroup called MGMT on an Integration instance that is running out of space. 2 days ago it was 26.2% and now it is 21%. What I can do? Thanks.

回复

要查看或添加评论,请登录

Srinivasulu M的更多文章

社区洞察

其他会员也浏览了