网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Linuxudev动态管理OracleASM磁盘-实验

1       概述

Red Hat Enterprise Linux (RHEL) 6以前,Oracle都是采用ASMLib包来管理ASM磁盘。但是20115月甲骨文发表了一份声明,声明中称Oracle将不再提供Red Hat Enterprise Linux (RHEL) 6ASMLib包和相关更新。

成都一家集口碑和实力的网站建设服务商,拥有专业的企业建站团队和靠谱的建站技术,十余年企业及个人网站建设经验 ,为成都超过千家客户提供网页设计制作,网站开发,企业网站制作建设等服务,包括成都营销型网站建设,高端网站设计,同时也为不同行业的客户提供成都网站建设、做网站的服务,包括成都电商型网站制作建设,装修行业网站制作建设,传统机械行业网站建设,传统农业行业网站制作建设。在成都做网站,选网站制作建设服务商就选创新互联公司

甲骨文在这份声明中表示,ASMLib更新将通过Unbreakable Linux NetworkULN)来发布,并仅对Oracle Linux客户开放。ULN虽然为甲骨文和红帽的客户服务,但如果客户想要使用ASMLib,就必须使用Oraclekernel来替换掉红帽的kernel

 

本实验部署Oracle+ASM,不再采用ASMLib,而是采用udev动态管理ASM磁盘。

 

注意:Linux 内核 2.6以上才支持udev

 

虚拟机:VMware Workstation 9

操作系统:Red Hat Enterprise Linux Server release 5.6

系统内核:2.6.18-238.el5

数据库:Oracle Database 11.2.0.1

 

2       实验步骤

之前已经基于udev的方式创建过ASM磁盘,而且已经安装好Oracle Grid Oracle Database,并创建好了数据库,接下来将添加41G磁盘,分别扩展现有ASM磁盘组DG_DATA,新建ASM磁盘组DG_NEW_DATA

 

查看新添加的磁盘,分别为/dev/sdb/dev/sdg/dev/sdh/dev/sdi

 

[root@ora32 dev]# fdisk -l

 

Disk /dev/sda: 23.6 GB, 23622320128 bytes

255 heads, 63 sectors/track, 2871 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sda1  *          1         65     522081  83 Linux

/dev/sda2             66        457    3148740   82 Linux swap / Solaris

/dev/sda3            458       2871   19390455  8e Linux LVM

 

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdb doesn't contain a valid partition table

 

Disk /dev/sdc: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdc1              1        261    2096451  83 Linux

 

Disk /dev/sdd: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdd1              1        261    2096451  83 Linux

 

Disk /dev/sde: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sde1              1        261    2096451  83 Linux

 

Disk /dev/sdf: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdf1              1        261    2096451  83 Linux

 

Disk /dev/sdg: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdg doesn't contain a valid partition table

 

Disk /dev/sdh: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdh doesn't contain a valid partition table

 

Disk /dev/sdi: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdi doesn't contain a valid partition table

 

 

 

分别对4块磁盘进行分区,每块磁盘分1个区即可。

[root@ora32 dev]# fdisk -l

 

Disk /dev/sda: 23.6 GB, 23622320128 bytes

255 heads, 63 sectors/track, 2871 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sda1  *          1         65     522081  83 Linux

/dev/sda2             66        457    3148740  82 Linux swap / Solaris

/dev/sda3            458       2871   19390455  8e Linux LVM

 

Disk /dev/sdb: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdb1              1        130    1044193+ 83 Linux

 

Disk /dev/sdc: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdc1               1        261    2096451  83 Linux

 

Disk /dev/sdd: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdd1              1        261    2096451  83 Linux

 

Disk /dev/sde: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sde1              1        261    2096451  83 Linux

 

Disk /dev/sdf: 2147 MB, 2147483648 bytes

255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdf1              1        261    2096451  83 Linux

 

Disk /dev/sdg: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdg1              1        130    1044193+ 83 Linux

 

Disk /dev/sdh: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdh2              1        130    1044193+ 83 Linux

 

Disk /dev/sdi: 1073 MB, 1073741824 bytes

