建立ASM磁碟組

來源:互聯網
上載者:User

ASM磁碟組是作為一個邏輯單元管理的一個ASM磁碟池。與其他任何LVM一樣,ASM管理大量物理卷並將其作為一個或多個邏輯卷呈交給Oracle。物理卷可以是實際的磁碟或磁碟的分區,或者是隸屬作業系統的卷管理器的卷。無論採用哪種方式,都不能使用任何檔案系統格式化,必須是裸裝置。

在Linux上,ASM能引用磁碟作為裸裝置,或通過使用ASMLib軟體。

  • 直接使用裸裝置的方法:

1. 在RHEL6以前的可以直接通過rawdevices的管理方法,系統安裝後預設已存在/etc/init.d/rawdevices和/etc/sysconfig/rawdevices這兩個檔案。

# cat /etc/redhat-releaseRed Hat Enterprise Linux Server release 5.8 (Tikanga)# rpm -qf /etc/init.d/rawdevices /etc/sysconfig/rawdevicesinitscripts-8.45.42-1.el5initscripts-8.45.42-1.el5# cat /etc/init.d/rawdevices#!/bin/bash## rawdevices       This shell script assignes rawdevices to block devices## chkconfig: 345 56 44# description: This scripts assignes raw devices to block devices \#              (such as hard drive partitions). This is for the use \#              of applications such as Oracle. You can set up the \#              raw device to block device mapping by editing \#              the file /etc/sysconfig/rawdevices.# config: /etc/sysconfig/rawdevices[ -f /bin/raw ] || exit 0[ -f /etc/sysconfig/rawdevices ] || exit 0# Exit if the file just has the default comments.LC_ALL=C /bin/egrep -q -v "^ *#" /etc/sysconfig/rawdevices 2>/dev/null || exit 0. /etc/init.d/functionsfunction assign_raw(){   LC_ALL=C egrep -v '^ *#' /etc/sysconfig/rawdevices |   while read RAW BLOCK; do     if [ -n "$RAW" -a -n "$BLOCK" ]; then         rawdirname=${RAW%/*}         if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then           echo $"  Please correct your /etc/sysconfig/rawdevices:"           echo $"     rawdevices are now located in the directory /dev/raw/ "           echo $"  If the command 'raw' still refers to /dev/raw as a file."           echo $"   you'll have to upgrade your util-linux package"           exit 0         fi         if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then           echo $"  Please correct your /etc/sysconfig/rawdevices:"           echo $"     rawdevices are now located in the directory /dev/raw/ "           echo $"  If the command 'raw' still refers to /dev/raw as a file."           echo $"   you'll have to upgrade your util-linux package"           exit 0         fi       echo "           $RAW  -->   $BLOCK";       raw $RAW $BLOCK     fi   done}# See how we were called.case "$1" in  start)        # Assign devices        echo $"Assigning devices: "        assign_raw#添加以下兩行(預設不存在),即預設情況下產生的裸裝置為root所有,#所以必須修改屬主,否則oracle使用者無法使用裸裝置        sleep 5        chown -R oracle:oinstall /dev/raw/        echo $"done"        ;;  stop)        # No action to be taken here        ;;  status)        ID=`id -u`        if [ $ID -eq 0 ]; then          raw -qa        else          echo $"You need to be root to use this command ! "        fi        ;;  restart|reload)        $0 start        ;;  *)        echo $"Usage: $0 {start|stop|status|restart}"        exit 1esacexit 0


