创建ASM With Oracle 10G

由于后文会相关的演示操作会用到ASM实例,因此在文章的开始就先创建一个简单的ASM实例,后面再开始详细的介绍ASM。

下面是创建一个ASM Instance的具体操作过程:

创建ASM实例的相关目录

[oracle@gtser1~]$ mkdir -p $ORACLE_BASE/admin/+ASM/bdump

[oracle@gtser1~]$ mkdir -p $ORACLE_BASE/admin/+ASM/cdump

[oracle@gtser1~]$ mkdir -p $ORACLE_BASE/admin/+ASM/hdump

[oracle@gtser1~]$ mkdir -p $ORACLE_BASE/admin/+ASM/pfile

[oracle@gtser1~]$ mkdir -p $ORACLE_BASE/admin/+ASM/udump

准备pfile的初始化参数

[oracle@gtser1~]$ vi /tmp/init+ASM.ora

INSTANCE_TYPE=ASM

"/tmp/init+ASM.ora"6L, 225C 已写入                                                                                                                                         

[oracle@gtser1~]$ cat /tmp/init+ASM.ora

INSTANCE_TYPE=ASM

*.instance_name='+ASM'

*.asm_diskstring='/dev/raw/raw*'

background_dump_dest=/u01/oracle/10g/admin/+ASM/bdump

core_dump_dest=/u01/oracle/10g/admin/+ASM/cdump

user_dump_dest=/u01/oracle/10g/admin/+ASM/udump

启动ASM实例

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

[oracle@gtser1~]$ sqlplus "/as sysdba"

 

SQL*Plus:Release 10.2.0.5.0 - Production on Sat Feb 23 15:20:17 2013

 

Copyright(c) 1982, 2010, Oracle.  All RightsReserved.

 

Connectedto an idle instance.

 

SQL>startup pfile='/tmp/init+ASM.ora'

ASMinstance started

 

TotalSystem Global Area  125829120 bytes

FixedSize                  2094512 bytes

VariableSize              98568784 bytes

ASMCache                  25165824 bytes

ORA-15110:no diskgroups mounted

 

创建spfile

SQL>create spfile from pfile;

createspfile from pfile

*

ERROR atline 1:

ORA-01078:failure in processing system parameters

LRM-00109:could not open parameter file

'/u01/oracle/10g/product/10.2.0/db_1/dbs/init+ASM.ora'

 

 

SQL>create spfile from pfile='/tmp/init+ASM.ora';

 

Filecreated.

查看实例信息

SQL>select instance_name,host_name,version,database_status from v$instance;

 

INSTAHOST_NAM VERSION    DATABASE

------------- ---------- --------

+ASM  gtser1  10.2.0.5.0 ACTIVE

查看磁盘信息

GROUP_NUMBERDISK_NUMBER NAME  HEADER_STATUS            FAILGROUP CREATE_DATE     PATH

----------------------- ----- ------------------------ --------- ----------------------------

           0           0       CANDIDATE                                         /dev/raw/raw4

           0           1       CANDIDATE                                         /dev/raw/raw2

           0           2       CANDIDATE                                         /dev/raw/raw3

           0           0       CANDIDATE                                        /dev/raw/raw1

查看磁盘组信息

SQL>select group_number,name,state,type,total_mb,free_mb from v$asm_diskgroup orderby 1,2;

 

no rowsselected

 

SQL>exit

Disconnectedfrom Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bitProduction

With thePartitioning, OLAP, Data Mining and Real Application Testing options

在OS查看相关进程

[oracle@gtser1~]$  ps -ef | grep asm

oracle    3323    1  0 15:20 ?        00:00:00 asm_pmon_+ASM

oracle    3325    1  0 15:20 ?        00:00:00 asm_psp0_+ASM

oracle    3327    1  0 15:20 ?        00:00:00 asm_mman_+ASM

oracle    3329    1  0 15:20 ?        00:00:00 asm_dbw0_+ASM

oracle    3331    1  0 15:20 ?        00:00:00 asm_lgwr_+ASM

oracle    3333    1  0 15:20 ?        00:00:00 asm_ckpt_+ASM

oracle    3335    1  0 15:20 ?        00:00:00 asm_smon_+ASM

oracle    3337    1  0 15:20 ?        00:00:00 asm_rbal_+ASM

oracle    3339    1  0 15:20 ?        00:00:00 asm_gmon_+ASM

oracle    3361 3256  0 15:28 pts/1    00:00:00 grep asm

[oracle@gtser1~]$ sqlplus "/as sysdba"

 

SQL*Plus:Release 10.2.0.5.0 - Production on Sat Feb 23 15:30:12 2013

 

Copyright(c) 1982, 2010, Oracle.  All RightsReserved.

 

 

Connectedto:

OracleDatabase 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With thePartitioning, OLAP, Data Mining and Real Application Testing options

 

SQL>show parameter spfile;

 

NAME                                 TYPE

----------------------------------------------------------

VALUE

------------------------------

spfile                               string

 

SQL>startup force;

ASMinstance started

 

TotalSystem Global Area  125829120 bytes

FixedSize                  2094512 bytes