255 heads, 63 sectors/track, 130 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

  Device Boot     Start        End     Blocks  Id System

/dev/sdi1              1        130    1044193+ 83 Linux

 

现在需要通过udev来管理这几个磁盘设备文件,通过规则文件将磁盘映射为固定名称,并赋予所属用户,用户组,操作权限等。

查看udev规则文件

[root@ora32 dev]# cd /etc/udev/rules.d

[root@ora32 rules.d]# ll

total 248

-rw-r--r-- 1 root root  515 Nov 25 2010 05-udev-early.rules

-rw-r--r-- 1 root root  948 Dec 8 2010 40-multipath.rules

-rw-r--r-- 1 root root 16153 Nov 25 2010 50-udev.rules

-rw-r--r-- 1 root root  163 Dec 11 2010 51-dlm.rules

-rw-r--r-- 1 root root  471 Nov 25 2010 51-hotplug.rules

-rw-r--r-- 1 root root  138 May 10 17:28 55-usm.rules

-rw-r--r-- 1 root root 58016 Oct 13 2006 60-libsane.rules

-rw-r--r-- 1 root root  143 Oct 13 2010 60-net.rules

-rw-r--r-- 1 root root 1088 Jul 18 2006 60-pcmcia.rules

-rw-r--r-- 1 root root  316 Sep 22 2010 60-raw.rules

-rw-r--r-- 1 root root 9175 Nov 13 2010 60-wacom.rules

-rw-r--r-- 1 root root  129 Nov 30 2010 61-uinput-stddev.rules

-rw-r--r-- 1 root root  214 Nov 30 2010 61-uinput-wacom.rules

-rw-r--r-- 1 root root 1823 Sep 19 2008 85-pcscd_ccid.rules

-rw-r--r-- 1 root root  114 Aug 29 2008 90-alsa.rules

-rw-r--r-- 1 root root   61 Nov 25 2010 90-dm.rules

-rw-r--r-- 1 root root   82 Nov 4 2010 90-hal.rules

-rw-r--r-- 1 root root  107 Nov 25 2010 95-pam-console.rules

-rw-r--r-- 1 root root  292 Nov 30 2010 98-kexec.rules

-rw-r--r-- 1 root root  669 May 13 13:51 99-oracle-asmdevices.rules

-rw-r--r-- 1 root root   60 Sep 16 2012 99-oracle.rules

-rw-r--r-- 1 root root  334 Sep 15 2012 99-vmware-scsi-udev.rules

-rw-r--r-- 1 root root 2319 Jul 9 2008 bluetooth.rules

 

udev规则文件“99-oracle-asmdevices.rules”之前已经创建好,看一下当前的映射规则和ASM磁盘情况。

[root@ora32 rules.d]# cat 99-oracle-asmdevices.rules

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c29c9a269653c7cd04ea2edb0c71", NAME="ASM_DISK_2G_1", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c29861258ebc95eded634a1f36fd", NAME="ASM_DISK_2G_2", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c296fd09d9ed213df1999820ca89", NAME="ASM_DISK_2G_3", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c2934ae12fd4af0dd366d85b42f5", NAME="ASM_DISK_2G_4", WNER="grid", GROUP="asmadmin", MODE="0660"

 

规则解释,以第一条为例。

系统启动时,udev根据系统总线scsi(BUS=="scsi")和内核设备文件名sd?1(KERNEL=="sd?1"),过滤出需要动态映射的设备,然后再利用/sbin/scsi_id(PROGRAM=="/sbin/scsi_id")命令输出的SCSI磁盘id,输出结果中匹配上"36000c29c9a269653c7cd04ea2edb0c71"的SCSI磁盘,则会应用后续的命名、授权等操作(NAME="ASM_DISK_2G_1", WNER="grid", GROUP="asmadmin", MODE="0660"),SCSI磁盘ID可以通过/sbin/scsi_id命令获取。

 

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdc/sdc1

36000c29c9a269653c7cd04ea2edb0c71

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdd/sdd1

36000c29861258ebc95eded634a1f36fd

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sde/sde1

36000c296fd09d9ed213df1999820ca89

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdf/sdf1