# vi /etc/sysconfig/rawdevices                //映射將要綁定的裸裝置/dev/raw/raw10  /dev/sda10/dev/raw/raw11  /dev/sda11/dev/raw/raw12  /dev/sda12/dev/raw/raw13  /dev/sda13/dev/raw/raw14  /dev/sda14# chkconfig rawdevices on# service rawdevices startAssigning devices:           /dev/raw/raw10  -->   /dev/sda10/dev/raw/raw10: bound to major 8, minor 10           /dev/raw/raw11  -->   /dev/sda11/dev/raw/raw11: bound to major 8, minor 11           /dev/raw/raw12  -->   /dev/sda12/dev/raw/raw12: bound to major 8, minor 12           /dev/raw/raw13  -->   /dev/sda13/dev/raw/raw13: bound to major 8, minor 13           /dev/raw/raw14  -->   /dev/sda14/dev/raw/raw14: bound to major 8, minor 14done# ls -l /dev/raw/total 0crw-rw----. 1 oracle oinstall 162, 10 May 27 08:37 raw10crw-rw----. 1 oracle oinstall 162, 11 May 27 08:37 raw11crw-rw----. 1 oracle oinstall 162, 12 May 27 08:37 raw12crw-rw----. 1 oracle oinstall 162, 13 May 27 08:37 raw13crw-rw----. 1 oracle oinstall 162, 14 May 27 08:37 raw14crw-rw----. 1 oracle oinstall 162,  0 May 27 08:19 rawctl# raw -qa/dev/raw/raw10: bound to major 8, minor 10/dev/raw/raw11: bound to major 8, minor 11/dev/raw/raw12: bound to major 8, minor 12/dev/raw/raw13: bound to major 8, minor 13/dev/raw/raw14: bound to major 8, minor 14


2. 在RHEL6中,系統裡面雖然已經不存在/etc/sysconfig/rawdevices和/etc/init.d/rawdevices檔案了,但是依然支援rawdevices的方式,可以通過如下方法來管理raw檔案。

  1. 手動建立/etc/sysconfig/rawdevices和/etc/init.d/rawdevices檔案,然後依然以rawdevices的方式

  2. 通過udev來管理raw,同樣也可以通過udev固定磁碟對應的裝置名稱

以下介紹udev的方式:

# fdisk -l /dev/sdbDisk /dev/sdb: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes   Device Boot      Start         End      Blocks   Id  System/dev/sdb1               1         261     2096451    5  Extended/dev/sdb5               1          25      200749+  83  Linux/dev/sdb6              26          50      200781   83  Linux/dev/sdb7              51          75      200781   83  Linux/dev/sdb8              76         100      200781   83  Linux/dev/sdb9             101         125      200781   83  Linux# vi /etc/udev/rules.d/60-raw.rulesACTION=="add",KERNEL=="sdb5",RUN+="/bin/raw /dev/raw/raw5 %N",OWNER="oracle", GROUP="oinstall", MODE="660"ACTION=="add",KERNEL=="sdb6",RUN+="/bin/raw /dev/raw/raw6 %N",OWNER="oracle", GROUP="oinstall", MODE="660"ACTION=="add",KERNEL=="sdb7",RUN+="/bin/raw /dev/raw/raw7 %N",OWNER="oracle", GROUP="oinstall", MODE="660"ACTION=="add",KERNEL=="sdb8",RUN+="/bin/raw /dev/raw/raw8 %N",OWNER="oracle", GROUP="oinstall", MODE="660"ACTION=="add",KERNEL=="sdb9",RUN+="/bin/raw /dev/raw/raw9 %N",OWNER="oracle", GROUP="oinstall", MODE="660"# raw -qa# start_udevStarting udev: [  OK  ]# raw -qa/dev/raw/raw5:  bound to major 8, minor 21/dev/raw/raw6:  bound to major 8, minor 22/dev/raw/raw7:  bound to major 8, minor 23/dev/raw/raw8:  bound to major 8, minor 24/dev/raw/raw9:  bound to major 8, minor 25# ls -l /dev/rawtotal 0crw-rw---- 1 oracle oinstall 162,  5 Jun  9 17:15 raw5crw-rw---- 1 oracle oinstall 162,  6 Jun  9 17:15 raw6crw-rw---- 1 oracle oinstall 162,  7 Jun  9 17:15 raw7crw-rw---- 1 oracle oinstall 162,  8 Jun  9 17:15 raw8crw-rw---- 1 oracle oinstall 162,  9 Jun  9 17:15 raw9


  • ASMLib:(非Linux系統只能使用裸裝置的方法)

ASMLib是一組可選的位於ASM和硬體之間的一個核心驅動程式工具,也是作為一個應用程式庫通過Oracle資料庫軟體訪問ASM磁碟。

它是Oracle 10g和11g單一實例資料庫以及RAC的ASM特性支援庫。ASM和資料庫執行個體可以使用ASMLib作為可替代的磁碟提供者。

