【ASM】ASMLIB 系列

简介: 【ASM】ASMLIB 系列 使用ASMLIB管理磁盘 在存储管理员给服务器提供磁盘设备后,它们对于服务器来说是可用的并且可以在Linux系统中 的/proc/partitions虚拟文件中可以看到。

【ASM】ASMLIB 系列


使用ASMLIB管理磁盘

在存储管理员给服务器提供磁盘设备后,它们对于服务器来说是可用的并且可以在Linux系统中 的/proc/partitions虚拟文件中可以看到。系统管理然后使用Linux fdisk工具来对磁盘设备进行分 区。被分区后磁盘设备现在可以被配置为ASMLIB磁盘,系统管理员创建ASMLIB磁盘。创建命 令:oracleasm createdisk。createdisk命令使用两个输入参数,通过设备来生成用户定义的磁盘名:


[root@racnode1]#/etc/init.d/oracleasm createdisk VOL1 /dev/sdg1
Creating Oracle ASM disk "VOL1" [ OK ]

磁盘名被限制为30个字符。它们必须使用字母开头但可以由其它ASCII字符组成,包括:大写字母, 数字和下划线。每一个被创建成功的磁盘被标识为ASMLIB磁盘并且会被显示在oracleasm文件系统 中/dev/oracleasm/disks/。文件系统是一种特定的不受任何方式进行维护。

用户可查询磁盘设备来判断是否它们是有效的ASMLIB磁盘。为了查询,使用下面的oracleasm querydisk命令。querydisk命令可以应用于裸设备和ASMLIB磁盘

[root@racnode1]#/etc/init.d/oracleasm querydisk /dev/sdg1
Checking if device "/dev/sdg" is an Oracle ASM disk [ OK ]

[root@racnode1]#/etc/init.d/oracleasm querydisk VOL1
Checking for ASM disk "VOL1" [ OK ]

另外,所有被标记的磁盘与使用ASMLIB创建的磁盘可以使用以下oracleasm listdisks命令来显示:

[root@racnode1]#/etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3

如果一个磁盘设备不是一个ASMLIB磁盘,会显示以下信息:

[root@racnode1]#/etc/init.d/oracleasm querydisk /dev/sdh1
Checking if device "/dev/sdh1" is an Oracle ASM disk [FAILED]

对于ASM不再需要的磁盘可以撤消标记并且使用oracleasm deletedisk命令来删除:

[root@racnode1]#/etc/init.d/oracleasm deletedisk VOL1
Deleting Oracle ASM disk "VOL1" [ OK ]

当ASMLIB用于RAC环境时,对于RAC的共享磁盘架构允许使用oracleasm createdisk命令只在一个节点 上创建ASMLIB磁盘,其它节点只需要使用ASMLIB扫描来查找ASMLIB磁盘就可以了。例如,对于两节点 RAC环境,节点1可以标记ASMLIB磁盘,节点2然后执行扫描ASMLIB磁盘来查找这些ASMLIB磁盘。

[root@racnode1]#/etc/init.d/oracleasm createdisk VOL1 /dev/sdg1
Creating Oracle ASM disk "VOL1" [ OK ]

[root@racnode2]#/etc/init.d/oracleasm scandisks
Scanning system for ASM disks [ OK ]

在合适的ASMLIB磁盘创建后,ASM的init.ora参数asm_diskstring可以保留缺省的NULL或者设置 为'ORCL:*'。一旦设置后,ASM将可以发现以下磁盘:

SQL> select name, library, path from v$asm_disk;
NAME        LIBRARY                   PATH
----------- ------------------------- -------------------------
VOL1        ASM Library Generic Linux ORCL:VOL1
VOL2        ASM Library Generic Linux ORCL:VOL2
VOL3        ASM Library Generic Linux ORCL:VOL3

注意,如果ASMLIB没有使用,那么上面的查询LIBRARY列将返回"System"。

重命名Disk
renamedisk命令被用来改变现有成员的标签而不会丢失数据。注意修改磁盘时只有当ASM不访问该磁 盘才行。因此磁盘组必须dismount,并且在RAC环境中,所有ASM节点必须都dismount磁盘组。当有 ASM实例访问被重新标签的磁盘时执行renamedisk操作可能造成损坏。因为renamedisk命令是危险的 通过打印消息可以看到:

[root@racnode1]#/etc/init.d/oracleasm renamedisk /dev/sdb3 VOL1
Warning: Changing the label of a disk marked for ASM is a very
dangerous operation. If this is really what you mean to do, you
must ensure that all Oracle and ASM instances have ceased using
this disk. Otherwise, you may LOSE DATA. If you really wish to
change the label, rerun with the force-renamedisk command.

[root@racnode1]#/etc/init.d/oracleasm force-renamedisk /dev/sdb3 VOL1
Renaming disk "/dev/sdb3" to "VOL1" [ OK ]

force_renamedisk命令使用两个参数:裸设备名,其次是ASM磁盘名。

discover磁盘
命令/sbin/oracleasm-discover是一个简单的工具来判断Oracle的Linux ASMLIB在discover操作时所看到那个磁盘。这个命令更多一个调试工具来验证discover所列出的请求磁盘。这个命令也列出了每个磁盘的最大I/O大小。最大I/O大小,ASMLIB可以作为一个命令发送给设备。

[root@racnode1]#/usr/sbin/oracleasm-discover 'ORCL:*'
Using ASMLib from /opt/oracle/extapi/32/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.0 (KABI_V1)]
Discovered disk: ORCL:VOL1 [819200 blocks (419430400 bytes), maxio 512]
Discovered disk: ORCL:VOL2 [1955808 blocks (1001373696 bytes), maxio 512]

最大I/O大小来自SCSI HBA设备与磁盘设备链中的其它设备。在上面的例子中,maxio等于512,512 byte或256K。如果maxio显示了最小值,比如128,那么它可能是中间组件比如多路径设备或HBA设备限制的原因。

升级ASMLIB
为了升级ASMLIB,系统管理员可以执行以下步骤。注意这是严格意义上的软件升级并且没有磁盘标签 被维护。这是一个节点本地升级,因此在RAC环境中,每个单独的节点应该被升级。
1.关闭ASM
2.执行/etc/init.d/oracleasm stop
3.执行rpm -Uvh oracleasm-*.rpm
4.执行/etc/init.d/oracleasm start
5.启动ASM

诊断ASMLIB
诊断ASMLIB从上到下的操作步骤为:
1.使用的Oracle ASMLIB的当前版本。验证软件版本。ASMLIB请求一个设备精确匹配给内核,因此使 用与uname -a命令输出匹配的oracleasm内核包。

[root@racnode1]# rpm -qa |grep oracleasm
oracleasm-support-2.0.3-1.i386.rpm
oracleasmlib-2.0.2-1.i386.rpm
oracleasm-2.6.9-42.0.3.ELsmp-2.0.3-1.i686.rpm


