当前位置:Gxlcms > mysql > 使用ASM管理方式创建Oracle数据库

使用ASM管理方式创建Oracle数据库

时间:2021-07-01 10:21:17 帮助过:87人阅读

10G以后Oracle推出了使用ASM(Auto Storage Management)管理的存储方式,随着Oralce版本的不断变更,ASM存储管理方式也越来越稳定.下

环境:

OS:Red Hat Linux As 5

DB:Oracle 10.2.0.4

10G以后Oracle推出了使用ASM(Auto Storage Management)管理的存储方式,随着Oralce版本的不断变更,ASM存储管理方式也越来越稳定.下面介绍如何使用ASM的管理方式创建单实例数据库.

----------------------------------创建ASM磁盘部分----------------------------------------

1.安装Asmlib

安装AsmlibB那个版本需要根据OS的内核版本来确定,这里我的操作系统内核版本如下:

[root@hxl asm]# uname -a
Linux hxl 2.6.18-8.el5xen #1 SMP Fri Jan 26 14:42:21 EST 2007 i686 i686 i386 GNU/Linux

选择安装的Asmlib包如下,在root用户下按照如下顺序执行,否则会报需要依赖的提示.

[root@hxl asm]#rpm -ivh oracleasm-support-2.1.7-1.el5.i386.rpm
[root@hxl asm]#rpm -ivh oracleasm-2.6.18-8.el5xen-2.0.4-1.el5.i686.rpm
[root@hxl asm]#rpm -ivh oracleasmlib-2.0.4-1.el5.i386.rpm
以上这些安装包可以到Oracle官网下载.

2.添加裸设备

编辑/etc/udev/rules.d/60-raw.rules文件添加如下内容

ACTION=="add", KERNEL=="sdb1",RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc1",RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1",RUN+="/bin/raw /dev/raw/raw3 %N"

设置裸设备权限给oracle用户,需要添加如下内容
KERNEL=="raw[1-3]*", OWNER="oracle" GROUP="oinstall", MODE="0660"

这里的sdb1 sdc1 sdd1 是新加入的磁盘分区,添加硬盘后可以使用fdisk创建分区(具体步骤省略),这里不需要格式化.

将如上内容添加到/etc/udev/rules.d/60-raw.rules后,执行如下命令使其生效.

[root@hxl asm]#start_udev

查看映射
[root@hxl]# raw -qa
/dev/raw/raw1: bound to major 8, minor 17
/dev/raw/raw2: bound to major 8, minor 33
/dev/raw/raw3: bound to major 8, minor 49

这个时候裸设备添加完成, 下面继续Asmlib的配置.

3.设置ASMlib驱动

[root@hxl oracle]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting without typing an
answer will keep that current value. Ctrl-C will abort.

Default user to own the driver interface [oracle]:
Default group to own the driver interface [oinstall]:
Start Oracle ASM library driver on boot (y/n) [y]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]

4.设置自动启动和关闭
#cd /etc/rc5.d 默认进入的是图形界面
[root@hxl rc5.d]# ln -s /etc/rc.d/init.d/oracleasm S99oracleasm
[root@hxl rc5.d]# ln -s /etc/rc.d/init.d/oracleasm K01oracleasm

[root@hxl rc5.d]# lsmod |grep oracleasm
oracleasm 44692 1
[root@hxl rc5.d]# dmesg |grep oracleasm
ASM: oracleasmfs mounted with options:

5.创建ASM磁盘(说明:createdisk 是针对分区,不是针对磁盘,即:先应将磁盘分区)

[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "VOL1" as an ASM disk: [ OK ]
[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
Marking disk "VOL2" as an ASM disk: [ OK ]
[root@hxl oracle]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "VOL3" as an ASM disk: [FAILED]

小插曲,在创建VOL3的时候提示失败,查看日志信息发现该设备在使用
[root@hxl oracle]#less /var/log/oracleasm

Instantiating disk: done
Unable to open device "/dev/sdd1": Device or resource busy
Unable to open device "/dev/sdd1": Device or resource busy

查看/etc/fstab发现/dev/sdd1 mount到了/u02,将该行注释掉,问题解决.

[root@hxl /]# more /etc/fstab
LABEL=/ / ext3 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=/u01 /u01 ext3 defaults 1 2
/dev/sdd1 /u02 ext3 defaults 1 2
LABEL=SWAP-sda2 swap swap defaults 0 0

人气教程排行