分类: Oracle
2008-03-11 12:29:50
• Automatic Storage Management
• Oracle10g New Feature
• 每个机器上允许一个ASM实例
• 不支持的文件类型
– 操作系统文件(非数据库相关)
– Oracle Binaries, trace files
– Voting Disk
– OCR
ASM支持单实例数据库
写入无序,读取有序
ASM提供了3种冗余方法。
external redundancy表示Oracle不帮你管理镜像,功能由外部存储系统实现,比如通过RAID技术。
normal redundancy(默认方式)表示Oracle提供2路镜像来保护数据。
high redundancy表示Oracle提供3路镜像来保护数据。
什么是 ASM failure group?
Oracle通过failure group来提供数据的高可用性。ASM使用的镜像算法并不是镜像整个disk,而是作extent级的镜像。所以很明显如果为各个failure group使用不同容量的disk是不明智的,因为这样在Oracle分配下一个extent的时候可能就会出现问题。在normal redundancy模式下,ASM环境中每分配一个extent都会有一个primary copy和一个second copy,ASM的算法保证了second copy和primary copy一定是在不同的failure group中,这就是failure group的意义。通过这个算法,ASM保证了即使一个failure group中的所有disk都损坏了,数据也是毫发无伤的。
Oracle在分配extent的时候,所有failure group中的这个将拥有相同数据的extent称为一个extent set,当Oracle将数据写入文件的时候,primary copy可能在任何一个failure group中,而second copy则在另外的failure group中,当Oracle读取数据的时候,除非是primary copy不可用,否则将优先从primary copy中读取数据,通过这种写入无序,读取有序的算法,Oracle保证了数据读取尽量分布在多个disk中。
因为公用一个硬件模块的磁盘很可能会同时损坏或者失效,所以通常我们在设计failure group时,应该把一个大的盘阵中在一个tray中的磁盘放在一个failure group中,这样我们就可以拿走一个tray,失效这个failure group,然后换上新的tray和磁盘,这跟RAID的思想是一样的。
ASM的冗余方式一经设定就无法更改,如果我们想把normal redundancy改为high redundancy就只能是创建一个新的failure group,然后把旧failure group中的文件通过RMAN或者DBMS_FILE_TRANSFER的方法移动到新failure group中去。
如果在ASM环境中没有创建failure groups情况会怎样?
即使没有显式指定,failure groups也是始终会创建的。在这种情况下,每个disk都属于一个failure group,在创建磁盘组的时候,failure group也会默认创建,名称就是disk的名字。
如果failure group出现故障怎样恢复?
- 如何使用kfed实用程序来查看ASM Disk header
我们测试的数据库是Oracle
cd $ORACLE_HOME/rdbms/lib
make -f ins_rdbms.mk ikfed
此时$ORACLE_HOME/bin目录中将会产生kfed程序。
使用kfed的语法是:kfed read *devicename* text=*filename*
假设我们要读取/dev/raw/raw1的文件头,那么使用下面的语句
kfed read /dev/raw/raw1 text=raw1.out
这样raw1的文件头信息将会被dump到raw1.out文件中,大家有兴趣可以去看一下文件内容,基本上通过名字和值还是能猜测出都是些什么内容的, 包括了这个ASM Disk创建时间是什么,每个block多大,Disk名字是什么,属于哪个Disk Group,Header Status是怎么样的。虽然大部分内容都可以从ASM实例的数据字典中获得,但是在我们碰到ASM磁盘故障的时候,kfed提供的信息往往更容易让我们 判断问题点。
kfed read /ocfs02/asm/data02 > fix.txt
kfed merge /ocfs02/asm/data03 text=fix.txt
- 如何清理ASM Disk
有时候一个ASM Disk由于故障,导致我们删也删不掉,加也加不进去,通常现象是磁盘的header status状态不正确但是disk header中仍然保留了部分磁盘组的信息。此时我们就需要clear这个磁盘,然后再将它重新加入磁盘组中。
dd if=
dd if=/dev/zero of=
注意:上述语句请谨慎操作,可能会出现问题。
Using kfed:
Reading a file:
kfed read
example:
% kfed read /dev/raw/raw1
kfbh.endian: 1 ; 0x000: 0x01
kfbh.hard: 130 ; 0x001: 0x82
kfbh.type: 1 ; 0x002: KFBTYP_DISKHEAD
kfbh.datfmt: 1 ; 0x003: 0x01
kfbh.block.blk: 0 ; 0x004: T=0 NUMB=0x0
kfbh.block.obj: 2147483648 ; 0x008: TYPE=0x8 NUMB=0x0
kfbh.check: 2932902794 ; 0x00c: 0xaed08b8a
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000
kfdhdb.driver.provstr: ORCLDISK ; 0x000: length=8
kfdhdb.driver.reserved[0]: 0 ; 0x008: 0x00000000
kfdhdb.driver.reserved[1]: 0 ; 0x00c: 0x00000000
kfdhdb.driver.reserved[2]: 0 ; 0x010: 0x00000000
kfdhdb.driver.reserved[3]: 0 ; 0x014: 0x00000000
kfdhdb.driver.reserved[4]: 0 ; 0x018: 0x00000000
kfdhdb.driver.reserved[5]: 0 ; 0x01c: 0x00000000
kfdhdb.compat: 168820736 ; 0x020: 0x0a100000
kfdhdb.dsknum: 0 ; 0x024: 0x0000
kfdhdb.grptyp: 1 ; 0x026: KFDGTP_EXTERNAL
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: ASM01_0000 ; 0x028: length=10
kfdhdb.grpname: ASM01 ; 0x048: length=5
kfdhdb.fgname: ASM01_0000 ; 0x068: length=10
kfdhdb.capname: ; 0x088: length=0
kfdhdb.crestmp.hi: 32837774 ; 0x0a8: HOUR=0xe DAYS=0x4 MNTH=0x4 YEAR=0x7d4
kfdhdb.crestmp.lo: 1555722240 ; 0x0ac: USEC=0x0 MSEC=0x29c SECS=0xb MINS=0x17
kfdhdb.mntstmp.hi: 32837774 ; 0x0b0: HOUR=0xe DAYS=0x4 MNTH=0x4 YEAR=0x7d4
kfdhdb.mntstmp.lo: 1563864064 ; 0x0b4: USEC=0x0 MSEC=0x1ab SECS=0x13 MINS=0x17
kfdhdb.secsize: 512 ; 0x0b8: 0x0200
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000
kfdhdb.mfact: 113792 ; 0x0c0: 0x0001bc80
kfdhdb.dsksize: 9075 ; 0x0c4: 0x00002373
kfdhdb.pmcnt: 2 ; 0x0c8: 0x00000002
kfdhdb.fstlocn: 1 ; 0x0cc: 0x00000001
kfdhdb.altlocn: 2 ; 0x0d0: 0x00000002
kfdhdb.f1b1locn: 2 ; 0x0d4: 0x00000002
kfdhdb.redomirrors[0]: 0 ; 0x0d8: 0x0000
kfdhdb.redomirrors[1]: 0 ; 0x0da: 0x0000
kfdhdb.redomirrors[2]: 0 ; 0x0dc: 0x0000
kfdhdb.redomirrors[3]: 0 ; 0x0de: 0x0000
kfdhdb.ub4spare[0]: 0 ; 0x0e0: 0x00000000
...
kfdhdb.ub4spare[60]: 0 ; 0x1d0: 0x00000000
kfdhdb.acdb.aba.seq: 0 ; 0x1d4: 0x00000000
kfdhdb.acdb.aba.blk: 0 ; 0x1d8: 0x00000000
kfdhdb.acdb.ents: 0 ; 0x1dc: 0x0000
kfdhdb.acdb.ub2spare: 0 ; 0x1de: 0x0000
Breakdown:
kfbh.endian
kf3.h /* endianness of writer */
Little endian = 1
Big endian = 0
kfbh.hard
kf3.h /* H.A.R.D. magic # and block size */
kfbh.type
kf3.h /* metadata block type */
kfbh.datfmt
kf3.h /* metadata block data format */
kfbh.block
kf3.h /* block location of this block */
blk -- Disk header should have T=0 and NUMB=0x0
obj -- Disk header should have TYPE=0x8 NUMB=
blk and obj values are derived from a series of macros in kf3.h. See
"KFBL Macros" in kf3.h for more information.
kfbh.check
kf3.h /* check value to verify consistency */
kfbh.fcn
kf3.h /* change number of last change */
kfdhdb.driver
kf3.h /* OSMLIB driver reserved block */
If no driver is defined "ORCLDISK" is used.
kfdhdb.compat
kf3.h /* Comaptible software version */
example: 0x0a100000
You get:
a=10 1=1 so
kfdhdb.dsknum
kf3.h /* OSM disk number *
This is the disk number. The first disk being "0". There can be up to
ub2 disks in a diskgroup. This allows for 65336 disks 0 through 65335.
kfdhdb.grptyp
kf3.h /* Disk group type */
kfdhdb.hdrsts
kf3.h /* Disk header status */
This is what is used to determine if a disk is available or not to
the diskgroup. 0x03 is the correct value for a valid status.
kfdhdb.dskname /* OSM disk name */
kfdhdb.grpname /* OSM disk group name */
kfdhdb.fgname /* Failure group name */
kfdhdb.capname /* Capacity grp, unused*/
kf3.h
kfdhdb.crestmp /* Creation timestamp */
kfdhdb.mntstmp /*
kf3.h To derive the hi and low time`from an unformated dump use the
"KFTS Macros" in kf3.h.
kfdhdb.secsize
kf3.h /* Disk sector size (bytes) */
This is the physical sector size of the disk in bytes. All I/O's to the
disk are described in physical sectors. This must be a power of 2. An
ideal value would be 4096, but most disks are formatted with 512 byte
sectors. (from asmlib.h)
kfdhdb.blksize
kf3.h /* Metadata block (bytes) */
kfdhdb.ausize
kf3.h /* Allocation Unit (bytes) */
kfdhdb.mfact
kf3.h /* Stride between phys addr AUs */
kfdhdb.dsksize
kf3.h /* Disk size in AUs */
Mulitply by AUs to get actual size of disk when added.
kfdhdb.pmcnt
kf3.h /* Permanent phys addressed AUs */
Number of physically addressed allocation units.
kfdhdb.fstlocn
kf3.h /* First FreeSpace table blk num */
Used to find freespace.
kfdhdb.altlocn
kf3.h /* First Alocation table blk num */
Used to find alocated space.
kfdhdb.f1b1locn
kf3.h /* File Directory blk 1 AU num */
Beginging for file directory.
• 使用文件模拟ASM
– Metalink : Note:266028.1
• 迁移一个数据库到ASM
– Metalink : Note:252219.1