Linux下为ASM增加空间
环境:
操作系统centos 5
数据库版本:11gr2
背景
ASM空间不够,需要为ASM增加磁盘空间,下面提到两种方法,每一种方法为直接增加原LV的大小,第二种方式为创建一个新的LV,再把这个LV添加到现有的diskgroup中
方法一:扩展原LV大小
1.查看ASM disk情况
我们看到空闲空间已经不多
SQL> select name,path,os_mb,free_mb from v$asm_disk;
NAME PATH OS_MB FREE_MB
------ ----------------------------- ------- --------
VOL3 /dev/mapper/VolGroup00-asmdata3 51200 2809
VOL2 /dev/mapper/VolGroup00-asmdata2 51200 2816
VOL1 /dev/mapper/VolGroup00-asmdata1 102400 5606
SQL>
1. 查看磁盘空间情况,
看是否还有空闲空间,如果有空间把空间划分出来,如果没有空间就要考虑加物理磁盘
[root@svr188 ~]# vgdisplay
-- Volume group --
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 12
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 9
Open LV 9
Max PV 0
Cur PV 1
Act PV 1
VG Size 546.50 GB
PE Size 32.00 MB
Total PE 17488
Alloc PE / Size 14816 / 463.00 GB
Free PE / Size 2672 / 83.50 GB
VG UUID AB1XBO-ensN-7dKS-i18y-cPZD-4FCf-2cMcMx
3.扩展原有lv大小
上面看到我们还有83G的空闲空间,本次增加30G空间到原来LV,增加LV物理大小后ASM并不会立即使用,需要使用执行ASM命令定义磁盘的大小
[root@svr188 ~]# lvextend -L +30G /dev/mapper/VolGroup00-asmdata3
Extending logical volume asmdata3 to 80.00 GB
Logical volume asmdata3 successfully resized
SQL> select name,path,os_mb,free_mb from v$asm_disk;
NAME PATH OS_MB FREE_MB
------- ------------------------------ ------- --------
VOL3 /dev/mapper/VolGroup00-asmdata3 81920 2809
VOL2 /dev/mapper/VolGroup00-asmdata2 51200 2816
VOL1 /dev/mapper/VolGroup00-asmdata1 102400 5606
SQL>
4.在ASM中重新定义逻辑卷的大小
注意11g中新增了一个角色sysasm,oracle的目的是把ASM和数据库分开管理,所有和ASM操作相关的语句都需要使用sysasm角色登陆
[grid@svr188 ~]$ sqlplus "/as sysasm"
SQL*Plus: Release 11.2.0.2.0 Production on Wed Aug 31 18:18:01 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Automatic Storage Management option
SQL> ALTER DISKGROUP DISKGROUP1 RESIZE DISK VOL3 SIZE 80g;
Diskgroup altered.
SQL>
执行上面操作后在oracle用户下面登陆数据库查看当前的ASM情况,可以看到空间已经加上去了
SQL> select name,path,os_mb,free_mb,t.TOTAL_MB from v$asm_disk t;
NAME PATH OS_MB FREE_MB TOTAL_MB
----- ------------------------- ------- ------ --------
VOL3 /dev/mapper/VolGroup00-asmdata3 81920 32596 81920
VOL2 /dev/mapper/VolGroup00-asmdata2 51200 4677 51200
VOL1 /dev/mapper/VolGroup00-asmdata1 102400 9336 102400
SQL>
方法二:创建一个新的LV
1.创建一个LV,并赋权给grid用户
新增一个LV
[root@svr188 ~]# lvcreate -L +50g -n asmdata4 VolGroup00
Logical volume "asmdata4" created
查看LV位置
[root@svr188 ~]# ls -lrt /dev/mapper/
brw-rw---- 1 root disk 253, 9 Aug 31 18:03 VolGroup00-asmdata4
brwxrwxr-x 1 grid dba 253, 8 Aug 31 18:03 VolGroup00-asmdata3
brwxrwxr-x 1 grid dba 253, 7 Aug 31 18:03 VolGroup00-asmdata2
brwxrwxr-x 1 grid dba 253, 6 Aug 31 18:03 VolGroup00-asmdata1
把这个lv的权限给grid用户
[root@svr188 ~]# chown grid.dba /dev/mapper/VolGroup00-asmdata4
[root@svr188 ~]# ls -lrt /dev/mapper/
brw-rw---- 1 grid dba 253, 9 Aug 31 18:03 VolGroup00-asmdata4
brwxrwxr-x 1 grid dba 253, 8 Aug 31 18:05 VolGroup00-asmdata3
brwxrwxr-x 1 grid dba 253, 6 Aug 31 18:06 VolGroup00-asmdata1
brwxrwxr-x 1 grid dba 253, 7 Aug 31 18:06 VolGroup00-asmdata2
2.使用asmlib创建硬盘映射
[root@svr188 ~]# /usr/sbin/oracleasm createdisk VOL4 /dev/mapper/VolGroup00-asmdata4
Writing disk header: done
Instantiating disk: done
[root@svr188 ~]# /usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@svr188 ~]# /usr/sbin/oracleasm listdisks
VOL4
[root@svr188 ~]#
3.查看磁盘情况
SQL> select name,path,os_mb,free_mb from v$asm_disk;
NAME PATH OS_MB FREE_MB
------- -------------------------------- ------- --------
VOL3 /dev/mapper/VolGroup00-asmdata3 81920 2809
VOL2 /dev/mapper/VolGroup00-asmdata2 51200 2816
VOL1 /dev/mapper/VolGroup00-asmdata1 102400 5606
/dev/mapper/VolGroup00-asmdata4 51200 0
ORCL:VOL4 51200 0
SQL>
4.在ASM中重新定义逻辑卷的大小
注意11g中新增了一个角色sysasm,oracle的目的是把ASM和数据库分开管理,所有和ASM操作相关的语句都需要使用sysasm角色登陆
[grid@svr188 ~]$ sqlplus "/as sysasm"
SQL*Plus: Release 11.2.0.2.0 Production on Wed Aug 31 18:18:01 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Automatic Storage Management option
SQL> ALTER DISKGROUP DISKGROUP1 ADD DISK 'ORCL:VOL4';
Diskgroup altered.
SQL>
执行上面操作后在oracle用户下面登陆数据库查看当前的ASM情况,可以看到空间已经加上去了
SQL> select name,path,os_mb,free_mb from v$asm_disk;
NAME PATH OS_MB FREE_MB
---- --------------------------- ----- -------
VOL3 /dev/mapper/VolGroup00-asmdata3 81920 26616
VOL2 /dev/mapper/VolGroup00-asmdata2 51200 16631
VOL1 /dev/mapper/VolGroup00-asmdata1 102400 33268
VOL4 ORCL:VOL4 51200 16634
/dev/mapper/VolGroup00-asmdata4 51200 0
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21605631/viewspace-715556/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/21605631/viewspace-715556/