2021-05-12 14:32:11
RHEL5 多路徑設定
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是否已經成功得到。
相關文章