[root@racnode1]# uname -a
Linux racnode1.us.oracle.com 2.6.9-42.0.3.ELsmp #1Thu May 15
17:03:45 EST 2006 i686 i686 i386 GNU/Linux

2.验证ASMLIB的安装设置

3.确保oracleasm configure命令正确运行,使用以下信息进行确认配置:
a.以root用户执行lsmod命令来显示加载的oracleasm模块。使用oracleasm模块"Used by"列会被设 置为1.

[root@db2 ~]# lsmod
Module                  Size  Used by
oracleasm              53591  1
8021q                  20994  0
garp                    7297  1 8021q
stp                     2256  1 garp
llc                     5608  2 garp,stp
cpufreq_ondemand        9398  80
ip6t_REJECT             4486  2
nf_conntrack_ipv6      10595  3
nf_defrag_ipv6         11368  1 nf_conntrack_ipv6
xt_state                1370  3
nf_conntrack           84658  2 nf_conntrack_ipv6,xt_state
ip6table_filter         1671  1
ip6_tables             19409  1 ip6table_filter
ipv6                  339024  660 ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
dm_round_robin          2531  34
dm_multipath           18562  18 dm_round_robin
uinput                  8917  0
sg                     30968  0
serio_raw               5631  0
iTCO_wdt                6353  0
iTCO_vendor_support     3030  1 iTCO_wdt
coretemp                6997  0
acpi_cpufreq           13345  0
freq_table              6987  2 cpufreq_ondemand,acpi_cpufreq
mperf                   1555  1 acpi_cpufreq
intel_powerclamp       10841  0
kvm_intel             130025  0
kvm                   438077  1 kvm_intel
crc32c_intel           14496  0
ghash_clmulni_intel     4707  0
microcode             115607  0
pcspkr                  2150  0
igb                   186225  0
hwmon                   2087  2 coretemp,igb
i2c_i801               12911  0
i2c_core               31228  1 i2c_i801
lpc_ich                12496  0
mfd_core                3955  1 lpc_ich
ioatdma                61937  168
dca                     7283  2 igb,ioatdma
i7core_edac            20072  0
edac_core              54168  1 i7core_edac
shpchp                 27901  0
ext4                  532546  2
jbd2                  100769  1 ext4
mbcache                 7575  1 ext4
sd_mod                 41045  38
crc_t10dif              1547  1 sd_mod
qla2xxx               562439  68
scsi_transport_fc      54538  1 qla2xxx
scsi_tgt               12075  1 scsi_transport_fc
sr_mod                 15980  0
cdrom                  40900  1 sr_mod
usb_storage            53806  0
megaraid_sas          101114  3
aesni_intel            45744  0
ablk_helper             2997  1 aesni_intel
cryptd                 10460  3 ghash_clmulni_intel,aesni_intel,ablk_helper
lrw                     4222  1 aesni_intel
aes_x86_64              7967  1 aesni_intel
xts                     3466  1 aesni_intel
gf128mul                7999  2 lrw,xts
pata_acpi               3782  0
ata_generic             3758  0
ata_piix               26525  0
dm_mirror              14208  0
dm_region_hash         11094  1 dm_mirror
dm_log                  9681  2 dm_mirror,dm_region_hash
dm_mod                 85047  41 dm_multipath,dm_mirror,dm_log

b.执行命令cat /proc/filesystem,并且确保在文件系统列表中存在一条名叫oracleasmfs的记录:

[root@db2 ~]# cat /proc/filesystems
nodev   sysfs
nodev   rootfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cpuset
nodev   tmpfs
nodev   devtmpfs
nodev   binfmt_misc
nodev   debugfs
nodev   securityfs
nodev   sockfs
nodev   pipefs
nodev   anon_inodefs
nodev   devpts
nodev   ramfs
nodev   hugetlbfs
        iso9660
nodev   pstore
nodev   mqueue
        ext4
nodev   asmdisk
nodev   oracleasmfs

c.执行命令 df -ha,它将显示所mount的oracleasmfs

/dev/mapper/vg_db2-LogVol00
                      1.1T  437G  592G  43% /
proc                     0     0     0    - /proc
sysfs                    0     0     0    - /sys
devpts                   0     0     0    - /dev/pts
tmpfs                 126G 1005M  125G   1% /dev/shm
/dev/sda1             190M   79M   98M  45% /boot
none                     0     0     0    - /proc/sys/fs/binfmt_misc
oracleasmfs              0     0     0    - /dev/oracleasm

确保oracleasm createdisk正确执行。为了让ASM使用,磁盘被通过createdisk命令来标记。当磁盘被标记后,会在磁盘头中写入签名--,磁盘将被标记ASM使用。可以使用以下命令来验证.执行oracleasm listdisks命令。这个命令将显示被标记为ASMLIB的磁盘。

[root@db2 ~]# oracleasm listdisks
ARCH0
ARCH1
ARCH2
ARCH3
CW_DATA1
OCR1
OCR2
OCR3
RLZY_ARCH1
RLZY_DATA1
RLZY_DATA2
RLZY_DATA3
SBK_DATA0
SBK_DATA1
SBK_DATA2
YB_DATA4
YB_DATA5

.对每个被标记为ASMLIB磁盘执行oracleasm querydisk命令来确保标记

[root@db2 ~]# oracleasm querydisk YB_DATA4
Disk "YB_DATA4" is a valid ASM disk

4.执行ls -l /dev/oracleasm/disks来确保磁盘的所属组与权限是grid:asmadmin

[root@db2 ~]# ls -l /dev/oracleasm/disks
total 0
brw-rw---- 1 grid asmadmin 252,  8 Dec  7 20:14 ARCH0
brw-rw---- 1 grid asmadmin 252,  9 Dec  7 20:17 ARCH1
brw-rw---- 1 grid asmadmin 252, 10 Dec  7 20:18 ARCH2
brw-rw---- 1 grid asmadmin 252, 11 Dec  7 20:18 ARCH3
brw-rw---- 1 grid asmadmin 252, 14 Dec  7 20:18 CW_DATA1
brw-rw---- 1 grid asmadmin 252,  1 Dec  7 20:18 OCR1
brw-rw---- 1 grid asmadmin 252,  2 Dec  7 20:18 OCR2
brw-rw---- 1 grid asmadmin 252,  6 Dec  7 20:18 OCR3
brw-rw---- 1 grid asmadmin 252,  7 Dec  7 20:18 RLZY_ARCH1
brw-rw---- 1 grid asmadmin 252,  3 Dec  7 20:18 RLZY_DATA1
brw-rw---- 1 grid asmadmin 252,  4 Dec  7 20:18 RLZY_DATA2
brw-rw---- 1 grid asmadmin 252,  5 Dec  7 20:18 RLZY_DATA3
brw-rw---- 1 grid asmadmin 252, 15 Dec  7 20:18 SBK_DATA0
brw-rw---- 1 grid asmadmin 252, 16 Dec  7 20:18 SBK_DATA1
brw-rw---- 1 grid asmadmin 252, 17 Dec  7 20:18 SBK_DATA2
brw-rw---- 1 grid asmadmin 252, 12 Dec  7 20:18 YB_DATA4
brw-rw---- 1 grid asmadmin 252, 13 Dec  7 20:18 YB_DATA5

