สวัสดีครับ วันนี้จะมาแนะนำวิธีการคอนฟิก Multipath I/O สำหรับ SAN Storage บน Ubuntu Server กันครับ
อะไรคือ Multipath ตามความเข้าใจของผมคือ สมมติว่าเราสร้าง Volume หรือ LUN ไว้บน Storage ไว้ 1 Volume/LUN แต่เรา Present Volume หรือ LUN นั้นออกมาจาก Port FC 2 Port เพื่อป้องกันการ Fail ของอุปกรณ์ จะทำให้เครื่อง Server เห็น Volume/LUN นั้นเป็น Disk 2 ลูก ทั้งที่จริงแล้วมันคือ Volume/LUN เดียวกัน ดังนั้นเราจำเป็นต้องทำการ Map ให้เครื่อง Server ของเราเห็น Disk เพียงลูกเดียวด้วยการทำ Multipath
ในตัวอย่างนี้ผมใช้ Ubuntu 10.04.3 LTS Server กับ SAN Storage HP MSA P2000 นะครับ
สำหรับ Ubuntu นั้นมี Package ตัวนึงที่ชื่อ multipath-tools ซึ่งเราสามารถติดตั้งด้วยใช้คำสั่ง
root@server1:~# apt-get install multipath-tools
ติดตั้งเสร็จแล้วก็ทำการสร้างไฟล์ /etc/multipath.conf โดยจะคำสั่ง vi สร้างไฟล์ขึ้นมาใหม่หรือจะใช้ cat ตามตัวอย่างด้านล่างก็ได้
root@server1:~# cat <<EOF > /etc/multipath.conf
defaults {
user_friendly_names yes
path_grouping_policy group_by_serial
path_checker tur
}
blacklist {
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^sda"
# blacklist any other locally attached block devices here
}
EOF
จากนั้นสั่ง restart service multipath-tools สักรอบ
root@agoldap:~# /etc/init.d/multipath-tools restart
ดูผลด้วยคำสั่ง multipath -lv
root@server1:~# multipath -lv
mpath0 (3600c0ff000134ec320b7334f02000000) dm-0 ,
[size=149G][features=0][hwhandler=0]
\_ round-robin 0 [prio=0][active]
\_ #:#:#:# - #:# [active][undef]
\_ round-robin 0 [prio=0][enabled]
\_ 0:0:1:14 sdb 8:16 [active][undef]
\_ round-robin 0 [prio=0][enabled]
\_ 1:0:0:14 sdc 8:32 [active][undef]
\_ round-robin 0 [prio=0][enabled]
\_ 1:0:1:14 sdd 8:48 [active][undef]
ผมก็จะได้ประมาณนี้ โดยเวลาเราจะอ้างถึง raw disk ก็อ้างชื่อเป็น mpath0 ซึ่งอยู่ใน /dev/mapper/mpath0
ลองทดสอง fdisk กันเลย
root@server1:~# fdisk /dev/mapper/mpath0
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): p
Disk /dev/mapper/mpath0: 160.0 GB, 160000000000 bytes
255 heads, 63 sectors/track, 19452 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: 0x8ca1da99
Device Boot Start End Blocks Id System
/dev/mapper/mpath0p1 * 1 19452 156248158+ 83 Linux
Command (m for help): d
Selected partition 1
Command (m for help): p
Disk /dev/mapper/mpath0: 160.0 GB, 160000000000 bytes
255 heads, 63 sectors/track, 19452 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: 0x8ca1da99
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-19452, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-19452, default 19452):
Using default value 19452
Command (m for help): p
Disk /dev/mapper/mpath0: 160.0 GB, 160000000000 bytes
255 heads, 63 sectors/track, 19452 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: 0x8ca1da99
Device Boot Start End Blocks Id System
/dev/mapper/mpath0p1 1 19452 156248158+ 83 Linux
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
ดู Partition ที่เราสร้างโดยการเข้าไปเช็คที่ /dev/mapper
root@server1:~# cd /dev/mapper/
root@server1:/dev/mapper# ls -l
total 0
crw-rw---- 1 root root 10, 59 2012-05-15 14:14 control
brw-rw---- 1 root disk 251, 0 2012-05-15 15:25 mpath0
brw-rw---- 1 root disk 251, 1 2012-05-15 15:25 mpath0-part1
root@server1:/dev/mapper#
Partition ที่เราเพิ่งสร้างคือ mpath0-part1
ทีนี้ลองมา format มันเป็น ext4 กัน
root@server1:~# mkfs.ext4 /dev/mapper/mpath0-part1
mke2fs 1.41.11 (14-Mar-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
9773056 inodes, 39062039 blocks
1953101 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1193 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
เสร็จแล้วก็ลอง mount ไปใช้ดู
root@server1:~# mount /dev/mapper/mpath0-part1 /backup
root@server1:~# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/cciss/c0d0p1 130G 2.1G 121G 2% /
none 3.9G 236K 3.9G 1% /dev
none 4.0G 0 4.0G 0% /dev/shm
none 4.0G 104K 3.9G 1% /var/run
none 4.0G 0 4.0G 0% /var/lock
none 4.0G 0 4.0G 0% /lib/init/rw
none 130G 2.1G 121G 2% /var/lib/ureadahead/debugfs
/dev/mapper/mpath0-part1
147G 188M 140G 1% /backup
หากต้องการจะให้มัน mount เองทุกครั้งตอนเปิดเครื่องก็เข้าไปแก้ไขไฟล์ /etc/fstab เองนะครับ
เป็นอันเสร็จครับ
แหล่งข้อมูล : https://www.sit.auckland.ac.nz/Configuring_SAN_access_with_Linux_multipath