ASM之磁碟建立及管理

Michael_DD發表於2014-12-04
ASM之磁碟建立及管理


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1.檢視ASM配置磁碟搜尋資訊

SQL> show parameter instance_type

asm例項系統
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ----------
instance_type                        string                 asm

普通例項系統
NAME                                 TYPE        VALUE
------------------------------------ ----------- ---------
instance_type                        string      RDBMS


SQL> show parameter asm_diskst


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2.使用oracleasm建立磁碟
[root@oradb ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1
Marking disk "VOL1" as an ASM disk: [ OK ]
[root@oradb ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd2
Marking disk "VOL2" as an ASM disk: [ OK ]
[root@oradb ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "VOL3" as an ASM disk: [ OK ]
[root@oradb ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sde2
Marking disk "VOL4" as an ASM disk: [ OK ]
[root@oradb ~]# /etc/init.d/oracleasm listdisks VOL1 VOL2 VOL3 VOL4


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3.建立磁碟組語法
CREATE DISKGROUP diskgroup_name [ { HIGH | NORMAL | EXTERNAL } REDUNDANCY ] [ FAILGROUP failgroup_name ] DISK [ NAME disk_name ] [ SIZE size_clause ] [ FORCE | NOFORCE ] ...;


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4.建立磁碟組
SQL> create diskgroup DG1 normal redundancy disk '/dev/oracleasm/disks/VOL1' name VOL1;
create diskgroup DG1 normal redundancy disk '/dev/oracleasm/disks/VOL1' name VOL1 * ERROR at line 1:
ORA-15018: diskgroup cannot be created --標準冗餘至少需要兩塊磁碟
ORA-15072: command requires at least 2 failure groups, discovered only 1

SQL> create diskgroup DG1 normal redundancy 2 disk '/dev/oracleasm/disks/VOL1' name DG1_VOL1 ,'/dev/oracleasm/disks/VOL2' name DG1_VOL2;
SQL>
create diskgroup DG2 normal redundancy  
failgroup FG1 disk '/dev/oracleasm/disks/VOL3' name DG2_FG1_VOL3
failgroup FG2 disk '/dev/oracleasm/disks/VOL4' name DG2_FG2_VOL4;
--使用標準冗餘建立磁碟組DG2

SQL> create diskgroup DG_ext external redundancy disk '/dev/oracleasm/disks/VOL10' name DG_ext_VOL10; --外部冗餘

SQL>
select group_number gno,name,state,type,total_mb,free_mb,
required_mirror_free_mb rmfmb,usable_file_mb ufmb
from v$asm_diskgroup;
 --檢視建立的磁碟組

GNO NAME                                                         STATE
---------- ------------------------------------------------------------ ----------------------
TYPE           TOTAL_MB    FREE_MB      RMFMB       UFMB
------------ ---------- ---------- ---------- ----------
         1 BACK                                                         MOUNTED
EXTERN             2047         26          0         26

         2 DATA                                                         MOUNTED
EXTERN             2047          0          0          0

         3 OCR                                                          MOUNTED
NORMAL             6141       5215       2047       1584



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5.磁碟組新增故障組和成員
--為非故障組新增成員
SQL> alter diskgroup DG1 add disk '/dev/oracleasm/disks/VOL5' name DG1_VOL5;

--為DG2新增一個故障組FG3及成員
SQL> alter diskgroup DG2 add failgroup FG3 disk '/dev/oracleasm/disks/VOL6' name DG2_FG3_VOL6;

--新增故障組及成員 --為DG2的個故障組各新增一個成員
SQL>
alter diskgroup DG2  
add failgroup FG1 disk '/dev/oracleasm/disks/VOL7'  
add failgroup FG2 disk '/dev/oracleasm/disks/VOL8'  
add failgroup FG3 disk '/dev/oracleasm/disks/VOL9';


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6.刪除磁碟組中的磁碟,故障組中的成員,磁碟組
SQL> alter diskgroup DG1 drop disk DG1_VOL5; --刪除磁碟組DG1中的磁碟VOL5
SQL> alter diskgroup DG2 drop disk DG2_0003; --刪除故障組中的單個成員
SQL> alter diskgroup DG2 drop disks in failgroup FG3; --刪除故障組及所有成員,注意此時為drop disks 複數形式
SQL>
alter diskgroup DG1 drop disk DG1_VOL4
add failgroup FG3 disk '/dev/oracleasm/disks/VOL9' name DG1_VOL11;
--刪除磁碟組中的磁碟,同時新增故障組FG3

SQL> drop diskgroup DG1; --刪除磁碟組


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7.調整磁碟組的容量
----故障組FG3的容量將被調整到G,如果磁碟空間不足,則調整失敗
SQL> alter diskgroup DG2 resize disks in failgroup FG3 size 10G;


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8.手動Rebalance
SQL> alter diskgroup DG2 rebalance power 3 wait;


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9.磁碟組的載入與解除安裝及內部一致性檢查
SQL> alter diskgroup all dismount;
SQL> alter diskgroup DG2 mount;
SQL> alter diskgroup DG2 check all;


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10.檢視磁碟組的partner
SQL> select name,state,type from v$asm_diskgroup where group_number=3; --檢視磁碟組DG3的資訊
SQL> select grp,disk,number_kfdpartner from x$kfdpartner where grp=3;  --磁碟組DG3使用了個磁碟,且冗餘度為標準冗餘 3 0 2

--磁碟組的partner 為磁碟組,2 3 1 0
--磁碟組的partner 為磁碟組,2 3 1 2 3 2 0
--磁碟組的partner 為磁碟組,1 3 2 1

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1356563/,如需轉載,請註明出處,否則將追究法律責任。

相關文章