最近学习了ASM 的一些知识, 总结一下,
关于ASM 的简单介绍:ASM全称为Automated Storage Management,即自动存储
管理,它是自Oracle10g这个版本
oracle推出的新功能。这是Oracle提供的一个卷管理器,用于替代操作系统所提供的LVM,它不仅支持单实例配置,也支持
RAC这样的多实例配置。将给Oracle数据库管理员带来极大的方便,ASM可以自动管理磁盘组,并提供数据冗余和优化。特别是对于
企业级的大型
DB管理员来说,可以使管理员可以从管理成百上千个数据文件这些琐碎的日常事务中解脱开来,以便处理其它更为重要的事务上去。
冗余级别 说明 高 如果至少可为该磁盘组分配三个故障组,则选择此级别。
正常 如果至少可为该磁盘组分配两个故障组,则选择此级别。
外部 如果只能为该磁盘组分配一个故障组,则选择此级别。如果选择此冗余级别,Oracle 假定您将使用外部应用程序或硬件组件为数据库文件提供镜像功能
一【如何在window环境下创建ASM实例】
第一步
使用asmtool 创建 asm
Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk1 500
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk2 500
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk3 500
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk4 500
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk5 200
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk6 100
C:\Documents and Settings\Administrator>asmtool -create d:\asm\asmdisk7 100
。
。
。
后面做迁移的时候,又添加了几个!
第二步 创建asm实例的参数文件:
ASM的实例名一定要以+开头,如+ASM,否则后面通过dbca配置ASM实例或创建数据库的时候,DBCA无法识别到之前的asm实例。
orcl.__large_pool_size=12288
*.compatible= '11.1.0.0.0'
*.db_unique_name='+ASM'
*.diagnostic_dest= F:\ORACL\ASM\‘
*.memory_target=857735168
*.open_cursors=300
*.processes=150
*._asm_allow_only_raw_disks=FALSE
*.asm_diskstring= F:\ORACL\ASM\*'
*.instance_type='ASM'
*.asm_power_limit=1
*.remote_login_passwordfile='SHARED'
第三步:创建ASM实例
C:\Documents and Settings\Administrator>oradim -new -asmsid +asm -startmode manual
第四步 配置CSS(Cluster Synchronization Services)
CSS主要用来同步ASM instance和它的client,也即database instance。可以由Oracle自带的localconfig命令来完成。
C:\Documents and Settings\Administrator>localconfig ---相关语法
usage: crssetup <config | add | del | deconfig | ldel | lres
| ladd | shutdown | upgrade | help>
config - configure and startup the cluster on nodes
add - add specified nodes to the cluster
del - delete the specified nodes from the cluster
deconfig - wipe out all cluster configuration information
ldel - local css delete from oracle home
lres - local css home reset to new oracle home
ladd - local css add to oracle home
shutdown - shutdown the selected nodes
upgrade - upgrade the specified nodes
help - print out this information
C:\Documents and Settings\Administrator>localconfig add
Step 1: creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'zhangrp', privgrp ''..
Operation successful.
Step 2: creating new CSS service
successfully created local CSS service
successfully added CSS to home --- 成功建立
第五步:启动ASM实例
C:\Documents and Settings\Administrator>set oracle_sid=+ASM
C:\Documents and Settings\Administrator>sqlplus "/ as sysdba"
SQL> startup
ASM 实例已启动
Total System Global Area 535662592 bytes
Fixed Size 1334380 bytes
Variable Size 509162388 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups mounted ---第一次打开ASM实例 ,磁盘还没有加载!
SQL> col host_name for a15
SQL> col instance_name for a15
SQL> col version for a15
SQL> select host_name,instance_name,version,status from v$instance;
HOST_NAME INSTANCE_NAME VERSION STATUS
--------------- --------------- --------------- ------------------------
YQL +asm 11.1.0.6.0 STARTED
SQL> col path for a30
SQL> select path ,mount_status from v$asm_disk order by disk_number;
PATH MOUNT_STATUS
------------------------------ --------------
F:\ORACL\ASM\ASMDISK1 CLOSED
F:\ORACL\ASM\ASMDISK10 CLOSED
F:\ORACL\ASM\ASMDISK2 CLOSED
F:\ORACL\ASM\ASMDISK3 CLOSED
F:\ORACL\ASM\ASMDISK4 CLOSED
F:\ORACL\ASM\ASMDISK5 CLOSED
F:\ORACL\ASM\ASMDISK6 CLOSED
F:\ORACL\ASM\ASMDISK7 CLOSED
F:\ORACL\ASM\ASMDISK8 CLOSED
F:\ORACL\ASM\ASMDISK9 CLOSED
10 rows selected.
SQL> select group_number,name, state,total_mb,free_mb fromv$asm_diskgroup;--检查磁盘组,当然还未创建呢!
no rows selected
第六步,创建磁盘组..
SQL> create diskgroup sys_data --外部冗余
2 External Redundancy
3 disk 'f:\oracl\asm\asmdisk1',
4 'f:\oracl\asm\asmdisk2',
5 'f:\oracl\asm\asmdisk3';
Diskgroup created.
SQL> create diskgroup flash_data --常规冗余,必须至少两个磁盘
2 External Redundancy
3 disk 'f:\oracl\asm\asmdisk4',
4 'f:\oracl\asm\asmdisk5';
Diskgroup created.
SQL> create diskgroup user_data
2 Normal Redundancy
3 failgroup user_fg_01 disk 'f:\oracl\asm\asmdisk6'
4 failgroup user_fg_02 disk 'f:\oracl\asm\asmdisk7';
Diskgroup created.
SQL> create diskgroup test_data ---高度冗余,至少三个磁盘
2 High Redundancy
3 failgroup test_fg_01 disk 'f:\oracl\asm\asmdisk8'
4 failgroup test_fg_02 disk 'f:\oracl\asm\asmdisk9'
5 failgroup test_fg_03 disk 'f:\oracl\asm\asmdisk10';
Diskgroup created.
----------查看----------
SQL> col path for a30
SQL> select path ,mount_status from v$asm_disk order by disk_number;
PATH MOUNT_STATUS
------------------------------ --------------
F:\ORACL\ASM\ASMDISK1 CACHED
F:\ORACL\ASM\ASMDISK4 CACHED
F:\ORACL\ASM\ASMDISK8 CACHED
F:\ORACL\ASM\ASMDISK6 CACHED
F:\ORACL\ASM\ASMDISK9 CACHED
F:\ORACL\ASM\ASMDISK5 CACHED
F:\ORACL\ASM\ASMDISK7 CACHED
F:\ORACL\ASM\ASMDISK2 CACHED
F:\ORACL\ASM\ASMDISK3 CACHED
F:\ORACL\ASM\ASMDISK10 CACHED
10 rows selected.
SQL> col name for a12
SQL> col allocation_unit_size for a6
SQL> select group_number,name,sector_size,block_size,
2 state,type,total_mb,free_mb
3 from v$asm_diskgroup;
GROUP_NUMBER NAME SECTOR_SIZE BLOCK_SIZE STATE
------------ ------------ ----------- ---------- ----------------------
TYPE TOTAL_MB FREE_MB
------------ ---------- ----------
1 SYS_DATA 512 4096 MOUNTED
EXTERN 1500 1446
2 FLASH_DATA 512 4096 MOUNTED
EXTERN 400 348
3 USER_DATA 512 4096 MOUNTED
NORMAL 200 98
4 TEST_DATA 512 4096 MOUNTED
HIGH 300 147
SQL> select group_number,name,
2 state,type,total_mb,free_mb
3 from v$asm_diskgroup;
GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB
------------ ------------ ---------------------- ------------ ---------- ----------
1 SYS_DATA MOUNTED EXTERN 1500 1446
2 FLASH_DATA MOUNTED EXTERN 400 348
3 USER_DATA MOUNTED NORMAL 200 98
4 TEST_DATA MOUNTED HIGH 300 147
SQL> show parameter asm_disk
NAME TYPE VALUE
-------- ---------------- ------------------------------
asm_diskgroups string SYS_DATA, FLASH_DATA, USER_DATA, TEST_DATA
asm_diskstring string F:\ORACL\ASM\*
SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown
第七步 创建ASM实例的密码文件
SQL> host orapwd file=F:\ORACL\product\11.1.0\db_1\database\PWDasm.orapassword=yang entries=10
第八步:修改pfile并转为spfile,创建密码文件
在参数文件里加入 asm_diskgroups='SYS_DATA', 'FLASH_DATA', 'USER_DATA', 'TEST_DATA'--根据实际情况作出修改!
SQL> create spfile from pfile;
File created.