ASM

简介:

ASM是ORACLE10G引入的一项新的存储管理技术,借助一个新增的ASM实例来实现对
原始设备的管理,多个原始设备被组织为一个或多个ASM磁盘卷组,存储的操作以
ASM磁盘卷组为单位进行,

所需软件包:
oracleasm-support-2.0.3-1.i386.rpm
oracleasm-2.6.9-42.EL-2.0.3-1.i686.rpm
oracleasmlib-2.0.2-1.i386.rpm

2、配置ASMLib
#/etc/init.d/oracleasm configure
Default user to own the driver interface [oracle]: oracle
Default group to own the driver interface [oinstall]: oinstall
Start Oracle ASM library driver on boot (y/n) [y]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]

Zx:
#ls -l /etc/init.d/*asm*
-rwxr-xr-x 1 root root 1861 Jul 6 2006 /etc/init.d/ibmasm
-rwxr-xr-x 1 root root 18084 Jul 25 2006 /etc/init.d/oracleasm

查看oracleasm启动时是否被加载:
#cd /etc/rc3.d
ls -l /etc/rc3.d/*oracleasm

查看ASM命令选项:
# /etc/init.d/oracleasm

若服务没有加载加入链接:
#ln -s ../init.d/oracleasm S29oracleasm
#ln -s ../init.d/oracleasm K01oracleasm

创建ASM磁盘:
[root@dbrac bin]# service oracleasm createdisk vol19 /dev/hda19
Marking disk "/dev/hda19" as an ASM disk: [ OK ]
[root@dbrac bin]# service oracleasm createdisk vol20 /dev/hda20
Marking disk "/dev/hda20" as an ASM disk: [ OK ]

查看ASM磁盘:
[root@dbrac bin]# /etc/init.d/oracleasm listdisks
VOL19
VOL20

如何查看ASM磁盘VOL19中有哪些设备:
[root@dbrac bin]# service oracleasm querydisk VOL19
Disk "VOL19" is a valid ASM disk on device [3, 19]

[root@dbrac bin]# ls -l /dev/hda* | grep '3, 19'
brw-rw---- 1 root disk 3, 19 Apr 20 2010 /dev/hda19

修改oracleasm脚本看看ASM信息写在系统什么位置
vi /etc/init.d/oracleasm/listdisks

listdisks)
if [ -d "${ORACLE_ASMMANAGER}/disks/" ]
then
ls -1 "${ORACLE_ASMMANAGER}/disks/"
# echo "\${ORACLE_ASMMANAGER} = ${ORACLE_ASMMANAGER} " #将信息打印出来
fi
;;

[root@stu6 ~]# service oracleasm listdisks
VOL19
VOL20
${ORACLE_ASMMANAGER} = /dev/oracleasm #打印出来了吧!原来ASM信息写在这!

[root@dbrac bin]# cd /dev/oracleasm
[root@dbrac oracleasm]# ls
disks iid

[root@stu6 oracleasm]# cd disks
[root@dbrac disks]# ls -l
total 0
brw-rw---- 1 oracle oinstall 3, 19 Apr 19 21:13 VOL19
brw-rw---- 1 oracle oinstall 3, 20 Apr 19 21:13 VOL20
ASM磁盘的信息在系统中都得到了!

使用oracleasm删除ASM磁盘
#/etc/init.d/oracleasm deletedisk VOL4

创建ASM数据库:用向导建库,存储模式选择ASM
dbca在建库过程中会出现一个提示要求启动oracle集群同步服务(CSS),启动方法是在root用户运行一个脚本:
#/u01/app/oracle/product/10.2.0/db_1/bin/localconfig add

ASM网络配置
listener.ora
########################
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = siemens)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = siemens)
)
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(SID_NAME = +ASM)
)
)

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1521))
)

#######################
tnsnames.ora
#######################
SIEMENS =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = siemens)
)
)

ASM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dbrac)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = +ASM)
)
)
########################

启动时先起ASM,停库时先停数据库

启动ASM实例问题:
create and start ASM instance:
ORA-01034:ORACLE not available 重新启动后问题解决!

查看磁盘组信息:
col name for a10
SELECT group_number,name,type,state,total_mb,free_mb,offline_disks FROM V$ASM_diskgroup;

GROUP_NUMBER NAME TYPE STATE TOTAL_MB FREE_MB OFFLINE_DISKS
------------ ----- ------ ----------- ---------- ---------- -------------
1 DGA NORMAL CONNECTED 4000 1420 0

查看ASM磁盘的信息:
col group# for 99
col disk# for 99
col name for a5
col path for a11
col LABEL for a7
col FAILGROUP for a10
select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

GROUP# DISK# LABEL REDUNDA STATE FAILGROUP NAME PATH TOTAL_MB FREE_MB
------ ----- ------- ------- -------- ---------- ----- ----------- ---------- ----------
1 1 VOL19 UNKNOWN NORMAL FG1 DGA1 ORCL:VOL19 2000 710
1 0 VOL20 UNKNOWN NORMAL FG2 DGA2 ORCL:VOL20 2000 710

在ASM实例下为磁盘组dga增加磁盘(大小写敏感):
alter diskgroup dgb add failgroup fg3 disk 'ORCL:VOL5' name vol5;

alter diskgroup dgb add failgroup fg3 disk '/dev/raw/raw6' name vol6;


从组中删除磁盘:
ALTER DISKGROUP dga DROP DISK vol21;

ALTER DISKGROUP dgA ADD DISK
'/dev/rdsk/c0t4d0s2' NAME A5,
'/dev/rdsk/c0t5d0s2' NAME A6,
'/dev/rdsk/c0t6d0s2' NAME A7,
'/dev/rdsk/c0t7d0s2' NAME A8;

ALTER DISKGROUP dgroupA ADD DISK '/devices/A*';

在ASM实例下删除磁盘组中的磁盘同时添加新磁盘:
ALTER DISKGROUP dgA DROP DISK vol21 ADD FAILGROUP fg3 DISK 'ORCL:VOL01' NAME VOL21;

在ASM实例下手工创建ASM磁盘组(external normal high):
<ASM磁盘>用 oracleasm createdisk 创建
CREATE DISKGROUP dgb external REDUNDANCY DISK 'ORCL:vol22' name dgb1 SIZE 1000M;

CREATE DISKGROUP dga NORMAL REDUNDANCY
FAILGROUP fg1 DISK 'ORCL:VOL01' name VOL01
FAILGROUP fg2 DISK 'ORCL:VOL02' name VOL02;

Vi $ORACLE_HOME/dbs/initorac.ora
#control_files
Db_create_file_dest=’+DGA’

使用<裸设备> oracle 代替ASM磁盘
CREATE DISKGROUP dgd NORMAL REDUNDANCY 
FAILGROUP controller1 DISK
'/dev/raw/raw1' NAME diskA1 SIZE 120G FORCE,
'/dev/raw/raw2',
'/dev/raw/raw3'
FAILGROUP controller2 DISK
'/dev/raw/raw4',
'/dev/raw/raw5',
'/dev/raw/raw6';

卸载磁盘组:
ALTER DISKGROUP dgA DISMOUNT;

检测磁盘组或磁盘:
ALTER DISKGROUP dga CHECK ALL;
alter diskgroup dga check disk vol19;

在模板中加入新项,默认是双镜像粗条带化模式(MIRROR 双镜像;HIGH 三镜像;UNPROTECTED 无镜像)
双镜像粗条带化(COARSE :1M)
ALTER DISKGROUP dgc ADD TEMPLATE my_template ATTRIBUTES (COARSE);
ALTER DISKGROUP dgc ADD TEMPLATE reliable ATTRIBUTES (MIRROR COARSE);
无镜像粗条带化
ALTER DISKGROUP dgc ADD TEMPLATE userdata ATTRIBUTES (UNPROTECTED);
双镜像细条带化(FINE :128K)
ALTER DISKGROUP dgc ADD TEMPLATE reliable ATTRIBUTES (MIRROR FINE);
修改模板项属性
alter diskgroup dgc alter template my_template attributes (fine);

使用自定义模板
ALTER SYSTEM SET DB_CREATE_FILE_DEST = '+dgc(my_template)';
CREATE TABLESPACE test;

删除模板中的项(模板默认选项不能删除):
ALTER DISKGROUP dgb DROP TEMPLATE reliable;

删除数据文件:
1.数据库实例
create tablespace test;
alter tablespace test offline;
2.ASM实例:
ALTER DISKGROUP dgA DROP FILE '+DGA/siemens/datafile/test.271.716979429';

在ASM实例下创建磁盘组中的目录:
ALTER DISKGROUP dgB ADD DIRECTORY '+dgB/mydir';
为OMF文件命名别名:
ALTER DISKGROUP dgroupA ADD ALIAS '+dgroupA/mydir/datafile.dbf' FOR '+dgroupA.274.38745';
ALTER DISKGROUP dgroupA DROP ALIAS '+dgroupA/mydir/datafile.dbf';

怎样查看磁盘组中的路径:(amscmd)

磁盘组dismount
alter diskgroup group2 dismount;
show parameter asm_diskgroups

磁盘组mount
alter diskgroup group2 mount;

控制均衡容错组数据的速度:
ALTER DISKGROUP dgb REBALANCE POWER 11;
平衡速度控制参数:
asm_power_limit = 1~11

增加容错组同时将数据从其它两组向该组平衡:
ALTER DISKGROUP group1 ADD FAILGROUP fail3 DISK 'ORCL:DISK10' REBALANCE POWER 11;

检查数据库平衡速度:
SELECT group_number, operation, state, est_work, sofar, est_rate, est_minutes FROM v$asm_operation;

修改磁盘组大小:
ALTER DISKGROUP group1 RESIZE ALL SIZE 4G;

删除磁盘组:
drop diskgroup group1 including contents;

取消删除:
ALTER DISKGROUP group1 UNDROP DISKS;

向容错组添加磁盘:纪录在+ASM/bdump/alert_+ASM.log,数据从该容错组中的其它磁盘向该盘平衡

从组中删除容错组:

如果有挂起则不能添加!提示ORA-15029: disk 'ORCL:DISK2' is already mounted by this instance!
HUNG如何处理:除非将组删除!但数据何处去?

ALTER DISKGROUP group1 ADD FAILGROUP fail1 DISK 'ORCL:DISK6' REBALANCE POWER 11;

恶意测试:破坏ASM磁盘数据
dd if=/dev/zero f=/dev/hda19 bs=10M count=20

删除垃圾文件:
1.得到卷组中的所有文件信息(在ASM实例):
select file_number,name from v$asm_alias;
2.找到有用文件(在数据库实例)
show parameter spfile
select name from v$datafile;
select name from v$controlfile;
select member from v$logfile;

---oracle10g----
V$ASM_TEMPLATE
V$ASM_ALIAS
V$ASM_FILE
V$ASM_CLIENT
V$ASM_DISKGROUP
V$ASM_DISKGROUP_STAT
V$ASM_DISK
V$ASM_DISK_STAT
V$ASM_OPERATION
---oracle11g----
V$ASM_ATTRIBUTE
V$ASM_DISK_IOSTAT


ASMCMD:
export ORACLE_SID=+ASM
asmcmd -p (-p 选项可以在提示中显示当前路径)

rm 删除文件
lsdg (list diskgroup)查看 ASM 实例挂载的磁盘,分配的空间大小、可用空间大小和脱机磁盘
du (disk utilization )查看目录内部已使用的空间大小
du +disk/test/controlfile
find -t CONRTOLFILE +group1/oraasm/ *
mkalias TEST_ASM.281.637521303 TEST_ASM01.DBF












本文转自东方之子736651CTO博客,原文链接: http://blog.51cto.com/ecloud/1184009,如需转载请自行联系原作者





相关文章
|
Kubernetes Cloud Native 物联网
使用ASM管理Knative服务(1):Knative on ASM概述
阿里云服务网格ASM集成ACK、ASK上Knative的Serving能力, 帮助用户方便管理Serverless工作负载,可以和事件很好的结合并且提供了基于请求驱动的自动扩缩的能力,而且在没有服务需要处理的时候可以缩容到零个实例。同时基于Service Mesh技术, Serving还具有流量灰度发布能力。
244 0
使用ASM管理Knative服务(1):Knative on ASM概述
|
存储 Java API
ASM 关键接口 MethodVisitor
ASM 关键接口 MethodVisitor
443 0
ASM 关键接口 MethodVisitor
|
Kubernetes 安全 架构师
ASM和服务网格
ASM是阿里云基于Istio的微服务治理服务
661 0
ASM和服务网格
|
SQL 数据库
ASM卷加盘
1.登陆服务器 2.登陆到ASM实例su - grid sqlplus '/as sysasm' SQL> SELECT path FROM v$asm_disk WHERE NAME IS NULL; PATH /dev/rdsk/c0t60060E8007C72E000030C72E0000...
853 0
|
Oracle 关系型数据库 网络架构
asm 状态INTERMEDIATE
asm INTERMEDIATE,asm 磁盘中状态显示INTERMEDIATE。
3201 0
|
存储 监控 Oracle
ASM
1540 0
|
SQL Web App开发 数据库
|
Java 数据库连接 应用服务中间件
|
存储 Oracle 关系型数据库
|
Oracle 关系型数据库 数据库