mulitpath配置+udev(red5+red6)

531968912發表於2015-04-18

今天遇到一次了multipath繫結的問題,所以把multipath簡單整理下
1、mutipath

mutipath裡Linux下提供的多路徑軟體,在redhat 5 和 red hat 6 上使用有些區別

2、安裝

    安裝多路徑軟體
    yum install kpartx  -y 
    yum install device-mapper-multipath -y
    配置開機啟動
    chkconfig multipathd on
    service multipathd start
    service multipathd reload
    建立配置檔案
    touch /etc/multipath.conf

3、常用命令

  1. multipath -F –刪除所有不使用的多路經裝置。

  2. multipath -v2 –檢測所有的路徑、多路徑和裝置對映

  3. multipath -l –選項來顯示現有多路徑配置

  4. dmsetup ls –檢視裝置

  5. 互動式檢視

  6.  
    # multipathd -k 
    multipathd> show status
    path checker states:
    up                  7
    multipathd>  show config --檢視配置
    multipathd> show devices --顯示裝置
    available block devices:
        sda devnode whitelisted, monitored
        sdb devnode whitelisted, monitored
        sdc devnode whitelisted, monitored
        sdd devnode whitelisted, monitored
        sde devnode whitelisted, monitored
        sdf devnode whitelisted, monitored
        sdg devnode whitelisted, monitored
        sr0 devnode blacklisted, unmonitored
        dm-0 devnode blacklisted, unmonitored
        dm-1 devnode blacklisted, unmonitored
        dm-2 devnode blacklisted, unmonitored
        dm-3 devnode blacklisted, unmonitored
        dm-4 devnode blacklisted, unmonitored
        dm-9 devnode blacklisted, unmonitored
        ram0 devnode blacklisted, unmonitored
        ram1 devnode blacklisted, unmonitored
        ram2 devnode blacklisted, unmonitored
        ram3 devnode blacklisted, unmonitored
        ram4 devnode blacklisted, unmonitored
        ram5 devnode blacklisted, unmonitored
        ram6 devnode blacklisted, unmonitored
        ram7 devnode blacklisted, unmonitored
        ram8 devnode blacklisted, unmonitored
        ram9 devnode blacklisted, unmonitored
        dm-10 devnode blacklisted, unmonitored
        loop0 devnode blacklisted, unmonitored
        loop1 devnode blacklisted, unmonitored
        loop2 devnode blacklisted, unmonitored
        loop3 devnode blacklisted, unmonitored
        loop4 devnode blacklisted, unmonitored
        loop5 devnode blacklisted, unmonitored
        loop6 devnode blacklisted, unmonitored
        loop7 devnode blacklisted, unmonitored
        ram10 devnode blacklisted, unmonitored
        ram11 devnode blacklisted, unmonitored
        ram12 devnode blacklisted, unmonitored
        ram13 devnode blacklisted, unmonitored
        ram14 devnode blacklisted, unmonitored
        ram15 devnode blacklisted, unmonitored
        zram0
    multipathd> show paths --顯示路徑
    hcil    dev dev_t pri dm_st  chk_st dev_st  next_check      
    0:2:0:0 sda 8:0   1   undef  ready  running orphan          
    3:0:0:0 sdb 8:16  1   active ready  running XXXXX..... 11/20
    3:0:0:1 sdc 8:32  1   active ready  running XXXXXXXX.. 16/20
    3:0:0:2 sdd 8:48  1   active ready  running XXXXXXXX.. 17/20
    4:0:0:0 sde 8:64  1   active ready  running XXXXXXXXXX 20/20
    4:0:0:1 sdf 8:80  1   active ready  running XXXX...... 8/20 
    4:0:0:2 sdg 8:96  1   active ready  running XXXXXXX... 14/20
    multipathd> show maps   --顯示對映
    name   sysfs uuid                             
    ocr    dm-4  360022a11000a187faf44b43900000013
    mpathc dm-3  360022a11000a187f21673b7000000040
    mpathb dm-2  360022a11000a187f21673bce00000041
    multipathd> show multipaths status --檢視狀態
    name   failback queueing paths dm-st  write_prot
    ocr    -        -        2     active rw        
    mpathc -        -        2     active rw        
    mpathb -        -        2     active rw        
    multipathd> show multipaths stats --檢視狀態
    name   path_faults switch_grp map_loads total_q_time q_timeouts
    ocr    0           0          1         0            0         
    mpathc 0           0          0         0            0         
    mpathb 0           0          0         0            0   
     
    multipathd> show topology
    mpathb (360022a11000a187f21673c8700000043) dm-2 HUASY,S6800T
    size=300G features='0' hwhandler='0' wp=rw
    |-+- policy='round-robin 0' prio=1 status=active
    | `- 3:0:0:0 sdb   8:16  active ready  running
    `-+- policy='round-robin 0' prio=1 status=enabled
      `- 4:0:0:0 sde   8:64  active ready  running
    mpathc (360022a11000a187f21673c2700000042) dm-3 HUASY,S6800T
    size=300G features='0' hwhandler='0' wp=rw
    |-+- policy='round-robin 0' prio=1 status=active
    | `- 3:0:0:1 sdc   8:32  active ready  running
    `-+- policy='round-robin 0' prio=1 status=enabled
      `- 4:0:0:1 sdf   8:80  active ready  running
    ocr (360022a11000a187faf44b41000000012) dm-4 HUASY,S6800T
    size=80G features='0' hwhandler='0' wp=rw
    |-+- policy='round-robin 0' prio=1 status=active
    | `- 3:0:0:2 sdd   8:48  active ready  running
    `-+- policy='round-robin 0' prio=1 status=enabled
      `- 4:0:0:2 sdg   8:96  active ready  running

4、配置

  1. /etc/multipath/bindings
  2. mulitpath 預設生成的裝置名位mpathx 這樣的裝置名。這樣的名字會儲存在/etc/multipath/bindings檔案裡,檔案裡由裝置名和wwid的對應關係,如果在配置rac時採用預設名字的方式,如兩本不一致請檢視此檔案 。Red 6的檔案在/etc/multipath/bindings,Red 5在 /var/lib/m ultipath/bindings.

    # cat /etc/multipath/bindings 
    # Multipath bindings, Version : 1.0
    # NOTE: this file is automatically maintained by the multipath program.
    # You should not need to edit this file in normal circumstances.
    #
    # Format:
    # alias wwid
    #
    mpatha 36b8ca3a0f8f4c5001adebca406dbbfc4
    mpathd 360022a11000a187faf44b43900000013
    mpathb 360022a11000a187f21673bce00000041
    mpathc 360022a11000a187f21673b7000000040
    mpathe 360022a11000a187fc76dc61000000014
    mpathf 360022a11000a187fc76dc63800000015
  3. etc/multipath/wwids
  4. 還有個檔案就是 etc/multipath/wwids,這個檔案顯示wwid

    # cat /etc/multipath/wwids 
    # Multipath wwids, Version : 1.0
    # NOTE: This file is automatically maintained by multipath and multipathd.
    # You should not need to edit this file in normal circumstances.
    #
    # Valid WWIDs:
    /360022a11000a187faf44b43900000013/
    /360022a11000a187f2168e465000000f6/
    /360022a11000a187f2168e420000000f5/
    /360022a11000a187f21673bce00000041/
    /360022a11000a187f21673b7000000040/
    /360022a11000a187fc76dc61000000014/
    /360022a11000a187fc76dc63800000015/
  5. /etc/multipath.conf
  6. 這個檔案是multipath主要的配置,可以採用預設配置檔案,建議進行配置,最簡單的配置就想

            multipath {
                    wwid                    360050763008101d4e00000000000000a
                    alias                   DATA03

5、配置許可權

在6.2之前配置multipath裝置的許可權只需要在裝置配置裡增加uid,gid,mode就可以

uid 1100 #uid
gid 1020 #gid

        multipath {
                wwid                    360050763008101d4e00000000000000a
                alias                   DATA03
                uid                     501                                               #uid
                gid                     501                                               #gid

}

在6.2之後配置multipath配置檔案裡去掉uid,gid,mode這三個引數,需要使用udev使用,示例檔案在/usr/share/doc/device-mapper-version中有一個模板檔案,
名為12-dm-permissions.rules,您可以使用它並將其放在 /etc/udev/rules.d 目錄中使其生效

[root@rac01 rules.d]#  vi 12-dm-permissions.rules
 ENV{DM_NAME}=="ocr", OWNER:="grid", GROUP:="asmadmin", MODE:="660"
 ENV{DM_NAME}=="data01", OWNER:="grid", GROUP:="asmadmin", MODE:="660"
 ENV{DM_NAME}=="data02", OWNER:="grid", GROUP:="asmadmin", MODE:="660"

在redhat6 multipath 取消了/dev/mpath 目錄,並且在mapper可以看到裝置是連結方式,在5上看不出來

  • redhat5
  • [root@xxx goldengate]# ls -l /dev/mapper/sd400G*
    brw-rw---- 1 root disk 253, 0 Jun 25 14:44 /dev/mapper/sd400G
    brw-rw---- 1 root disk 253, 5 Jun 25 15:47 /dev/mapper/sd400Gp1
  • redhat6
  • [root@xhdb-paas01 ~]# ls -l /dev/mapper/
    total 0
    crw-rw---- 1 root root 10, 236 May  4 10:19 control
    lrwxrwxrwx 1 root root       7 May  4 10:45 mpathb -> ../dm-2
    lrwxrwxrwx 1 root root       7 May  4 10:45 mpathc -> ../dm-3
    lrwxrwxrwx 1 root root       7 May  4 10:26 ocr -> ../dm-4

在啟動udev後,檢視/dev/mapper/下的檔案還會是root許可權因為是軟連結,得檢視/dev/dm-n想裝置

[root@xhdb-paas01 ~]# ls -l /dev/dm-*
brw-rw---- 1 root disk     252,  0 May  4 10:19 /dev/dm-0
brw-rw---- 1 root disk     252,  1 May  4 10:19 /dev/dm-1
brw-rw---- 1 root disk     252, 10 May  4 10:19 /dev/dm-10
brw-rw---- 1 root disk     252,  2 May  4 10:45 /dev/dm-2
brw-rw---- 1 root disk     252,  3 May  4 10:45 /dev/dm-3
brw-rw---- 1 grid asmadmin 252,  4 May  4 14:05 /dev/dm-4
brw-rw---- 1 root disk     252,  9 May  4 10:19 /dev/dm-9

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

相關文章