5.验证ASMLIB发现字符串(可以在DBCA中指定或设置asm_diskstring参数)是否被设置ORCL:*或NUL。 如果ASM实例在运行,那么检查ASM的alert log查看是否正确设置。

6.对ASM alert log中关于发现所显示的任何信息使用Linux/Unix的grep命令。如果成功加载ASMLIB 将会显示以下信息:

Loaded ASM Library - Generic Linux, version 2.0.1 library for
ASMLIB interface

下面的查询显示被发现的ASMLIB磁盘:

SQL> SELECT LIBRARY, PATH FROM V$ASM_DISK;
LIBRARY                                     PATH
------------------------------------------- ----------------
ASM Library - Generic Linux, version 2.0.0.1 ORCL:VOL1
ASM Library - Generic Linux, version 2.0.0.1 ORCL:VOL2
ASM Library - Generic Linux, version 2.0.0.1 ORCL:VOL3

如果在Library列显示system,那么asm_diskstring没有设备--,ASMLIB不能用于访问磁盘。ASMLIB 需要通过磁盘符ORCL:*来访问磁盘。检查asm_diskstring是否设置为ORCL:*或NULL:

SQL> SELECT LIBRARY, PATH FROM V$ASM_DISK;
LIBRARY        PATH
-------------- -------------------------------------------------
System         /dev/oracleasm/disks/DATA1D1
System         /dev/oracleasm/disks/DATA1D2
System         /dev/oracleasm/disks/DATA1D3

7.查看ASM alert log中是否有以下错误信息:

ORA-15186: ASMLIB error function = [asm_open], error = [1],mesg = [Operation not  permitted]

这个消息通常意味着在/etc/init.d/oracleasm configure操作时ASMLIB配置权限不正确

迁移到ASMLIB
在许多情况下可能需要将一个"member"ASM裸磁盘转换为一个ASMLIB磁盘。例如,当安装ASMLIB后需 要执行。相反,如果需要卸载ASMLIB,可以将一个ASMLIB磁盘转换为一个标准的ASM磁盘。所有这种操 作不会损坏磁盘上的数据。然而,在转换之前必须将磁盘组dismount。

这种转换不会损坏数据因为磁盘上的结构和磁盘打开ASM所读取的信息。ASM读取磁盘头并且识别它属 于那个磁盘组。当一个磁盘被增加到一个磁盘组时,ASM将对磁盘写入一些信息。两个重要的条目是 磁盘标记与ASMLIB标签。所有ASM磁盘有一个标记ORCLSDISK印记在磁盘上面。如果标记已经存在,那 么磁盘可以当前被使用或者被ASM格式化了。这个标记可以由ASM或ASMLIB所创建。例如,当ASM在创 建磁盘组时使用一个磁盘作为一个裸设备时,ASM会自动增加这个标记。相反,当通过ASMLIB命 令/etc/init.d/oracleasm createdisk命令时磁盘会增加ASMLIB标记。不管使用那种工具创建标记, 一旦标记被创建,磁盘就会被打上标签。

磁盘头的第二部分与ASMLIB相关,是ASMLIB标签。这是指派给ASMLIB用来标识磁盘的24个字符的字符 串。当通过ASMLIB的/etc/init.d/oracleasm createdisk命令来配置磁盘时,相关的标签会被写入设备。注意ASM会保存磁盘的内容,但写入这部分信息是留给ASMLIB。

下面是一个对ASM磁盘(不是ASMLIB)的一个简单dump,这个磁盘被加入一个磁盘。在磁盘头中的ASM磁 盘名为DATA_0003:

