Windows下虚拟ASM磁盘搭建基于ASM的Oracle 10g数据库系统(1)_向往著 ...
Windows下虚拟ASM磁盘搭建基于ASM的Oracle 10g数据库系统(1)

很多人对Oracle 10g推出的ASM技术感到畏惧,总觉得是一个black box,自己驾御不了,其实呢,ASM并不是黑匣子,只是大家还没有xx掌握她、了解她。本小结不对ASM技术本身做过多的介绍,假设你对ASM技术有了一定的了解(至少看过一些别人的案例或相关的技术白皮书什么的吧?),本文介绍一个在Windows XP环境下构建一个基于ASM的Oracle 10g(10.2.0.4)单机的数据库,从而给大家提供一个ASM的学习环境,从而尽快的了解ASM,让她变的不再陌生!

 

在Windows平台下,Oracle提供了一个工具叫asmtool(位于%ORACLE_HOME%bin目录下),通过asmtool可以构建虚拟ASM磁盘,从而让我们有了一个可以在虚拟ASM磁盘上建立学习环境的机会。

不过大家要注意,这种方法不是官方支持的的,所以千万不要用于生产系统,xx于学习研究

 

{dy}步:创建ASM虚拟磁盘

在我这个个测试中,我总共创建4个diskgroup,下面创建的asm磁盘的单位是M

asmtool -create d:asmdiskasmdisk1 500
asmtool -create d:asmdiskasmdisk2 500
asmtool -create d:asmdiskasmdisk3 500 -- SYS_DATA External Redundancy
asmtool -create d:asmdiskasmdisk4 200
asmtool -create d:asmdiskasmdisk5 200 -- FLASH_DATA External Redundancy
asmtool -create d:asmdiskasmdisk6 100
asmtool -create d:asmdiskasmdisk7 100 -- USER_DATA Normal Redundancy

asmtool -create d:asmdiskasmdisk8 100
asmtool -create d:asmdiskasmdisk9 100

asmtool -create d:asmdiskasmdisk10 100 -- TEST_DATA High Redundancy

具体的执行过程就略了。执行完了的结果就是:

D:oracle10g>dir d:asmdisk
驱动器 D 中的卷是 应用盘
卷的序列号是 64B6-D634

d:asmdisk 的目录

2009-07-13 09:51 <DIR> .
2009-07-13 09:51 <DIR> ..
2009-07-13 09:42 524,288,000 asmdisk1
2009-07-13 09:51 104,857,600 asmdisk10
2009-07-13 09:44 524,288,000 asmdisk2
2009-07-13 09:46 524,288,000 asmdisk3
2009-07-13 09:46 209,715,200 asmdisk4
2009-07-13 09:47 209,715,200 asmdisk5
2009-07-13 09:47 104,857,600 asmdisk6
2009-07-13 09:47 104,857,600 asmdisk7
2009-07-13 09:48 104,857,600 asmdisk8
2009-07-13 09:48 104,857,600 asmdisk9
10 个文件 2,516,582,400 字节
2 个目录 7,263,399,936 可用字节
D:oracle10g>

第二步:配置CSS(Cluster Synchronization Services)

CSS主要用来同步ASM instance和它的client,也即database instance。可以由Oracle自带的localconfig命令来完成。Localconfig命令也位于ORACLE_HOMEbin目录下.

%ORACLE_HOME%binlocalconfig add


D:oracle10g>localconfig add
Step 1: creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'zhangrp', privgrp ''..
Operation successful.
Step 2: creating new CSS service
successfully created local CSS service
successfully added CSS to home

D:oracle10g>

配置完成后,在Windows Services中会出现类似如下一个entry


--检查CSS守护进程的状态

D:oracle10g>crsctl check cssd
CSS appears healthy
D:oracle10g>

 

备注:如果后期要删除这个css服务,只需要在windows command下执行如下命令即可:

localconfig delete

 

第三步:准备ASM实例的参数文件

注意:ASM的实例名一定要以+开头的字符串,比如+ASM,否则后面通过dbca配置ASM实例或创建数据库的时候,DBCA无法识别到之前的asm实例。

参见Metalink Doc ID: 403644.1

 

先创建一个pfile文件,我的这个测试ASM实例的名字就叫+ASM,所以我需要在%ORACLE_HOME%database下创建一个INIT+asm.ORA的参数文件,内容如下:

*._asm_allow_only_raw_disks=FALSE
*.asm_diskstring='D:asmdiskasmdisk*'
*.background_dump_dest='D:adminasmbdump'
*.core_dump_dest='D:adminasmcdump'
*.instance_type='ASM'
*.large_pool_size=12M

