您的位置:首页 > 数据库 > Oracle

RHEL下创建ORACLE ASM数据库

2013-11-27 14:03 399 查看
在真正的生产大数据环境中,存储管理是DBA的主要工作之一,比如生产系统上表空间的监控,当一个表空间满或者使用率过高时,可能需要
DBA添加一块磁盘到操作系统中,然后再在新加的磁盘上添加数据文件。如果这个操作作用的环境是单个磁盘,那么不是这个动作影响相对较小。
然而,如果使用的是RAID或者LVM,那么现在大量的数据仍然分布在以前的磁盘上,如果我们在新添加磁盘之后想让数据均匀的分布在磁盘上,
可能就要耗费很大的经历来做原先数据的导出导入。那么如果有一种方法,能实现我们就把一块磁盘加到系统里,然后告诉
Oracle 我们要用这块盘了,剩下的工作全部由Oracle 来完成,该是多好的一件事情!幸
运的是,Oracle1 已经提供了这个功能, 这就是ASM( Automatic Storage
Management)。我们称为“自动存储管理”。Oracle10g 的ASM 不但帮助DBA 从繁琐的
磁盘空间管理中解脱出来,而且更值得关注的是ASM 同时提供了条带和镜像的功能,而这
些功能原先需要通过单独地配置RAID 来实现。正是因为ASM的这些优点,所以ASM越来越流行和推广,尤其是生产上存在大量的ASM存储RAC系统。
本文通过实验,在RHEL 4下搭建一个ASM的单实例数据库,后续可能我会发布搭建ASM RAC的实验文章。
首先需要查看Linux系统的内核版本,因为要针对不同的内核版本,来下载asm的驱动包,asm的驱动包包括
oracleasm、oracleasmlib和oracleasmsupport三个版本,在RHEL下面你需要安装三个驱动包,而在Oracle自己的小企鹅版Linux中,前两个已经安装,
只需要装support。
uname -r查看我的系统内核如下:
[root@localhost ~]# uname -r
2.6.9-78.ELsmp
[root@localhost ~]#
所以我要下载这个内核对应的驱动包,ASM的驱动包在Oracle官网的
Server and Storage->Oracle Linux Downloads可以下载。
1.首先我在我的虚拟机Linux下增加4块磁盘,每个磁盘建占满整个磁盘的主分区,四块磁盘后面我将建两个ASM的组,一个主GROUP和一个冗余GROUP。
我的系统中磁盘情况如下:
[root@localhost ~]# 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 * 1 13 104391 83 Linux
/dev/sda2 14 1958 15623212+ 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 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
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sdf: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdf doesn't contain a valid partition table
[root@localhost ~]#
可以看到现在没有分区的有sdb-sdf的5块磁盘,其中sdb大小10G,我暂时不用,我对sdc、sdd、sde、sdf分区,它们都是5G.分区后如下:
[root@localhost ~]# 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 * 1 13 104391 83 Linux
/dev/sda2 14 1958 15623212+ 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 652 5237158+ 83 Linux
Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1 1 652 5237158+ 83 Linux
Disk /dev/sde: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 652 5237158+ 83 Linux
Disk /dev/sdf: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdf1 1 652 5237158+ 83 Linux
[root@localhost ~]#
2.安装ASM驱动包:
[root@localhost asm]# pwd
/oracle/asm
[root@localhost asm]# ls -l
鎬荤敤閲?252
-rw-r--r-- 1 root root 134679 2013-08-18 oracleasm-2.6.9-78.ELsmp-2.0.5-1.el4.i686.rpm
-rw-r--r-- 1 root root 13105 2013-08-18 oracleasmlib-2.0.4-1.el4.i386.rpm
-rw-r--r-- 1 root root 83636 2013-08-18 oracleasm-support-2.1.7-1.el4.i386.rpm
[root@localhost asm]# rpm -ivh oracleasm*
璀﹀憡锛歰racleasm-2.6.9-78.ELsmp-2.0.5-1.el4.i686.rpm: V3 DSA 绨界珷锛歂OKEY, key ID b38a8516
婧栧倷涓?.. ########################################### [100%]
1:oracleasm-support ########################################### [ 33%]
2:oracleasm-2.6.9-78.ELsm########################################### [ 67%]
3:oracleasmlib ########################################### [100%]
[root@localhost asm]#
3.配置ASMLib:
/etc/init.d/oracleasm configure
[root@localhost asm]# /etc/init.d/oracleasm configure
以上操作将加载 oracleasm.o 驱动,并且mount 上ASM 文件系统,同时我们还可以通过以
下命令来手工的卸载和加载ASMLib
# /etc/init.d/oracleasm disable
4.创建ASM磁盘:
/etc/init.d/oracleasm createdisk DF1 /dev/sdc1
/etc/init.d/oracleasm createdisk DF2 /dev/sdd1
/etc/init.d/oracleasm createdisk DF3 /dev/sde1
/etc/init.d/oracleasm createdisk DF4 /dev/sdf1
[root@localhost asm]# /etc/init.d/oracleasm createdisk DF1 /dev/sdc1
Marking disk "DF1" as an ASM disk: [ OK ]
[root@localhost asm]# /etc/init.d/oracleasm createdisk DF2 /dev/sdd1
Marking disk "DF2" as an ASM disk: [ OK ]
[root@localhost asm]# /etc/init.d/oracleasm createdisk DF3 /dev/sde1
Marking disk "DF3" as an ASM disk: [ OK ]
[root@localhost asm]# /etc/init.d/oracleasm createdisk DF4 /dev/sdf1
Marking disk "DF4" as an ASM disk: [ OK ]
[root@localhost asm]#
scan并查看创建的ASM磁盘:
/etc/init.d/oracleasm scandisks
/etc/init.d/oracleasm listdisks
[root@localhost asm]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@localhost asm]# /etc/init.d/oracleasm listdisks
DF1
DF2
DF3
DF4
[root@localhost asm]#
四块ASM磁盘创建完成。
下面开始以oracle用户登录,来创建ASM实例和ASM的数据库。
5.root用户运行本地配置脚本,如果这里不运行的话,在安装ASM实例的时候就会弹出提示:
[oracle@localhost ~]$ echo $ORACLE_HOME
/oracle/oracle/product/10.2.0
[oracle@localhost ~]$
#cd /oracle/oracle/product/10.2.0/bin
#./localconfig add
[root@localhost 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.
localhost
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
[root@localhost bin]#
6.DBCA创建ASM实例
选择创建ASM,将DF1、DF2建为DATA组,DF3、DF4建为RECO组。ASM方式选择normal,如果为external,相当于没有ASM的软RAID服务。
7.DBCA创建ASM管理的数据库
存储选择ASM,数据文件组选择DATA,闪回恢复区选RECO。创建完成。如果打开OEM,则可以在OEM下面查看ASM实例和数据库实例,安装完成后在ORACLE_HOME/install/readme文件中有访问OEM的地址。
8.测试ASM:
[oracle@localhost install]$ export ORACLE_SID=+ASM
[oracle@localhost install]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 17 18:56:02 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
+ASM STARTED
SQL> select name,allocation_unit_size,total_mb from v$asm_diskgroup;
NAME ALLOCATION_UNIT_SIZE TOTAL_MB
------------------------------ -------------------- ----------
DATA 1048576 10228
RECO 1048576 10228
数据库中查看datafile:
[oracle@localhost install]$ export ORACLE_SID=asmdb1
[oracle@localhost install]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 17 18:58:16 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/asmdb1/datafile/system.256.823718933
+DATA/asmdb1/datafile/undotbs1.258.823718937
+DATA/asmdb1/datafile/sysaux.257.823718933
+DATA/asmdb1/datafile/users.259.823718937
SQL>

本文出自 “hunter的Oracle世界” 博客,转载请与作者联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: