手动创建oracle 10g ASM磁盘组

准备环境:

oracle 10g 联机文档、已经配置10g数据库软件的主机、oracleasm library rpm包、2块5GB硬盘


1、  查看本机磁盘信息

[root@shiyueasm~]# fdisk -l


Disk/dev/sda: 16.1 GB, 16106127360 bytes

255 heads,63 sectors/track, 1958 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes


  Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *        307        1958    13269690  83  Linux

/dev/sda2               1         306    2457913+  82 Linux swap


Partitiontable entries are not in disk order


Disk/dev/sdb: 10.7 GB, 10737418240 bytes

255heads, 63 sectors/track, 1305 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes


  Device Boot      Start         End      Blocks  Id  System

/dev/sdb1   *          1        1305    10482381  83  Linux


Disk/dev/sdc: 5368 MB, 5368709120 bytes

255heads, 63 sectors/track, 652 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes


Disk/dev/sdc doesn’t contain a valid partition table


Disk/dev/sdd: 5368 MB, 5368709120 bytes

255heads, 63 sectors/track, 652 cylinders

Units =cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/sdd doesn’t contain a validpartition table


2、  对新添加的2块磁盘进行分区

[root@shiyueasm~]# fdisk /dev/sdc

Devicecontains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Buildinga new DOS disklabel. Changes will remain in memory only,

until youdecide to write them. After that, of course, the previous

contentwon’t be recoverable.


Warning:invalid flag 0×0000 of partition table 4 will be corrected by w(rite)


Command(m for help): n

Commandaction

  e  extended

  p  primary partition (1-4)

p

Partitionnumber (1-4): 1

Firstcylinder (1-652, default 1):

Usingdefault value 1

Lastcylinder or +size or +sizeM or +sizeK (1-652, default 652):

Usingdefault value 652


Command(m for help): w

Thepartition table has been altered!


Callingioctl() to re-read partition table.

Syncingdisks.

[root@shiyueasm~]# fdisk /dev/sdd

Devicecontains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Buildinga new DOS disklabel. Changes will remain in memory only,

until youdecide to write them. After that, of course, the previous

contentwon’t be recoverable.


Warning:invalid flag 0×0000 of partition table 4 will be corrected by w(rite)


Command(m for help): n

Commandaction

  e  extended

  p  primary partition (1-4)

p

Partitionnumber (1-4): 1

Firstcylinder (1-652, default 1):

Usingdefault value 1

Lastcylinder or +size or +sizeM or +sizeK (1-652, default 652):

Usingdefault value 652


Command(m for help): w

Thepartition table has been altered!


Callingioctl() to re-read partition table.

Syncing disks.


3、  上传 oracle asmlibrary rpm包并对上传的包进行安装

[root@shiyueasmu01]# cd asm rpm for rhel4.0/

[root@shiyueasmasm rpm for rhel4.0]# ll

total 236

-rw-r�Cr�C  1 root root 129218 Apr 29  2010oracleasm-2.6.9-42.ELsmp-2.0.3-1.i686.rpm

-rw-r�Cr�C  1 root root 13105 Apr 29  2010oracleasmlib-2.0.4-1.el4.i386.rpm

-rw-r�Cr�C  1 root root 82542 Apr 29  2010oracleasm-support-2.1.3-1.el4.i386.rpm

[root@shiyueasmasm rpm for rhel4.0]# rpm -ivh *

warning:oracleasmlib-2.0.4-1.el4.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516

Preparing…               ########################################### [100%]

  1:oracleasm-support     ########################################### [ 33%]

 2:oracleasm-2.6.9-42.ELsm########################################### [67%]

  3:oracleasmlib          ########################################### [100%]


4、  配置ASM驱动

[root@shiyueasm~]# /etc/init.d/oracleasm configure

Configuringthe Oracle ASM library driver.


This willconfigure the on-boot properties of the Oracle ASM library

driver.  The following questions will determinewhether the driver is

loaded onboot and what permissions it will have. The current values

will beshown in brackets (‘[]‘).  Hitting<ENTER> without typing an

answerwill keep that current value.  Ctrl-Cwill abort.


Defaultuser to own the driver interface []: oracle

Defaultgroup to own the driver interface []: oinstall

StartOracle ASM library driver on boot (y/n) [n]: y

Scan forOracle ASM disks on boot (y/n) [y]:

WritingOracle ASM library driver configuration: done

Initializingthe Oracle ASMLib driver: [  OK  ]

Scanning the system for Oracle ASMLibdisks: [  OK  ]

5、  创建ASM磁盘组

[root@shiyueasm~]# /etc/init.d/oracleasm createdisk VOL01 ‘/dev/sdc1′

Markingdisk “VOL02″ as an ASM disk: [ OK  ]

[root@shiyueasm~]# /etc/init.d/oracleasm createdisk VOL02 ‘/dev/sdd1′

Marking disk “VOL01″ as anASM disk: [  OK  ]

6、  手动创建磁盘组参数文件

[oracle@shiyueasm~]$ cd $ORACLE_HOME/dbs

[oracle@shiyueasmdbs]$ ll

total 48

-rw-r�Cr�C  1 oracle oinstall   934 May 26 10:52 db.sql

-rw-rw―-  1 oracle oinstall  1544 May 26 10:32 hc_shiyue.dat

-rw-r―�C  1 oracle oinstall 12920 May  3  2001initdw.ora

-rw-r―�C  1 oracle oinstall  8385 Sep 11 1998 init.ora

-rw-r�Cr�C  1 oracle oinstall   996 May 26 10:31 initshiyue.ora

-rw-rw―-  1 oracle oinstall    24 May 26 10:52 lkSHIYUE