[root@db2 ~]# dd if=/dev/mapper/yb_data4 bs=128 count=1 | od -a
1+0 records in
1+0 records out
0000000 soh stx soh soh nul nul nul nul etx nul nul nul   K eot   [   l
128 bytes (128 B) copied0000020   N   d   ? nul nul nul nul nul nul nul nul nul nul nul  nul nul
, 0.000253206 s, 506 kB/s
0000040   O   R   C   L   D   I   S   K nul nul nul nul nul nul nul nul
0000060 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
0000100 nul nul  sp  vt etx nul soh etx   D   A   T   A   _   0   0   0
0000120   3 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
0000140 nul nul nul nul nul nul nul nul   D   A   T   A nul nul nul nul
0000160 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
0000200
[root@db2 ~]#

下面例子使对使用/etc/init.d/oracleasm createdisk命令所创建的ASMLIB磁盘进行一个简单的dump 注意YB_DATA4被写入ORCLDISK标签中:

[root@db2 ~]# oracleasm querydisk -v -p  YB_DATA4
Disk "YB_DATA4" is a valid ASM disk
/dev/sdn: LABEL="YB_DATA4" TYPE="oracleasm"
/dev/sdae: LABEL="YB_DATA4" TYPE="oracleasm"
/dev/mapper/yb_data4: LABEL="YB_DATA4" TYPE="oracleasm"
[root@db2 ~]# dd if=/dev/mapper/yb_data4 bs=128 count=1 | od -a
1+0 records in
1+0 records out
128 bytes (128 B) copied, 0.000204442 s, 626 kB/s
0000000 soh stx soh soh nul nul nul nul etx nul nul nul   K eot   [   l
0000020   N   d   ? nul nul nul nul nul nul nul nul nul nul nul nul nul
0000040   O   R   C   L   D   I   S   K   Y   B   _   D   A   T   A   4
0000060 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
0000100 nul nul  sp  vt etx nul soh etx   D   A   T   A   _   0   0   0
0000120   3 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
0000140 nul nul nul nul nul nul nul nul   D   A   T   A nul nul nul nul
0000160 nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul nul
0000200

在这个例子中,标记ORCLDISK与YB_DATA4被写入磁盘头。下面ASMLIB扫描磁盘时,它将查看标记 ORCLDISK与YB_DATA4,并使用YB_DATA创建一个ASMLIB磁盘到设备的映射。后续,ASM将通过ASMLIB驱 动来发现这个磁盘。如果磁盘最初没有通过ASMLIB管理,当ASM发现磁盘时,将通过ASM裸设备访问, 它将检测试没有ASMLIB标记存在。这就是为什么从ASMLIB访问迁移到裸设备来访问不存在问题的原因 。

使用ASMLIB与Multipath工具
多路径设备使用伪设备来生成虚拟子路径。在执行磁盘发现操作时,ASMLIB使用伪文 件/proc/partitions。这是一个Linux文件它记录了所有设备与之匹配的分区。

[root@db2 ~]# cat /proc/partitions
major minor  #blocks  name

  11        0    1048575 sr0
  11        1    1048575 sr1
   8        0 1171062784 sda
   8        1     204800 sda1
   8        2   16777216 sda2
   8        3 1154079744 sda3
   8       64  629145600 sde
   8       48   10485760 sdd
   8       32   10485760 sdc
   8       80  629145600 sdf
   8       96  629145600 sdg
   8      112   10485760 sdh
   8      128  629145600 sdi
   8      144  629145600 sdj
   8      160  629145600 sdk
   8      176  629145600 sdl
   8      192  629145600 sdm
   8      224  629145600 sdo
   8      208  629145600 sdn
  65        0  629145600 sdq
   8      240  209715200 sdp
  65       16  629145600 sdr
  65       32  629145600 sds
  65       48   10485760 sdt
  65       64   10485760 sdu
  65       80  629145600 sdv
  65       96  629145600 sdw
  65      112  629145600 sdx
  65      128   10485760 sdy
  65      144  629145600 sdz
  65      160  629145600 sdaa
  65      176  629145600 sdab
  65      192  629145600 sdac
  65      208  629145600 sdad
  65      224  629145600 sdae
  65      240  629145600 sdaf
  66        0  209715200 sdag
  66       16  629145600 sdah
  66       32  629145600 sdai
  66       48  629145600 sdaj
 252        0 1154076672 dm-0
 252        1   10485760 dm-1
 252        2   10485760 dm-2
 252        3  629145600 dm-3
 252        4  629145600 dm-4
 252        5  629145600 dm-5
 252        6   10485760 dm-6
 252        7  629145600 dm-7
 252        8  629145600 dm-8
 252        9  629145600 dm-9
 252       10  629145600 dm-10
 252       11  629145600 dm-11
 252       12  629145600 dm-12
 252       13  629145600 dm-13
 252       14  209715200 dm-14
 252       15  629145600 dm-15
 252       16  629145600 dm-16
 252       17  629145600 dm-17

为了让多路径正确工作,ASMLIB必须只能对伪设备操作。因此ASMLIB必须使用伪设备来进行修改。通 过修改/etc/sysconfig/oracleasm中的两个参数来进行配置:
.oracleasm_scanorder使用通用前缀指定ASMLIB扫描设备的顺序。
.oracleasm_scanexclude通过ASMLIB指定那个设备不被发现。

例如,使用IBM v7000与多路径配置ASMLIB进行如下设置:
ORACLEASM_SCANORDER="dm"
ORACLEASM_SCANEXCLUDE="sd"

在这个例子中,ASMLIB基于/dev/dm来扫描磁盘并且排除/dev/sd*的设备。下面 是/etc/sysconfig/oracleasm文件的一个配置例子:

[root@db2 ~]# cat /etc/sysconfig/oracleasm
#
# This is a configuration file for automatic loading of the Oracle
# Automatic Storage Management library kernel driver.  It is generated
# By running /etc/init.d/oracleasm configure.  Please use that method
# to modify this file
#

# ORACLEASM_ENABLED: 'true' means to load the driver on boot.
ORACLEASM_ENABLED=true

# ORACLEASM_UID: Default user owning the /dev/oracleasm mount point.
ORACLEASM_UID=grid

# ORACLEASM_GID: Default group owning the /dev/oracleasm mount point.
ORACLEASM_GID=asmadmin

# ORACLEASM_SCANBOOT: 'true' means scan for ASM disks on boot.
ORACLEASM_SCANBOOT=true

# ORACLEASM_SCANORDER: Matching patterns to order disk scanning
ORACLEASM_SCANORDER="dm"

# ORACLEASM_SCANEXCLUDE: Matching patterns to exclude disks from scan
ORACLEASM_SCANEXCLUDE="sd"

# ORACLEASM_USE_LOGICAL_BLOCK_SIZE: 'true' means use the logical block size
# reported by the underlying disk instead of the physical. The default
# is 'false'
ORACLEASM_USE_LOGICAL_BLOCK_SIZE=false

小结:
ASMLIB是Oracle 10g与11g中ASM功能的支持library。ASMLIB允许Oracle数据库更有效的使用ASM与访 问磁盘组。ASMLIB的目的,它是ASM的一个插件,提供了一种识别与访问块设备的替接口。另外, ASMLIB API能够让存储与操作系统厂商来提供存储相关的扩展功能。这些功能可能提供一些好处,比 如提高性能与增加完整性。但ASMLIB对于ASM不是必须使用的。



3.3.1.4 Configuring Disks for Oracle ASM with ASMLIB

The Oracle Automatic Storage Management (Oracle ASM) library driver (ASMLIB) simplifies the configuration and management of the disk devices by eliminating the need to rebind disk devices used with Oracle ASM each time the system is restarted.

Without ASMLIB Linux 2.6 kernel and later, block device paths do not maintain permissions and path persistence unless you create a permissions or rules file on each cluster member node; block device paths that were /dev/sda can appear as /dev/sdb after a system restart. Adding new disks requires you to modify the udev file to provide permissions and path persistence for the new disk.

With ASMLIB, you define the range of disks you want to have made available as Oracle ASM disks. ASMLIB maintains permissions and disk labels that are persistent on the storage device, so that label is available even after an operating system upgrade. You can update storage paths on all cluster member nodes by running one oracleasm command on each node.

If you intend to use Oracle ASM on block devices for database storage for Linux, then Oracle recommends that you install the ASMLIB driver and associated utilities, and use them to configure the disks for Oracle ASM.

Caution:

On IBM: Linux on System z servers, due to a block size compatibility issue, you cannot use ASMLIB with SCSI storage devices and Fibre Channel Protocol (FCP) for Oracle Grid Infrastructure release 11.2.0.1 and later.

Workaround: use block device directly (for example, using paths similar to /dev/mapper/mpatha_part1), or use DASD disks.

See Also:

My Oracle Support notes How to Manually Configure Disk Storage devices for use with Oracle ASM 11.2 on IBM: Linux on System z under SLES (Doc ID 1350008.1 ) and How to Manually Configure Disk Storage devices for use with Oracle ASM 11.2 on IBM: Linux on System z under Red Hat 5 (Doc ID 1351746.1 ), available at the following URL:

https://support.oracle.com

To use the Oracle Automatic Storage Management library driver (ASMLIB) to configure Oracle ASM devices, complete the following tasks.

Note:

To create a database during the installation using the Oracle ASM library driver, you must choose an installation method that runs ASMCA in interactive mode. You must also change the default disk discovery string to ORCL:*.
3.3.1.4.1 Installing and Configuring the Oracle ASM Library Driver Software

ASMLIB is already included with Unbreakable Enterprise Kernel packages, and with SUSE 11. If you are a member of the Unbreakable Linux Network, then you can install the ASMLIB rpms by subscribing to the Oracle Software for Enterprise Linux channel, and using up2date to retrieve the most current package for your system and kernel. For additional information, refer to the following URL:

http://www.oracle.com/technetwork/topics/linux/asmlib/index-101839.html 

To install and configure the ASMLIB driver software manually, follow these steps:

  1. Enter the following command to determine the kernel version and architecture of the system:

    # uname -rm
    
  2. Download the required ASMLIB packages from the Oracle Technology Network (OTN) Web site:

    http://www.oracle.com/technetwork/server-storage/linux/downloads/index-088143.html 

    Note:

    You must install oracleasm-support package version 2.0.1 or later to use ASMLIB on Red Hat Enterprise Linux 5 Advanced Server. ASMLIB is already included with SUSE distributions.

    Tip:

    My Oracle Support note 1089399.1 for information about ASMLIB support with Red Hat distributions:

    https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=1089399.1

    You must install the following packages, where version is the version of the ASMLIB driver, arch is the system architecture, and kernel is the version of the kernel that you are using:

    oracleasm-support-version.arch.rpm
    oracleasm-kernel-version.arch.rpm
    oracleasmlib-version.arch.rpm
    
  3. Switch user to the root user:

    $ su -
    
  4. Enter a command similar to the following to install the packages:

    # rpm -ivh oracleasm-support-version.arch.rpm \
               oracleasm-kernel-version.arch.rpm \
               oracleasmlib-version.arch.rpm
    

    For example, if you are using the Red Hat Enterprise Linux 5 AS kernel on an AMD64 system, then enter a command similar to the following:

    # rpm -ivh oracleasm-support-2.1.3-1.el5.x86_64.rpm \
         oracleasm-2.6.18-194.26.1.el5xen-2.0.5-1.el5.x86_64.rpm \
         oracleasmlib-2.0.4-1.el5.x86_64.rpm
    
  5. Enter the following command to run the oracleasm initialization script with the configure option:

    # /usr/sbin/oracleasm configure -i
    

    Note:

    The oracleasm command in /usr/sbin is the command you should use. The /etc/init.d path is not deprecated, but the oracleasm binary in that path is now used typically for internal commands.
  6. Enter the following information in response to the prompts that the script displays:

    Prompt Suggested Response
    Default user to own the driver interface: Standard groups and users configuration: Specify the Oracle software owner user (for example, oracle)

    Job role separation groups and users configuration: Specify the Grid Infrastructure software owner (for example, grid)

    Default group to own the driver interface: Standard groups and users configuration: Specify the OSDBA group for the database (for example, dba).

    Job role separation groups and users configuration: Specify the OSASM group for storage administration (for example, asmadmin).

    Start Oracle ASM Library driver on boot (y/n): Enter y to start the Oracle Automatic Storage Management library driver when the system starts.
    Scan for Oracle ASM disks on boot (y/n) Enter y to scan for Oracle ASM disks when the system starts.

    The script completes the following tasks:

    • Creates the /etc/sysconfig/oracleasm configuration file

    • Creates the /dev/oracleasm mount point

    • Mounts the ASMLIB driver file system

      Note:

      The ASMLIB driver file system is not a regular file system. It is used only by the Oracle ASM library to communicate with the Oracle ASM driver.
  7. Enter the following command to load the oracleasm kernel module:

    # /usr/sbin/oracleasm init
    
  8. Repeat this procedure on all nodes in the cluster where you want to install Oracle RAC.

3.3.1.4.2 Configuring Disk Devices to Use Oracle ASM Library Driver on x86 Systems

To configure the disk devices to use in an Oracle ASM disk group, follow these steps:

  1. If you intend to use IDE, SCSI, or RAID devices in the Oracle ASM disk group, then follow these steps:

    1. If necessary, install or configure the shared disk devices that you intend to use for the disk group and restart the system.

    2. To identify the device name for the disks to use, enter the following command:

      # /sbin/fdisk -l
      

      Depending on the type of disk, the device name can vary:

      Disk Type Device Name Format Description
      IDE disk
      /dev/hdxn 
      In this example, x is a letter that identifies the IDE disk and n is the partition number. For example, /dev/hda is the first disk on the first IDE bus.
      SCSI disk
      /dev/sdxn 
      In this example, x is a letter that identifies the SCSI disk and n is the partition number. For example, /dev/sda is the first disk on the first SCSI bus.
      RAID disk
      /dev/rd/cxdypz /dev/ida/cxdypz 
      Depending on the RAID controller, RAID devices can have different device names. In the examples shown, x is a number that identifies the controller, y is a number that identifies the disk, and z is a number that identifies the partition. For example, /dev/ida/c0d1 is the second logical drive on the first controller.

      To include devices in a disk group, you can specify either whole-drive device names or partition device names.

      Note:

      Oracle recommends that you create a single whole-disk partition on each disk.
    3. Use either fdisk or parted to create a single whole-disk partition on the disk devices.

  2. Enter a command similar to the following to mark a disk as an Oracle ASM disk:

    # /usr/sbin/oracleasm createdisk DISK1 /dev/sdb1
    

    In this example, DISK1 is the name you assign to the disk.

    Note:

    The disk names that you specify can contain uppercase letters, numbers, and the underscore character. They must start with an uppercase letter.

    If you are using a multi-pathing disk driver with Oracle ASM, then make sure that you specify the correct logical device name for the disk.

  3. To make the disk available on the other nodes in the cluster, enter the following command as root on each node:

    # /usr/sbin/oracleasm scandisks
    

    This command identifies shared disks attached to the node that are marked as Oracle ASM disks.

3.3.1.4.3 Configuring Disk Devices to Use ASM Library Driver on IBM: Linux on System z
  1. If you formatted the DASD with the compatible disk layout, then enter a command similar to the following to create a single whole-disk partition on the device:

    # /sbin/fdasd -a /dev/dasdxxxx
    
  2. Enter a command similar to the following to mark a disk as an ASM disk:

    # /etc/init.d/oracleasm createdisk DISK1 /dev/dasdxxxx
    

    In this example, DISK1 is a name that you want to assign to the disk.

    Note:

    The disk names that you specify can contain uppercase letters, numbers, and the underscore character. They must start with an uppercase letter.

    If you are using a multi-pathing disk driver with ASM, then make sure that you specify the correct logical device name for the disk.

  3. To make the disk available on the other cluster nodes, enter the following command as root on each node:

    # /etc/init.d/oracleasm scandisks
    

    This command identifies shared disks attached to the node that are marked as ASM disks.

3.3.1.4.4 Administering the Oracle ASM Library Driver and Disks

To administer the Oracle Automatic Storage Management library driver (ASMLIB) and disks, use the oracleasm initialization script with different options, as described in Table 3-7.

Table 3-7 ORACLEASM Script Options

Option Description
configure

Use the configure option to reconfigure the Oracle Automatic Storage Management library driver, if necessary:

# /usr/sbin/oracleasm configure -i

To see command options, enter oracleasm configure without the -i flag.

enable
disable

Use the disable and enable options to change the actions of the Oracle Automatic Storage Management library driver when the system starts. The enable option causes the Oracle Automatic Storage Management library driver to load when the system starts:

# /usr/sbin/oracleasm enable
start
stop
restart

Use the start, stop, and restart options to load or unload the Oracle Automatic Storage Management library driver without restarting the system:

# /usr/sbin/oracleasm restart
createdisk

Use the createdisk option to mark a disk device for use with the Oracle Automatic Storage Management library driver and give it a name:

# /usr/sbin/oracleasm createdisk DISKNAME devicename 
deletedisk

Use the deletedisk option to unmark a named disk device:

# /usr/sbin/oracleasm deletedisk DISKNAME 

Caution: Do not use this command to unmark disks that are being used by an Oracle Automatic Storage Management disk group. You must delete the disk from the Oracle Automatic Storage Management disk group before you unmark it.

querydisk

Use the querydisk option to determine if a disk device or disk name is being used by the Oracle Automatic Storage Management library driver:

# /usr/sbin/oracleasm querydisk {DISKNAME | devicename}
listdisks

Use the listdisks option to list the disk names of marked Oracle Automatic Storage Management library driver disks:

# /usr/sbin/oracleasm listdisks
scandisks

Use the scandisks option to enable cluster nodes to identify which shared disks have been marked as Oracle Automatic Storage Management library driver disks on another node:

# /usr/sbin/oracleasm scandisks

3.3.1.5 Configuring ASMLIB for Multipath Disks

Additional configuration is required to use the Oracle Automatic Storage Management library Driver (ASMLIB) with third party vendor multipath disks.

See Also:

My Oracle Support site for updates to supported storage options:
https://support.oracle.com 
3.3.1.5.1 About Using Oracle ASM with Multipath Disks

Oracle ASM requires that each disk is uniquely identified. If the same disk appears under multiple paths, then it causes errors. In a multipath disk configuration, the same disk can appear three times:

  1. The initial path to the disk

  2. The second path to the disk

  3. The multipath disk access point.

For example: If you have one local disk, /dev/sda, and one disk attached with external storage, then your server shows two connections, or paths, to that external storage. The Linux SCSI driver shows both paths. They appear as /dev/sdb and /dev/sdc. The system may access either /dev/sdb or /dev/sdc, but the access is to the same disk.

If you enable multipathing, then you have a multipath disk (for example, /dev/multipatha), which can access both /dev/sdb and /dev sdc; any I/O to multipatha can use either the sdb or sdc path. If a system is using the /dev/sdb path, and that cable is unplugged, then the system shows an error. But the multipath disk will switch from the /dev/sdb path to the /dev/sdc path.

Most system software is unaware of multipath configurations. They can use any paths (sdb, sdc or multipatha). ASMLIB also is unaware of multipath configurations.

By default, ASMLIB recognizes the first disk path that Linux reports to it, but because it imprints an identity on that disk, it recognizes that disk only under one path. Depending on your storage driver, it may recognize the multipath disk, or it may recognize one of the single disk paths.

Instead of relying on the default, you should configure Oracle ASM to recognize the multipath disk.

3.3.1.5.2 Disk Scan Ordering

The ASMLIB configuration file is located in the path /etc/sysconfig/oracleasm. It contains all the startup configuration you specified with the command /etc/init.d/oracleasm configure. That command cannot configure scan ordering.

The configuration file contains many configuration variables. The ORACLEASM_SCANORDER variable specifies disks to be scanned first. The ORACLEASM_SCANEXCLUDE variable specifies the disks that are to be ignored.

Configure values for ORACLEASM_SCANORDER using space-delimited prefix strings. A prefix string is the common string associated with a type of disk. For example, if you use the prefix string sd, then this string matches all SCSI devices, including /dev/sda, /dev/sdb, /dev/sdc and so on. Note that these are not globs. They do not use wild cards. They are simple prefixes. Also note that the path is not a part of the prefix. For example, the /dev/ path is not part of the prefix for SCSI disks that are in the path /dev/sd*.

For Oracle Linux and Red Hat Enterprise Linux version 5, when scanning, the kernel sees the devices as /dev/mapper/XXX entries. By default, the 2.6 kernel device file naming scheme udev creates the /dev/mapper/XXX names for human readability. Any configuration using ORACLEASM_SCANORDER should use the /dev/mapper/XXX entries.

3.3.1.5.3 Configuring Disk Scan Ordering to Select Multipath Disks

To configure ASMLIB to select multipath disks first, complete the following procedure:

  1. Using a text editor, open the ASMLIB configuration file /etc/sysconfig/oracleasm.

  2. Edit the ORACLEASM_SCANORDER variable to provide the prefix path of the multipath disks. For example, if the multipath disks use the prefix multipath (/dev/mapper/multipatha, /dev/mapper/multipathb and so on), and the multipath disks mount SCSI disks, then provide a prefix path similar to the following:

    ORACLEASM_SCANORDER="multipath sd"
    
  3. Save the file.

When you have completed this procedure, then when ASMLIB scans disks, it first scans all disks with the prefix string multipath, and labels these disks as Oracle ASM disks using the /dev/mapper/multipathX value. It then scans all disks with the prefix string sd. However, because ASMLIB recognizes that these disks have already been labeled with the /dev/mapper/multipath string values, it ignores these disks. After scanning for the prefix strings multipath and sd, Oracle ASM then scans for any other disks that do not match the scan order.

In the example in step 2, the key word multipath is actually the alias for multipath devices configured in /etc/multipath.conf under the multipaths section. For example:

multipaths {
       multipath {
               wwid                    3600508b4000156d700012000000b0000
               alias                   multipath
               ...
       }
       multipath {
               ...
               alias                   mympath
               ...
       }
       ...
}

The default device name is in the format /dev/mapper/mpath* (or a similar path).

3.3.1.5.4 Configuring Disk Order Scan to Exclude Single Path Disks

To configure ASMLIB to exclude particular single path disks, complete the following procedure:

  1. Using a text editor, open the ASMLIB configuration file /etc/sysconfig/oracleasm.

  2. Edit the ORACLEASM_SCANEXCLUDE variable to provide the prefix path of the single path disks. For example, if you want to exclude the single path disks /dev sdb and /dev/sdc, then provide a prefix path similar to the following:

    ORACLEASM_SCANEXCLUDE="sdb sdc"
    
  3. Save the file.

When you have completed this procedure, then when ASMLIB scans disks, it scans all disks except for the disks with the sdb and sdc prefixes, so that it ignores /dev/sdb and /dev/sdc. It does not ignore other SCSI disks, nor multipath disks. If you have a multipath disk (for example, /dev/multipatha), which accesses both /dev/sdb and /dev sdc, but you have configured ASMLIB to ignore sdb and sdc, then ASMLIB ignores these disks and instead marks only the multipath disk as an Oracle ASM disk.



在采用asmlib时,确认物理磁盘的方法


在采用asmlib作为asm驱动时,此时,通过v$asm_disk视图无法确认具体物理磁盘:

SQL> select disk_number,path from v$asm_disk

 2  where group_number=1;

 

DISK_NUMBER PATH

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

         0 ORCL:VOL12

         1 ORCL:VOL13

可以通过如下的几种方法实现:

1dd方法:

[root@rac1 ~]# dd if=/dev/sdb13 bs=1 count=45 |hexdump -c |more

45+0 records in

45+0 records out

45 bytes (45 B) copied, 9.4e-05 seconds, 479 kB/s

0000000 001 202 001 001  \0  \0  \0  \0  \0  \0  \0 200 253 243 245 371

0000010  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0

0000020   O   R   C   L   D   I   S   K   V   O   L   1   2            

000002d

这可以确定/dev/sdb13VOL12

 

2、通过major号确定:

[root@rac1 ~]# ls -l /dev/oracleasm/disks/VOL12

brw-rw---- 1 oracle oinstall 8, 29 May 15 22:02 /dev/oracleasm/disks/VOL12

[root@rac1 ~]# ls -l /dev/sd* |grep "8, 29"

brw-r----- 1 root disk 8, 29 May 15 22:02 /dev/sdb13


[grid@node2 ~]$ cd /dev/oracleasm/disks/

[grid@node2 disks]$ ll

total 0

brw-rw---- 1 grid oinstall 8, 33 Mar 10 12:04 ARCHDISK

brw-rw---- 1 grid oinstall 8, 49 Mar 10 12:04 DATADISK

brw-rw---- 1 grid oinstall 8, 65 Mar 10 12:04 OVDISK

[grid@node2 disks]$ ls -l /dev/sd* |grep "8, 33"

brw-rw---- 1 grid oinstall 8, 33 Mar 10 12:04 /dev/sdc1

[grid@node2 disks]$ ls -l /dev/sd* |grep "8, 49"

brw-r----- 1 root disk     8, 49 Mar 10 12:04 /dev/sdd1

[grid@node2 disks]$ ls -l /dev/sd* |grep "8, 65"

brw-rw---- 1 grid oinstall 8, 65 Mar 10 12:04 /dev/sde1

[grid@node2 disks]$ 





在Red Hat Linux Server 6上能否使用ASMLib?  

分类: Oracle

原文地址:在Red Hat Linux Server 6上能否使用ASMLib? 作者:尛样儿



    从安装Oracle Database的角度来看,Oracle Linux要比Red Hat Linux更加适合,况且即使是Red Hat Linux 6,ASMLib也不是唯一的选择,但出于历史原因,我们通过这篇文章讨论一下在Red Hat Linux Server 6上能否使用ASMLib?

下面是Oracle对在Red Hat Linux 6上使用ASMLib的说明:

Oracle ASMLib Downloads for Red Hat Enterprise Linux Server 6

Note:  All ASMLib installations require that the 'kmod-oracleasm','oracleasmlib' and 'oracleasm-support' packages be installed on the system. The 'oracleasmlib' and 'oracleasm-support' packages are available for download at the locations listed below. 
 
The kernel driver package 'kmod-oracleasm' is available directly from Red Hat, and can be installed from the "RHEL Server Supplementary (v. 6 64-bit x86_64)" channel on Red Hat Network (RHN).  Use the ASMLib kernel driver that corresponds to the version of the Red Hat Enterprise Linux kernel you're running. 

To identify which version of the ASMLib kernel driver you need, view the description field of the 'kmod-oracleasm' package in the "RHEL Server Supplementary (v. 6 64-bit x86_64)" channel on RHN. 

   使用ASMLib需要3个包:kmod-oracleasm oracleasmlib oracleasm-support,
后两个包都可以直接在网站上下载到,关键是第一个ASMLib内核驱动包 需要到RHN上更新,且应该匹配操作系统的内核版本。

上文字来源于:http://www.oracle.com/technetwork/server-storage/linux/asmlib/rhel6-1940776.html

[root@localhost opt]# cd /opt
[root@localhost opt]# ls
rh  rhel-server-supplementary-6.4-x86_64-dvd.iso
[root@localhost opt]# mount -o loop rhel-server-supplementary-6.4-x86_64-dvd.iso /mnt
[root@localhost opt]# cd /mnt
[root@localhost mnt]# find . -name kmod-oracleasm*
[root@localhost mnt]# 

rhel-server-supplementary光盘中找不到kmod-oracleasm包。

下面是Oracle对在Oracle Linux 6上使用ASMLib的说明:


Oracle ASMLib Downloads for Oracle Linux 6


Note:  All ASMLib installations require the  oracleasmlib  and  oracleasm-support  packages appropriate for their machine.

The  oracleasm-support  package can be downloaded from the  Unbreakable Linux Network (ULN) if you have an active support subscription, or from  http://public-yum.oracle.com  if you do not. 

The oracleasm kernel driver is built into the Unbreakable Enterprise Kernel for Oracle Linux 6 and does not need to be installed manually. 

The oracleasm kernel driver for the 64-bit (x86_64) Red Hat Compatible Kernel for Oracle Linux 6 can be installed manually from  ULN  or  http://public-yum.oracle.com  using the yum tool:
# yum install kmod-oracleasm

This kernel driver is not version-specific and does not need to be upgraded when the kernel is upgraded.


如果使用的是Oracle Linux的uek内核,oracleasm已经被编译到了内核中,如果使用的是和Red Hat兼容的内核,那么需要手动安装kmod-oracleasm包。

以上文字来源于:http://www.oracle.com/technetwork/server-storage/linux/asmlib/ol6-1709075.html


下载oracle提供的yum配置文件,从Oracle服务器上安装kmod-oracleasm文件:

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel-source.repo
[root@localhost yum.repos.d]# wget http://public-yum.oracle.com/public-yum-ol6.repo
--2014-03-25 22:43:05--  http://public-yum.oracle.com/public-yum-ol6.repo
Resolving public-yum.oracle.com... 2.16.54.48, 2.16.54.96
Connecting to public-yum.oracle.com|2.16.54.48|:80... failed: Connection reset by peer.
Connecting to public-yum.oracle.com|2.16.54.96|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4233 (4.1K) [text/plain]
Saving to: “public-yum-ol6.repo”

100%[===================================================================================================>] 4,233       --.-K/s   in 0s      

2014-03-25 22:43:07 (190 MB/s) - “public-yum-ol6.repo” saved [4233/4233]

[root@localhost yum.repos.d]# yum install kmod-oracleasm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
ol6_UEK_latest                                                                                                        | 1.2 kB     00:00     
ol6_UEK_latest/primary                                                                                                |  13 MB     03:26     
ol6_UEK_latest                                                                                                                       281/281
ol6_latest                                                                                                            | 1.4 kB     00:00     
ol6_latest/primary                                                                                                    |  36 MB     15:39     
ol6_latest                                                                                                                       24977/24977
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kmod-oracleasm.x86_64 0:2.0.6.rh1-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================
 Package                             Arch                        Version                               Repository                       Size
=============================================================================================================================================
Installing:
 kmod-oracleasm                      x86_64                      2.0.6.rh1-2.el6                       ol6_latest                       34 k

Transaction Summary
=============================================================================================================================================
Install       1 Package(s)

Total download size: 34 k
Installed size: 115 k
Is this ok [y/N]: y
Downloading Packages:
kmod-oracleasm-2.0.6.rh1-2.el6.x86_64.rpm                                                                             |  34 kB     00:00     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle


参考http://public-yum.oracle.com/页面,在Red Hat Linux Server 6上执行下面的wget命令:

[root@localhost yum.repos.d]# wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
--2014-03-25 23:06:00--  http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6
Resolving public-yum.oracle.com... 46.33.75.121, 46.33.75.138
Connecting to public-yum.oracle.com|46.33.75.121|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1011 [text/plain]
Saving to: “/etc/pki/rpm-gpg/RPM-GPG-KEY-oracle”

100%[===================================================================================================>] 1,011       --.-K/s   in 0s      
2014-03-25 23:06:01 (27.6 MB/s) - “/etc/pki/rpm-gpg/RPM-GPG-KEY-oracle” saved [1011/1011]

[root@localhost yum.repos.d]# yum install kmod-oracleasm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package kmod-oracleasm.x86_64 0:2.0.6.rh1-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================
 Package                             Arch                        Version                               Repository                       Size
=============================================================================================================================================
Installing:
 kmod-oracleasm                      x86_64                      2.0.6.rh1-2.el6                       ol6_latest                       34 k

Transaction Summary
=============================================================================================================================================
Install       1 Package(s)

Total size: 34 k
Installed size: 115 k
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Importing GPG key 0xEC551F03:
 Userid: "Oracle OSS group (Open Source Software group) "
 From  : /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : kmod-oracleasm-2.0.6.rh1-2.el6.x86_64                                                                                     1/1 
mylocalnet/productid                                                                                                  | 1.7 kB     00:00 ... 
  Verifying  : kmod-oracleasm-2.0.6.rh1-2.el6.x86_64                                                                                     1/1 

Installed:
  kmod-oracleasm.x86_64 0:2.0.6.rh1-2.el6                                                                                                    

Complete!

[root@localhost yum.repos.d]# cd /opt
[root@localhost opt]# ls
oracleasmlib-2.0.4-1.el6.x86_64.rpm  oracleasm-support-2.1.8-1.el6.x86_64.rpm  rh  rhel-server-supplementary-6.4-x86_64-dvd.iso
[root@localhost opt]# rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm oracleasm-support-2.1.8-1.el6.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [ 50%]
   2:oracleasmlib           ########################################### [100%]

    至此在Red Hat Linux Server 6.4 x86_64bit上成功安装了kmod-oracleasm oracleasm-support oracleasmlib 3个包。

下面是ASMLib的配置和使用实验:

[root@localhost ~]# /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 []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: 
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [  OK  ]
Scanning the system for Oracle ASMLib disks: [  OK  ]
[root@localhost ~]# fdisk -l

Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000f1993

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         679     5242880   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             679        6528    46980096   83  Linux

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@localhost ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x15fd0887.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

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, +cylinders or +size{K,M,G} (1-1044, default 1044): 
Using default value 1044

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# /etc/init.d/oracleasm status
Checking if ASM is loaded: yes
Checking if /dev/oracleasm is mounted: yes
[root@localhost ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "VOL1" as an ASM disk: [FAILED]


跟踪/var/log/messages可以发现有如下的报错:
......
Mar 25 15:34:47 localhost kernel: type=1400 audit(1395732887.792:22623): avc:  denied  { associate } for  pid=2044 comm="oracleasm-insta" name="VOL1" scontext=unconfined_u:object_r:unlabeled_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=filesystem

可以大致看出这个错误根操作系统的内核有关系。

由此在Red Hat Linux Server 6上安装、使用ASMLib失败!

   通过这个实验并不能确切的说在Red Hat Linux Server 6上不能使用ASMLib,或许通过更换内核,或购买正版Linux从Redhat更新kmod-oracleasm可以正常的使用ASMLib,但这未免也太过于折腾了吧,使用udev将块设备转换为字符设备来直接使用就挺好!


--end--




About Me

...............................................................................................................................

● 本文整理自网络

● 本文在itpub(http://blog.itpub.net/26736162)、博客园(http://www.cnblogs.com/lhrbest)和个人微信公众号(xiaomaimiaolhr)上有同步更新

● 本文itpub地址:http://blog.itpub.net/26736162/abstract/1/

● 本文博客园地址:http://www.cnblogs.com/lhrbest

● 本文pdf版及小麦苗云盘地址:http://blog.itpub.net/26736162/viewspace-1624453/

● 数据库笔试面试题库及解答:http://blog.itpub.net/26736162/viewspace-2134706/

● QQ群:230161599     微信群:私聊

● 联系我请加QQ好友(646634621),注明添加缘由

● 于 2017-07-01 09:00 ~ 2017-07-31 22:00 在魔都完成

● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解

● 版权所有,欢迎分享本文,转载请保留出处

...............................................................................................................................

拿起手机使用微信客户端扫描下边的左边图片来关注小麦苗的微信公众号:xiaomaimiaolhr,扫描右边的二维码加入小麦苗的QQ群,学习最实用的数据库技术。

img_e3029f287d989cd04bd75432ecc1c172.png
DBA笔试面试讲解
欢迎与我联系

目录
相关文章
|
SQL 数据库
ASM卷加盘
1.登陆服务器 2.登陆到ASM实例su - grid sqlplus '/as sysasm' SQL> SELECT path FROM v$asm_disk WHERE NAME IS NULL; PATH /dev/rdsk/c0t60060E8007C72E000030C72E0000...
810 0
|
Oracle 关系型数据库 Unix
solaris asm disk
solaris oracle asm disk,solaris rac ,
1600 0
|
存储 Oracle 网络协议
|
SQL 存储 Oracle
|
Oracle 关系型数据库 数据库
|
SQL Web App开发 数据库
|
关系型数据库 Unix Oracle
|
Oracle 关系型数据库 数据库
|
存储 文字识别 关系型数据库
|
Java 数据库连接 应用服务中间件