这是在Oracle 10.2的单机(非RAC)环境中创建ASM的实验记录。
主要的步骤如下:
1、使用新增的磁盘创建vg及lv
2、将lv映射为raw
3、编辑ASM实例的pfile,启动实例
4、创建ASM DiskGroup
我这里主要是实验目的,所以使用了lvm以及raw,一般在生产环境中的ASM是不推荐使用lvm的,因为lvm隐藏了物理磁盘架构,可能导致ASM效率低下,具体说明可以参考官方文档。
我使用的操作系统是CentOS 5,已经集成了asmlib。如果使用其他没有集成asmlib的Linux,参照 ASM官方主页 下载安装。
详细的操作过程如下:
[@more@]1、使用新增的磁盘创建vg及lv
1.1、查看新增加的磁盘
[root@oracle /]# ls -l /dev/sd* brwxrwxrwx 1 oracle dba 8, 0 Dec 17 10:10 /dev/sda brwxrwxrwx 1 oracle dba 8, 16 Dec 17 10:10 /dev/sdb |
1.2、使用fdisk命令为两个新增加的磁盘分区,都只分一个区,使用最大容量
[root@oracle /]# fdisk /dev/sda The number of cylinders for this disk is set to 1044. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1044, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): Using default value 1044 Command (m for help): p Disk /dev/sda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 1044 8385898+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@oracle /]# fdisk /dev/sdb The number of cylinders for this disk is set to 1044. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1044, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): Using default value 1044 Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 1044 8385898+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
1.2、为新建的分区创建pv
[root@oracle /]# pvcreate sdb1 /dev/sdb1 Device sdb1 not found (or ignored by filtering). Physical volume "/dev/sdb1" successfully created [root@oracle /]# pvcreate sda1 /dev/sda1 Device sda1 not found (or ignored by filtering). Physical volume "/dev/sda1" successfully created |
1.3、创建名称为vg_asm的vg
[root@oracle /]# vgcreate vg_asm /dev/sda1 /dev/sdb1 Volume group "vg_asm" successfully created |
1.4、在vg_asm上创建lv,名称为lv_asm123
[root@oracle /]# lvcreate -L 4G -n lv_asm1 vg_asm Logical volume "lv_asm1" created [root@oracle /]# lvcreate -L 4G -n lv_asm2 vg_asm Logical volume "lv_asm2" created [root@oracle /]# lvcreate -L 3.99G -n lv_asm3 vg_asm Rounding up size to full physical extent 3.99 GB Logical volume "lv_asm3" created [root@oracle /]# ls -l /dev/vg_asm/ total 0 lrwxrwxrwx 1 root root 26 Dec 17 10:43 lv_asm1 -> /dev/mapper/vg_asm-lv_asm1 lrwxrwxrwx 1 root root 26 Dec 17 10:43 lv_asm2 -> /dev/mapper/vg_asm-lv_asm2 lrwxrwxrwx 1 root root 26 Dec 17 10:44 lv_asm3 -> /dev/mapper/vg_asm-lv_asm3 |
1.5、将3个新创建的lv映射为裸设备
编辑/etc/sysconfig/rawdevices文件,增加如下三行/dev/raw/raw1 /dev/vg_asm/lv_asm1 /dev/raw/raw2 /dev/vg_asm/lv_asm2 /dev/raw/raw3 /dev/vg_asm/lv_asm3 |
执行如下命令,使新增加的裸设备生效
[root@oracle /]# service rawdevices restart Assigning devices: /dev/raw/raw1 --> /dev/vg_asm/lv_asm1 /dev/raw/raw1: bound to major 253, minor 2 /dev/raw/raw2 --> /dev/vg_asm/lv_asm2 /dev/raw/raw2: bound to major 253, minor 3 /dev/raw/raw3 --> /dev/vg_asm/lv_asm3 /dev/raw/raw3: bound to major 253, minor 4 done |
查看新增加的裸设备状态
[root@oracle /]# ls -l /dev/raw/ total 0 crw------- 1 root root 162, 1 Dec 17 10:46 raw1 crw------- 1 root root 162, 2 Dec 17 10:46 raw2 crw------- 1 root root 162, 3 Dec 17 10:46 raw3 [root@oracle /]# |
创建裸设备的链接到oradata目录,这一步可以省略,这里只是为了方便以后查看各个裸设备的用途
[root@oracle /]# ln -s /dev/raw/raw1 /oracle/oradata/asm1 ln -s /dev/raw/raw2 /oracle/oradata/asm2 ln -s /dev/raw/raw3 /oracle/oradata/asm3 [root@oracle /]# ln -s /dev/raw/raw2 /oracle/oradata/asm2 [root@oracle /]# ln -s /dev/raw/raw3 /oracle/oradata/asm3 [root@oracle /]# [root@oracle /]# [root@oracle /]# ls -l /oracle/oradata total 8 lrwxrwxrwx 1 root root 13 Dec 17 10:48 asm1 -> /dev/raw/raw1 lrwxrwxrwx 1 root root 13 Dec 17 10:48 asm2 -> /dev/raw/raw2 lrwxrwxrwx 1 root root 13 Dec 17 10:48 asm3 -> /dev/raw/raw3 |
设置裸设备的使用权限
[root@oracle /]# chown oracle:oinstall /dev/raw/raw1 chown oracle:oinstall /dev/raw/raw2 chown oracle:oinstall /dev/raw/raw3 chmod 600 /dev/raw/raw1 chmod 600 /dev/raw/raw2 chmod 600 /dev/raw/raw3 [root@oracle /]# chown oracle:oinstall /dev/raw/raw2 [root@oracle /]# chown oracle:oinstall /dev/raw/raw3 [root@oracle /]# chmod 600 /dev/raw/raw1 [root@oracle /]# chmod 600 /dev/raw/raw2 [root@oracle /]# chmod 600 /dev/raw/raw3 [root@oracle /]# [root@oracle /]# [root@oracle /]# ls -l /dev/raw/raw1 total 0 crw------- 1 oracle oinstall 162, 1 Dec 17 10:46 raw1 crw------- 1 oracle oinstall 162, 2 Dec 17 10:46 raw2 crw------- 1 oracle oinstall 162, 3 Dec 17 10:46 raw3 |
将设置裸设备使用权限的语句写入自动启动脚本中
编辑 /etc/rc.local 文件,增加如下内容
chown oracle:oinstall /dev/raw/raw1 chown oracle:oinstall /dev/raw/raw2 chown oracle:oinstall /dev/raw/raw3 chmod 600 /dev/raw/raw1 chmod 600 /dev/raw/raw2 chmod 600 /dev/raw/raw3 |
3、编辑ASM实例的pfile,启动实例
以下操需要使用oracle用户完成,所以先su到oracle用户
[root@oracle oradata]# su - oracle |
进入$ORACLE_HOME/dbs目录
[oracle@oracle ~]$ cd $ORACLE_HOME/dbs [oracle@oracle dbs]$ pwd /oracle/app/10.1/dbs |
在这个目录下创建名称为init+ASM.ora的文件,内容如下:
instance_type=asm |
设置ORACLE_SID环境变量
[oracle@oracle dbs]$ export ORACLE_SID=+ASM |
登录数据库,启动ASM实例
[oracle@oracle dbs]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 17 10:54:18 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount pfile='/oracle/app/10.1/dbs/init+ASM.ora'; ASM instance started Total System Global Area 79691776 bytes Fixed Size 1217812 bytes Variable Size 53308140 bytes ASM Cache 25165824 bytes |
--------begin 异常情况处理 begin--------
如果启动的时候报如下错误
ORA-29701: unable to connect to Cluster Manager |
这需要用root用户执行localconfig add命令(在$ORACLE_HOME/bin目录下),启动cssd进程,如下:
[root@oracle bin]# pwd /oracle/app/10.1/bin [root@oracle 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 90 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. oracle CSS is active on all nodes. Oracle CSS service is installed and running under init(1M) [root@oracle bin]# ps -ef|grep css|grep -v grep root 5126 1 0 09:44 ? 00:00:00 /bin/su -l oracle -c sh -c 'cd /oracle/app/10.1/log/oracle/cssd; ulimit -c unlimited; exec /oracle/app/10.1/bin/ocssd ' oracle 5229 5126 0 09:45 ? 00:00:00 /oracle/app/10.1/bin/ocssd.bin |
----------end 异常情况处理 end----------
使用pfile文件生成spfile
SQL> create spfile from pfile='/oracle/app/10.1/dbs/init+ASM.ora'; File created. |
使用spfile重启ASM实例
SQL> shutdown abort; ASM instance shutdown SQL> startup nomount; ASM instance started Total System Global Area 79691776 bytes Fixed Size 1217812 bytes Variable Size 53308140 bytes ASM Cache 25165824 bytes |
4、创建ASM DiskGroup
SQL> create diskgroup data external redundancy disk '/dev/raw/raw1','/dev/raw/raw2','/dev/raw/raw3'; Diskgroup created. SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options |
5、检查新创建的磁盘组
[oracle@oracle dbs]$ asmcmd ASMCMD> lsdg State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name MOUNTED EXTERN N N 512 4096 1048576 12280 12226 0 12226 0 DATA/ ASMCMD> ls DATA/ ASMCMD> exit |
--end--
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22049049/viewspace-1029758/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22049049/viewspace-1029758/