1. 程式人生 > >oracle asm管理

oracle asm管理

oracle asm

oracle asm管理

1、asm優點

概念:

auto storage manage

db+instance<=====> raw裸設備


性能比較:raw > asm > filesystem

管理方便性 filesystem > asm > raw


邏輯結構

數據庫<--表空間(tablespace)<---段(segment)<----區(extend)<---數據塊(block)


物理結構:SAN存儲 NFS存儲

數據文件()


ASM結構::

ASM磁盤組《---ASM磁盤《---ASM分配單元《---磁盤物理塊

|

ASM文件


asm功能和特點

對文件而不是邏輯卷進行條帶化,更加細粒化

提供聯機磁盤重新配置和動態重新平衡

允許調整重新平衡速度

與每一個文件為基礎提供冗余

只支持oracle DB文件

可識別支持集群環境

可自動安裝



asm優點:

可以讓ASM免除如下:

I/O性能優化

數據文件移動和重新組織

文件名管理

邏輯卷管理

文件系統管理

集群文件系統管理

裸設備管理




raid 0 1 (卷)


raid1 2快盤 內容一模一樣

raid0 2塊盤 各一半

raid5 3塊盤 一半 一半 全部

raid 1 和 raid 0 4塊盤分成2組 2組對稱





2、管理asm實例

asm實例是asm進程和內存組件的結合


asm後臺進程:

arcn歸檔進程

ckpt檢查點進程

dbwn數據寫進程

diag診斷進程

jnnn作業隊列進程

lgwr日誌寫進程

pmon進程監視器

pspo進程衍生進程

qmnn 隊列監視器

reco恢復器進程

smon系統監視器

mman內存管理器進程

vktm虛擬計時器進程


如果集群還有如下進程:

lmon全局入隊服務監視器進程

lmdn全局入隊服務守護進程

lmsn 全局高速緩存服務進程

lckn鎖定進程



ps -ef | grep asm --colour

數據庫實例請求創建oracle DB文件的過程:


數據庫請求創建文件

asm前臺進程創建一個持續操作目錄(COD)條目並在磁盤組中為新的文件分配空間

asmb數據庫進程接收新文件的區映射

現在文件處於打開狀態,數據庫進程直接初始化該文件

初始化後,數據庫進程請求提交文件創建,這會導致asm

前臺進程清除cod條目並將文件的acd信息寫入磁盤,為將磁盤標記為已經創建。


asm動態性能視圖

v$asm_alias v$asm_attribute

v$asm_client

v$asm_disk

v$asm_disk_iostat

v$asm_disk_stat

v$asm_operation

v$asm_template


asm系統權限:

sysasm osasm

sysdba osdba

sysoper osoper


命令行登錄:

sqlplus / as sysasm


SQL> show parameter spfile;


NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

spfile string +DATA/asm/asmparameterfile/reg

istry.253.943292165

SQL> create pfile from spfile;


File created.


目錄: /u01/app/oracle/product/11.2.0/grid/dbs/

startup pfile=‘/u01/app/oracle/product/11.2.0/grid/dbs/init+ASM.ora‘;


asm實例的啟動及關閉


SQL> show parameter name;


NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

db_unique_name string +ASM

instance_name string +ASM

lock_name_space string

service_names string +ASM


查看asm組

SQL> select name,state from v$asm_diskgroup;


NAME STATE

------------------------------ -----------

DATA MOUNTED

FRA MOUNTED



SQL> select GROUP_NUMBER,INSTANCE_NAME,DB_NAME from v$asm_client;


GROUP_NUMBER INSTANCE_N DB_NAME

------------ ---------- ----------

########## +ASM +ASM

########## orcl orcl

########## orcl orcl


為了安全 先關閉數據庫

su - oracle

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.



SQL> shutdown immediate

ASM diskgroups volume disabled

ASM diskgroups dismounted

ASM instance shutdown


asm啟動到nomount狀態

SQL> startup nomount

ASM instance started


Total System Global Area 283930624 bytes

Fixed Size 2212656 bytes

Variable Size 256552144 bytes

ASM Cache 25165824 bytes


查看目前磁盤組:

SQL> show parameter asm_diskgroup


NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

asm_diskgroups string FRA

SQL> select name,state from v$asm_diskgroup;


NAME STATE

------------------------------ -----------

FRA DISMOUNTED

DATA DISMOUNTED


掛著磁盤組:

alter diskgroup data mount;

alter diskgroup fra mount;

SQL> alter diskgroup data mount;


Diskgroup altered.


SQL> alter diskgroup fra mount;


Diskgroup altered.


SQL>


查看磁盤組狀態:

SQL> select name,state from v$asm_diskgroup;


NAME STATE

------------------------------ -----------

FRA MOUNTED

DATA MOUNTED


SQL>


############

SQL> shutdown immediate

ASM diskgroups volume disabled

ASM diskgroups dismounted

ASM instance shutdown

SQL> startup

ASM instance started


Total System Global Area 283930624 bytes

Fixed Size 2212656 bytes

Variable Size 256552144 bytes

ASM Cache 25165824 bytes

ASM diskgroups mounted

ASM diskgroups volume enabled

