說明

    Multipath 是 CentOS/RedHat 內建套件,可用作兩 port 的 HBA 卡連接 Storage時,有雙路由的備援架構。

    系統環境

    1. RedHat 4.7
    2. NetApp FAS2240
    3. SAN Switch x 2
    4. HBA Card: QLogic, port x 2
      #>lspci
      Fibre Channel: QLogic Corp. ISP2532-based 8Gb Fibre Channel to PCI Express HBA (rev 02)

    RedHat 的 HBA Card 驅動

    建議安裝方法為,在安裝 RedHat 前先安裝 HBA 卡,然後安裝 RedHat 時會自動驅動 HBA 卡。

    如果無法重新安裝 RedHat 試試修改 /etc/modprobe.conf,加上這一行

    alias scsi_hostadapter2 qla2500
    

    TIPs:

    scsi_hostadapterX 編號視實際狀況修改

    查出 HBA 卡的 WWN
    #> cat /proc/scsi/qla2xxx/2

    SCSI Device Information:
    scsi-qla0-adapter-node=5001438004253c81;
    scsi-qla0-adapter-port=5001438004253c80; <---- WWN
    scsi-qla0-target-0=50001fe1500e28fd;
    scsi-qla0-target-1=50001fe1500e28f9;
    scsi-qla0-target-2=500a09829140a66c;
    

    TIPs:

    另一個 HBA port 裝置檔為 /proc/scsi/qla2xxx/3,以此類推

    每個 port 有獨立的 WWN

    NetApp storage 分配 LUN 以此 WWN 作為 Host Mapping 的主要參數

    驅動後的模組列表
    # lsmod | grep qla
    qla2500               209985  0
    qla2xxx               203681  13 qla2500
    scsi_transport_fc      19521  1 qla2xxx
    scsi_mod              153489  7 ib_srp,qla2xxx,scsi_transport_fc,sr_mod,libata,cciss,sd_mo   d

    SAN Storge 設定與接線

    1. 將 NetApp storage、SAN switch、RedHat 接上各自的光纖線

    2. 找出 RedHat 的 HBA 卡 兩 port 各自的 WWN

    3. 設定 NetApp,將 LUNs 分配至兩個 WWN Hosts 

    設定 Multipath

    更新:RedHat 客戶中心有提供設定 multipath.conf 線上協助導引,網頁必須先登入才能瀏覽
    https://access.redhat.com/labs/multipathhelper/

    必要的套件安裝

    rpm -q device-mapper
    rpm -q device-mapper-multipath
    yum install device-mapper
    yum install device-mapper-multipath
    

    CentOS 5.x)

    編輯 /etc/multipath.conf

    # Blacklist all devices by default. Remove this to enable multipathing
    # on the default devices.
    devnode_blacklist {
    #        devnode "*" << 註解這一行
    }
    
    ## Use user friendly names, instead of using WWIDs as names.
    defaults {
            user_friendly_names yes
    }
    

    TIPs

    注意:即使啟動了 multipathd 服務,預設是抓不到任何 LUNs 的,必須註解上述的那一行

    啟動 multipathd 服務

    #> service multipathd start
    #> chkconfig multipathd on 
    

    CentOS 6/7)

    • 預設沒有設定檔 /etc/multipath.conf,執行這個指令會自動產生,並且將服務 multipathd 設定成自動執行。
    #> mpathconf --enable --with_multipathd y
    
    • 不用修改 multipath.conf
       

    檢視 multupah 的裝置

    CentOS 5.x

    [root@cdb3-b ~]# multipath -ll
    mpath1 (360a98000383035537824474d3936556a) dm-4 NETAPP,LUN
    [size=700G][features=3 queue_if_no_path pg_init_retries 50][hwhandler=0][rw]
    \_ round-robin 0 [prio=4][active]
     \_ 1:0:1:0 sdb        8:16  [active][ready]
     \_ 2:0:1:0 sdd        8:48  [active][ready]
    \_ round-robin 0 [prio=1][enabled]
     \_ 1:0:0:0 sda        8:0   [active][ready]
     \_ 2:0:0:0 sdc        8:32  [active][ready]
    

    CentOS 6.x

    [root@cdb3 ~]# multipath -ll
    mpathb (360a98000383035537824474d39365568) dm-2 NETAPP,LUN
    size=700G features='4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle' hwhandler='0' wp=rw
    |-+- policy='round-robin 0' prio=4 status=active
    | |- 1:0:1:0 sdc 8:32 active ready running
    | `- 2:0:1:0 sde 8:64 active ready running
    `-+- policy='round-robin 0' prio=1 status=enabled
      |- 1:0:0:0 sdb 8:16 active ready running
      `- 2:0:0:0 sdd 8:48 active ready running
    
    安裝 NetApp 管理工具

    *建議*安裝 LUN 管理工具 - NetApp Linux Host Utilities

    yum install libnl
    rpm -ivh QConvergeConsoleCLI-1.0.01-32.x86_64.rpm
    rpm -ivh netapp_linux_host_utilities-6-2.x86_64.rpm
    

    TIPs:

    - 如果沒有安裝這套件,將無法使用 sanlun 指令

    - 適用 CentOS 5.x/6.x

    新增 LUN 需系統重新開機)

    一旦重新開機後,所有的 LUN disks (在 dual path SAN 架構下會有多個 LUN disks)應該都會被偵測到,並且會有一個 mpathXX 的裝置名稱

    #> multipath -l
    mpath1 (360a98000424732615124444150534a35)
    [size=100 GB][features="1 queue_if_no_path"][hwhandler="0"]
    \_ round-robin 0 [active]
     \_ 2:0:2:0 sde 8:64 [active]
     \_ 3:0:2:0 sdf 8:80 [active]
    
    mpath0 (3600508b400068e5c00012000001a0000)
    [size=100 GB][features="1 queue_if_no_path"][hwhandler="0"]
    \_ round-robin 0 [active]
     \_ 2:0:0:1 sda 8:0  [active]
     \_ 3:0:0:1 sdc 8:32 [active]
    \_ round-robin 0 [enabled]
     \_ 2:0:1:1 sdb 8:16 [active]
     \_ 3:0:1:1 sdd 8:48 [active]
    

    TIPs:

    mpathX 這路徑可作為 LVM 的 PV 或直接格式化為 filesystem,完整路徑為 /dev/mapper/mpathX

    2:0:0:1 這表示為 host : channel : ID : LUN

    Host 2 與 Host 3 表示 HBA 卡有兩個 port 或者單 port 的卡兩張

    新增/移除 LUN 系統不需重開機)

    參考教學:

     

    CentOS/RedHat 5.x 以後

    從 CentOS/RedHat 5 以後或者 SLES 10 以後,可以安裝以下套件:

    yum install sg3_utils
    

    不停機下掃描新的 LUN Disk

    檢視目前現有的 LUN Disks
    #> sanlun lun show all
    
    掃描所有 LUN
    #> scsi-rescan
    NOTE: 如果偵測不到新 LUN,試試加上 -a
    #> scsi-rescan -a
    
    再次檢視目前的 LUN Disks
    #> sanlun lun show all
    

    移除 LUN 的程序

    要移除現有的 LUN disk 必須依照以下步驟完成:

    1. 執行 umount 卸載
    2. 執行 lvremove 移除 LV
    3. 需要時,執行 vgremove 移除 VG
    4. 執行 pvremove 移除 PV
    5. 執行 multipath -f mpathXX 移除 multipathXX
      NOTE: 如果沒有執行這步驟,一旦移除 LUN 後系統可能會 Hang。
    6. 從 Storage 管理介面移除這個 LUN disk
      NOTE: 當 LUN 被移除後,執行 sanlun lun show all,那些移除的 LUN 會顯示 unknown。
    7. 執行 scsi-rescan -r 移除所有未使用的 LUN disk
      NOTE: 執行後輸出訊息,應該要顯示類似
      4 device(s) removed.
              [5:0:1:0]
              [5:0:3:0]
              [6:0:1:0]
              [6:0:3:0]
      重新執行 sanlun lun show all,那些 unknown 就會消失。
    CentOS/RedHat 4.x:

    參考教學:

     

    使用附檔區的兩個 script

    1. remove-LUNs.sh
    2. rescan-LUNs.sh

     

    新增 LUN disk 步驟

    1. 在 NetApp storage 上完成 LUN Mapping 的設定
    2. 在 RedHat 上執行 rescan-LUNs.sh
    3. 在 RedHat 上執行 multipath -l
       

    移除現有 LUN disk

    1. 在 RedHat 上卸載不用的 mpathX
    2. 在 RedHat 上執行 sanlun lun show all 找出 LUN 的名稱與 NetApp 上路徑
      註:要執行 sanlun 指令必須先安裝 NetApp 的套件 netapp_linux_host_utilities-6-2.x86_64.rpm
    3. 在 NetApp 上移除所對應的 LUN
    4. 在 RedHat 上執行 multipath -l
      找出要移除 LUN disks 的 host:channel:id:LUN
      執行 remove-LUNs.sh <host> <channel> <id> <LUN>

    LVM 管理

    將 LUN 新增為一個 PV

    #> pvcreate /dev/mapper/mpath6
    

    NOTE: PV 新增後,執行 pvdisplay 時的裝置名稱會是 dm-X。

    新增 VG

    #> vgcreate dbVG /dev/mapper/mpath6
    

    指令更多用法

    multipath
     /etc/init.d/multipathd start Manually starts the multipathing service on the Linux host.
     multipath -ll Displays the multipathing configuration.
     multipath -v2 Creates the initial multipathing configuration.
     multipath -f device_map Removes an existing LUN from the multipathing configuration.
     multipath -ll -v2 -d Displays the multipathing configuration in verbose mode.
     multipath -t 或 multipathd show config 顯示目前的設定參數
    Accesing LUNs on host
     sanlun fcp show adapter -v Displays HBA information.
     sanlun fcp show adapter Display WWPN of HBA cards
     sanlun lun show all Lists available LUNs as seen by the sanlun script.
     sanlun lun show -p Provides multipath information for both DM-Multipath and Veritas
    Storage Foundation
    TM
    dynamic multipathing solutions.
     ls -lh /dev/mapper/ Lists DM-Multipath devices generated for LUNs.
     e2label device label Creates a persistent label for a file system. device is the partition; label
    is a unique string up to 16 characters. Not needed with DM-Multipath.

    Q & A

    Q: RHEL 7 不會使用 alias path

    使用 NetApp Storage,執行 multipath -ll

    360a98000443437576f2444726e556d76 dm-2 NETAPP  ,LUN
    size=800G features='4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle' hwhandler='1 alua' wp=rw
    |-+- policy='service-time 0' prio=50 status=active
    | `- 6:0:0:0 sdb 8:16 active ready running
    `-+- policy='service-time 0' prio=10 status=enabled
      `- 6:0:3:0 sdc 8:32 active ready running

    不會顯示 alias name: mpathXX

    參閱官方手冊:https://access.redhat.com/solutions/2061463

    檢視 multipath 可支援的裝置清單

    multipath -t 
    
    沒有看到 NetApp 的裝置
    

    解決方法:編輯 multipath.conf,加入 NetApp 的參數設定
    NOTE:僅適合 NetApp Storage

    defaults {
            user_friendly_names yes
            find_multipaths yes
    }
    
    devices {
            device {
                    vendor "NETAPP"
                    product "LUN.*"
                    path_grouping_policy "group_by_prio"
                    path_checker "tur"
                    features "3 queue_if_no_path pg_init_retries 50"
                    hardware_handler "0"
                    prio "ontap"
                    failback immediate
                    rr_weight "uniform"
                    rr_min_io 128
                    flush_on_last_del "yes"
                    dev_loss_tmo "infinity"
                    user_friendly_names yes
                    retain_attached_hw_handler yes
                    detect_prio yes
            }
    

    載入新設定

    #> systemctl reload multipathd
    
    #> multipath -ll
    mpatha (360a98000443437576f2444726e556d76) dm-2 NETAPP  ,LUN
    size=800G features='4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle' hwhandler='1 alua' wp=rw
    |-+- policy='service-time 0' prio=50 status=active
    | |- 4:0:0:0 sdb 8:16 active ready running
    | `- 6:0:0:0 sdd 8:48 active ready running
    `-+- policy='service-time 0' prio=10 status=enabled
      |- 4:0:3:0 sdc 8:32 active ready running
      `- 6:0:3:0 sde 8:64 active ready running
    
    Q: 安裝 netapp_linux_host_utilities 時,出現錯誤訊息

    Warning: libnl.so library not found, some sanlun commands may not work. Refer Li nux Host Utilities Installation and Set up Guide for more details
    Warning: libHBAAPI.so library not found, some sanlun commands may not work. Refe r Linux Host Utilities Installation and Setup Guide for more details

    Ans:

    先安裝 libnl

    yum install libnl
    

    再安裝以下套件任一個

    下載位址:

    1. http://driverdownloads.qlogic.com/QL...emcatid=111969
    2. http://driverdownloads.qlogic.com/QL...t+%2864-bit%29

     

    • QConvergeConsole CLI (x64)
    • SANsurfer CLI (x86/x64)
    Q: 執行 pvscan、vgscan 或開機時出現以下訊息

    Found duplicate PV XXXXXXXXXXXXXXXX: using /dev/sdb not /dev/sda

    Ans:這通常會發生在系統有作 multipath 與 LVM 設定後,原因是 CentOS 4/5 預設 LVM 的設定會掃描所有的磁碟裝置,然而,當系統設定有 multipath 時,LVM 應該管理 mpathX 或 dm-X 的裝置,而不再是 sdX 裝置。

    要使 LVM 不再對 sdX 裝置作管理,可以修改 /etc/lvm/lvm.conf,此外,如果要使每次系統開機時,LVM 不要對 sdX 裝置作掃描,還必須要重建 initrd 開機映像檔,並且修改 grub.conf 相關的設定。

    操作步驟如下:

    1. 編輯 /etc/lvm/lvm.conf

    ...
    filter = [ "r|/dev/sd.*|", "a|/.*|" ]
    ... 
    

    NOTE:

    r|/dev/sd.*| 這設定會排除所有 sda, sdb, ...等所有磁碟裝置掃描,如果系統有使用其中某個裝置,必須自行修改這規則。

    存檔離開

    執行 pvscan 或 vgscan,如果不再出現 Warning,繼續步驟 2。

    2. 重建 initrd 開機映像檔

    #> cd /boot
    #> mkinitrd -f -v /boot/initrd-$(uname -r).multipath.img $(uname -r) 
    

    編輯 /boot/grub/grub.conf
    複製 title 段落的所有行,並依照實際狀況修改

    title CentOS (2.6.18-398.el5-Multipath)                      <== 加上 Multipath
              root (hd0,0)
              kernel /vmlinuz-2.6.18-398..........
              initrd /initrd-2.6.18-398.el5.multipath.img     <== 重建後的initrd 開機映像檔名
    

    存檔離開

    3. 重新開機後,出現開機選單後,選擇第二個開機項目。

    如果開機訊息不再出現警告文字,而且系統一切正常,就可以再修改 grub.conf 的 default=1。

    標籤 (Edit tags)
    • No tags

    文件 2

    文件大小日期附件上傳者 
     remove-LUNs.sh
    For RHEL v4 only
    912 位元15:29, 3 Feb 2016alang動作
     rescan-LUNs.sh
    For RHEL v4 only
    363 位元15:29, 3 Feb 2016alang動作
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core