052-part5 -ASM

gaopengtttt發表於2013-08-27

1、ASM 3種關閉啟動方式
-----使用SQLPLUS 連線到SYSASM直接SHUTDOWN IMMEDIATE,啟動直接STARTUP即可
-----使用SRVCTL 命令
[grid@tasm ~]$ srvctl stop diskgroup -g ARCH
[grid@tasm ~]$ srvctl stop diskgroup -g DATA
[grid@tasm ~]$ srvctl stop asm -o immediate
啟動使用srvctl start asm -o open 即可
-----使用ASMCMD命令
ASMCMD> shutdown -h
Unknown option: h
usage: shutdown [ --normal |--abort|--immediate ]
help:  help shutdown
ASMCMD> startup -h
Unknown option: h
usage: startup [--nomount] [--restrict] [ --pfile pfile ]
help:  help startup

2、
create diskgroup data normal redundancy
failgroup T1 disk
'/dev/raw/raw1' name d1     --force 可以刪除以前的資料
failgroup T2 disk
'/dev/raw/raw2' name d2;

CREATE DISKGROUP   data2  External Redundancy DISK '/dev/raw/raw8'
       ATTRIBUTE 'compatible.asm' = '11.2', 'compatible.rdbms' = '11.1'
      
High Redundancy
-----------------
drop diskgroup data including contents;
-----刪除磁碟組,如果磁碟組包含檔案必須使用INCLUDING CONTENTS。
SQL> alter diskgroup data add disk
  2  '/dev/raw/raw8' name T3D ;

Diskgroup altered.
--------完成後進行平衡需要一定的時間

SQL> alter diskgroup data drop disk t3d;

Diskgroup altered.
--------完成後需要刪除磁碟需要一定的時間把AU進行平衡,如果是普通冗餘當你刪除倒數第二個磁碟時會報錯,因為最小2個失效組

SQL> select state,NAME,MODE_STATUS,FREE_MB,path,HEADER_STATUS from v$asm_disk;
 
STATE    NAME                           MODE_STATUS    FREE_MB PATH                                                                             HEADER_STATUS
-------- ------------------------------ ----------- ---------- -------------------------------------------------------------------------------- -------------
NORMAL   DATA_0000                      ONLINE             816 /dev/raw/raw5                                                                    MEMBER
NORMAL   DATA_0001                      ONLINE             815 /dev/raw/raw6                                                                    MEMBER
NORMAL   ARCH_0000                      ONLINE            2642 /dev/raw/raw7                                                                    MEMBER
DROPPING T3D                            ONLINE            2759 /dev/raw/raw8                                                                    MEMBER
這裡狀態為DROPPING在DROPPING期間即可進行UNDROP,但是一個刪除完成就不可以了

SQL> alter diskgroup data undrop disks;

Diskgroup altered.
--------在還沒有刪除完成前可以進行回退操作
SQL> select state,NAME,MODE_STATUS,FREE_MB,path,HEADER_STATUS from v$asm_disk;
 
STATE    NAME                           MODE_STATUS    FREE_MB PATH                                                                             HEADER_STATUS
-------- ------------------------------ ----------- ---------- -------------------------------------------------------------------------------- -------------
NORMAL   DATA_0000                      ONLINE             761 /dev/raw/raw5                                                                    MEMBER
NORMAL   DATA_0001                      ONLINE             761 /dev/raw/raw6                                                                    MEMBER
NORMAL   ARCH_0000                      ONLINE            2642 /dev/raw/raw7                                                                    MEMBER
NORMAL                                  ONLINE               0 /dev/raw/raw8                                                                    FORMER
 刪除完成後,狀態變為NORMAL,HEADER狀態變為FROMER,表示曾經使用過,
 
 
 3、相容性
