Oracle ASM 管理

君落塵發表於2015-03-23

一.檢查ASMLIB是否安裝成功:

檢查驅動載入情況:
[root@rhel1 disks]# lsmod | grep oracleasm
oracleasm              84136  1

檢查oracleasmfs檔案系統:
[root@rhel1 disks]# df -a |head -1;df -a | grep oracleasm
檔案系統               1K-塊        已用     可用 已用% 掛載點
oracleasmfs                  0         0         0   -  /dev/oracleasm


[root@rhel1 disks]# cat /proc/filesystems | grep oracleasm
nodev   oracleasmfs


asm disk建立成功後,會在/dev/oracleasm/disks目錄下有相應的檔案:
[root@rhel1 disks]# pwd
/dev/oracleasm/disks
[root@rhel1 disks]# ls
VOL1  VOL2  VOL3


如果在asmlib使用過程中有報錯,可以檢視詳細的日誌資訊:
/var/log/oracleasm


二.引數介紹:

instance_type=[RDBMS | ASM]
如果是ASM的話,該引數一定要是ASM。

asm_power_limit=[1 - 11]
指定了磁碟自動平衡負載的等級,數字越大,表示自動均衡能力越強。

asm_diskstring
指定了ASM例項啟動時自動尋找磁碟的特徵。如引數設定為/dev/mapper/*,那麼ASM例項在disk group新增磁碟時會預設把所有/dev/mapper目錄下的磁碟都顯示出來,預設情況為NULL,也就是所有磁碟裝置都顯示出來。

asm_diskgroups
指定例項啟動時自動MOUNT的磁碟組。

三.日常維護:
[root@rhel1 /]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]

[root@rhel1 /]# /etc/init.d/oracleasm listdisks
VOL1

[root@rhel1 /]# /etc/init.d/oracleasm querydisk -p VOL1
Disk "VOL1" is a valid ASM disk
/dev/sdb6: LABEL="VOL1" TYPE="oracleasm"


[root@rhel1 /]# fdisk -l /dev/sdb6
Disk /dev/sdb6: 4055 MB, 4055030784 bytes
255 heads, 63 sectors/track, 492 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb6 doesn't contain a valid partition table

SQL> set linesize 200
SQL> col name format a30
SQL> col path format a30
SQL> select group_number,disk_number,name,path from v$asm_disk;

GROUP_NUMBER DISK_NUMBER NAME                           PATH
------------ ----------- ------------------------------ ------------------------------
           1           0 ASM1                           ORCL:VOL1

SQL> select group_number,name,type,total_mb,free_mb from v$asm_diskgroup;

GROUP_NUMBER NAME                           TYPE     TOTAL_MB    FREE_MB
------------ ------------------------------ ------ ---------- ----------
           1 DG1                            EXTERN       3867        910

[root@rhel1 sbin]# ./oracleasm createdisk VOL2 /dev/sdb8
Writing disk header: done
Instantiating disk: done
[root@rhel1 sbin]# ./oracleasm createdisk VOL3 /dev/sdb9
Writing disk header: done
Instantiating disk: done
[root@rhel1 sbin]# ./oracleasm createdisk VOL4 /dev/sdb10
Writing disk header: done
Instantiating disk: done
[root@rhel1 sbin]# ./oracleasm createdisk VOL5 /dev/sdb11
Writing disk header: done
Instantiating disk: done
[root@rhel1 sbin]# ./oracleasm scandisks               
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...

[root@rhel1 sbin]# ./oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5

[oracle@rhel1 ~]$ export ORACLE_SID=+ASM1
[oracle@rhel1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Mar 2 03:03:44 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> alter diskgroup DG1 add disk '/dev/oracleasm/disks/VOL2' name data02;
alter diskgroup DG1 add disk '/dev/oracleasm/disks/VOL2' name data02
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15031: disk specification '/dev/oracleasm/disks/VOL2' matches no disks
ORA-15014: location '/dev/oracleasm/disks/VOL2' is not in the discovery set


SQL> alter diskgroup DG1 add disk 'ORCL:VOL2' name data02;

Diskgroup altered.

ORCL關鍵字說明:
Linux ASMLib 的發現字串
  ASMLib 使用發現字串來確定 ASM 正在請求哪些磁碟。一般的 Linux ASMLib 使用 glob 字串。字串必須以 "ORCL:" 為字首。磁碟透過名稱來指定。可以透過發現字串 "ORCL:VOL1" 在 ASM 中,發現以名稱 "VOL1" 建立的磁碟。類似地,可以用發現字串 "ORCL:VOL*" 來查詢所有以字串 "VOL" 開始的磁碟。
不能在發現字串中用路徑名稱來發現磁碟。如果缺少字首,那麼一般的 Linux ASMLib 將完全忽略發現字串,認為它適用於一個不同的 ASMLib。唯一的例外是空字串 (""),它被認為是一個全萬用字元。這與發現字串 "ORCL:*" 完全等價。

[root@rhel1 sbin]# su - oracle
[oracle@rhel1 ~]$ export ORACLE_SID=+ASM1
[oracle@rhel1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Apr 25 17:29:57 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> create diskgroup dg2 external redundancy disk 'ORCL:VOL3';

Diskgroup created.

SQL> select path from v$asm_disk;

PATH
--------------------------------------------------------------------------------
ORCL:VOL1
ORCL:VOL2
ORCL:VOL3

SQL> col name format a20;
SQL>  select name,state from v$asm_diskgroup;

NAME                 STATE
-------------------- ----------------------
DG1                  MOUNTED
FLASHAREA1           MOUNTED
DG2                  MOUNTED

SQL> drop diskgroup dg2 including contents;

Diskgroup dropped.

SQL> alter diskgroup dg1 add disk 'ORCL:VOL3';

Diskgroup altered.

SQL> alter diskgroup dg1 rebalance power 11;

Diskgroup altered.

SQL> alter diskgroup dg1 check all;

Diskgroup altered.

SQL> alter diskgroup dg1 check all repair;

Diskgroup altered.

SQL> select path from v$asm_disk where group_number in (select group_number from v$asm_diskgroup where name='DG1');

PATH
--------------------------------------------------------------------------------
ORCL:VOL1
ORCL:VOL3

SQL> alter diskgroup dg1 drop disk 'VOL3';  //注意這裡是DISK的名字v$asm_disk.name

Diskgroup altered.

SQL> select name from v$asm_diskgroup;

NAME
--------------------
DG1
FLASHAREA1

SQL> select name from v$asm_disk;

NAME
--------------------
DGDISK1
FLASHAREADISK01

SQL> create diskgroup dg2 external redundancy disk 'ORCL:VOL3';

Diskgroup created.

四.ASMCMD
[oracle@rhel1 ~]$ asmcmd
ASMCMD> help
ASMCMD> du
Used_MB      Mirror_used_MB
   1970                1970
ASMCMD> lsdg
State    Type    Rebal  Unbal  Sector  Block       AU  Total_MB  Free_MB
Req_mir_free_MB  Usable_file_MB  Offline_disks  Name
MOUNTED  EXTERN  N      N         512   4096  1048576      1961        0                0    
         0              0  DG1/
MOUNTED  EXTERN  N      N         512   4096  1048576      1961     1911                0
           1911              0  DG2/
MOUNTED  EXTERN  N      N         512   4096  1048576      1961     1764                0
           1764              0  FLASHAREA1/

ASMCMD> lsct
DB_Name   Status        Software_Version  Compatible_version  Instance_Name
ractest   CONNECTED           10.2.0.4.0          10.2.0.3.0  ractest1
ractest   CONNECTED           10.2.0.4.0          10.2.0.3.0  ractest1

ASMCMD> ls
DG1/
DG2/
FLASHAREA1/

ASMCMD> cd +/               //回到根目錄

五.相關動態效能檢視
SQL> col instance_name format a30;
SQL> select instance_name,db_name,status from v$asm_client; //檢視是否有資料庫例項連線上ASM例項
INSTANCE_NAME                  DB_NAME  STATUS
------------------------------ -------- ------------
+ASM2                          ractest  CONNECTED
+ASM2                          ractest  CONNECTED

SQL> select operation,state,power,actual,sofar from v$asm_operation;//記錄BALANCE操作
no rows selected

SQL> col path format a20;
SQL> select path, state, total_mb, free_mb from v$asm_disk;//ASM DISK
PATH                 STATE      TOTAL_MB    FREE_MB
-------------------- -------- ---------- ----------
ORCL:VOL1            NORMAL         1961          0
ORCL:VOL2            NORMAL         1961          0

SQL> select name,state,type,total_mb,free_mb from v$asm_diskgroup; //ASM DISKGROUP
NAME                           STATE       TYPE     TOTAL_MB    FREE_MB
------------------------------ ----------- ------ ---------- ----------
DG1                            CONNECTED   EXTERN       1961          0
FLASHAREA1                     CONNECTED   EXTERN       1961       1764
DG2                            DISMOUNTED                  0          0

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

相關文章