VariableSize              98568784 bytes

ASMCache                  25165824 bytes

ORA-15110:no diskgroups mounted

 

 

SQL>show parameter spfile;

 

NAME                                 TYPE

----------------------------------------------------------

VALUE

------------------------------

spfile                               string

/u01/oracle/10g/product/10.2.0

/db_1/dbs/spfile+ASM.ora

SQL>exit

Disconnectedfrom Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bitProduction

With thePartitioning, OLAP, Data Mining and Real Application Testing options   

创建密码文件      

[oracle@gtser1~]$ orapwd file=/u01/oracle/10g/product/10.2.0/db_1/dbs/orapw+ASM password=000000enter=5

Usage:orapwd file=<fname> entries=<users> force=<y/n>ignorecase=<y/n> nosysdba=<y/n>

 

  where

    file - name of password file (required),

    password - password for SYS will beprompted if not specified at command line,

    entries - maximum number of distinct DBA(optional),

    force - whether to overwrite existing file(optional),

    ignorecase - passwords are case-insensitive(optional),

    nosysdba - whether to shut out the SYSDBAlogon (optional Database Vault only).

   

  There must be no spaces around the equal-to(=) character.

[oracle@gtser1~]$ orapwd file=/u01/oracle/10g/product/10.2.0/db_1/dbs/orapw+ASMpassword=000000 entries=5

创建磁盘组,创建名为data01的外部冗余的磁盘组,用于存放数据文件

SQL>create diskgroup data01 external redundancy disk '/dev/raw/raw1' name disk1;

 

Diskgroupcreated.

将raw2添加到data01磁盘组

SQL>alter diskgroup data01 add disk '/dev/raw/raw2' name d2;

 

Diskgroupaltered.

创建磁盘组,创建名为fra的外部冗余的磁盘组,用于FRA

SQL>create diskgroup fra external redundancy disk '/dev/raw/raw3' name d3, '/dev/raw/raw4'name d4;

 

Diskgroupcreated.

SQL>select group_number,disk_number,name,header_status,failgroup,create_date,pathfrom v$asm_disk order by 1,2;

 

GROUP_NUMBERDISK_NUMBER NAME   HEADER_STATUS            FAILGROUP CREATE_DATE     PATH

----------------------- ------ ------------------------ --------- ----------------------------

           1           0 DISK1  MEMBER                   DISK1     23-FEB-13       /dev/raw/raw1

           1           1 D2     MEMBER                   D2        24-FEB-13       /dev/raw/raw2

           2           0 D3     MEMBER                   D3        24-FEB-13       /dev/raw/raw3

           2           1 D4     MEMBER                   D4        24-FEB-13       /dev/raw/raw4

 

SQL>select group_number,name,state,type,total_mb,free_mb,usable_file_mb,required_mirror_free_mbfrom v$asm_diskgroup order by 1,2;

 

GROUP_NUMBERNAME   STATE        TYPE        TOTAL_MB     FREE_MB USABLE_FILE_MBREQUIRED_MIRROR_FREE_MB

------------------ ------------ -------- ----------- ----------- -------------------------------------

           1 DATA01 MOUNTED      EXTERN       2048.00     1996.00           1996                       0

           2 FRA    MOUNTED     EXTERN       2048.00     1996.00           1996                       0


其他一些语法:

SQL> create diskgroup group_high highredundancy

  2  failgroup fg1 disk '/dev/raw/raw1' name d1

  3  failgroup fg2 disk '/dev/raw/raw2' name d2

  4  failgroup fg3 disk '/dev/raw/raw3' name d3;

 

Diskgroup created.

 

SQL> create diskgroup group_normal normalredundancy

  2  failgroup fg4 disk '/dev/raw/raw4' name d4

  3  failgroup fg5 disk '/dev/raw/raw5' name d5;

 

Diskgroup created.

 

SQL> create diskgroup group_external externalredundancy disk '/dev/raw/raw6';

 

Diskgroup created.

 

SQL> drop diskgroup group_external;

 

Diskgroup dropped.

 

SQL> alter diskgroup group_normal add disk'/dev/raw/raw6' name d61;

 

Diskgroup altered.

 

SQL> alter diskgroup group_normal resize diskd61 size 150m;

 

Diskgroup altered.

 

SQL> alter diskgroup group_normal drop diskd61;

 

Diskgroup altered.

 

SQL> alter diskgroup group_normal addfailgroup fg5 disk '/dev/raw/raw6' name d6;

 

Diskgroup altered.

 

SQL> alter diskgroup group_high dismount;

 

Diskgroup altered.

 

SQL> alter diskgroup all dismount;

 

Diskgroup altered.

 

SQL> alter diskgroup all mount;

 

Diskgroup altered.

 

ASM目录和别名

SQL> alter diskgroup group_normal adddirectory '+group_normal/mydir';

 

Diskgroup altered.

 

SQL> alter diskgroup group_normal add alias'+group_normal/gt10g/datafile/gtlions01.dbf' for'+group_normal/gt10g/datafile/GTLIONS.256.807383189';

 

Diskgroup altered.

 


 

你可能感兴趣的:(创建ASM With Oracle 10G)