linux 多路径配置
首先介绍一下什么是多路径(multi-path)?先说说多路径功能产生的背景,在多路径功能出现之前,主机上的硬盘是直接挂接到一个总线(PCI)上,路径是一对一的关系,也就是一条路径指向一个硬盘或是存储设备,这样的一对一关系对于操作系统而言,处理相对简单,但是缺少了可靠性。当出现了光纤通道网络(Fibre Channle)也就是通常所说的SAN网络时,或者由iSCSI组成的IPSAN环境时,由于主机和存储之间通过光纤通道交换机或者多块网卡及IP来连接时,构成了多对多关系的IO通道,也就是说一台主机到一台存储设备之间存在多条路径。当这些路径同时生效时,I/O流量如何分配和调度,如何做IO流量的负载均衡,如何做主备。这种背景下多路径软件就产生了。
多路径的主要功能就是和存储设备一起配合实现如下功能:
1.故障的切换和恢复
2.IO流量的负载均衡
3.磁盘的虚拟化
在linux操作系统中,RedHat和Suse的2.6的内核中都自带了免费的多路径软件包,ESX操作系统下也是自带了免费的多路径功能,而windows操作系统下,就需要购买一个叫MPIO的软件lience才能使用multi-path多路径功能。其他windows和ESX操作系统下的多路径 功能都是图形化界面比较简单这里就不多做介绍了,在这里就是介绍一下linux环境下如何配置multi-path多路径功能。
一、Linux下multipath相关工具和参数介绍:
3、dm-multipath.ko和dm.ko:dm.ko是device mapper驱动。它是实现multipath的基础。dm-multipath其实是dm的一个target驱动。
接着通过命令:multipath –ll 查看多路径状态查看模块是否加载成功
[root@liujing ~]# multipath –ll 查看多路径状态
Mar 10 19:18:28 | /etc/multipath.conf does not exist, blacklisting all devices.
Mar 10 19:18:28 | A sample multipath.conf file is located at
Mar 10 19:18:28 | /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
Mar 10 19:18:28 | You can run /sbin/mpathconf to create or modify /etc/multipath.conf
Mar 10 19:18:28 | DM multipath kernel driver not loaded ----DM模块没有加载
初始化完了之后再通过multipath -ll命令查看是否加载成功
[root@liujing ~]# multipath -ll
Mar 10 19:21:14 | /etc/multipath.conf does not exist, blacklisting all devices.
Mar 10 19:21:14 | A sample multipath.conf file is located at
Mar 10 19:21:14 | /usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf
Mar 10 19:21:14 | You can run /sbin/mpathconf to create or modify /etc/multipath.conf
DM multipath kernel driver not loaded ----这个提示没了说明DM模块已加载成功。
从上面的提示可以看到,DM模块是成功加载,但是/etc/下没有multipath.conf 配置文件,下一步介绍如何配置multipath.conf 文件。
通过vi命令创建一个Multipath的配置文件路径是/etc/multipath.conf ,在配置文件中添加multipath正常工作的最简配置如下:
# /etc/init.d/multipathd start #开启mulitipath服务
[root@liujing mapper]# service multipathd start
Starting multipathd daemon: 没有提示OK
[root@liujing mapper]# /etc/init.d/multipathd stop
Stopping multipathd daemon: [ OK ]
[root@localhost mapper]# /etc/init.d/multipathd start
Starting multipathd daemon: [ OK ] -----提示OK 正常开启服务
[root@liujing mapper]# multipath -ll
mpatha (360a9800064665072443469563477396c) dm-0 NETAPP,LUN ----创建了一个lun
size=3.5G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=4 status=active
|- 1:0:0:0 sdb 8:16 active ready running ----多路径下的两个盘符sdb和sde.
`- 2:0:0:0 sde 8:64 active ready running
目录/dev/mapper/ 下多了两个文件夹mpatha 和mpathap1。
[root@liujing mapper]# cd /dev/mapper/
Disk /dev/sda: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 287 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 287 17850 141071360 83 Linux
Disk /dev/sdb: 3774 MB, 3774873600 bytes
117 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7254 * 512 = 3714048 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 65536 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1016 3685001 83 Linux
Partition 1 does not start on physical sector boundary.
Disk /dev/sde: 3774 MB, 3774873600 bytes
117 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7254 * 512 = 3714048 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 65536 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 1016 3685001 83 Linux
Partition 1 does not start on physical sector boundary.
配置后多了/dev/mapper/mpatha和/dev/mapper/mpathap1:
[root@localhost mapper]# fdisk -l
Disk /dev/sda: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 287 2097152 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 287 17850 141071360 83 Linux
Disk /dev/sdb: 3774 MB, 3774873600 bytes
117 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7254 * 512 = 3714048 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 65536 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1016 3685001 83 Linux
Partition 1 does not start on physical sector boundary.
Disk /dev/sde: 3774 MB, 3774873600 bytes
117 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7254 * 512 = 3714048 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 65536 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 1016 3685001 83 Linux
Partition 1 does not start on physical sector boundary.
Disk /dev/mapper/mpatha: 3774 MB, 3774873600 bytes
117 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 7254 * 512 = 3714048 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 65536 bytes
Device Boot Start End Blocks Id System
/dev/mapper/mpathap1 1 1016 3685001 83 Linux
Partition 1 does not start on physical sector boundary.
Disk /dev/mapper/mpathap1: 3773 MB, 3773441024 bytes
255 heads, 63 sectors/track, 458 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 65536 bytes
Disk /dev/mapper/mpathap1 doesn't contain a valid partition table
# multipath -F #删除现有路径 两个新的路径就会被删除
# multipath -v2 #格式化路径 格式化后又出现
要对多路径软件生成的磁盘进行操作直接操作/dev/mapper/目录下的磁盘就行.
在对多路径软件生成的磁盘进行分区之前最好运行一下pvcreate命令:
# fdisk /dev/mapper/mpatha 分区时用这个目录/dev/mapper/mpatha
用fdisk对多路径软件生成的磁盘进行分区保存时会有一个报错,此报错不用理会.
[root@liujing mnt]# ls -l /dev/mapper/
crw-rw----. 1 root root 10, 58 Mar 10 19:10 control
lrwxrwxrwx. 1 root root 7 Mar 10 20:28 mpatha -> ../dm-0
lrwxrwxrwx. 1 root root 7 Mar 10 20:33 mpathap1 -> ../dm-1
的mpathap1就是我们对multipath磁盘进行的分区
# mkfs.ext4 /dev/mapper/mpathap1 #对mpath1p1分区格式化成ext4文件系统
# mount /dev/mapper/mpathap1 /mnt/ #挂载mpathap1分区
4. 分区磁盘:
上面有提到分区时用目录/dev/mapper/mpatha
[root@liujing~]# fdisk /dev/mapper/mpatha
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xac956c3a.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n------------------------新建分区
Command action
e extended
p primary partition (1-4)
p-----------------------------主分区
Partition number (1-4): 1
First cylinder (1-1016, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1016, default 1016):
Using default value 1016
Command (m for help): w ---------------------写入列表相当于保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
注:如果同一台设备的两个node挂同样的盘符,另一个盘符还需要再次写入w就行。不需要n了。
5. 格式化:
[root@liujing ~]# mkfs.ext4 /dev/mapper/mpathap1
mke2fs 1.41.12 (17-May-2010)
/dev/sdd1 alignment is offset by 1024 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1 blocks, Stripe width=16 blocks
230608 inodes, 921250 blocks
46062 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=943718400
29 block groups
32768 blocks per group, 32768 fragments per group
7952 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6. 挂载 /dev/mapper/mpathap1 到 /mnt
[root@liujing ~]# mount /dev/mapper/mpathap1 /mnt
三、multipath的高级配置之前的配置都是用multipath的默认配置来完成multipath,比如映射设备的名称,multipath负载均衡的方法都是默认设置。那有没有按照我们自己定义的方法来配置multipath呢,答案是OK。
1、multipath.conf文件的配置
接下来的工作就是要编辑/etc/multipath.conf的配置文件
multipath.conf主要包括blacklist、multipaths、devices三部份的配置
blacklist配置
blacklist {
devnode "^sda"
}
Multipaths部分配置multipaths和devices两部份的配置。
multipaths {
multipath {
wwid **************** #此值multipath -v3可以看到
alias iscsi-dm0 #映射后的别名,可以随便取
path_grouping_policy multibus #路径组策略
path_checker tur #决定路径状态的方法
path_selector "round-robin 0" #选择那条路径进行下一个IO操作的方法
}
}
Devices部分配置
devices {
device {
vendor "iSCSI-Enterprise" #厂商名称
product "Virtual disk" #产品型号
path_grouping_policy multibus #默认的路径组策略
getuid_callout "/sbin/scsi_id -g -u -s /block/%n" #获得唯一设备号使用的默认程序
prio_callout "/sbin/acs_prio_alua %d" #获取有限级数值使用的默认程序
path_checker readsector0 #决定路径状态的方法
path_selector "round-robin 0" #选择那条路径进行下一个IO操作的方法
failback immediate #故障恢复的模式
no_path_retry queue #在disable queue之前系统尝试使用失效路径的次数的数值
rr_min_io 100 #在当前的用户组中,在切换到另外一条路径之前的IO请求的数目
}
}
下面是相关参数的标准文档的介绍:
Attribute |
Description |
|||||||||
wwid |
Specifies the WWID of the multipath device to which the multipath attributes apply. This parameter is mandatory for this section of themultipath.conf file. |
|||||||||
alias |
Specifies the symbolic name for the multipath device to which themultipath attributes apply. If you are using user_friendly_names, do not set this value tompathn; this may conflict with an automatically assigned user friendly name and give you incorrect device node names. |
|||||||||
path_grouping_policy |
|
|||||||||
path_selector |
|
|||||||||
failback |
|
|||||||||
prio |
|
|||||||||
no_path_retry |
|
|||||||||
rr_min_io |
Specifies the number of I/O requests to route to a path before switching to the next path in the current path group. This setting is only for systems running kernels older that 2.6.31. Newer systems should userr_min_io_rq. The default value is 1000. |
|||||||||
rr_min_io_rq |
Specifies the number of I/O requests to route to a path before switching to the next path in the current path group, using request-based device-mapper-multipath. This setting should be used on systems running current kernels. On systems running kernels older than 2.6.31, use rr_min_io. The default value is 1. |
|||||||||
rr_weight |
If set to priorities, then instead of sending rr_min_io requests to a path before callingpath_selector to choose the next path, the number of requests to send is determined byrr_min_io times the path's priority, as determined by the prio function. If set touniform, all path weights are equal. |
|||||||||
flush_on_last_del |
If set to yes, then multipath will disable queueing when the last path to a device has been deleted. |
在我本地的一个完整的高级配置如下:
[root@liujing ~]# vi /etc/multipath.conf
blacklist {
devnode "^sda"
}
multipaths {
multipath {
wwid 360a98000646650724434697454546156
alias mpathb_fcoe
path_grouping_policy multibus
#path_checker "directio"
prio "random"
path_selector "round-robin 0"
}
}
devices {
device {
vendor "NETAPP"
product "LUN"
getuid_callout "/lib/udev/scsi_id --whitelisted --device=/dev/%n"
#path_checker "directio"
#path_selector "round-robin 0"
failback immediate
no_path_retry fail
}
}
其中 wwid,vendor,product, getuid_callout这些参数可以通过:multipath -v3命令来获取。如果在/etc/multipath.conf中有设定各wwid 别名,别名会覆盖此设定。
转载于:https://blog.51cto.com/leesbing/1905448
linux 多路径配置相关推荐
- 多路径配置udev_学习笔记:Linux多路径配置 multipath实现设备用户组绑定详细设置...
天萃荷净 Linux多路径软件配置,通过multipath实现设备用户组绑定详细设置 现在的Linux系统中,很多都会使用系统自带的multipath多路径软件,在以前的版本中,我们一般通过multi ...
- linux多路径策略配置,linux 多路径配置
首先介绍一下什么是多路径(multi-path)?先说说多路径功能产生的背景,在多路径功能出现之前,主机上的硬盘是直接挂接到一个总线(PCI)上,路径是一对一的关系,也就是一条路径指向一个硬盘或是存储 ...
- linux vi路径配置,Linux 下 Vi 配置文件 .vimrc 文件
配置 vim 的方法是在用户主目录下建立个.vimrc文件,我一般使用root帐户,所以就在/root/下建立一个.vimrc文件:vi /root/.vimrc,以下是我的配置,直接复制粘贴进去即可 ...
- Linux共享库路径配置
Linux共享库路径配置 Linux下找不到共享库文件的典型现象为明明已经安装某个软包(如libnet,MySQL),编译链接可以正常进行,但是在运行时出现如"error while loa ...
- linux系统开启多路径,Linux系统怎么配置多路径
摘要 腾兴网为您分享:Linux系统怎么配置多路径,追追漫画,中国知网,小米社区,问作业等软件知识,以及天天ios,四维看看,镜子,中国北斗卫星导航系统,精准数据采集,qq应用宝,券之家,毒app,任 ...
- linux 多路径 parted,Ubuntu存储多路径配置
Ubuntu 的存储多路径配置和redhat基本类似,大体如下 安装multipath-tool apt-get install multipath-tools 编辑multipath.conf vi ...
- 超详干货!Linux 环境变量配置全攻略
点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 本文转自|机器学习实验室 Linux环境变量配置 在自定义安装软件 ...
- Ubuntu Linux下如何配置Android开发环境
下载和安装Win7系统Android开发环境中讲了怎样在Win7系统中安装Android开发环境,那么怎样在Linux系统中配置Android开发环境呢?本篇文章就将演示如何使用Eclipse.And ...
- linux 多路径重启,(linux多路径连接iScsi存储重启自动连接.docx
(linux多路径连接iScsi存储重启自动连接 RHEL系统带有iSCSI initiator软件,下面描述如何配置iSCSI Initiator实现对ISCSI卷的访问Linux iscsi 介绍 ...
- linux cmake 交叉编译配置 简介
很多时候,我们在开发的时候是面对嵌入式平台,因此由于资源的限制需要用到相关的交叉编译.即在你host宿主机上要生成target目标机的程序.里面牵扯到相关头文件的切换和编译器的选择以及环境变量的改变等 ...
最新文章
- Java 集合类详解
- 哈佛牙学院博士后:教你口腔保健基本功之刷牙篇
- HIve分组查询返回每组的一条记录
- POJ2402+模拟
- Python单元测试之unittest
- qdialog 返回值_python-PyQt QDialog返回响应是或否
- PHP 发邮件《转》
- Groovy语言之SpringBoot整合JDBC案例
- ZooKeeper配额指南
- 专门针对音乐发烧友开发的5款App
- golang笔记(1)-数据库查询结果映射至结构体
- 数学分析教程(科大)——6.4笔记+习题
- JDK下载常用的几种方法
- 深度学习入门-基于python的理论与实现(五)误差反向传播法
- AGV调度系统实现(一)
- 如何将word文档转换成电子书?
- 班章管家理财入门基础常识有什么?理财产品怎样买最合适
- html document自动加载,document.html
- train_test_split(),随机划分训练集和测试集的函数
- mysql创建外键时1025_navicat设置外键报错1025怎么办
热门文章
- Atitti html5 h5 新特性attilax总结
- Atitit.判断汉字的编码 regedit 注册表里面的reg_sz
- Atitit.jsou html转换纯文本 java c# php
- Atitit.软件开发概念(11)--网络子系统--url编码 空格问题URLEncoder java js php
- atitit.html5 拼图游戏的解决之道.
- paip.hibernate save 失败的解决
- paip.提升用户体验----注册用户名可修改\
- 王川: 重要的东西, 往往是看不见的
- Rust : 闭包、move 与自由变量的穿越
- 【回归预测】基于matlab麻雀搜索算法优化CNN回归预测【含Matlab源码 282期】