CentOS6.5系统光纤连接存储的多路径配置及使用方法




CentOS 

系统光纤连接存储的多路径配置及使用方法

 

1

、安装多路径软件包:

 

device-mapper-1.02.67-2.el5 

device-mapper-event-1.02.67.2.el5 

device-mapper-multipath-0.4.7-48.el5 

2

、检查安装包的安装情况

 

#rpm 

aq |grep multipath 

 

3

、安装上述多路径软件包

 

# rpm -ivh device-mapper-1.02.67-2.el5.x86_64.rpm 

# rpm -ivh device-mapper-event-1.02.67-2.el5.x86_64.rpm 

# rpm -ivh device-mapper-multipath-0.4.7-48.el5.x86_64.rpm 

安装过程中可能会提示需要安装其他的关联软件包

主要与多路径软件相关联的软件包如下

libaio-0.3.107-10.e16.i686.rpm 

libaio-0.3.107-10.e16.x86_64.rpm 

libaio-devel-0.3.107-10.e16.i686.rpm 

libaio-devel-0.3.107-10.e16.x86_64.rpm 

如服务器可以连接公网的话

,

可直接用

yum

来安装

,yum

会自动将相关联的软件安装上

#yum install y 

device-mapper* 

检查安装情况

 

#rpm 

aq|grep multipath 

 

安装完成后需重启机器

4

、配置多路径软件

multipath 

4.1 

、将多路径软件添加至内核模块中

 

#modprobe dm-multipath 

#modprobe dm-round-robin 

检查内核添加情况

 

#lsmod |grep multipath 

 

4.2

、将多路径软件

multipath

设置为开机自启动

 

#chkconfig 

 

--level 2345 multipathd on 

检查

 

#chkconfig 

 

--list|grep multipathd 

 

启动

multipath

服务

 

#service multipathd restart 

4.3

、配置

multipath

软件

编辑

/etc/multipath.conf 

 

 

 

注意

:

默认情况下

, /etc/multipath.conf

是不存在的

,

需要做如下准备工作

4.3.1 

 

cd

/sbin

,

用如下命令生成

multipath.conf

文件

#mpathconf --enable --find_multipaths y --with_module y --with_chkconfig y 

4.3.2

、查看并获取存储分配给服务器的逻辑盘

lun

wwid

信息

 

#more /etc/multipath/wwids 

 

 

编辑

/etc/multipath.conf,

编辑

multipath

的配置文件时

,

可将自动生成的

multipath.conf

保留

,

重新

vim

个新的

multipath

文件

#vim /etc/multipath.conf 

[root@ahltimt3 ~]# vim /etc/multipath.conf 

