手机版
你好,游客 登录 注册
背景:
阅读新闻

Multipath实现LUN设备名称的持久化

[日期:2013-04-23] 来源:CSDN  作者:tianlesoftware [字体:大 中 小]

2.3.4 重启multipathd 服务,验证配置

 

[root@rac1 dev]# service multipathd restart

Device /dev/sda1 not found

Command failed

Stopping multipathd daemon: [OK]

Starting multipathd daemon: [OK]

 

 

进入/dev/mapper 目录进行验证:

root@rac3 mapper]# ls -lrt /dev/mapper/*

crw------- 1 root root10, 62 Nov1 05:51 /dev/mapper/control

brw-rw---- 1 root disk 253,0 Nov1 06:20 /dev/mapper/rac-share

 

 

用 multipath –ll 命令查看到两条活跃路径,他们之间互为A/A 关系。断掉其中一根线路,那么系统自动切换到另外一条。

[root@rac3 mapper]# multipath -ll

rac-share (14f504e46494c450034594d6462472d534745442d6a714841) dm-0 OPNFILER,VIRTUAL-DISK

[size=37G][features=1 queue_if_no_path][hwhandler=0][rw]

/_ round-robin 0 [prio=2][active]

/_ 2:0:0:0 sdf 8:80[active][ready]

/_ 3:0:0:0 sdg 8:96[active][ready]

 

 

2.3.5 将multipathd服务设置成开机自启动

[root@rac3 mapper]# chkconfig multipathd on

 

 

2.3.6 分区或者创建PV

看到了我们刚才配置的多路径的目录。 但是这里有一个问题。 因为这个是设备创建的,还不能挂载。我们需要对个这个设备进行分区或者创建为PV.

 

注意,用fdisk分区并保存后,必须刷新multipath的映射表,以便其创建分区对应的设备符.

 

(1)分区

 

[root@rac3 mapper]# fdisk /dev/mapper/rac-share

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

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

 

The number of cylinders for this disk is set to 4838.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

Command (m for help): n

Command action

eextended

pprimary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-4838, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-4838, default 4838):

Using default value 4838

 

Command (m for help): w

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.

Syncing disks.

 

[root@rac3 mapper]# multipath -F --清除多路径设备缓存

[root@rac3 mapper]# multipath –v3--重新加载

[root@rac3 mapper]# fdisk -l

……

Disk /dev/sdf: 39.7 GB, 39795556352 bytes

255 heads, 63 sectors/track, 4838 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Device BootStartEndBlocksIdSystem

/dev/sdf11483838861203+83Linux

 

Disk /dev/sdg: 39.7 GB, 39795556352 bytes

255 heads, 63 sectors/track, 4838 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Device BootStartEndBlocksIdSystem

/dev/sdg11483838861203+83Linux

 

Disk /dev/dm-0: 39.7 GB, 39795556352 bytes

255 heads, 63 sectors/track, 4838 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Device BootStartEndBlocksIdSystem

/dev/dm-0p11483838861203+83Linux

 

分区之后使用fdisk –l 命令查看磁盘会看到磁盘下面已经有分区的信息了。 这时磁盘就可以mount挂载及使用了。

 

 

(2)创建PV

 

要配置LVM,可以按以下步骤进行:

1. 创建和初始化物理卷(Physical Volume),通过pvcreate建立pv,即pv阶段;

2. 添加物理卷到卷组(Volume Group),使用vgcreate加入多个pv成为vg,即vg阶段;

3. 在卷组上创建逻辑卷(logical volume),使用lvcreate划分vg,成为一个或多个lv,即lv阶段;

 

常用命令:

# pvcreate /dev/md0#创建PV

# pvscan

# vgcreate LVM1 /dev/md0#创建VG

# vgdisplayLVM1

# lvcreate -L 1.5TB -n data1 LVM1#创建LV

# lvcreate -L 325GB -n data2 LVM1#创建LV

# lvscan#查看LV信息

# pvscan#再次查看PV信息

# vgdisplay LVM1#再次查看VG信息

 

 

挂载命令:

#mount /dev/LVM1/data1 /data1

#mount /dev/LVM1/data2 /data2

 

设置开机自动挂载:

编辑/etc/fstab

/dev/LVM1/data1/data1ext3defaults2 2

/dev/LVM1/data2/data2ext3defaults2 2

 

 

示例:

 

[root@rac3 mapper]# pvcreate /dev/mapper/rac-share

Physical volume "/dev/mapper/rac-share" successfully created

[root@rac3 mapper]# vgcreate vg0 /dev/mapper/rac-share

Volume group "vg0" successfully created

[root@rac3 mapper]# lvcreate -L 10M -n lv1 vg0

Rounding up size to full physical extent 12.00 MB

Logical volume "lv1" created

[root@rac3 mapper]# lvdisplay

--- Logical volume ---

LV Name/dev/vg0/lv1

VG Namevg0

LV UUIDXkbDyS-btpZ-fIFA-MvBH-d4kl-hibU-RhuKu1

LV Write Accessread/write

LV Statusavailable

# open0

LV Size12.00 MB

Current LE3

Segments1

Allocationinherit

Read ahead sectorsauto

- currently set to256

Block device253:1

[root@rac3 mapper]# mkfs.ext3 /dev/mapper/vg0-lv1 -- 格式化

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

3072 inodes, 12288 blocks

614 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=12582912

2 block groups

8192 blocks per group, 8192 fragments per group

1536 inodes per group

Superblock backups stored on blocks:

8193

 

Writing inode tables: done

Creating journal (1024 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 28 mounts or

180 days, whichever comes first.Use tune2fs -c or -i to override.

 

 

注意:

有部分multipath版本存在与lvm兼容的问题。当使用device-mapper设备创建lvm完成,重启后,虽然lvm仍存在,但/dev/mapper下的设备丢失。可以参考:

https://bugs.launchpad.net/Ubuntu/+source/multipath-tools/+bug/230006

 

解决方法:

/etc/lvm/lvm.conf文件中加入:

types=["device-mapper", 1]

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款