SQL> show parameter diskgroup


NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

asm_diskgroups string FRA, DATA


SQL> select name,state from v$asm_diskgroup;


NAME STATE

------------------------------ -----------

DATA MOUNTED

FRA MOUNTED


startup 與 startup mount 、 startup open 在asm上面 是一樣的


#卸載磁盤組

alter diskgroup data dismount;



另外一種 保護模式:(修復模式)

startup restrict;

SQL> startup restrict;

ASM instance started


Total System Global Area 283930624 bytes

Fixed Size 2212656 bytes

Variable Size 256552144 bytes

ASM Cache 25165824 bytes

ASM diskgroups mounted

ASM diskgroups volume enabled

SQL> select name,state from v$asm_diskgroup;


NAME STATE

------------------------------ -----------

DATA RESTRICTED

FRA RESTRICTED


這時啟動數據庫報錯 因為asm保護模式

SQL> startup

ORA-01078: failure in processing system parameters

ORA-01565: error in identifying file ‘+DATA/orcl/spfileorcl.ora‘

ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl/spfileorcl.ora

ORA-15056: additional error message

ORA-17503: ksfdopn:DGOpenFile05 Failed to open file +DATA/orcl/spfileorcl.ora

ORA-17503: ksfdopn:2 Failed to open file +DATA/orcl/spfileorcl.ora

ORA-15236: diskgroup DATA mounted in restricted mode

ORA-06512: at line 4



############

srvctl stop asm -f 強制關閉磁盤組


crs_stat -t


srvctl start asm 啟動磁盤組,但是沒有mount


把磁盤組打開到mount狀態

srvctl start diskgroup -g data

srvctl start diskgroup -g fra



srvctl stop diskgroup -g data

srvctl stop diskgroup -g fra


##############



asmcmd

[[email protected] ~]$ asmcmd

ASMCMD>


ASMCMD> shutdown --help

Unknown option: help

usage: shutdown [--immediate] [--abort]

help: help shutdown


ASMCMD> shutdown --immediate

ASM diskgroups volume disabled

ASM diskgroups dismounted

ASM instance shutdown

Connected to an idle instance.


有這麽多命令???????

ASMCMD> -- help

commands:

--------


md_backup, md_restore


lsattr, setattr


cd, cp, du, find, help, ls, lsct, lsdg, lsof, mkalias

mkdir, pwd, rm, rmalias


chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg, mount

offline, online, rebal, remap, umount


dsget, dsset, lsop, shutdown, spbackup, spcopy, spget

spmove, spset, startup


chtmpl, lstmpl, mktmpl, rmtmpl


chgrp, chmod, chown, groups, grpmod, lsgrp, lspwusr, lsusr

mkgrp, mkusr, orapwusr, passwd, rmgrp, rmusr


volcreate, voldelete, voldisable, volenable, volinfo

volresize, volset, volstat


ASMCMD>


ASMCMD> startup --help

Unknown option: help

usage: startup [--nomount] [--restrict] [--pfile <pfile.ora>]

help: help startup



3、管理ASM磁盤組

8個2G


2個磁盤組 DATA FRA


SQL> select name from v$datafile;


NAME

--------------------------------------------------------------------------------

+DATA/orcl/datafile/system.256.943301251

+DATA/orcl/datafile/sysaux.257.943301251

+DATA/orcl/datafile/undotbs1.258.943301251

+DATA/orcl/datafile/users.259.943301251

+DATA/orcl/datafile/example.265.943301433


SQL> select name from v$controlfile;


NAME

--------------------------------------------------------------------------------

+DATA/orcl/controlfile/current.260.943301383

+FRA/orcl/controlfile/current.256.943301385


磁盤組的冗余度:

外部冗余:asm不提供如何數據鏡像

正常冗余:asm提供數據雙向鏡像

高冗余:asm提供3向鏡像

fdisk -l


fdisk /dev/sdj

fdisk /dev/sdk

fdisk /dev/sdl

fdisk /dev/sdm

fdisk /dev/sdn

fdisk /dev/sdo

fdisk /dev/sdp

fdisk /dev/sdq


vim /etc/udev/rules.d/60-raw.rules


start_udev

raw -aq


ll /dev/raw

chown oracle.oinstall /dev/raw/raw1*

chmod 660 /dev/raw/raw1*



sqlplus / as sysasm

set lines 180;

col name for a20;

col path for a50;

select name,path from v$asm_disk order by 1;


SQL> select name,path from v$asm_disk order by 1;


NAME PATH

-------------------- --------------------------------------------------

DATA_0000 /dev/raw/raw1

DATA_0001 /dev/raw/raw2

DATA_0002 /dev/raw/raw3

DATA_0003 /dev/raw/raw4

FRA_0000 /dev/raw/raw5

FRA_0001 /dev/raw/raw6

FRA_0002 /dev/raw/raw7

FRA_0003 /dev/raw/raw8

/dev/raw/raw12

/dev/raw/raw11

/dev/raw/raw15


NAME PATH

-------------------- --------------------------------------------------

/dev/raw/raw16

/dev/raw/raw18

/dev/raw/raw17