ASMLib有以下三個組件:

核心驅動:oracleasm            Linux中支援oracle ASMLib的核心驅動程式需根據核心版本下載)

支援工具:oracleasm-support    提供用於配置和啟動ASM驅動程式的工具 + 生產力

應用程式庫:oracleasmlib       提供了實際的ASM庫

# uname -r2.6.18-308.el5# ls oracleasm*oracleasm-2.6.18-308.el5-2.0.5-1.el5.x86_64.rpmoracleasm-support-2.1.8-1.el5.x86_64.rpmoracleasmlib-2.0.4-1.el5.x86_64.rpm# rpm -ivh oracleasmlib*warning: oracleasm-2.6.18-308.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159Preparing...                ########################################### [100%]   1:oracleasm-support      ########################################### [100%]   2:oracleasm-2.6.18-308.el########################################### [100%]   3:oracleasmlib           ########################################### [100%]# /etc/init.d/oracleasm configureConfiguring the Oracle ASM library driver.This will configure the on-boot properties of the Oracle ASM librarydriver.  The following questions will determine whether the driver isloaded on boot and what permissions it will have.  The current valueswill be shown in brackets ('[]').  Hitting <ENTER> without typing ananswer will keep that current value.  Ctrl-C will abort.Default user to own the driver interface []: oracleDefault group to own the driver interface []: oinstallStart Oracle ASM library driver on boot (y/n) [n]: yScan for Oracle ASM disks on boot (y/n) [y]:Writing Oracle ASM library driver configuration: doneInitializing the Oracle ASMLib driver: [  OK  ]Scanning the system for Oracle ASMLib disks: [  OK  ]# /etc/init.d/oracleasm enableWriting Oracle ASM library driver configuration: [  OK  ]Loading module "oracleasm": [  OK  ]Mounting ASMlib driver filesystem: [  OK  ]Scanning system for ASM disks: [  OK  ]# /etc/init.d/oracleasm createdisk VOL1 /dev/sda5Marking disk "VOL2" as an ASM disk: [  OK  ]# /etc/init.d/oracleasm createdisk VOL2 /dev/sda6Marking disk "VOL2" as an ASM disk: [  OK  ]# /etc/init.d/oracleasm createdisk VOL3 /dev/sda7Marking disk "VOL3" as an ASM disk: [  OK  ]# /etc/init.d/oracleasm createdisk VOL4 /dev/sda8Marking disk "VOL4" as an ASM disk: [  OK  ]# /etc/init.d/oracleasm createdisk VOL5 /dev/sda9Marking disk "VOL5" as an ASM disk: [  OK  ]# /etc/init.d/oracleasm scandisksScanning system for ASM disks:[  OK  ]# /etc/init.d/oracleasm listdisksVOL1VOL2VOL3VOL4VOL5# ll /dev/oracleasm/disks/total 0brw-rw---- 1 oracle oinstall 8, 5 Jun  3 09:53 VOL1brw-rw---- 1 oracle oinstall 8, 6 Jun  3 10:00 VOL2brw-rw---- 1 oracle oinstall 8, 7 Jun  3 10:00 VOL3brw-rw---- 1 oracle oinstall 8, 8 Jun  3 10:00 VOL4brw-rw---- 1 oracle oinstall 8, 9 Jun  3 10:00 VOL5//到這裡ASM的工作就完成了,這裡的磁碟可以被Oracle所使用,使用oracleasm-discover來探測ASM硬碟:# oracleasm-discoverUsing ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]Discovered disk: ORCL:VOL1 [4899762 blocks (2508678144 bytes), maxio 512]Discovered disk: ORCL:VOL2 [4899762 blocks (2508678144 bytes), maxio 512]Discovered disk: ORCL:VOL3 [4899762 blocks (2508678144 bytes), maxio 512]Discovered disk: ORCL:VOL4 [4899762 blocks (2508678144 bytes), maxio 512]Discovered disk: ORCL:VOL5 [7373772 blocks (3775371264 bytes), maxio 512]




本文出自 “ゞ煙花っ笑” 部落格,請務必保留此出處http://vnimos.blog.51cto.com/2014866/1220666

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.