defaults { 

 

 

 

 

 

 

 

 

find_multipaths yes 

 

 

 

 

 

 

 

 

user_friendly_names no 

blacklist { 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#-------

黑名单项

:

即不使用多路径的硬盘

,

如服务器本地盘等

 

 

 

 

 

 

 

wwid 3600508b1001c5ae72efe1fea025cd2e5 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#-------

不使用多路径的本地盘

wwid

 

 

 

 

 

 

 

devnode "^hd[a-z]" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#--------

不使用多路径的本地盘

hd

名称

 

multipaths { 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#---

使用多路径软件项

 

 

 

 

 

 

 

 

multipath { 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#---

单块存储盘配置

,

如有多块存储盘

,

如多个

multipath{}

配置

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

wwid 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

360050763008181d6d000000000000021

 

 

 

 

 

 

 

 

 

#---

使用多路径的存储盘

wwid

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

alias 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

IBMStorage001

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#

该存储盘多路径后的别名

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_grouping_policy 

 

 

 

multibus 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_selector 

 

 

 

 

 

 

 

 

 

 

"round-robin 0" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

failback 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

manual 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

rr_weight 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

priorities

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

no_path_retry 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

multipath { 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

wwid 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

360050763008181d6d000000000000022 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

alias 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

IBMStorage002 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_grouping_policy 

 

 

 

multibus 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_selector 

 

 

 

 

 

 

 

 

 

 

"round-robin 0" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

failback 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

manual 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

rr_weight 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

priorities 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

no_path_retry 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

devices { 

 

 

 

 

 

 

 

device { 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

vendor 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

"IBM" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#---

存储厂家名称

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

product 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

"V5000" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#---

存储产品型号

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_grouping_policy 

 

 

 

multibus 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

getuid_callout 

 

 

 

 

 

 

 

 

 

"/lib/udev/scsi_id --whitelisted --device=/dev/%n" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_checker 

 

 

 

 

 

 

 

 

 

 

 

readsector0 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

path_selector 

 

 

 

 

 

 

 

 

 

 

"round-robin 0" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

hardware_handler 

 

 

 

 

 

 

 

"0" 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

failback 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

15 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

rr_weight 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

priorities 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

no_path_retry 

 

 

 

 

 

 

 

 

 

 

queue 

 

 

 

 

 

 

 

保存文件后退出

4.4

、启动

multipath

配置

 

#multipath 

v2 

 

由上图可看出

,

名称为

IBMStorage015

的逻辑盘的

wwid

号为

360050763008181d6d000000000000001,

产品

型号为

IBM2145,

该逻辑盘大小为

200G,

4

条链路

,

每条链路的状态均为

running

,

4

条链路均正常

.(

图中环

境为存储双控制器

---

SAN---

服务器双

HBA

,

当存储划分一个

lun

逻辑盘给服务器后

,

服务器因为一个

lun

逻辑

盘多条链路的原因会在系统中生成

4

块相同的

wwid

号的逻辑盘

,

这样就给系统的使用带来不便

,

故需要引入多路

径软件

.

当然多路径软件最主要是为了安全

,

4

条链路中的某一条两条三条出现故障的情况

,

仍然不影响系统的

使用

查看、检查多路径情况

 

# multipath -l|more 

 

启用

multipath

配置后

,

会在

/dev/mapper

下生成多路径逻辑盘

 

#cd /dev/mapper 

#ll 

 

至此

,

多路径

multipath

配置完成

 

5

LVM

使用和管理多路径逻辑盘

 

5.1

fdisk 

磁盘分区

 

由上述图中环境可知,单块逻辑盘大小为

200G,

若需要使用小于

200G

,

需要将这

200G

进行

fdisk

分区

,

即上图

中的

p1(

分成多块时

,

会有

p2

p3

#fdisk /dev/mapper/IBMStorage004 

[root@ahltimt3 mapper]# fdisk /dev/mapper/IBMStorage004 

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel 

Building a new DOS disklabel with disk identifier 0xe24e10c0. 

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): 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#-----

新建分区

 

Command action 

 

 

 

 

 

extended 

 

 

 

 

 

primary partition (1-4) 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#----

分区类型为主分区

 

Partition number (1-4):

 1 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#-----

分区号即

p?

 

First cylinder (1-26108, default 1): 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#----

分区在逻辑盘的开始块号

 

Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): 

26108

 

 

 

 

 

 

#----

分区在逻辑盘的结束块号

 

Command (m for help):

 t 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#----

编辑分区类型

 

Selected partition 1 

Hex code (type L to list codes):

 8e 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#----8e

linux

使用的逻辑卷类型

(

查看所有类型可

L

查看

Changed system type of partition 1 to 8e (Linux LVM) 

Command (m for help): 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#-----

查看刚刚分区的类型信息

 

Disk /dev/mapper/IBMStorage004: 214.7 GB, 214748364800 bytes 

255 heads, 63 sectors/track, 26108 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 

Disk identifier: 0xe24e10c0 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Device Boot 

 

 

 

 

 

Start 

 

 

 

 

 

 

 

 

End 

 

 

 

 

 

Blocks 

 

 

Id 

 

System 

/dev/mapper/

IBMStorage004p1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

26108

 

 

 

209712478+ 

 

8e

 

 

Linux LVM

 

Command (m for help): 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

#-----

保存后退出

 

The partition table has been altered! 

Calling ioctl() to re-read partition table. 

WARNING: Re-reading the partition table failed with error 22: Invalid argument. 

The kernel still uses the old table. The new table will be used at 

the next reboot or after you run partprobe(8) or kpartx(8) 

Syncing disks. 

#cd /dev/mapper 

#ll 

 

此图中多出一个

IBMStrage004p1 

5.2

、创建物理卷

 

#pvcreate /dev/mapper/IBMStorage004p1 

 

5.3

、创建卷组

 

#vgcreate vgdata002 /dev/mapper/IBMStorage004p1 

 

5.4

、创建逻辑卷

 

#lvcreate -L 100G -n lv_data002 vgdata002 

 

5.5

、格式化逻辑卷

 

# mkfs.ext4 

 

/dev/vgdata002

/lv_data002 

 

#mount /dev/vgdata002

/lv_data002 /wjshtest 

 

说明

:

使用

lvm

管理逻辑盘后

,

即可在线对

VG

LV

等的在线增加

/

减少等操作。参考命令有:

 

#vgextend vgdata002 /dev/mapper/IBMStorage003p1 

 

----

扩展卷组

(

将物理卷

IBMStorage003p1

添加到

vgdata002) 

#lvextend -L +20G /dev/vgdata2

/lvdata2 

 

 

 

 

 

 

 

 

 

 

 

 

-----

扩展逻辑卷

(

增加

20G) 

#lvreduce -L -20G /dev/vgdata2

/lvdata2 

 

 

 

 

 

 

 

 

 

 

 

 

-----

缩小逻辑卷

(

减少

20G) 

#resize2fs -p /dev/mapper/vgmedia-lv_media 

 

 

 

 

 

 

 

------

扩展文件系统

 

 

 

 

 

多路径软件的命令可用

#multipath 

help

查看






  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值