ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 单节点Windows上的ASM

单节点Windows上的ASM

原创 Linux操作系统 作者:qgrape 时间:2011-10-31 15:37:46 0 删除 编辑

单节点Windows上的ASM

2009-06-17 16:21

ASM (Automatic Storage Management) Oracle 10g的一个重要新特性,在实现数据库I/O自动负载平衡,数据文件镜像等方面起着重要的作用。即使是单节点的数据库,Oracle也推荐使用ASM。但一般文档上提到ASM时,都需要有磁盘组或者多块磁盘才能实现,这使得很多人无法建立学习和实践的环境。下面的实验将带领你在windows xp的操作系统中建立ASM环境,并将已有的数据库转移到ASM中,同时该实验
1.
不需要磁盘组或者多块磁盘
2.
不需要在Windows xp中安装虚拟机,Linux等复杂的步骤

=====================
一、建立ASM Instance
=====================

1. 建立模拟磁盘
建立ASM Instance,首先要在一个磁盘上模拟出多块磁盘。Oracleasmtool可以实现这个功能。AsmtoolOracle 10g for Windows的一个自带工具,位于ORACLE_HOME\bin目录下。

C:\>md C:\asmdisks

C:\>cd asmdisks

C:\asmdisks>asmtool -create C:\asmdisks\disk1 1000;

C:\asmdisks>asmtool -create C:\asmdisks\disk2 1000;

C:\asmdisks>asmtool -create C:\asmdisks\disk3 1000;

C:\asmdisks>asmtool -create C:\asmdisks\disk4 1000;

C:\asmdisks>asmtool -create C:\asmdisks\disk5 1000;

C:\asmdisks>dir
Volume in drive C is OS
Volume Serial Number is FCC6-4EA2

Directory of C:\asmdisks

01/03/2007 09:28 AM   

          .
01/03/2007 09:28 AM              ..
01/03/2007 09:12 AM     1,048,576,000 disk1
01/03/2007 10:01 AM     1,048,576,000 disk2
01/03/2007 10:01 AM     1,048,576,000 disk3
01/03/2007 10:01 AM     1,048,576,000 disk4
01/03/2007 10:01 AM     1,048,576,000 disk5
               5 File(s) 5,242,880,000 bytes
               2 Dir(s) 48,027,619,328 bytes free
              
这样我们就在C:\asmdisks目录中生成了5个文件,每个大小为1GASM instance会把它们当成51G的硬盘。

2. 配置CSS(Cluster Synchronization Services)
CSS
主要用来同步ASM instance和它的client,也即database instance。这一步就算不是在cluster环境中也是必须的,可以由Oracle自带的localconfig命令来完成。Localconfig命令也位于ORACLE_HOME\bin目录下。

C:\oracle\product\10.2.0\db_1\BIN>localconfig add
Step 1: creating new OCR repository
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'corp\e468447', privgrp ''..
Operation successful.
Step 2: creating new CSS service
successfully created local CSS service
successfully added CSS to home

检查CSS daemon状态:

C:\asmdisks>crsctl check cssd
CSS appears healthy

“CSS appears healthy”表明该进程正在运行。

3. 创建ASM Instanceinitial文件
ASM Instance
有自己的初始参数文件,可以为spfile或者文本文件。通过在文件名中嵌入SID,来区分ASM InstanceDatabase Instance。单节点的环境中,ASM SID默认为+ASM, RAC中各节点上的SID默认为+ASMnode#

打开记事本编辑初始参数文件。
C:\oracle\product\10.2.0\db_1\database>notepad init+ASM.ora
INSTANCE_TYPE=ASM        #
必须设置的参数,而且值只能为ASM
DB_UNIQUE_NAME=+ASM
LARGE_POOL_SIZE=8M       #
ASMinternal packages使用,至少8M
ASM_DISKSTRING='C:\asmdisks\*' #
告诉ASM Instance物理磁盘位置
_ASM_ALLOW_ONLY_RAW_DISKS=FALSE #Oracle
隐藏参数,允许ASM使用非裸设备。