*.db_unique_name='+ASM'

*.asm_power_limit=1
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='D:adminasmudump'

注意:此处"_asm_allow_only_raw_disks"为隐含参数,设为FALSE是为了允许ASM使用非裸设备,在这里是必须要设置为FALSE的。

第四步:创建ASM实例

D:oracle10g>oradim -new -asmsid +asm -startmode manual
Instance created.

备注:如果后期要删除这个asm实例,只需要在windows command下执行如下命令即可:

oradim -delete -asmsid +asm

第五步:连接到ASM实例

D:oracle10g>set ORACLE_SID=+ASM
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

D:oracle10g>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jul 13 10:15:33 2009
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area 83886080 bytes
Fixed Size 1295152 bytes
Variable Size 57425104 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups mounted
SQL>

注意:这里有一个ORA-15110的错误信息,因为是首次启动asm实例,还没有创建diskgroup,所以显示15110错误是正常的,忽略掉该错误,继续后面的步骤。

 

SQL> select host_name,instance_name,version,status from v$instance;
HOST_NAME INSTANCE_NAME VERSION STATUS
--------------- -------------- ------------- ----------
zhangrp-cn +asm 10.2.0.4.0 STARTED

第六步:创建磁盘组

按照我之前的规划,我这里需要创建4个磁盘组.

--查看一下磁盘信息
SQL> col path for a30
SQL> select path,mount_status from v$asm_disk order by disk_number;
PATH MOUNT_STATUS
---------------------- --------------
D:ASMDISKASMDISK1 CLOSED
D:ASMDISKASMDISK10 CLOSED
D:ASMDISKASMDISK2 CLOSED
D:ASMDISKASMDISK3 CLOSED
D:ASMDISKASMDISK4 CLOSED
D:ASMDISKASMDISK5 CLOSED
D:ASMDISKASMDISK6 CLOSED
D:ASMDISKASMDISK7 CLOSED
D:ASMDISKASMDISK8 CLOSED
D:ASMDISKASMDISK9 CLOSED

10 rows selected.
SQL>

可以看到,我之前创建的10块ASM虚拟磁盘mount 状态全是closed,因为他们还没有被加到任何的diskgroup中.下面开始创建我的diskgroup

--系统用的磁盘组SYS_DATA,由3块500M的磁盘组成,采用外部冗余

SQL> create diskgroup sys_data
2
External Redundancy
3 disk 'd:asmdiskasmdisk1',
4 'd:asmdiskasmdisk2',
5 'd:asmdiskasmdisk3';

Diskgroup created.
--闪回用的磁盘组FLASH_DATA,由2块200M的磁盘组成,采用外部冗余
SQL> create diskgroup flash_data
2
External Redundancy
3 disk 'd:asmdiskasmdisk4',
4 'd:asmdiskasmdisk5';

Diskgroup created.
--用户STUDY用的磁盘组USER_DATA,由2块100M的磁盘组成,采用2-way冗余
SQL> create diskgroup user_data

2 Normal Redundancy
3 failgroup user_fg_01 disk 'd:asmdiskasmdisk6'
4 failgroup user_fg_02 disk 'd:asmdiskasmdisk7';

Diskgroup created.
--测试用的磁盘组TEST_DATA,由3块100M的磁盘组成,采用3-way冗余
SQL> create diskgroup test_data

2 High Redundancy
3 failgroup test_fg_01 disk 'd:asmdiskasmdisk8'
4 failgroup test_fg_02 disk 'd:asmdiskasmdisk9'
5 failgroup test_fg_03 disk 'd:asmdiskasmdisk10';

Diskgroup created.
SQL>

--再看一下磁盘的状态

SQL> select path,mount_status from v$asm_disk order by disk_number;
PATH MOUNT_STATUS
---------------------- --------------
D:ASMDISKASMDISK1 CACHED
D:ASMDISKASMDISK10 CACHED
D:ASMDISKASMDISK2 CACHED
D:ASMDISKASMDISK3 CACHED
D:ASMDISKASMDISK4 CACHED
D:ASMDISKASMDISK5 CACHED
D:ASMDISKASMDISK6 CACHED
D:ASMDISKASMDISK7 CACHED
D:ASMDISKASMDISK8 CACHED
D:ASMDISKASMDISK9 CACHED


10 rows selected.
SQL>

这时的磁盘状态,MOUNT_STATUS变成"CACHED",表示磁盘已经成为磁盘组的一部分,并且正在被ASM Instance访问

