【ASM】ASMLIB 系列

lhrbest發表於2017-02-23

【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群,學習最實用的資料庫技術。

【ASM】ASMLIB 系列
DBA筆試面試講解
歡迎與我聯絡

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2134171/,如需轉載,請註明出處,否則將追究法律責任。

相關文章