歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> RHEL5 多路徑配置

RHEL5 多路徑配置

日期:2017/2/28 14:02:32   编辑:Linux教程

1 檢查軟件包是否安裝
[root@pcvmaster ~]# rpm -qa|grep device-mapper
device-mapper-libs-1.02.74-10.el6.x86_64
device-mapper-event-libs-1.02.74-10.el6.x86_64
device-mapper-multipath-0.4.9-56.el6.x86_64
device-mapper-1.02.74-10.el6.x86_64
device-mapper-event-1.02.74-10.el6.x86_64
device-mapper-multipath-libs-0.4.9-56.el6.x86_64
2 安裝multipath
[root@pcvmaster ~]# yum -yinstall multipath
3 開機啟動
[root@pcvmaster ~]# chkconfigmultipathd on
4 編輯multipath配置文件
vi /etc/multipath.conf
# This is a basicconfiguration file with some examples, for device mapper
# multipath.
# For a complete list of thedefault configuration values, see
#/usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf.defaults
# For a list of configurationoptions with descriptions, see
#/usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf.annotated
#
# REMEMBER: After updatingmultipath.conf, you must run
#
# service multipathd reload
#
# for the changes to takeeffect in multipathd

## By default, devices withvendor = "IBM" and product = "S/390.*" are
## blacklisted. To enablemulitpathing on these devies, uncomment the
## following lines.
#blacklist_exceptions {
# device {
# vendor "IBM"
# product "S/390.*"
# }
#}

## Use user friendly names,instead of using WWIDs as names.
defaults {
user_friendly_names yes
}
##
## Here is an example of howto configure some standard options.
##
#
#defaults {
# udev_dir /dev
# polling_interval 10
# selector "round-robin0"
# path_grouping_policy multibus
# getuid_callout "/lib/udev/scsi_id--whitelisted --device=/dev/%n"
# prio alua
# path_checker readsector0
# rr_min_io 100
# max_fds 8192
# rr_weight priorities
# failback immediate
# no_path_retry fail
# user_friendly_names yes
#}
##
## The wwid line in thefollowing blacklist section is shown as an example
## of how to blacklistdevices by wwid. The 2 devnode lines arethe
## compiled in defaultblacklist. If you want to blacklist entire types
## of devices, such as allscsi devices, you should use a devnode line.
## However, if you want toblacklist specific devices, you should use
## a wwid line. Since there is no guarantee that a specificdevice will
## not change names on reboot(from /dev/sda to /dev/sdb for example)
## devnode lines are notrecommended for blacklisting specific devices.
##
#blacklist {
# wwid 26353900f02796769
# devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
# devnode "^hd[a-z]"
#}
#multipaths {
# multipath {
# wwid 3600508b4000156d700012000000b0000
# alias yellow
# path_grouping_policy multibus
# path_checker readsector0
# path_selector "round-robin0"
# failback manual
# rr_weight priorities
# no_path_retry 5
# }
# multipath {
# wwid 1DEC_____321816758474
# alias red
# }
#}
#devices {
# device {
# vendor "COMPAQ "
# product "HSV110(C)COMPAQ"
# path_grouping_policy multibus
# getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
# path_checker readsector0
# path_selector "round-robin0"
# hardware_handler "0"
# failback 15
# rr_weight priorities
# no_path_retry queue
# }
# device {
# vendor "COMPAQ "
# product "MSA1000 "
# path_grouping_policy multibus
# }
#}

blacklist {
devnode"^(ram|raw|loop|fd|md|dm-|sr|sr|scd|st)[0-9]*"
devnode"^hd[a-z]"
}
devices {
device {
vendor"Netapp"
path_grouping_policymultibus
features "1queue_if_no_path"
path_checkerreadsector()
failback immediate
}
}
5 啟動服務
[root@pcvmaster ~]#/etc/init.d/multipathd start
6 刪除現有沒有使用的路徑
[root@pcvmaster ~]# multipath–F
7 格式化路徑,檢測路徑,合並路徑
[root@pcvmaster ~]# multipath-v2
8 查看多路徑狀態
[root@pcvmaster ~]# multipath–ll
9 重啟系統
[root@pcvmaster ~]# reboot
10創建PV多塊磁盤,
[root@pcvmaster ~]# pvcreate/dev/mapper/mpath{d,f,e,p,t,k,j,c,s,q}
11添加多塊磁盤到Volbackup
[root@pcvmaster~]# vgcreateVolbackup /dev/mapper/mpath{d,f,e,p,t,k,j,c,s,q}
12創建LV
[root@pcvmaster ~]# lvcreate-l 1310780 -n LogVol01 Volbackup
13格式化LV
[root@pcvmaster ~] mkfs.ext4/dev/Volbackup/LogVol01
14掛載
[root@pcvmaster ~]# mount/dev/Volbackup/LogVol01 /backup
15FAQ
15.1 模塊沒有加載成功後
如果模塊沒有加載成功請使用下列命初始化DM,或重啟系統
---Use thefollowing commands to initialize and start DM for the first time:
# modprobedm-multipath
# modprobe dm-round-robin
# servicemultipathd start
# multipath –v2
15.2 multipath原理介紹
1、device-mapper-multipath:即multipath-tools。主要提供multipathd和multipath等工具和 multipath.conf等配置文件。這些工具通過device mapper的ioctr的接口創建和配置multipath設備(調用device-mapper的用戶空間庫。創建的多路徑設備會在/dev/mapper中)。

2、device-mapper:主要包括兩大部分:內核部分和用戶部分。內核部分主要由device mapper核心(dm.ko)和一些target driver(md-multipath.ko)。核心完成設備的映射,而target根據映射關系和自身特點具體處理從mappered device 下來的i/o。同時,在核心部分,提供了一個接口,用戶通過ioctr可和內核部分通信,以指導內核驅動的行為,比如如何創建mappered device,這些divece的屬性等。linux device mapper的用戶空間部分主要包括device-mapper這個包。其中包括dmsetup工具和一些幫助創建和配置mappered device的庫。這些庫主要抽象,封裝了與ioctr通信的接口,以便方便創建和配置mappered device。multipath-tool的程序中就需要調用這些庫。

3、dm-multipath.ko和dm.ko:dm.ko是devicemapper驅動。它是實現multipath的基礎。dm-multipath其實是dm的一個target驅動。

4、scsi_id:包含在udev程序包中,可以在multipath.conf中配置該程序來獲取scsi設備的序號。通過序號,便可以判斷多個路徑對應了同一設備。這個是多路徑實現的關鍵。scsi_id是通過sg驅動,向設備發送EVPD page80或page83 的inquery命令來查詢scsi設備的標識。但一些設備並不支持EVPD 的inquery命令,所以他們無法被用來生成multipath設備。但可以改寫scsi_id,為不能提供scsi設備標識的設備虛擬一個標識符,並輸出到標准輸出。multipath程序在創建multipath設備時,會調用scsi_id,從其標准輸出中獲得該設備的scsi id。在改寫時,需要修改scsi_id程序的返回值為0。因為在multipath程序中,會檢查該直來確定scsi id是否已經成功得到。

更多RedHat相關信息見RedHat 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=10

Copyright © Linux教程網 All Rights Reserved