背景:
新接手一台linux+oracle+asm的数据库db1,现在要对该db的asmdisk进行存储回收,为确保正确删除asmdisk及对应磁盘设备,需把asmdisk的与磁备设备映射出来,并进一步梳理好处理步骤。
处理步骤:
1) 确认回收的asm diskgroup,命令如下:
select * from v$asm_diskgroup;
col path format a100
col name format a30
select name,path,total_mb from v$asm_disk;
2) 确认要删除datadg ,并将空间回收给存储同一使用,根据1)的结果,返查DATADG_DISK01,DATADG_DISK02对的设备。
记得使用root用户执行
oracleasm querydisk -d DATADG_DISK01
oracleasm querydisk -d DATADG_DISK02
返回的结果如下:
Disk "DATADG_DISK01" is a valid ASM disk on device /dev/sdd1[8,49]
Disk "DATADG_DISK02" is a valid ASM disk on device /dev/sdf[8,80]
3)删除磁盘组
使用asm安装用户登录,并输出环境变量。
sqlplus / as sysasm
drop diskgroup datadg including contents; <<<删除磁盘组及其存储所有数据文件
4)删除磁盘
oracleasm deletedisk DATADG_DISK01
oracleasm deletedisk DATADG_DISK02
5) 完成,通知系统管理员回收DATADG_DISK01和DATADG_DISK02对的应的磁盘。
补充一点:
1. 除了用oracleasm querydisk -d asmdisk反查对应的物理设备外,我们还可以用kfed read /dev/sdd1 确认它的磁盘头信息是就是我们要删除的,当然这个是在oracle deletedisk前执行,双重保障,减少风险。
kfdhdb.dskname: DATADG_0001 ; 0x028: length=11
kfdhdb.grpname: DATADG ; 0x048: length=6
kfdhdb.fgname: DATADG_0001 ; 0x068: length=11
2. 关于asmdisk的重用,只要将asmdisk将一个diskgroup drop掉后,就可以立即重用。
alter diskgroup datadg drop disk datadg_disk01;
alter diskgroup fradg add disk datadg_disk01;
asm在增加asmdisk时会自动格式化,但在官方文档中只找create diskgroup时format disk的说明,没有明确增加disk时也会format,但是我在实测时,在add disk时,磁盘的容量的确format过了。
声明:可能每个版本及平台不一样,表现也不一样,在进行之前先在测试环境完成测试,以及确保数据库完成备分。
3.oracle官方文档记录
Creating Disk Groups
The
CREATE DISKGROUP
SQL statement is used to create disk groups. When creating a disk group, you need to:
- Assign a unique name to the disk group.
- Specify the redundancy level of the disk group.
If you want ASM to mirror files, you specify the redundancy level as
NORMAL REDUNDANCY
(2-way mirroring by default for most file types) or
HIGH REDUNDANCY
(3-way mirroring for all files). You specify
EXTERNAL REDUNDANCY
if you do not want mirroring by ASM. For example, you might choose
EXTERNAL REDUNDANCY
if you want to use storage array protection features.
- Specify the disks as belonging to specific failure groups.
For information about failure groups, refer to
"Understanding ASM Concepts"
and
"ASM Mirroring and Failure Groups"
.
- Specify the disks that are to be formatted as ASM disks belonging to the disk group.<<<<<<<在创建磁盘组时,被指定的disk是会被格式化的。
The disks can be specified using operating system dependent wildcard characters in search strings that ASM then uses to find the disks. You can specify names for the disks with the
NAME
clause or use the system-generated names.
- Optionally specify disk group attributes, such software compatibility or allocation unit size.