--首先需要配置css服务
[root@rhel /]# cd /home/db/oracle/product/10.2.0/bin
[root@rhel bin]# ./localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 30 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
rhel
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
[root@rhel bin]# ps -ef|grep d.bin
oracle 16501 16273 1 06:50 ? 00:00:00 /home/db/oracle/product/10.2.0/bin/ocssd.bin
root 16519 15239 0 06:51 pts/0 00:00:00 grep d.bin
--编辑asm初始化参数文件
[root@rhel bin]# su - oracle
[oracle@rhel ~]$ vi $ORACLE_HOME/dbs/init+ASM.ora
INSTANCE_TYPE = ASM
ASM_DISKSTRING='/dev/sd*'
[oracle@rhel ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Aug 29 06:54:44 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount;
ASM instance started
Total System Global Area 79691776 bytes
Fixed Size 1272096 bytes
Variable Size 53253856 bytes
ASM Cache 25165824 bytes
SQL> select name, header_status, path from v$asm_disk;
NAME HEADER_STATU PATH
------------------------------ ------------ ------------------------------
CANDIDATE /dev/sda1
CANDIDATE /dev/sdb1
--创建磁盘组
SQL> CREATE DISKGROUP DG1 NORMAL REDUNDANCY
2 FAILGROUP controller1 DISK
3 '/dev/sda1'
4 FAILGROUP controller2 DISK
5 '/dev/sdb1';
Diskgroup created.
SQL> select name,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,TYPE,TOTAL_MB,FREE_MB from v$asm_diskgroup;
NAME SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE TYPE TOTAL_MB FREE_MB
---------- ----------- ---------- -------------------- ----------- ------ ---------- ----------
DG1 512 4096 1048576 MOUNTED NORMAL 2038 1936
SQL> select name, header_status, path from v$asm_disk;
NAME HEADER_STATU PATH
---------- ------------ ------------------------------
DG1_0001 MEMBER /dev/sdb1
DG1_0000 MEMBER /dev/sda1
--磁盘组的mount与umount
SQL> startup nomount
ASM instance started
Total System Global Area 79691776 bytes
Fixed Size 1272096 bytes
Variable Size 53253856 bytes
ASM Cache 25165824 bytes
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /home/db/oracle/product/10.2.0
/dbs/spfile+ASM.ora
SQL> show parameter disk
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups string
asm_diskstring string /dev/sd*
disk_asynch_io boolean TRUE
SQL> alter diskgroup dg1 mount;
Diskgroup altered.
SQL> show parameter asm_diskgroups
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups string DG1
--为了使磁盘组能自动被mount,需要将asm_diskgroups='DG1' 加入到初始化参数文件中:
SQL> alter system set asm_diskgroups='DG1' scope=both;
System altered.
SQL> show parameter asm_diskgroups
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups string DG1
SQL> shutdown
ASM diskgroups dismounted
ASM instance shutdown
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@rhel ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Wed Aug 29 07:41:09 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup mount;
ASM instance started
Total System Global Area 79691776 bytes
Fixed Size 1272096 bytes
Variable Size 53253856 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> col name for a10
SQL> set lines 132
SQL> select name,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,TYPE,TOTAL_MB,FREE_MB from v$asm_diskgroup;
NAME SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE TYPE TOTAL_MB FREE_MB
---------- ----------- ---------- -------------------- ----------- ------ ---------- ----------
DG1 512 4096 1048576 MOUNTED NORMAL 2038 1936
---这一次,diskgroup被自动挂载了
--删除磁盘组,如果磁盘上有文件,需要加including contents
SQL> drop diskgroup dg1 including contents;
Diskgroup dropped.
SQL> select name, header_status, path from v$asm_disk;
NAME HEADER_STATU PATH
------------------------- ------------ ---------------
FORMER /dev/sdb1
FORMER /dev/sda1
--重新创建磁盘组
SQL> CREATE DISKGROUP DG1 external redundancy disk
2 '/dev/sd*';
Diskgroup created.
SQL> select name, header_status, path from v$asm_disk;
NAME HEADER_STATU PATH
------------------------- ------------ ---------------
DG1_0000 MEMBER /dev/sdb1
DG1_0001 MEMBER /dev/sda1
--添加磁盘到磁盘组中
---首先将磁盘分区并修改分区权限
[root@rhel ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# chown oracle:dba /dev/sdc1
--启动ASM实例,查看磁盘
SQL> select name, header_status, path from v$asm_disk;
NAME HEADER_STATU PATH
------------------------------ ------------ ----------
CANDIDATE /dev/sdc1
DG1_0000 MEMBER /dev/sdb1
DG1_0001 MEMBER /dev/sda1
--可见/dev/sdc1已经被发现,将该磁盘加入到磁盘组dg1中:
SQL> ALTER DISKGROUP dg1 ADD DISK '/dev/sdc1';
Diskgroup altered.
--观察v$asm_operation视图,可见正在进行rebalnce操作:
SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- -----------
1 REBAL RUN 1 1 121 419 230 1
---查看v$asm_disk视图,可见数据已经被移到了新加的磁盘上,且分布均匀:
SQL> select DISK_NUMBER,name,PATH,TOTAL_MB,FREE_MB from v$asm_disk;
DISK_NUMBER NAME PATH TOTAL_MB FREE_MB
----------- ------------------------------ ---------- ---------- ----------
2 DG1_0002 /dev/sdc1 1019 604
0 DG1_0000 /dev/sdb1 1019 603
1 DG1_0001 /dev/sda1 1019 603
--创建一个表空间,然后再次查看v$asm_disk视图:
SQL> create tablespace users datafile '+DG1/oradata/mbs/users01.dbf' size 200m;
Tablespace created.
--可以发现数据文件被均匀的分布在各个磁盘上:
SQL> select DISK_NUMBER,name,PATH,TOTAL_MB,FREE_MB from v$asm_disk;
DISK_NUMBER NAME PATH TOTAL_MB FREE_MB
----------- ------------------------------ ---------- ---------- ----------
2 DG1_0002 /dev/sdc1 1019 536
0 DG1_0000 /dev/sdb1 1019 536
1 DG1_0001 /dev/sda1 1019 536
以上是在oracle 10g环境下测试通过
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-742254/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10972173/viewspace-742254/