RDBMS:11.2.0.4
当ASM的磁盘冗余为external的时候,是否可以换掉一块盘。
经过测试,是可以的。前提条件是,磁盘要有较大的空余空间,因为要把换掉的磁盘上的extent ,reblance到其他的盘上。
如果空间不够,可能会失败,这次进行的测试,所占用空间比较小,剩余空间比较大。测试成功。
参考文档:
https://docs.oracle.com/cd/E11882_01/server.112/e18951/asmdiskgrps.htm#OSTMG10071
To drop disks from a disk group, use the DROP DISK clause of the ALTER DISKGROUP statement. You can also drop all of the disks in specified failure groups using the DROP DISKS IN FAILGROUP clause.
When a disk is dropped, the disk group is rebalanced by moving all of the file extents from the dropped disk to other disks in the disk group. A drop disk operation might fail if not enough space is available on the other disks. The best approach is to perform both the add and drop operation with the same ALTER DISKGROUP statement. This has the benefit of rebalancing data extents only one time and ensuring that there is enough space for the rebalance operation to succeed.
-- 创建测试用的表空间test, 放在磁盘组+test上 ,创建用户test,默认的表空间是test 。创建表,数据存放在表空间test上。
- SYS@test2>create tablespace test datafile '+test' size 100M autoextend on;
-
- Tablespace created.
-
- SYS@test2>create user test identified by oracle;
-
- User created.
-
- SYS@test2>alter user test default tablespace test;
-
- User altered.
-
- SYS@test2>grant dba to test;
-
- Grant succeeded.
-
- SYS@test2>
- SYS@test2>conn test/oracle
- Connected.
- TEST@test2>create table test as select * from dba_tables;
-
- Table created.
-
- TEST@test2>
-- 通过dbms_rowid来查看表test中的数据,发现对应的file_id是7,查看file_id为7的数据文件,发现是存放在磁盘组+test上的
- select rowid,
- dbms_rowid.rowid_object(rowid) object_id,
- dbms_rowid.rowid_relative_fno(rowid) file_id,
- dbms_rowid.rowid_block_number(rowid) block_id,
- dbms_rowid.rowid_row_number(rowid) num
- from test;
-
- ROWID OBJECT_ID FILE_ID BLOCK_ID NUM
- ------------------ ---------- ---------- ---------- ----------
- AAAVt3AAHAAAADtAAC 88951 7 237 2
- AAAVt3AAHAAAADtAAD 88951 7 237 3
- AAAVt3AAHAAAADtAAE 88951 7 237 4
- AAAVt3AAHAAAADtAAF 88951 7 237 5
- AAAVt3AAHAAAADtAAG 88951 7 237 6
- AAAVt3AAHAAAADtAAH 88951 7 237 7
- AAAVt3AAHAAAADtAAI 88951 7 237 8
- AAAVt3AAHAAAADtAAJ 88951 7 237 9
-
- 2879 rows selected.
-
- TEST@test2>
-
- SYS@test2>select file_name from dba_data_files where file_id = 7;
-
- FILE_NAME
- --------------------------------------------------------------------------------
- +TEST/test/datafile/test.256.1111411155
-
- SYS@test2>
-- 查看磁盘组信息,test磁盘组是external冗余 ,两块盘,asm-test1和asm-test2 ,drop掉其中一块盘后,还剩余一块盘。数据正常,2879条。
- SYS@+ASM2>select group_number,name from v$asm_diskgroup;
-
- GROUP_NUMBER NAME
- ------------ ------------------------------
- 1 DATA
- 2 OCR
- 3 TEST
- SYS@+ASM2>select group_number,name,type from v$asm_diskgroup;
-
- GROUP_NUMBER NAME TYPE
- ------------ ------------------------------ ------
- 1 DATA EXTERN
- 2 OCR NORMAL
- 3 TEST EXTERN
-
- SYS@+ASM2>
- SYS@+ASM2>select path from v$asm_disk where GROUP_NUMBER = 3;
-
- PATH
- --------------------------------------------------------------------------------
- /dev/asm-test1
- /dev/asm-test2
-
- SYS@+ASM2>
- SYS@+ASM2>select name,path from v$asm_disk where GROUP_NUMBER = 3;
-
- NAME PATH
- -------------------- ----------------------------------------
- TEST_0000 /dev/asm-test1
- TEST_0001 /dev/asm-test2
-
- SYS@+ASM2>
- alter diskgroup TEST drop disk 'TEST_0000';
- SYS@+ASM2>alter diskgroup TEST drop disk 'TEST_0000';
-
- Diskgroup altered.
- SYS@+ASM2>select name,path from v$asm_disk where GROUP_NUMBER = 3;
-
- NAME PATH
- -------------------- ----------------------------------------
- TEST_0001 /dev/asm-test2
-
- SYS@+ASM2>
-
- SYS@test2>select count(*) from test.test;
-
- COUNT(*)
- ----------
- 2879
-
- SYS@test2>
-
- SYS@+ASM2>select name,path from v$asm_disk where GROUP_NUMBER = 3;
-
- NAME PATH
- -------------------- ----------------------------------------
- TEST_0001 /dev/asm-test2
-
- SYS@+ASM2>
-- 再次将drop掉的磁盘添加上。
- SYS@+ASM2>ALTER DISKGROUP TEST ADD DISK '/dev/asm-test1' NAME TEST_0000;
-
- Diskgroup altered.
-
- SYS@+ASM2>select * from V$ASM_OPERATION;
-
- no rows selected
-
- SYS@+ASM2>select name,path from v$asm_disk where GROUP_NUMBER = 3;
-
- NAME PATH
- -------------------- ----------------------------------------
- TEST_0000 /dev/asm-test1
- TEST_0001 /dev/asm-test2
-
- SYS@+ASM2>
-- alrt log 中,可以看到reblance 。
- SQL> alter diskgroup TEST drop disk 'TEST_0000'
- NOTE: GroupBlock outside rolling migration privileged region
- NOTE: requesting all-instance membership refresh for group=3
- Sat Jul 30 14:47:47 2022
- NOTE: membership refresh pending for group 3/0xfab86ef8 (TEST)
- Sat Jul 30 14:47:50 2022
- GMON querying group 3 at 16 for pid 18, osid 3765
- SUCCESS: refreshed membership for 3/0xfab86ef8 (TEST)
- SUCCESS: alter diskgroup TEST drop disk 'TEST_0000'
- NOTE: starting rebalance of group 3/0xfab86ef8 (TEST) at power 1
- Starting background process ARB0
- Sat Jul 30 14:47:51 2022
- ARB0 started with pid=34, OS id=15309
- NOTE: assigning ARB0 to group 3/0xfab86ef8 (TEST) with 1 parallel I/O
- cellip.ora not found.
- NOTE: F1X0 copy 1 relocating from 0:2 to 1:80 for diskgroup 3 (TEST)
- NOTE: Attempting voting file refresh on diskgroup TEST
- NOTE: Refresh completed on diskgroup TEST. No voting file found.
- NOTE: stopping process ARB0
- SUCCESS: rebalance completed for group 3/0xfab86ef8 (TEST)
- Sat Jul 30 14:47:57 2022
- NOTE: GroupBlock outside rolling migration privileged region
- NOTE: requesting all-instance membership refresh for group=3
- GMON updating for reconfiguration, group 3 at 17 for pid 34, osid 15335
- NOTE: group 3 PST updated.
- SUCCESS: grp 3 disk TEST_0000 emptied
- SUCCESS: ALTER DISKGROUP TEST ADD DISK '/dev/asm-test1' NAME TEST_0000
- NOTE: starting rebalance of group 3/0xfab86ef8 (TEST) at power 1
- Starting background process ARB0
- Sat Jul 30 14:55:10 2022
- ARB0 started with pid=35, OS id=16572
- NOTE: assigning ARB0 to group 3/0xfab86ef8 (TEST) with 1 parallel I/O
- cellip.ora not found.
- NOTE: Attempting voting file refresh on diskgroup TEST
- NOTE: Refresh completed on diskgroup TEST. No voting file found.
- NOTE: stopping process ARB0
- SUCCESS: rebalance completed for group 3/0xfab86ef8 (TEST)
- Sat Jul 30 14:55:16 2022
- NOTE: GroupBlock outside rolling migration privileged region
- NOTE: requesting all-instance membership refresh for group=3
- Sat Jul 30 14:55:19 2022
- NOTE: membership refresh pending for group 3/0xfab86ef8 (TEST)
- Sat Jul 30 14:55:22 2022
- GMON querying group 3 at 37 for pid 18, osid 3765
- SUCCESS: refreshed membership for 3/0xfab86ef8 (TEST)
- NOTE: Attempting voting file refresh on diskgroup TEST
- NOTE: Refresh completed on diskgroup TEST. No voting file found.
-
-
- END
END