ASM驱动安装与ASM盘建立(一)
上一篇 / 下一篇 2011-04-14 20:53:33 / 个人分类:ASM
前段时间安装虚拟Linux上的ASM实例,中间反复了几次,不过最终解决了这部分的问题。现记录下来与大家分享。
ASM是Oracle针对数据存储提出的解决方案。区别于传统的Oracle数据库使用数据库实例进行文件管理,ASM体系专门建立了ASM实例。同数据库实例相似,ASM实例是由一系列后台进程和一块共享内存SGA组成,专门负责文件的读写。数据库实例(单个和多个)不需要直接进行数据在磁盘上的读写,而是只需要连接ASM实例,与ASM实例进行交互读写数据。ASM专门进行I/O负载和存储管理等系列工作。
环境说明
本环境使用VMWare虚拟机搭建的CentOS4.8。虚拟硬盘两块,分别为30G和10G。其中30G空间为操作系统和软件,10G第二块硬盘分区作为ASM盘。
规划方案:计划将第二块硬盘分为三个分区,各个分区大小相等。每个分区作为一个ASM盘,名称分别为VOL1、VOL2和VOL3。
此时,第一块磁盘sda划分为系统盘区sda1,挂入点为/目录。此时使用率为9%。另一个sda2为swap分区,空间大概为1.5G左右。
Last login: Wed Apr 6 23:26:00 2011 from 192.168.0.1
[root@asmlab ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 28G 2.3G 25G 9% /
none 498M 0 498M 0% /dev/shm
硬件信息
[root@asmlab dev]# ls -l | grep sd
brw-rw---- 1 root disk 8, 0 Apr 9 2011 sda
brw-rw---- 1 root disk 8, 1 Apr 9 2011 sda1
brw-rw---- 1 root disk 8, 2 Apr 9 2011 sda2
brw-rw---- 1 root disk 8, 16 Apr 9 2011 sdb
磁盘分区情况为:
[root@asmlab dev]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3686 29607763+ 83 Linux
/dev/sda2 3687 3915 1839442+ 82 Linux swap
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
进行ASM盘分区
首先需要根据规划方案,对sdb盘进行分区格式化操作。在linux上,可以使用fdisk命令,在交互的方式下进行磁盘分区。
[root@asmlab dev]# fdisk /dev/sdb --命令方式:fdisk <进行分区的磁盘文件>
The number of cylinders for this disk is set to 1566.
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 otherOSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m–查看一下命令方式
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n–新建立一个分区
Command action–要求输入新建主分区还是拓展分区,注意:一块硬盘上主分区只能有四个
e extended
p primary partition (1-4)
p//选择主分区
Partition number (1-4): 1//主分区编号输入
First cylinder (1-1566, default 1): 1//分区起始柱面,该硬盘可用的范围是1-1566;
Last cylinder or +size or +sizeM or +sizeK (1-1566, default 1566): 500//分区截止柱面
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2//输入第二个分区
First cylinder (501-1566, default 501): 501
Last cylinder or +size or +sizeM or +sizeK (501-1566, default 1566): 1000
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1001-1566, default 1001): 1001
Last cylinder or +size or +sizeM or +sizeK (1001-1566, default 1566): 1560
--注意:此时分区信息还没有正式写入,要求输入w命令后才能写入!
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
此时,分区信息为:
[root@asmlab dev]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3686 29607763+ 83 Linux
/dev/sda2 3687 3915 1839442+ 82 Linux swap
Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 500 4016218+ 83 Linux
/dev/sdb2 501 1000 4016250 83 Linux
/dev/sdb3 1001 1560 4498200 83 Linux
分区建立之后,还要用特定的文件系统格式进行分区格式化。
[root@asmlab dev]#mkfs.ext3/dev/sdb1//使用ext3格式进行格式化磁盘分区/dev/sdb1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
502944 inodes, 1004054 blocks
50202 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1031798784
31 block groups
32768 blocks per group, 32768 fragments per group
16224 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@asmlab dev]# mkfs.ext3 /dev/sdb2
180 days, whichever comes first. Use tune2fs -c or -i to override.
(篇幅所限,有删节…)
[root@asmlab dev]# mkfs.ext3 /dev/sdb3
mke2fs 1.35 (28-Feb-2004)
180 days, whichever comes first. Use tune2fs -c or -i to override.
(篇幅所限,有删节…)
准备好分区磁盘之后,就可以进行ASM驱动安装和ASM disk配置构建了。
ASM驱动安装与ASM盘建立(二)
上一篇 / 下一篇 2011-04-17 13:18:47 / 个人分类:ASM
ASM驱动安装
ASM管理的逻辑结构是两个层次,ASM磁盘组DiskGroup和ASM磁盘Disk。磁盘组是一个或者多个磁盘的集合。ASM磁盘对应的物理种类很多,比如分区、物理磁盘乃至裸设备等,都可以作为ASM磁盘的一种。
Oracle为ASM磁盘提供了识别的机制,就是我们要说的ASM驱动库包。ASMLib的作用就是标记某个磁盘或者存储设备是一个ASM磁盘,以及磁盘的名称。这样,在新建立ASM实例和DiskGroup的时候,可以更方便的识别。
从Linux4.x开始,Oracle就针对各个Linux内核提供ASMLib驱动。目前比较常用的Linux版本,如RedHat、CentOS等的用户,在安装Oracle ASM的时候是可以免费下载到ASMLib包的。但是从Linux6开始,也就是Oracle全力推广自己开发的Linux操作系统,就宣布不会针对新的其他版本Linux提供ASMLib支持,同时限制只有注册Linux用户才能下载到新版本的ASMLib。
但是,在一般情况下,不安装ASMLib也是可以顺利安装上ASM实例的。只是需要进行一些调整,本文就不加以累述了。我们实验环境是CentOS4.8,还是有免费的ASMLib支持的。
首先,检查确定所有Linux内核版本。
针对不同的Linux内核版本,Oracle是提供了不同的asmLib驱动支持的。首先要搞清楚使用的Linux内核版本,之后选择合适的版本下载。
[root@asmlab ~]# uname -r
2.6.9-89.ELsmp
[root@asmlab ~]# uname -a
Linux asmlab.localdomain2.6.9-89.ELsmp #1 SMP Mon Jun 22 12:32:43 EDT 2009 i686 i686 i386 GNU/Linu
可见此时使用的内核系列是2.6.89.Elsmp,请注意严格进行版本匹配。因为在2.6.89版本下,还有一系列的子版本。对ASMLib来说,是不承认的。
对Linux4.X系列的OS,可以选择到Oracle官方网站上进行下载。路径地址是:http://www.oracle.com/technetwork/topics/linux/downloads/rhel4-092650.html。该地址下提供了多种硬件平台、多种Kernel版本的ASM工具库。通常需要下载三个支持rpm包即可以,oracleasm-support、oracleasmlib和oracleasm。
我们实验模拟的是Intel x86 32位Linux,所以选择下面三个安装rpm文件。
//上传到指定Linux目录上
[root@asmlab upload]# ls
oracleasm-2.6.9-89.ELsmp-2.0.5-1.el4.i686.rpm
oracleasmlib-2.0.4-1.el4.i386.rpm
oracleasm-support-2.1.4-1.el4.i386.rpm
之后,依据顺序将三个rpm包进行安装。
[root@asmlab upload]# rpm -ivh oracleasm-support-2.1.4-1.el4.i386.rpm
warning: oracleasm-support-2.1.4-1.el4.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [100%]
[root@asmlab upload]# rpm -ivh oracleasm-2.6.9-89.ELsmp-2.0.5-1.el4.i686.rpm
warning: oracleasm-2.6.9-89.ELsmp-2.0.5-1.el4.i686.rpm: V3 DSA signature: NOKEY, key ID b38a8516
Preparing... ########################################### [100%]
1:oracleasm-2.6.9-89.ELsm########################################### [100%]
[root@asmlab upload]# rpm -ivh oracleasmlib-2.0.4-1.el4.i386.rpm
warning: oracleasmlib-2.0.4-1.el4.i386.rpm: V3 DSA signature: NOKEY, key ID b38a8516
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]
Linux中,rpm包就类似于windows下的可执行程序,而且是安装程序。安装rpm包之后,就可以使用ASM包工具对存储盘进行标识,创建ASM Disk。
首先可以进行ASM驱动配置。
//配置ASM参数
[root@asmlab ~]# /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 <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid//接口用户
Default group to own the driver interface []: dba//接口用户组
Start Oracle ASM library driver on boot (y/n) [n]: y//启动时是否加载ASM驱动程序
Scan for Oracle ASM disks on boot (y/n) [y]: y//启动时是否进行ASM磁盘扫描;
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
更换所有权。
[root@asmlab ~]# chown grid:asmadmin /dev/sdb1
[root@asmlab ~]# chown grid:asmadmin /dev/sdb2
[root@asmlab ~]# chown grid:asmadmin /dev/sdb3
开始创建ASM磁盘。
//创建系列ASM磁盘VOL1 VOL2和VOL3
[root@asmlab ~]# /usr/sbin/oracleasm createdisk VOL1 /dev/sdb1
Writing disk header: done
Instantiating disk: done
[root@asmlab ~]# /usr/sbin/oracleasm createdisk VOL2 /dev/sdb2
Writing disk header: done
Instantiating disk: done
[root@asmlab ~]# /usr/sbin/oracleasm createdisk VOL3 /dev/sdb3
Writing disk header: done
Instantiating disk: done
手工进行ASM磁盘扫描。
[root@asmlab ~]# /usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@asmlab ~]# /usr/sbin/oracleasm listdisks
VOL1
VOL2
VOL3
到此,ASM Disk建立完成。之后可以选择安装Oracle11g的Grid组件,在建立ASM DiskGroup的时候,就可以看到我们在此处建立的ASM盘。