36000c2934ae12fd4af0dd366d85b42f5

 

从上述结果可以看出,udev已经做了如下映射关系。

/block/sdc/sdc1 => ASM_DISK_2G_1

/block/sdd/sdd1 => ASM_DISK_2G_2

/block/sde/sde1 => ASM_DISK_2G_3

/block/sdf/sdf1 => ASM_DISK_2G_4

 

[grid@ora32 dev]$ ll ASM*

brw-rw---- 1 grid asmadmin 8, 33 May 13 14:57 ASM_DISK_2G_1

brw-rw---- 1 grid asmadmin 8, 49 May 13 14:57 ASM_DISK_2G_2

brw-rw---- 1 grid asmadmin 8, 65 May 13 14:54 ASM_DISK_2G_3

brw-rw---- 1 grid asmadmin 8, 81 May 13 14:57 ASM_DISK_2G_4

 

通过Oracle视图看一下当前磁盘组、磁盘的使用情况。

[grid@ora32 ~]$ sqlplus / as sysasm

 

SQL*Plus: Release 11.2.0.1.0 Production on Mon May 13 14:54:01 2013

 

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

 

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Automatic Storage Management option

 

SQL>

SQL>

SQL> col name for a10

SQL> SELECT group_number,name,type,state,total_mb,free_mb,offline_disks FROM V$ASM_diskgroup;

 

GROUP_NUMBER NAME      TYPE  STATE        TOTAL_MB   FREE_MB OFFLINE_DISKS

------------ ---------- ------ ----------- ---------- ---------- -------------

          1 DG_DATA   EXTERN MOUNTED          8188      6448            0

 

 

SQL> col group# for 99

SQL> col disk# for 99

SQL> col name for a5

SQL> col path for a11

SQL> col LABEL for a7

SQL> col FAILGROUP for a10

SQL> select GROUP_NUMBER group#,DISK_NUMBER disk#,LABEL,STATE,FAILGROUP,name,path,TOTAL_MB,FREE_MB from v$asm_disk;

 

GROUP# DISK# LABEL  STATE   FAILGROUP NAME PATH         TOTAL_MB   FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

    1    2        NORMAL  DG_DATA_00 DG_DA /dev/ASM_DI      2047      1612

                             02        TA_00 SK_2G_3

                                        02

 

    1    3        NORMAL  DG_DATA_00 DG_DA /dev/ASM_DI      2047      1611

                             03        TA_00 SK_2G_4

                                        03

 

    1    1        NORMAL  DG_DATA_00 DG_DA /dev/ASM_DI      2047      1613

                             01        TA_00 SK_2G_2

                                        01

 

GROUP# DISK# LABEL  STATE   FAILGROUP NAME PATH         TOTAL_MB   FREE_MB

------ ----- ------- -------- ---------- ----- ----------- ---------- ----------

 

    1    0        NORMAL  DG_DATA_00 DG_DA /dev/ASM_DI      2047      1612

                             00        TA_00 SK_2G_1

                                        00

 

现将新增的4块硬盘通过udev映射为需要的设备文件,然后将其中2块增加到ASM磁盘组DG_DATA中,另外2块则新建一个ASM磁盘组DG_NEW_DATA。

 

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdb/sdb1

36000c2968513d97eb7cdd25bdbd10600

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdg/sdg1

36000c29682ba5ec7a4c8a189499a89bb

[root@ora32 rules.d]# /sbin/scsi_id -g -s /block/sdh/sdh2

36000c292aa4a4ebbb25d15d2084c01ca

[root@ora32 rules.d]# /sbin/scsi_id -g -s /blokc/sdi/sdi1

 

新增设备映射规则

[root@ora32 rules.d]# vi 99-oracle-asmdevices.rules

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c29c9a269653c7cd04ea2edb0c71", NAME="ASM_DISK_2G_1", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c29861258ebc95eded634a1f36fd", NAME="ASM_DISK_2G_2", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c296fd09d9ed213df1999820ca89", NAME="ASM_DISK_2G_3", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c2934ae12fd4af0dd366d85b42f5", NAME="ASM_DISK_2G_4", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c2968513d97eb7cdd25bdbd10600", NAME="ASM_DISK_1G_1", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c29682ba5ec7a4c8a189499a89bb", NAME="ASM_DISK_1G_2", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c292aa4a4ebbb25d15d2084c01ca", NAME="ASM_DISK_1G_3", WNER="grid", GROUP="asmadmin", MODE="0660"

 

KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id",

RESULT=="36000c29a98ca1bd8a0012e99f992a19d", NAME="ASM_DISK_1G_4", WNER="grid", GROUP="asmadmin", MODE="0660"

 

 

如果是第一次配置udev映射关系,需要如下操作。

1、 在目录/etc/udev/rules.d/中新建99-oracle-asmdevices.rules文件。

2、配置SCSI设备为可信任设备,配置/etc/scsi_id.config文件,添加options=-g配置项。

[root@ora32 rules.d]# cat /etc/scsi_id.config

#

# scsi_id configuration

#

# lower or upper case has no affect on the left side. Quotes (") are

# required for spaces in values. Model is the same as the SCSI

# INQUIRY product identification field. Per the SCSI INQUIRY, the vendor

# is limited to 8 bytes, model to 16 bytes.

#

# The first matching line found is used. Short matches match longer ones,

# if you do not want such a match space fill the extra bytes. If no model

# is specified, only the vendor string need match.

#

# ptions=

# vendor=string[,model=string],options=

 

# some libata drives require vpd page 0x80

vendor="ATA",options=-p 0x80

options=-g

 

测试udev能否正确映射

[root@ora32 ~]# testudev /block/sdg/sdg1

-bash: testudev: command not found

[root@ora32 ~]# udevtest /block/sdb/sdb1

main: looking at device '/block/sdb/sdb1' from subsystem 'block'

udev_rules_get_name: add symlink 'disk/by-id/scsi-36000c2968513d97eb7cdd25bdbd10600-part1'

udev_rules_get_name: add symlink 'disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1'

run_program: '/lib/udev/vol_id --export /dev/.tmp-8-17'

run_program: '/lib/udev/vol_id' returned with status 4

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

udev_rules_get_name: rule applied, 'sdb1' becomes 'ASM_DISK_1G_1'

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

run_program: '/sbin/scsi_id'

run_program: '/sbin/scsi_id' (stdout) '36000c2968513d97eb7cdd25bdbd10600'

run_program: '/sbin/scsi_id' returned with status 0

udev_device_event: device '/block/sdb/sdb1' already in database, validate currently present symlinks

udev_node_add: creating device node '/dev/ASM_DISK_1G_1', major = '8', minor = '17', mode = '0660', uid = '503', gid = '504'

udev_node_add: creating symlink '/dev/disk/by-id/scsi-36000c2968513d97eb7cdd25bdbd10600-part1' to '../../ASM_DISK_1G_1'

udev_node_add: creating symlink '/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1' to '../../ASM_DISK_1G_1'

main: run: 'socket:/org/kernel/udev/monitor'

main: run: '/lib/udev/udev_run_devd'

main: run: 'socket:/org/freedesktop/hal/udev_event'

main: run: '/sbin/pam_console_apply /dev/ASM_DISK_1G_1 /dev/disk/by-id/scsi-36000c2968513d97eb7cdd25bdbd10600-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1'

main: run: '/bin/sh -c 'echo 180 >/sys/block/sdb/sdb1/timeout''

 

 

 

[root@ora32 ~]# udevtest /block/sdg/sdg1

main: looking at device '/block/sdg/sdg1' from subsystem 'block'

udev_rules_get_name: add symlink 'disk/by-id/scsi-36000c29682ba5ec7a4c8a189499a89bb-part1'

udev_rules_get_name: add symlink 'disk/by-path/pci-0000:00:10.0-scsi-0:0:6:0-part1'

run_program: '/lib/udev/vol_id --export /dev/.tmp-8-97'

run_program: '/lib/udev/vol_id' returned with status 4

run_program: '/sbin/scsi_id'


标题名称:Linuxudev动态管理OracleASM磁盘-实验
标题路径:http://bjjierui.cn/article/jihihs.html