oracle asm管理
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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管理的主要内容,如果未能解决你的问题,请参考以下文章