Autostoragemanagement自动存储管理,它是oracle10g的新增功能,它将日益复杂的存储管理变得简单。它使的添加删除磁盘变得简单,并且动态调整i/o,通过设置故障组可以更好的保护数据安全。
ASM体系结构,它是通过一个ASM实例来管理磁盘组。
安装ASMlib:
首先到官网下载ASMlib所需软件
http://www.oracle.com/technetwork/server-storage/linux/downloads/rhel5-084877.html
支持和库文件可以直接下载,内核文件,可以uname-a然后下载
lrpm-Uvhoracleasm-support-2.1.8-1.el5.i386.rpm
rpm-Uvhoracleasm-2.6.18-164.el5xen-2.0.5-1.el5.i686.rpm
Rpm-Uvhoracleasmlib-2.0.4-1.el5.i386.rpm
配置asm服务
安装完毕开始配置asm服务,这里先创建好所需用户oracle和组dba。
[root@localhost~]#/etc/init.d/oracleasmconfigure
ConfiguringtheOracleASMlibrarydriver.
Thiswillconfiguretheon-bootpropertiesoftheOracleASMlibrary
driver.Thefollowingquestionswilldeterminewhetherthedriveris
loadedonbootandwhatpermissionsitwillhave.Thecurrentvalues
willbeshowninbrackets('[]').Hitting<ENTER>withouttypingan
answerwillkeepthatcurrentvalue.Ctrl-Cwillabort.
Defaultusertoownthedriverinterface[]:oracle
Defaultgrouptoownthedriverinterface[]:dba
StartOracleASMlibrarydriveronboot(y/n)[n]:y
ScanforOracleASMdisksonboot(y/n)[y]:y
WritingOracleASMlibrarydriverconfiguration:done
InitializingtheOracleASMLibdriver:[OK]
[root@localhost~]#/etc/init.d/oracleasmdisable卸载
[root@localhost~]#/etc/init.d/oracleasmenable加载
配置ASM磁盘
先分别创建新分区,然后创建asm磁盘磁盘名称大写
Fdisk/dev/sdb
/etc/init.d/oracleasmcreatediskVOL1/dev/sdb1
/etc/init.d/oracleasmcreatediskVOL2/dev/sdc1
/etc/init.d/oracleasmcreatediskVOL3/dev/sdd1
/etc/init.d/oracleasmcreatediskVOL3/dev/sde1
/etc/init.d/oracleasmlistdisk列出磁盘
创建asm实例
ASM实例创建步骤:
1、创建初始化文件
#vi$ORACLE_HOME/dbs/init+ASM.ora参数文件添加7行语句
2、创建密码文件
$orapwdfile=orapwd+ASMpassword=dba
3、创建目录结构
$mkdir-p$ORACLE_HOME/+ASM/udump
$mkdir-p$ORACLE_HOME/+ASM/bdump
$mkdir-p$ORACLE_HOME/+ASM/cdump
4、启动实例
$exportORACLE_SID=+ASM启动实例
5、创建spfile文件,重新启动
$sqlplus/assysdba
Sql>startup
Ora-15110:Nodiskgroupmounted.
Sql>createspfilefrompfile;
Sql>shutdownimmediate;
Sql>startup;
6.创建磁盘组
Sql>creatediskgroupdgroup1normalredundancy
failgroupfgroup1disk‘ORCL:VOL1’,’ORCL:VOL2’
failgroupfgroup2disk‘ORCL:VOL3’,’ORCL:VOL4’;
Diskgroupcreated.
Sql>selectname,statefromv$asm_diskgroup;
Namestate
------------------------------------------
DGROUP1MOUNTED
SQL>alterdiskgroupdgroup1mount;也可以手工挂载
数据库使用磁盘组
按照正常步骤完成oracle数据的创建,然后通过dbca启动创建数据库实例,在存储一项中选择asm,然后选择我们建立的磁盘组完成安装完成即可。
启动asm数据库
启动asm数据库,必须先启动asm实例,然后启动数据库实例
首先启动ASM实例
exportORACLE_SID=+ASM
$sqlplus/assysdba
SQL>startup
ASMdiskgroupmounted;
Sql>exit
然后启动数据
exportORACLE_SID=ipap
$sqlplus/assysdba
SQL>startup
Databasemounted;
Databaseopen;
ASM环境添加磁盘
Fdisk/dev/sdf创建新分区
/etc/init.d/oracleasmcreatediskVOL5/dev/sdf1
/etc/init.d/oracleasmcreatediskVOL6/dev/sdg1
exportORACLE_SID=+ASM
$sqlplus/assysdba
Sql>select*fromv$asm_disk;
6rowselected.
Sql>alterdiskgroupdgroup1add
failgroupfgroup1disk‘ORCL:VOL5’
failgroupfgroup2disk’ORCL:VOL6’;
Diskgroupaltered.
sql>descv$asm_operation;
Sql>selectgroup_number,opera,stat,est_work,sofar,est_rate,est_minutesfromv$asm_operation;
刷新数据就不断变化,最后发现没有行被选择,说明磁盘被分配完毕
查看磁盘大小,看到空间增大
进行ASM环境的验证
exportORACLE_SID=ipap
$sqlplus/assysdba
SQL>startup
Sql>createtablespacetestdatafile‘+DGROUP1’size200M;
Sql>createuserasmuseridentifiedbypassworddefaulttablespacetest;
Sql>grantconnect,resourcetoasmuser;
Sql>connasmuser/password
Sql>createtablet(idint,namevachar2(23));
Tablecreated。
ASM删除磁盘
exportORACLE_SID=+ASM
$sqlplus/assysdba
Sql>alterdiskgroupdgroup1dropdiskVOL4;
Diskgroupaltered.
Sql>selectgroup_number,opera,stat,est_work,sofar,est_rate,est_minutesfromv$asm_operation;
Sql>alterdiskgroupdgroup1rebalance;
当norowselected时,完成磁盘分配工作,也可以进行平衡。