/dev/raw/raw13

/dev/raw/raw14




創建磁盤組:

create diskgroup test normal redundancy failgroup fg1 disk ‘/dev/raw/raw11‘ name test_1,‘/dev/raw/raw12‘ name test_2 failgroup fg2 disk ‘/dev/raw/raw13‘ name test_3,‘/dev/raw/raw14‘ name test_4;


SQL> create diskgroup test normal redundancy failgroup fg1 disk ‘/dev/raw/raw11‘ name

test_1,‘/dev/raw/raw12‘ name test_2 failgroup fg2 disk ‘/dev/raw/raw13‘ name test_3,‘/dev/raw/raw14‘ name test_4;

Diskgroup created.


SQL> select name,state from v$asm_diskgroup;


NAME STATE

-------------------- -----------

DATA MOUNTED

FRA MOUNTED

TEST MOUNTED


查看磁盤組及單前大小及空閑大小

set pages 1000;

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


GROUP_NUMBER NAME STATE TOTAL_MB FREE_MB

------------ -------------------- ----------- ---------- ----------

1 DATA MOUNTED 8188 4557

2 FRA MOUNTED 8188 7954

3 TEST MOUNTED 2044 1938

select a.group_number,a.name,b.name,b.path from v$asm_diskgroup a,v$asm_disk b where a.group_number=b.group_number order by 1,2,3,4;

GROUP_NUMBER NAME NAME PATH

------------ -------------------- -------------------- --------------------

1 DATA DATA_0000 /dev/raw/raw1

1 DATA DATA_0001 /dev/raw/raw2

1 DATA DATA_0002 /dev/raw/raw3

1 DATA DATA_0003 /dev/raw/raw4

2 FRA FRA_0000 /dev/raw/raw5

2 FRA FRA_0001 /dev/raw/raw6

2 FRA FRA_0002 /dev/raw/raw7

2 FRA FRA_0003 /dev/raw/raw8

3 TEST TEST_1 /dev/raw/raw11

3 TEST TEST_2 /dev/raw/raw12

3 TEST TEST_3 /dev/raw/raw13

3 TEST TEST_4 /dev/raw/raw14


12 rows selected.


修改磁盤組:


刪除磁盤組:

drop diskgroup test including contents;



往磁盤組中添加磁盤:

alter diskgroup test add disk ‘/dev/raw/raw15‘ name A5,‘/dev/raw/raw16‘ name A6,‘/dev/raw/raw17‘ name A7,‘/dev/raw/raw18‘ name A8;


從磁盤組中刪除磁盤:

alter diskgroup test drop disk A5;


取消磁盤操作undrop

alter diskgroup test undrop disk A5;


查看asm的兼容性:

SQL> select name ,DATABASE_COMPATIBILITY,COMPATIBILITY from v$asm_diskgroup where name=‘FRA‘;


NAME DATABASE_COMPATIBILITY COMPATIBILITY

-------------------- ------------------------------------------------------------ -----------------

-------------------------------------------FRA 10.1.0.0.0 11.2.0.0.0


SQL> select name ,DATABASE_COMPATIBILITY,COMPATIBILITY from v$asm_diskgroup where name=‘TEST‘;


NAME

------------------------------

DATABASE_COMPATIBILITY

------------------------------------------------------------

COMPATIBILITY

------------------------------------------------------------

TEST

10.1.0.0.0

10.1.0.0.0


修改asm兼容性(asm和rdbms)


alter diskgroup test set attribute ‘compatible.asm‘=‘11.2.0.0.0‘;

alter diskgroup test set attribute ‘compatible.rdbms‘=‘11.2.0.0.0‘;


SQL> select name ,DATABASE_COMPATIBILITY,COMPATIBILITY from v$asm_diskgroup where name=‘TEST‘;


NAME

------------------------------

DATABASE_COMPATIBILITY

------------------------------------------------------------

COMPATIBILITY

------------------------------------------------------------

TEST

11.2.0.0.0

11.2.0.0.0


select name,path from v$asm_disk order by 1,2;


#drop test_1;不記錄磁盤變化

alter diskgroup test offline disk test_1 drop after 0 h;

select name,repair_timer,state from v$asm_disk_stat;

select name,path from v$asm_disk order by 1,2;


重新上線:

alter diskgroup test add disk ‘/dev/raw/raw11‘ name test_1;


SQL> alter diskgroup test add disk ‘/dev/raw/raw11‘ name test_1;

alter diskgroup test add disk ‘/dev/raw/raw11‘ name test_1

*

ERROR at line 1:

ORA-15032: not all alterations performed

ORA-15033: disk ‘/dev/raw/raw11‘ belongs to diskgroup "TEST"


清空磁盤:

dd if=/dev/zero of=/dev/raw/raw11 bs=1M count=10;


重新添加:

SQL> alter diskgroup test add disk ‘/dev/raw/raw11‘ name test_1;


Diskgroup altered.


###repair_timer小於3.6小時

alter diskgroup test offline disk test_1 drop after 3.6 h;


本文出自 “梁小明的博客” 博客,請務必保留此出處http://7038006.blog.51cto.com/7028006/1929115

oracle asm管理