-rw-r―�C  1 oracle oinstall  1536 May 26 10:32 orapwshiyue

[oracle@shiyueasm dbs]$ viinit+ASM.ora

asm_diskstring=”

background_dump_dest=/u01/admin/shiyueasm/bdump

core_dump_dest=/u01/admin/shiyueasm/cdump

user_dump_dest=/u01/admin/shiyueasm/udump

instance_type=’asm’

large_pool_size=20m

remote_login_passwordfile=’shared’

7、  创建相关目录

[oracle@shiyueasm~]$ mkdir -p /u01/admin/shiyueasm/bdump

[oracle@shiyueasm~]$ mkdir -p /u01/admin/shiyueasm/cdump

[oracle@shiyueasm ~]$ mkdir -p/u01/admin/shiyueasm/udump

8、  切换至ASM实例

[oracle@shiyueasm ~]$ export ORACLE_SID=+ASM

9、  启动ASM

[oracle@shiyueasm~]$ sqlplus / as sysdba


SQL*Plus:Release 10.2.0.1.0 �C Production on Mon Aug 8 11:39:22 2011


Copyright(c) 1982, 2005, Oracle.  All rightsreserved.


Connectedto an idle instance.


SQL>startup

ORA-29701: unable to connect toCluster Manager

[注]出现错误,该错误是由于没有添加CSS服务所致,所以下一步我们来添加CSS服务。


10、        添加CSS服务

[root@shiyueasm~]# /u01/app/oracle/product/10.2/db_1/bin/localconfig add

/etc/oracledoes not exist. Creating it now.

Successfullyaccumulated necessary OCR keys.

CreatingOCR keys for user ‘root’, privgrp ‘root’..

Operationsuccessful.

Configurationfor local CSS has been initialized


Adding toinittab

Startupwill be queued to init within 90 seconds.

Checkingthe status of new Oracle init process…

Expectingthe CRS daemons to be up within 600 seconds.

CSS isactive on these nodes.

       shiyueasm

CSS isactive on all nodes.

Oracle CSS service is installed andrunning under init(1M)

11、             重新启动ASM

[oracle@shiyueasm~]$ sqlplus / as sysdba


SQL*Plus:Release 10.2.0.1.0 �C Production on Mon Aug 8 11:44:46 2011


Copyright(c) 1982, 2005, Oracle.  All rightsreserved.


Connectedto an idle instance.


SQL>startup

ASMinstance started


TotalSystem Global Area   92274688 bytes

FixedSize                  1217884 bytes

VariableSize              65890980 bytes

ASMCache                  25165824 bytes

ORA-15110: no diskgroups mounted

【注】出现ORA-15110的错误是正常的,因为我们还没有创建磁盘组呢。

12、创建ASM磁盘组

        (1)external冗余方式

SQL> creatediskgroup shiyueasm external redundancy disk ‘ORCL:VOL01′;


Diskgroupcreated.


SQL> alterdiskgroup shiyueasm add disk ‘ORCL:VOL02′;


Diskgroupaltered.


SQL> selectname ,state from v$asm_diskgroup;


NAME                           STATE

――――――――――             ―――�C

SHIYUEASM                      MOUNTED


(2)normal冗余方式

        SQL>create diskgroup shiyueasm normal redundancy        

      2 failgroup shiyueasm_1 disk ‘ORCL:VOL01′

      3 failgroup shiyueasm_2 disk ‘ORCL:VOL02′;


Diskgroupcreated.


SQL> selectname,block_size,free_mb,state from v$asm_diskgroup;


NAME                           BLOCK_SIZE    FREE_MB   STATE

――――――――――              ―――-       ―――-   ―――�C

SHIYUEASM                          4096      10126    MOUNTED

【注】我们可以看到使用normal方式的冗余10G的空间我们只能使用50%,在生产环境下一班会选择external这样一种外部冗余方式


12、             创建SPFILE文件并关闭磁盘组重启

SQL>create spfile from pfile;


Filecreated.


SQL>shutdown immediate

ASMdiskgroups dismounted

ASMinstance shutdown

SQL>startup

ASMinstance started


TotalSystem Global Area   92274688 bytes

FixedSize                  1217884 bytes

VariableSize              65890980 bytes

ASMCache                  25165824 bytes

ORA-15110: no diskgroups mounted

【注】为什么我已经创建了磁盘组为什么还会提示ORA-15110: no diskgroups mounted呢?让我们往下看

13、             解决问题

SQL>show parameter asm;


NAME                                 TYPE        VALUE

―――――――――――――――�C ――――――――――

asm_diskgroups                       string

asm_diskstring                        string

asm_power_limit                      integer     1

【注】注意到问题了吗?asm_diskgroups上的值是空的,好,让我们手动指定磁盘组的名字。

SQL> alter system set asm_diskgroups=shiyueasm scope=both;


System altered.


SQL> show parameter asm;


NAME                                TYPE        VALUE

―――――――――――― ―――――――――――――�C

asm_diskgroups                      string      SHIYUEASM

asm_diskstring                      string

asm_power_limit                     integer     1


14、             重启ASM

SQL>shutdown immediate

ORA-15100:invalid or missing diskgroup name



ASMinstance shutdown

SQL>startup

ASMinstance started


TotalSystem Global Area   92274688 bytes

FixedSize                  1217884 bytes

VariableSize              65890980 bytes

ASMCache                  25165824 bytes

ASMdiskgroups mounted

SQL>select name,state from v$asm_diskgroup;


NAME                           STATE

――――――――――            ―――�C

SHIYUEASM                      MOUNTED


OK,大功告成,手动创建ASM磁盘组就这么简单!




你可能感兴趣的:(ASM)