在存儲上共享了一個500G的空間,映射到Linux系統提供上,環境由2個節點組成。node
用fdisk 格式化以後以下:app
[root@rac1 u01]# fdisk -l框架
……ide
Disk /dev/sdk: 536.8 GB, 536870912000 bytes工具
255 heads, 63 sectors/track, 65270cylinders測試
Units = cylinders of 16065 * 512 = 8225280bytesspa
Device Boot Start End Blocks Id System插件
/dev/sdk1 1 65270 524281243+ 83 Linuxrest
……orm
[root@rac1u01]#
可是建立文件系統時報錯:
[root@rac1 u01]# mkfs -t ext3 /dev/sdk1
mke2fs 1.39 (29-May-2006)
/dev/sdk1 isapparently in use by the system; will not make a filesystem here!
提示/dev/sdk1 正在被使用。 /dev/sdk1 正在被DM管理,因此咱們建立文件系統時提示報錯,咱們手工的移除,就能夠正常的建立文件系統,操做以下:
[root@rac1 u01]# dmsetup status
mpath2: 0 2097152 multipath 2 0 1 0 1 1 A 01 0 8:16 A 0
mpath11p1: 0 1048562487 linear
mpath9: 0 209715200 multipath 2 0 1 0 1 1 A0 1 0 8:128 A 0
mpath8: 0 629145600 multipath 2 0 1 0 1 1 A0 1 0 8:112 A 0
mpath7: 0 629145600 multipath 2 0 1 0 1 1 A0 1 0 8:96 A 0
mpath6: 0 2097152 multipath 2 0 1 0 1 1 A 01 0 8:80 A 0
mpath5: 0 2097152 multipath 2 0 1 0 1 1 A 01 0 8:64 A 0
mpath11: 0 1048576000 multipath 2 0 1 0 1 1A 0 1 0 8:160 A 0
mpath4: 0 2097152 multipath 2 0 1 0 1 1 A 01 0 8:48 A 0
mpath10: 0 209715200 multipath 2 0 1 0 1 1A 0 1 0 8:144 A 0
mpath3: 0 2097152 multipath 2 0 1 0 1 1 A 01 0 8:32 A 0
[root@rac1 u01]# dmsetup remove_all
[root@rac1 u01]# dmsetupstatus
No devices found
[root@rac1 u01]# mkfs -text3 /dev/sdk1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
65536000 inodes, 131070310 blocks
6553515 blocks (5.00%) reserved for thesuper user
First data block=0
Maximum filesystem blocks=4294967296
4000 block groups
32768 blocks per group, 32768 fragments pergroup
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystemaccounting information: done
This filesystem will be automaticallychecked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
--建立文件系統成功。
--mount 成功:
[root@rac1 u01]# mount /dev/sdk1/u01/backup
[root@rac1 u01]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 59G 22G 35G 39% /
/dev/sda1 996M 51M 894M 6% /boot
tmpfs 32G 0 32G 0% /dev/shm
/dev/sda4 145G 188M 138G 1% /u01/dave
/dev/sdk1 493G 198M 467G 1% /u01/backup
--修改/etc/fstab 文件,讓開機自動掛載:
[root@rac2 mapper]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/sdk1 /u01/backup ext3 defaults 0 0
但重啓後測試,該文件不能正常掛載,手工掛載也會失敗。
因此,這種解決方法不行。
補充內容:
Device mapper 是 Linux 2.6 內核中提供的一種從邏輯設備到物理設備的映射框架機制,在該機制下,用戶能夠很方便的根據本身的須要制定實現存儲資源的管理策略,如條帶化,鏡像,快照等. 當前比較流行的 Linux 下的邏輯卷管理器如 LVM2(Linux Volume Manager 2 version)、EVMS(EnterpriseVolume Management System)、dmraid(Device Mapper RaidTool)等都是基於該機制實現的. 只要用戶在用戶空間制定好映射策略,按照本身的須要編寫處理具體IO請求的 target driver插件,就能夠很方便的實現這些特性.
Device Mapper主要包含內核空間的映射和用戶空間的device mapper庫及dmsetup工具.
關於Multipath的配置說明,參考:
Multipath實現LUN設備名稱的持久化
http://www.cndba.cn/Dave/article/725
--獲取wwid:
[root@rac1 mapper]# /sbin/scsi_id -g -u -s/block/sdk
3690b11c00022bc0e000003e55105b786
--修改multipath.conf 文件:
[root@rac1 mapper]# vi /etc/multipath.conf
multipaths {
multipath {
wwid 3690b11c00022bc0e000003e55105b786
alias backup
path_grouping_policy multibus
path_checker readsector0
path_selector "round-robin 0"
failback manual
rr_weight priorities
no_path_retry 5
}
# multipath {
# wwid 1DEC_____321816758474
# alias red
# }
}
"/etc/multipath.conf" 177L, 4832Cwritten
--重啓multipath:
[root@rac1 mapper]# service multipathdrestart
Stopping multipathd daemon: [ OK ]
Starting multipathd daemon: [ OK ]
--檢查文件:
[root@rac1 mapper]# cd /dev/mapper/
[root@rac1 mapper]# ll
total 0
brw-rw---- 1 root disk253, 9 Feb 20 12:35 backup
brw-rw---- 1 root disk253, 10 Feb 20 12:35 backupp1
crw------- 1 root root 10, 60 Feb 20 12:35 control
brw-rw---- 1 root disk 253, 8 Feb 20 12:35 mpath10
brw-rw---- 1 root disk 253, 0 Feb 20 12:35 mpath2
brw-rw---- 1 root disk 253, 1 Feb 20 12:35 mpath3
brw-rw---- 1 root disk 253, 2 Feb 20 12:35 mpath4
brw-rw---- 1 root disk 253, 3 Feb 20 12:35 mpath5
brw-rw---- 1 root disk 253, 4 Feb 20 12:35 mpath6
brw-rw---- 1 root disk 253, 5 Feb 20 12:35 mpath7
brw-rw---- 1 root disk 253, 6 Feb 20 12:35 mpath8
brw-rw---- 1 root disk 253, 7 Feb 20 12:35 mpath9
--mount 文件:
[root@rac1 mapper]# mount/dev/mapper/backupp1 /u01/backup
--檢查mount:
[root@rac1 mapper]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 59G 22G 34G 39% /
/dev/sda1 996M 51M 894M 6% /boot
tmpfs 32G 364M 32G 2% /dev/shm
/dev/sda4 145G 188M 138G 1% /u01/dave
/dev/mapper/backupp1 493G 198M 467G 1% /u01/backup
修改/etc/fstab文件後,重啓能夠正常的自動掛載。可是這裏是2個節點,存儲配置的也是共享的。 可是在節點1建立的文件,在節點2上不能識別,經測試,只有在從新mount以後,才能夠看到另外一個節點建立的文件。
測試步驟以下:
[root@rac1 backup]# ll
total 24
-rw-r--r-- 1 root root 0 Feb 20 12:57 bl
drwxr-xr-x 2 root root 4096 Feb 20 12:55 dave
-rw-r--r-- 1 root root 5 Feb 20 12:55 dvd
drwx------ 2 root root 16384 Feb 20 12:10lost+found
--建立文件orcl:
[root@rac1 backup]# touch orcl
--在節點2 umount 目錄:
[root@rac2 backup]# umount /u01/backup
umount: /u01/backup: device is busy
umount: /u01/backup: device is busy
[root@rac2 backup]# fuser -km /u01/backup
/u01/backup: 9848c
[root@rac2 ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 70G 20G 46G 31% /
/dev/sda1 996M 51M 894M 6% /boot
tmpfs 32G 364M 32G 2% /dev/shm
/dev/mapper/backupp1 493G 198M 467G 1% /u01/backup
[root@rac2 ~]# umount /u01/backup
--確認umount 成功:
[root@rac2 ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 70G 20G 46G 31% /
/dev/sda1 996M 51M 894M 6% /boot
tmpfs 32G 364M 32G 2% /dev/shm
--再次mount:
[root@rac2 ~]# mount /dev/mapper/backupp1 /u01/backup
[root@rac2 ~]# cd /u01/backup
[root@rac2 backup]# ll
total 24
-rw-r--r-- 1 root root 0 Feb 20 12:57 bl
drwxr-xr-x 2 root root 4096 Feb 20 12:55 dave
-rw-r--r-- 1 root root 5 Feb 20 12:55 dvd
drwx------ 2 root root 16384 Feb 20 12:10lost+found
-rw-r--r-- 1 root root 0 Feb 20 14:34 orcl
[root@rac2 backup]#
此次就在節點2上看到咱們節點1上建立的文件了。
---------------------------------------------------------------------------------------
版權全部,文章容許轉載,但必須以連接方式註明源地址,不然追究法律責任!
QQ:492913789
Email:ahdba@qq.com
Blog: http://www.cndba.cn/dave
Weibo: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware