linux磁盘关系知识心得
来源:程序员人生 发布时间:2015-01-07 08:57:47 阅读次数:2792次
之前也多多少少的了解过linux的磁盘管理,包括硬盘,逻辑盘,lvm等,但不系统,但昨天在检查linux
数据库的时候还是遇到了很多的问题和困惑,就顺便又温习了1下相干知识。
首先看1下磁盘的情况:df -k
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/mapper/vg_sspdb1-lv_root
51606140 2754580 46230120 6% /
tmpfs 32984140 0 32984140 0% /dev/shm
/dev/sda1 495844 38042 432202 9% /boot
/dev/mapper/vg_sspdb1-lv_home
777577944 201368 737877824 1% /home
/dev/mapper/ssp-data 1078031100 206080 1023064216 1% /opt/sspdata
看了这个后感觉分区不太公道,因而又查了磁盘的情况:fdisk -l
Disk /dev/sda: 897.0 GB, 896998047744 bytes
255 heads, 63 sectors/track, 109053 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: 0x0007306b
注:这块磁盘分了两个区,1个是linux分区,1个是lvm分区
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 109054 875461632 8e Linux LVM
注:下面的3个分区是linux了lv分区,就是vg下面的lv分区
Disk /dev/mapper/vg_sspdb1-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x00000000
Disk /dev/mapper/vg_sspdb1-lv_swap: 33.8 GB, 33848033280 bytes
255 heads, 63 sectors/track, 4115 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: 0x00000000
Disk /dev/mapper/vg_sspdb1-lv_home: 808.9 GB, 808934440960 bytes
255 heads, 63 sectors/track, 98347 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: 0x00000000
Disk /dev/sdb: 1121.5 GB, 1121501315072 bytes
255 heads, 63 sectors/track, 136348 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: 0x00000000
Disk /dev/sdc: 1121.5 GB, 1121501315072 bytes
255 heads, 63 sectors/track, 136348 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: 0x00000000
这个分区很奇怪当时看起来很1直没有弄懂,看名字也很奇怪,不像是vg或lv分区,后面明白了,后面会继续解释的。
Disk /dev/mapper/ssp-data: 1121.5 GB, 1121501315072 bytes
255 heads, 63 sectors/track, 136348 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: 0x00000000
先查1下pv信息,可以知道pv是由第1个硬盘的第2个盘构成的:pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_sspdb1
PV Size 834.91 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 213735
Free PE 0
Allocated PE 213735
PV UUID JIOUSx-HSBm-L1uJ-roee-DARr-BMRw-XfgeRP
然后再查vg信息:vgdisplay
--- Volume group ---
VG Name vg_sspdb1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 834.90 GiB
PE Size 4.00 MiB
Total PE 213735
Alloc PE / Size 213735 / 834.90 GiB
Free PE / Size 0 / 0
VG UUID 5fmSVl⑴ZfR-Z01F-Ktx0-qeKg-rB97-wxk27c
然后再查询lv验证上面的疑问:lvdisplay
--- Logical volume ---
LV Path /dev/vg_sspdb1/lv_root
LV Name lv_root
VG Name vg_sspdb1
LV UUID gxYyXJ-KdQY-XivF-ZfH8-ET7H-gX5Y-WjAVak
LV Write Access read/write
LV Creation host, time ssp-db⑴, 2014⑴2-05 17:42:41 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_sspdb1/lv_home
LV Name lv_home
VG Name vg_sspdb1
LV UUID NprKvy-Uc76-JjHf-oZo2-LxBR-NS59-ima9VJ
LV Write Access read/write
LV Creation host, time ssp-db⑴, 2014⑴2-05 17:42:46 +0800
LV Status available
# open 1
LV Size 753.38 GiB
Current LE 192865
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
--- Logical volume ---
LV Path /dev/vg_sspdb1/lv_swap
LV Name lv_swap
VG Name vg_sspdb1
LV UUID hD9Hx9-EonS-RpBH-Qiv0-s4kY-PeXv-Z6RaNG
LV Write Access read/write
LV Creation host, time ssp-db⑴, 2014⑴2-05 17:43:52 +0800
LV Status available
# open 1
LV Size 31.52 GiB
Current LE 8070
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
通过上面的查询得知,大概了解了,里面的关系,但有个问题就是/dev/mapper/ssp-data,这个磁盘信息1直不知道从哪里来的:
然后看1下硬盘信息,通过此信息可以知道lv和dm的对应关系 Block device 253:1和下面的major minor有关系:cat /proc/partitions
major minor #blocks name
8 0 875974656 sda
8 1 512000 sda1
8 2 875461632 sda2
253 0 52428800 dm-0
253 1 33054720 dm⑴
253 2 789975040 dm⑵
8 16 1095216128 sdb
8 32 1095216128 sdc
253 3 1095216128 dm⑶
然后查询 /dev/mapper/的详细信息,看到这个上面的名字和fdisk-l的名字很像了吧,下面的就是lv名字和硬盘的对应关系,所以我们从df-k看到的就是vg_sspdb1-lv_home这类名字,其实就是个快捷链接:ll /dev/mapper/
总用量 0
crw-rw----. 1 root root 10, 58 12月 22 11:35 control
lrwxrwxrwx. 1 root root 7 12月 22 11:45 ssp-data -> ../dm⑶
lrwxrwxrwx. 1 root root 7 12月 22 11:35 vg_sspdb1-lv_home -> ../dm⑵
lrwxrwxrwx. 1 root root 7 12月 22 11:35 vg_sspdb1-lv_root -> ../dm-0
lrwxrwxrwx. 1 root root 7 12月 22 11:35 vg_sspdb1-lv_swap -> ../dm⑴
但是还不知道ssp-data是从哪里来的。
然后再看1下存储装备及其文件系统的信息:cat /etc/fstab
/dev/mapper/vg_sspdb1-lv_root / ext4 defaults 1 1
UUID=1f705c1d-fc2c⑷3ee⑻7af⑷900830a3ec0 /boot ext4 defaults 1 2
/dev/mapper/vg_sspdb1-lv_home /home ext4 defaults 1 2
/dev/mapper/vg_sspdb1-lv_swap swap swap defaults 0 0
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
/dev/mapper/ssp-data /opt/sspdata ext4 _netdev 0 0
从上面的分析发现1个不1致的地方,就是ssp-data的类型是_netdev,从名字是上来看是和网络相干的。我们在接着查询。
查看1下iscsi存储情况,表示此期间启用了存储。
ps -ef|grep iscsi
root 2074 1972 10 14:24 pts/0 00:00:00 grep iscsi
[root@justin Packages]# chkconfig --list|grep iscsi
iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off
iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
查看1下iscsi的信息
more /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.redhat:4ef28aa338b5
显示磁盘阵列:iscsiadm -m node
10.11.102.2:3260,9 iqn.2000-09.com.fujitsu:storage-system.eternus-dx400:00C0C1P0
查看文件信息:ls /var/lib/iscsi/nodes/
iqn.2000-09.com.fujitsu:storage-system.eternus-dx400:00C0C1P0
然后查询,表示有多路径进行启动:ps -ef|grep multipathd
root 2726 1 0 2014 ? 00:01:50 /sbin/multipathd
root 10379 10358 0 11:26 pts/1 00:00:00 grep multipathd
然后查看:multipath -ll
ssp-data (3600000e00d10000000100846001f0000) dm⑶ FUJITSU,ETERNUS_DX400
size=1.0T features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='round-robin 0' prio=130 status=active
| `- 14:0:0:0 sdb 8:16 active ready running
`-+- policy='round-robin 0' prio=10 status=enabled
`- 13:0:0:0 sdc 8:32 active ready running
然后这个名字和fdisk -l中的名字对应上了。
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