compatible.asm 管理者版本,管理ASM diskgroup的例項必須大於等於這個設定
compatible.rdbms 使用者版本,使用ASM diskgroup 的例項必須大於等於這個設定
而compatible.asm必須大於等於compatible.rdbms ,否則報錯如下:

 SQL> CREATE DISKGROUP data2 DISK '/dev/raw/raw8'
  2         ATTRIBUTE 'compatible.asm' = '11.1', 'compatible.rdbms' = '11.2';
CREATE DISKGROUP data2 DISK '/dev/raw/raw8'
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15234: target RDBMS compatibility (11.2.0.0.0) exceeds ASM compatibility
(11.1.0.0.0)

(SQL> CREATE DISKGROUP data2 DISK '/dev/raw/raw8'
  2         ATTRIBUTE 'compatible.asm' = '11.2', 'compatible.rdbms' = '11.1';
CREATE DISKGROUP data2 DISK '/dev/raw/raw8'
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15072: command requires at least 2 regular failure groups, discovered only
1

SQL> CREATE DISKGROUP   data2  External Redundancy DISK '/dev/raw/raw8'
  2         ATTRIBUTE 'compatible.asm' = '11.2', 'compatible.rdbms' = '11.1';

Diskgroup created.

SQL> select * from v$asm_diskgroup;
 
GROUP_NUMBER NAME                           SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE       TYPE     TOTAL_MB    FREE_MB HOT_USED_MB COLD_USED_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB OFFLINE_DISKS COMPATIBILITY                                                DATABASE_COMPATIBILITY                                       VOTING_FILES
------------ ------------------------------ ----------- ---------- -------------------- ----------- ------ ---------- ---------- ----------- ------------ ----------------------- -------------- ------------- ------------------------------------------------------------ ------------------------------------------------------------ ------------
           1 ARCH                                   512       4096              1048576 CONNECTED   EXTERN       2870       2642           0          228                       0           2642             0 11.2.0.0.0                                                   10.1.0.0.0                                                   N
           2 DATA                                   512       4096              1048576 CONNECTED   NORMAL       5740       1502           0         4238                       0            751             0 11.2.0.0.0                                                   11.2.0.0.0                                                   N
           3 DATA2                                  512       4096              1048576 MOUNTED     EXTERN       2870       2818           0           52                       0           2818             0 11.2.0.0.0                                                   11.1.0.0.0                                                   N
 
4、檢視屬性
SQL> SELECT dg.name AS diskgroup, t.name, t.stripe, t.redundancy, t.primary_region, t.mirror_region
  2         FROM V$ASM_DISKGROUP dg, V$ASM_TEMPLATE t
  3         WHERE dg.group_number = t.group_number and dg.name = 'DATA' ORDER BY t.name;
 
DISKGROUP                      NAME                           STRIPE REDUNDANCY PRIMARY_REGION MIRROR_REGION
------------------------------ ------------------------------ ------ ---------- -------------- -------------
DATA                           ARCHIVELOG                     COARSE MIRROR     COLD           COLD
DATA                           ASMPARAMETERFILE               COARSE MIRROR     COLD           COLD
DATA                           AUTOBACKUP                     COARSE MIRROR     COLD           COLD
DATA                           BACKUPSET                      COARSE MIRROR     COLD           COLD
DATA                           CHANGETRACKING                 COARSE MIRROR     COLD           COLD
DATA                           CONTROLFILE                    FINE   HIGH       COLD           COLD
DATA                           DATAFILE                       COARSE MIRROR     COLD           COLD
DATA                           DATAGUARDCONFIG                COARSE MIRROR     COLD           COLD
DATA                           DUMPSET                        COARSE MIRROR     COLD           COLD
DATA                           FLASHBACK                      COARSE MIRROR     COLD           COLD
DATA                           FLASHFILE                      COARSE MIRROR     COLD           COLD
DATA                           OCRFILE                        COARSE MIRROR     COLD           COLD
DATA                           ONLINELOG                      COARSE MIRROR     COLD           COLD
DATA                           PARAMETERFILE                  COARSE MIRROR     COLD           COLD
DATA                           TEMPFILE                       COARSE MIRROR     COLD           COLD
DATA                           XTRANSPORT                     COARSE MIRROR     COLD           COLD

SQL> SELECT dg.name AS diskgroup, SUBSTR(a.name,1,18) AS name,
  2       SUBSTR(a.value,1,24) AS value, read_only FROM V$ASM_DISKGROUP dg,
  3       V$ASM_ATTRIBUTE a WHERE dg.name = 'DATA'
  4       AND dg.group_number = a.group_number and a.NAME NOT LIKE 'template%';
 
DISKGROUP                      NAME                                                                             VALUE                                                                            READ_ONLY
------------------------------ -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ---------
DATA                           disk_repair_time                                                                 3.6h                                                                             N
DATA                           au_size                                                                          1048576                                                                          Y
DATA                           sector_size                                                                      512                                                                              Y
DATA                           compatible.asm                                                                   11.2.0.0.0                                                                       N
DATA                           compatible.rdbms                                                                 11.2.0.0.0                                                                       N
DATA                           cell.smart_scan_ca                                                               FALSE                                                                            N
DATA                           access_control.ena                                                               FALSE                                                                            N
DATA                           access_control.uma                                                               066                                                                              N


alter diskgroup data offline disk DATA_0000 drop after  0.5m; 可以指定disk_repair_time的時間,本列30秒後刪除DISK。

SQL> select * from v$asm_disk;
 
GROUP_NUMBER DISK_NUMBER COMPOUND_INDEX INCARNATION MOUNT_STATUS HEADER_STATUS MODE_STATUS STATE    REDUNDANCY LIBRARY                                                               OS_MB   TOTAL_MB    FREE_MB HOT_USED_MB COLD_USED_MB NAME                           FAILGROUP                      LABEL                           PATH                                                                             UDID                                                             PRODUCT                          CREATE_DATE MOUNT_DATE  REPAIR_TIMER      READS     WRITES  READ_ERRS WRITE_ERRS  READ_TIME WRITE_TIME BYTES_READ BYTES_WRITTEN PREFERRED_READ HASH_VALUE  HOT_READS HOT_WRITES HOT_BYTES_READ HOT_BYTES_WRITTEN COLD_READS COLD_WRITES COLD_BYTES_READ COLD_BYTES_WRITTEN VOTING_FILE SECTOR_SIZE FAILGROUP_TYPE
------------ ----------- -------------- ----------- ------------ ------------- ----------- -------- ---------- ---------------------------------------------------------------- ---------- ---------- ---------- ----------- ------------ ------------------------------ ------------------------------ ------------------------------- -------------------------------------------------------------------------------- ---------------------------------------------------------------- -------------------------------- ----------- ----------- ------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------- -------------- ---------- ---------- ---------- -------------- ----------------- ---------- ----------- --------------- ------------------ ----------- ----------- --------------
           2           1       33554433  3940853700 CACHED       MEMBER        ONLINE      NORMAL   UNKNOWN    System                                                                 2870       2870        751           0         2119 DATA_0001                      DATA_0001                                                      /dev/raw/raw6                                                                                                                                                                      2013/8/13 2 2013/8/25 1            0      12399      15727          0          0 305.731401 384.269159 2402186240    2244893696 U               559735068          0          0              0                 0       9428        5562       141222912          155028480 N                   512 REGULAR
           1           0       16777216  3940853698 CACHED       MEMBER        ONLINE      NORMAL   UNKNOWN    System                                                                 2870       2870       2642           0          228 ARCH_0000                      ARCH_0000                                                      /dev/raw/raw7                                                                                                                                                                      2013/8/14 0 2013/8/25 1            0       8593      14440          0          0  37.040936  79.919776  136900608     163531776                 797869928          0          0              0                 0       8094        9978       132796416          145255424 N                   512 REGULAR
           2           0       33554432  3940853699 MISSING      UNKNOWN       OFFLINE     FORCING  UNKNOWN    System                                                                    0       2870        751           0         2119 _DROPPED_0000_DATA             DATA_0000                                                                                                                                                                                                                                         2013/8/13 2 2013/8/25 1            0                                                                                            U              1316795825                                                                                                                  N                     0 REGULAR
          
刪除後NAME更名為_DROPPED_0000_DATA,狀態均有變化,這裡實際上是如果出現磁碟讀寫錯誤,ASM會自動的設定DISK為OFFLINE

SQL>  select state,NAME,MODE_STATUS,FREE_MB,path,HEADER_STATUS from v$asm_disk;
 
STATE    NAME                           MODE_STATUS    FREE_MB PATH                                                                             HEADER_STATUS
-------- ------------------------------ ----------- ---------- -------------------------------------------------------------------------------- -------------
NORMAL   DATA_0001                      ONLINE             751 /dev/raw/raw6                                                                    MEMBER
NORMAL   ARCH_0000                      ONLINE            2642 /dev/raw/raw7                                                                    MEMBER
FORCING  _DROPPED_0000_DATA             OFFLINE            751                                                                                  UNKNOWN
NORMAL                                  ONLINE               0 /dev/raw/raw8                                                                    FORMER
NORMAL                                  ONLINE               0 /dev/raw/raw5                                                                    MEMBER  ---這裡是原始的磁碟

這種狀態下沒有辦法恢復了,只有重新鍵入磁碟

SQL> alter diskgroup data add disk '/dev/raw/raw5' force;

Diskgroup altered.

SQL> r
  1*  select state,NAME,MODE_STATUS,FREE_MB,path,HEADER_STATUS,GROUP_NUMBER from v$asm_disk

STATE    NAME                           MODE_ST    FREE_MB PATH                                                                                                           HEADER_STATU GROUP_NUMBER
-------- ------------------------------ ------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------ ------------
NORMAL                                  ONLINE           0 /dev/raw/raw8                                                                                                  FORMER                   0
FORCING  _DROPPED_0000_DATA             OFFLINE       1108                                                                                                                UNKNOWN                  2
NORMAL   DATA_0001                      ONLINE         751 /dev/raw/raw6                                                                                                  MEMBER                   2
NORMAL   DATA_0002                      ONLINE        2511 /dev/raw/raw5                                                                                                  MEMBER                   2
NORMAL   ARCH_0000                      ONLINE        2642 /dev/raw/raw7                                                                                                  MEMBER                   1

DATA_0002 free_mb不斷減少,_DROPPED_0000_DATA free_mb不斷增多,實際上_DROPPED_0000_DATA並不是一塊真實的盤而是一個佔位而已表示曾經的DATA_0000磁碟出現了故障OFFLINE刪除了,並且
如果需要新增盤的話,需要多少空間而已,當然這個特性只能在高冗餘或者普通冗餘有用,當你新加入盤後資料會從健康的盤同步到新的盤中,同步完成後會自動消失,因為磁碟組又恢復到正常狀態,
及普通冗餘有2個失效組,高冗餘有3個失效組。
SQL> r
  1*  select state,NAME,MODE_STATUS,FREE_MB,path,HEADER_STATUS,GROUP_NUMBER from v$asm_disk

STATE    NAME                           MODE_ST    FREE_MB PATH                                                                                                           HEADER_STATU GROUP_NUMBER
-------- ------------------------------ ------- ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------ ------------
NORMAL                                  ONLINE           0 /dev/raw/raw8                                                                                                  FORMER                   0
NORMAL   DATA_0001                      ONLINE         751 /dev/raw/raw6                                                                                                  MEMBER                   2
NORMAL   DATA_0002                      ONLINE         751 /dev/raw/raw5                                                                                                  MEMBER                   2
NORMAL   ARCH_0000                      ONLINE        2642 /dev/raw/raw7                                                                                                  MEMBER                   1

最後恢復完成

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

相關文章