SQL> select group_number,name,sector_size,block_size,allocation_unit_size,state,type,total_mb,free_mb from v$asm_diskgroup;
GROUP_NUMBER NAME SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE TYPE TOTAL_MB FREE_MB
------------ ----------- ----------- ---------- -------------------- --------- ------ ---------- -------
1 FLASH_DATA 512 4096 1048576 MOUNTED EXTERN 400 348
2 SYS_DATA 512 4096 1048576 MOUNTED EXTERN 1500 1446
3 TEST_DATA 512 4096 1048576 MOUNTED HIGH 300 147
4 USER_DATA 512 4096 1048576 MOUNTED NORMAL 200 98
SQL>


SQL> show parameter asm_disk
NAME TYPE VALUE
------------------ ----------- ------------------------------------------
asm_diskgroups string SYS_DATA, FLASH_DATA, USER_DATA, TEST_DATA
asm_diskstring string D:asmdiskasmdisk*
SQL>

第七步:关闭ASM实例,修改pfile并转为spfile,创建密码文件

在这一步中,先关闭ASM实例,然后修改pfile,增加如下参数:

asm_diskgroups='SYS_DATA', 'FLASH_DATA', 'USER_DATA', 'TEST_DATA'

--关闭ASM实例

SQL> shutdown immediate;
ASM diskgroups dismounted
ASM instance shutdown
--编辑INITasm.ORA参数文件,增加asm_diskgroups设置保存退出。内容如下

SQL> host more d:oracle10gdatabaseINITasm.ORA
*._asm_allow_only_raw_disks=FALSE
*.asm_diskstring='D:asmdiskasmdisk*'
*.asm_diskgroups='SYS_DATA', 'FLASH_DATA', 'USER_DATA', 'TEST_DATA'
*.background_dump_dest='D:adminasmbdump'
*.core_dump_dest='D:adminasmcdump'
*.instance_type='ASM'
*.large_pool_size=12M
*.db_unique_name='ASM'
*.asm_power_limit=1
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='D:adminasmudump'
 

--创建密码文件

D:oracle10g>orapwd file=d:oracle10gdatabasePWDasm.ora password=admin entries=10
D:oracle10g>


--重启ASM实例
SQL> startup
ASM instance started

Total System Global Area 83886080 bytes
Fixed Size 1295152 bytes
Variable Size 57425104 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL>

好了,刚才的"ORA-15110: no diskgroups mounted"错误信息也没了。

--生成SPFILE

SQL> create spfile from pfile;
File created.
SQL>

--配置listener.ora和tnsnames.ora,这样就可以通过pl/sql developer这样的工具连接访问你的ASM实例了。参见我另外的文章:如何从远程连接ASM实例

    

    

    

SQL> select file_id,file_name,tablespace_name from dba_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ------------------------------------- -----------------
4 +SYS_DATA/oratest/users01.dbf USERS
3 +SYS_DATA/oratest/sysaux01.dbf SYSAUX
2 +SYS_DATA/oratest/undotbs01.dbf UNDOTBS1
1 +SYS_DATA/oratest/system01.dbf SYSTEM
SQL> create tablespace study datafile '+USER_DATA/oratest/study.dbf' size 30M
2 extent management local segment space management auto;
Tablespace created

SQL> select file_id,file_name,tablespace_name from dba_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- ----------------------------------- -----------------
4 +SYS_DATA/oratest/users01.dbf USERS
3 +SYS_DATA/oratest/sysaux01.dbf SYSAUX
2 +SYS_DATA/oratest/undotbs01.dbf UNDOTBS1
1 +SYS_DATA/oratest/system01.dbf SYSTEM
5 +USER_DATA/oratest/study.dbf STUDY

SQL> select group_number,name,state,type,total_mb,free_mb from v$asm_diskgroup;
GROUP_NUMBER NAME STATE TYPE TOTAL_MB FREE_MB
------------ -------------- ----------- ------ ---------- ----------
1 FLASH_DATA MOUNTED EXTERN 400 346
2 SYS_DATA CONNECTED EXTERN 1500 466
3 TEST_DATA MOUNTED HIGH 300 147
4 USER_DATA CONNECTED NORMAL 200 32
SQL>

SQL> create user study identified by study default tablespace study quota unlimited on study;
User created

SQL> grant connect,resource,dba to study;
Grant succeeded
SQL> conn study/study@oratest
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as study
SQL>



郑重声明:资讯 【Windows下虚拟ASM磁盘搭建基于ASM的Oracle 10g数据库系统(1)_向往著 ...】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——