ASM命令

asm使用的镜像算法:asm并不镜像disks,它镜象extents. 当asm分配一个primary extent of a file to one disk in a failure group.它会在另一个failure group中分配一个mirror copy of that extent to another disk in another failure group. asm可以确保mirror copy不会在同一个failure group.

redundancy(冗余):normal---two-way mirrored(两个failure group)

root@danaly ~]# su - oracle
[oracle@danaly ~]$ cd $ORACLE_HOME/rdbms/lib
[oracle@danaly lib]$ make -f ins_rdbms.mk ikfed

我们简单看一下便以过程:

[root@danaly ~]# su - oracle
[oracle@danaly ~]$ cd $ORACLE_HOME/rdbms/lib

[oracle@danaly lib]$make -f ins_rdbms.mk ikfed Linking KFED utility (kfed)
rm -f /opt/oracle/product/10.2.0/rdbms/lib/kfed
gcc -o /opt/oracle/product/10.2.0/rdbms/lib/kfed ...
mv -f /opt/oracle/product/10.2.0/bin/kfed /opt/oracle/product/10.2.0/bin/kfedO
mv: cannot stat `/opt/oracle/product/10.2.0/bin/kfed': No such file or directory
make: [ikfed] Error 1 (ignored)
mv /opt/oracle/product/10.2.0/rdbms/lib/kfed /opt/oracle/product/10.2.0/bin/kfed
chmod 751 /opt/oracle/product/10.2.0/bin/kfed
[oracle@danaly lib]$ which kfed~/product/10.2.0/bin/kfed

 

kfed有很多用途,我们可以用-h参数看一下相关帮助:
[oracle@danaly lib]$ kfed -h
as/mlib ASM Library [asmlib='lib']
aun/um AU number to examine or update [AUNUM=number]
aus/z Allocation Unit size in bytes [AUSZ=number]
blkn/um Block number to examine or update [BLKNUM=number]
blks/z Metadata block size in bytes [BLKSZ=number]
ch/ksum Update checksum before each write [CHKSUM=YES/NO]
cn/t Count of AUs to process [CNT=number]
d/ev ASM device to examine or update [DEV=string]
o/p KFED operation type [OP=READ/WRITE/MERGE/NEW/FORM/FIND/STRUCT]
p/rovnm Name for provisioning purposes [PROVNM=string]
te/xt File name for translated block text [TEXT=string]
ty/pe ASM metadata block type number [TYPE=number]

我们来读取一下ASM磁盘头看一下ASM磁盘的相关信息:
[oracle@danaly /]$ kfed read /dev/oracleasm/disks/VOL1
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: 851041336 ; 0x00c: 0x32b9dc38
kfbh.fcn.base: 0 ; 0x010: 0x00000000
kfbh.fcn.wrap: 0 ; 0x014: 0x00000000
kfbh.spare1: 0 ; 0x018: 0x00000000
kfbh.spare2: 0 ; 0x01c: 0x00000000kfdhdb.driver.provstr: ORCLDISKVOL1 ; 0x000: length=12 ---磁盘卷名
kfdhdb.driver.reserved[0]: 827084630 ; 0x008: 0x314c4f56
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: 0x0000kfdhdb.grptyp: 1 ; 0x026: KFDGTP_EXTERNAL --冗余方式
kfdhdb.hdrsts: 3 ; 0x027: KFDHDR_MEMBER
kfdhdb.dskname: VOL1 ; 0x028: length=4kfdhdb.grpname: ORADG ; 0x048: length=5 --磁盘组名称
kfdhdb.fgname: VOL1 ; 0x068: length=4
kfdhdb.capname: ; 0x088: length=0
kfdhdb.crestmp.hi: 32875626 ; 0x0a8: HOUR=0xa DAYS=0x3 MNTH=0x9 YEAR=0x7d6
kfdhdb.crestmp.lo: 3478022144 ; 0x0ac: USEC=0x0 MSEC=0x39a SECS=0x34 MINS=0x33
kfdhdb.mntstmp.hi: 32875626 ; 0x0b0: HOUR=0xa DAYS=0x3 MNTH=0x9 YEAR=0x7d6
kfdhdb.mntstmp.lo: 3544465408 ; 0x0b4: USEC=0x0 MSEC=0x110 SECS=0x34 MINS=0x34
kfdhdb.secsize: 512 ; 0x0b8: 0x0200
kfdhdb.blksize: 4096 ; 0x0ba: 0x1000
kfdhdb.ausize: 1048576 ; 0x0bc: 0x00100000
kfdhdb.mfact: 113792 ; 0x0c0: 0x0001bc80
kfdhdb.dsksize: 19077 ; 0x0c4: 0x00004a85
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.dbcompat: 168820736 ; 0x0e0: 0x0a100000
kfdhdb.grpstmp.hi: 32875626 ; 0x0e4: HOUR=0xa DAYS=0x3 MNTH=0x9 YEAR=0x7d6
kfdhdb.grpstmp.lo: 3477741568 ; 0x0e8: USEC=0x0 MSEC=0x288 SECS=0x34 MINS=0x33
kfdhdb.ub4spare[0]: 0 ; 0x0ec: 0x00000000
kfdhdb.ub4spare[1]: 0 ; 0x0f0: 0x00000000
kfdhdb.ub4spare[2]: 0 ; 0x0f4: 0x00000000
kfdhdb.ub4spare[3]: 0 ; 0x0f8: 0x00000000
kfdhdb.ub4spare[4]: 0 ; 0x0fc: 0x00000000
kfdhdb.ub4spare[5]: 0 ; 0x100: 0x00000000
kfdhdb.ub4spare[6]: 0 ; 0x104: 0x00000000
kfdhdb.ub4spare[7]: 0 ; 0x108: 0x00000000
kfdhdb.ub4spare[8]: 0 ; 0x10c: 0x00000000
kfdhdb.ub4spare[9]: 0 ; 0x110: 0x00000000
kfdhdb.ub4spare[10]: 0 ; 0x114: 0x00000000
kfdhdb.ub4spare[11]: 0 ; 0x118: 0x00000000
kfdhdb.ub4spare[12]: 0 ; 0x11c: 0x00000000
kfdhdb.ub4spare[13]: 0 ; 0x120: 0x00000000
kfdhdb.ub4spare[14]: 0 ; 0x124: 0x00000000
kfdhdb.ub4spare[15]: 0 ; 0x128: 0x00000000
kfdhdb.ub4spare[16]: 0 ; 0x12c: 0x00000000
kfdhdb.ub4spare[17]: 0 ; 0x130: 0x00000000
kfdhdb.ub4spare[18]: 0 ; 0x134: 0x00000000
kfdhdb.ub4spare[19]: 0 ; 0x138: 0x00000000
kfdhdb.ub4spare[20]: 0 ; 0x13c: 0x00000000
kfdhdb.ub4spare[21]: 0 ; 0x140: 0x00000000
kfdhdb.ub4spare[22]: 0 ; 0x144: 0x00000000
kfdhdb.ub4spare[23]: 0 ; 0x148: 0x00000000
kfdhdb.ub4spare[24]: 0 ; 0x14c: 0x00000000
kfdhdb.ub4spare[25]: 0 ; 0x150: 0x00000000
kfdhdb.ub4spare[26]: 0 ; 0x154: 0x00000000
kfdhdb.ub4spare[27]: 0 ; 0x158: 0x00000000
kfdhdb.ub4spare[28]: 0 ; 0x15c: 0x00000000
kfdhdb.ub4spare[29]: 0 ; 0x160: 0x00000000
kfdhdb.ub4spare[30]: 0 ; 0x164: 0x00000000
kfdhdb.ub4spare[31]: 0 ; 0x168: 0x00000000
kfdhdb.ub4spare[32]: 0 ; 0x16c: 0x00000000
kfdhdb.ub4spare[33]: 0 ; 0x170: 0x00000000
kfdhdb.ub4spare[34]: 0 ; 0x174: 0x00000000
kfdhdb.ub4spare[35]: 0 ; 0x178: 0x00000000
kfdhdb.ub4spare[36]: 0 ; 0x17c: 0x00000000
kfdhdb.ub4spare[37]: 0 ; 0x180: 0x00000000
kfdhdb.ub4spare[38]: 0 ; 0x184: 0x00000000
kfdhdb.ub4spare[39]: 0 ; 0x188: 0x00000000
kfdhdb.ub4spare[40]: 0 ; 0x18c: 0x00000000
kfdhdb.ub4spare[41]: 0 ; 0x190: 0x00000000
kfdhdb.ub4spare[42]: 0 ; 0x194: 0x00000000
kfdhdb.ub4spare[43]: 0 ; 0x198: 0x00000000
kfdhdb.ub4spare[44]: 0 ; 0x19c: 0x00000000
kfdhdb.ub4spare[45]: 0 ; 0x1a0: 0x00000000
kfdhdb.ub4spare[46]: 0 ; 0x1a4: 0x00000000
kfdhdb.ub4spare[47]: 0 ; 0x1a8: 0x00000000
kfdhdb.ub4spare[48]: 0 ; 0x1ac: 0x00000000
kfdhdb.ub4spare[49]: 0 ; 0x1b0: 0x00000000
kfdhdb.ub4spare[50]: 0 ; 0x1b4: 0x00000000
kfdhdb.ub4spare[51]: 0 ; 0x1b8: 0x00000000
kfdhdb.ub4spare[52]: 0 ; 0x1bc: 0x00000000
kfdhdb.ub4spare[53]: 0 ; 0x1c0: 0x00000000
kfdhdb.ub4spare[54]: 0 ; 0x1c4: 0x00000000
kfdhdb.ub4spare[55]: 0 ; 0x1c8: 0x00000000
kfdhdb.ub4spare[56]: 0 ; 0x1cc: 0x00000000
kfdhdb.ub4spare[57]: 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

ASM的功能越来越强大和完善了。

kfod查看oracle asm磁盘信息
[oracle@linren ~]$ kfod disk=all;
--------------------------------------------------------------------------------
 Disk          Size Path
================================================================================
   1:       1019 Mb ORCL:VOL1
   2:       1019 Mb ORCL:VOL2
   3:       1024 Mb ORCL:VOL3
--------------------------------------------------------------------------------
ORACLE_SID ORACLE_HOME
================================================================================
      +ASM /home/oracle/oracle/product/10.2.0/db_1
[oracle@linren ~]$

http://www.oracle-base.com/articles/10g/AutomaticStorageManagement10g.php

SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      ASM1, ASM2
asm_diskstring                       string      ORCL:VOL*
asm_power_limit                      integer     1
SQL> alter diskgroup asm2 dismount;

Diskgroup altered.

SQL> show parameter asm

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      ASM1
asm_diskstring                       string      ORCL:VOL*
asm_power_limit                      integer     1

SQL> alter diskgroup asm2 mount;

Diskgroup altered.

SQL> drop diskgroup asm2 including contents;

Diskgroup dropped.

SQL> CREATE DISKGROUP ASM2 EXTERNAL REDUNDANCY DISK 'ORCL:VOL3';

Diskgroup created.

增加磁盘

alter diskgroup asm1 add disk 'ORCL:VOL3';

 

SQL>  select * from v$asm_operation;

GROUP_NUMBER OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK   EST_RATE
------------ ----- ---- ---------- ---------- ---------- ---------- ----------
EST_MINUTES
-----------
           1 REBAL RUN           1          1        652        659        378
          0

SQL>  ALTER DISKGROUP asm1 REBALANCE POWER 5;

Diskgroup altered.

SQL>  select * from v$asm_operation;

GROUP_NUMBER OPERA STAT      POWER     ACTUAL      SOFAR   EST_WORK   EST_RATE
------------ ----- ---- ---------- ---------- ---------- ---------- ----------
EST_MINUTES
-----------
           1 REBAL REAP          5          0          6         24          0
          0
如何使用Oracle10gR2,一点测试 :
1.硬盘分区
示例,划分三个硬盘分区:

[root@danaly etc]# fdisk /dev/cciss/c0d0

The number of cylinders for this disk is set to 8854.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/cciss/c0d0: 72.8 GB, 72833679360 bytes
255 heads, 63 sectors/track, 8854 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/cciss/c0d0p1 * 1 33 265041 83 Linux
/dev/cciss/c0d0p2 34 555 4192965 82 Linux swap
/dev/cciss/c0d0p3 556 686 1052257+ 83 Linux
/dev/cciss/c0d0p4 687 8854 65609460 5 Extended
/dev/cciss/c0d0p5 687 1730 8385898+ 83 Linux
/dev/cciss/c0d0p6 1731 2774 8385898+ 83 Linux
/dev/cciss/c0d0p7 2775 3818 8385898+ 83 Linux
/dev/cciss/c0d0p8 3819 4601 6289416 83 Linux

Command (m for help): n
First cylinder (4602-8854, default 4602):
Using default value 4602
Last cylinder or +size or +sizeM or +sizeK (4602-8854, default 8854): +20000M

Command (m for help): n
First cylinder (7035-8854, default 7035):
Using default value 7035
Last cylinder or +size or +sizeM or +sizeK (7035-8854, default 8854): +3000M

Command (m for help): n
First cylinder (7401-8854, default 7401):
Using default value 7401
Last cylinder or +size or +sizeM or +sizeK (7401-8854, default 8854): +3000M

Command (m for help): p

Disk /dev/cciss/c0d0: 72.8 GB, 72833679360 bytes
255 heads, 63 sectors/track, 8854 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/cciss/c0d0p1 * 1 33 265041 83 Linux
/dev/cciss/c0d0p2 34 555 4192965 82 Linux swap
/dev/cciss/c0d0p3 556 686 1052257+ 83 Linux
/dev/cciss/c0d0p4 687 8854 65609460 5 Extended
/dev/cciss/c0d0p5 687 1730 8385898+ 83 Linux
/dev/cciss/c0d0p6 1731 2774 8385898+ 83 Linux
/dev/cciss/c0d0p7 2775 3818 8385898+ 83 Linux
/dev/cciss/c0d0p8 3819 4601 6289416 83 Linux
/dev/cciss/c0d0p9 4602 7034 19543041 83 Linux
/dev/cciss/c0d0p10 7035 7400 2939863+ 83 Linux
/dev/cciss/c0d0p11 7401 7766 2939863+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.


2.绑定ASM磁盘

[root@danaly data1]# /etc/init.d/oracleasm createdisk VOL5 /dev/cciss/c0d0p10
Marking disk "/dev/cciss/c0d0p10" as an ASM disk: [ OK ]
[root@danaly data1]# /etc/init.d/oracleasm createdisk VOL6 /dev/cciss/c0d0p11
Marking disk "/dev/cciss/c0d0p11" as an ASM disk: [ OK ]
[root@danaly data1]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5
VOL6


3.启动ASM实例,创建磁盘组

[oracle@danaly ~]$ export ORACLE_SID=+ASM
[oracle@danaly ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Sep 3 00:28:09 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted

SQL> select group_number,disk_number,mode_status from v$asm_disk;

GROUP_NUMBER DISK_NUMBER MODE_STATUS
------------ ----------- --------------
0 4 ONLINE
0 5 ONLINE
1 0 ONLINE
1 1 ONLINE
1 2 ONLINE
1 3 ONLINE

6 rows selected.



SQL> select group_number,disk_number,mode_status,name from v$asm_disk;

GROUP_NUMBER DISK_NUMBER MODE_STATUS NAME
------------ ----------- -------------- ---------------------------------
0 4 ONLINE
0 5 ONLINE
1 0 ONLINE VOL1
1 1 ONLINE VOL2
1 2 ONLINE VOL3
1 3 ONLINE VOL4

6 rows selected.

SQL> create diskgroup orag2 external redundancy disk 'ORCL:VOL5';

Diskgroup created.

SQL> select group_number,disk_number,mode_status,name from v$asm_disk;

GROUP_NUMBER DISK_NUMBER MODE_STATUS NAME
------------ ----------- -------------- -------------------------------------
0 5 ONLINE
1 0 ONLINE VOL1
1 1 ONLINE VOL2
1 2 ONLINE VOL3
1 3 ONLINE VOL4
2 0 ONLINE VOL5

6 rows selected.


4.创建表空间

[oracle@danaly ~]$ export ORACLE_SID=danaly
[oracle@danaly ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Sep 3 00:47:04 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 943718400 bytes
Fixed Size 1222744 bytes
Variable Size 281020328 bytes
Database Buffers 654311424 bytes
Redo Buffers 7163904 bytes
Database mounted.
Database opened.
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+ORADG/danaly/datafile/system.264.600016955
+ORADG/danaly/datafile/undotbs1.265.600016969
+ORADG/danaly/datafile/sysaux.266.600016977
+ORADG/danaly/datafile/users.268.600016987

SQL> create tablespace eygle datafile '+ORAG2' ;

Tablespace created.

SQL> select name from v$datafile;

NAME
---------------------------------------------------------------------------------
+ORADG/danaly/datafile/system.264.600016955
+ORADG/danaly/datafile/undotbs1.265.600016969
+ORADG/danaly/datafile/sysaux.266.600016977
+ORADG/danaly/datafile/users.268.600016987
+ORAG2/danaly/datafile/eygle.256.600137647


5.向现有磁盘组增加磁盘

[oracle@danaly log]$ export ORACLE_SID=+ASM
[oracle@danaly log]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Sep 3 01:36:37 2006

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options

SQL> alter diskgroup orag2 add disk 'ORCL:VOL6';

Diskgroup altered.


一点测试过程的记录,供参考. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值