C:\oracle\product\10.2.0\db_1\database>dir
Volume in drive C is OS
Volume Serial Number is FCC6-4EA2

Directory of C:\oracle\product\10.2.0\db_1\database

12/28/2006 09:48 AM   

          .
12/28/2006 09:48 AM              ..
11/17/2006 09:14 AM              archive
11/17/2006 03:33 PM             2,048 hc_orcl.dat
12/28/2006 09:49 AM               123 init+ASM.ora
11/17/2006 09:38 AM                59 initorcl.ora
06/25/2005 03:18 AM            31,744 oradba.exe
12/28/2006 08:56 AM             4,092 oradim.log
11/21/2006 10:03 AM             1,536 PWDorcl.ora
              37 File(s)         42,888 bytes
               3 Dir(s) 47,781,150,720 bytes free

4. oradim创建Oracle ASM实例。
C:\oracle\product\10.2.0\db_1\database>oradim -NEW -ASMSID +ASM -STARTMODE auto
实例已创建。

其中
-NEW: indicates that you are creating a new instance. This is a mandatory parameter
-ASMSID SID: is the name of the Automatic Storage Management (ASM) instance to create
STARTMODE: indicates whether to start the instance when the Oracle Database service is started. Default is manual


5.
连接到ASM Instance
C:\oracle\product\10.2.0\db_1\database>set ORACLE_SID=+ASM

C:\oracle\product\10.2.0\db_1\database>sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 12 28 10:04:21 2006

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


连接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> show user
USER
"SYS"
SQL> select status from v$instance;

STATUS
------------------------
STARTED

6. 创建磁盘组
SQL> set pages 3000
SQL> set lines 132
SQL> column path format a50
SQL> select path,mount_status from v$asm_disk;

PATH                                               MOUNT_STATUS
-------------------------------------------------- --------------
C:\ASMDISKS\DISK1                                  CLOSED
C:\ASMDISKS\DISK2                                  CLOSED
C:\ASMDISKS\DISK5                                  CLOSED
C:\ASMDISKS\DISK4                                  CLOSED
C:\ASMDISKS\DISK3                                  CLOSED

注意MOUNT_STATUS"CLOSED",因为磁盘组还没创建。


SQL> create diskgroup dgroup1 normal redundancy disk
2 'C:\asmdisks\disk1',
3 'C:\asmdisks\disk2',
4 'C:\asmdisks\disk3',
5 'C:\asmdisks\disk4',
6 'C:\asmdisks\disk5';

磁盘组已创建。

再检查磁盘状态,MOUNT_STATUS变成"CACHED",表示磁盘已经成为磁盘组的一部分,并且正在被ASM Instance访问。
SQL> select path,mount_status from v$asm_disk;

PATH                                               MOUNT_STATUS
-------------------------------------------------- --------------
C:\ASMDISKS\DISK1                                  CACHED
C:\ASMDISKS\DISK2                                  CACHED
C:\ASMDISKS\DISK3                                  CACHED
C:\ASMDISKS\DISK4                                  CACHED
C:\ASMDISKS\DISK5                                  CACHED


关闭ASM Instance,
SQL> shutdown immediate;
ASM
磁盘组已卸装
ASM
实例已关闭

init+ASM.ora中加入参数 ASM_DISKGROUPS='DGROUP1',并创建spfile
SQL> create spfile from pfile='C:\oracle\product\10.2.0\db_1\database\init+asm.ora';

文件已创建。

启动ASM Instance
SQL> startup
ASM
实例已启动

Total System Global Area   79691776 bytes
Fixed Size                  1247396 bytes
Variable Size              53278556 bytes
ASM Cache                  25165824 bytes
ASM
磁盘组已装载

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12330444/viewspace-709978/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 修改数据库的SID
请登录后发表评论 登录
全部评论

注册时间:2008-04-09

  • 博文量
    223
  • 访问量
    514045