LVM设备的建立3

开启两个shell一个用来监控一个来做实验,第一台检测,第二台做项目
第一台主机:
监控语句

pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata
====
====
====
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   17G  1.2G   16G   7% /

监控命令

[root@server15 ~]# watch -n 1 "pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata"

第二台主机:
1划分物理分区

[root@server15 ~]# udevadm settle 修改完物理分区的同步命令

新建的两个500M的物理分区

[root@server15 ~]# fdisk /dev/vdb
Command (m for help): P
Disk /dev/vdb: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb51dee8d

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     1026047      512000   83  Linux
/dev/vdb2         1026048     2050047      512000   83  Linux

2要做Lvm,所以要修改分区的类型

[root@server15 ~]# fdisk /dev/vdb
Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): l
l可以查看到所有的类型,Lvm为8e

[root@server15 ~]# fdisk /dev/vdb
Command (m for help): t           修改分区类型
Partition number (1,2, default 2):1       修改分区的id
Hex code (type L to list all codes): 8e   
Changed type of partition 'Linux' to 'Linux LVM'

同理修改2以后

Command (m for help): p

Disk /dev/vdb: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xb51dee8d
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048     1026047      512000   8e  Linux LVM
/dev/vdb2         1026048     2050047      512000   8e  Linux LVM

3物理分区变成物理卷(建立物理卷)

[root@server15 ~]# pvcreate /dev/vdb1
  Physical volume "/dev/vdb1" successfully created.
[root@server15 ~]# pvcreate /dev/vdb2
  Physical volume "/dev/vdb2" successfully created.

Every 1.0s: pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata       Tue Jul  6 22:12:28 2021
 PV         VG   Fmt  Attr PSize   PFree
/dev/vdb1	  lvm2 ---  500.00m 500.00m
/dev/vdb2	  lvm2 ---  500.00m 500.00m

第一台物理卷检测到

4建立物理卷组

[root@server15 ~]# vgcreate westos_vg /dev/vdb1
  Volume group "westos_vg" successfully created
[root@server15 ~]# vgdisplay westos_vg 
 --- Volume group ---
  VG Name               westos_vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               496.00 MiB
  PE Size               4.00 MiB
  Total PE              124
  Alloc PE / Size       0 / 0   
  Free  PE / Size       124 / 496.00 MiB
  VG UUID               44GfO9-XkBI-35yg-9fsv-E0pe-9mIc-hU68KQ
可以看到pe大小默认为4M
[root@server15 ~]# man vgcreate 
-s|--physicalextentsize Size[m|UNIT]
              Sets the physical extent size of PVs in the VG.  The value must be either a power of
              2 of at least 1 sector (where the sector size is the largest sector size of the PVs
              currently used in the VG), or at least 128KiB.  Once this value has been set, it is
              difficult to change without recreating the VG, unless no extents need moving.
pe最小不能小于128K

更改pe为2M

[root@server15 ~]# vgremove westos_vg 
  Volume group "westos_vg" successfully removed
[root@server15 ~]# vgcreate -s 2M westos_vg /dev/vdb1
  Volume group "westos_vg" successfully created
[root@server15 ~]# vgdisplay westos_vg | grep PE
  PE Size               2.00 MiB
原先pe 4M变成2M

监控

Every 1.0s: pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata       Tue Jul  6 22:25:20 2021
  /dev/vdb1  westos_vg lvm2 a--  498.00m 498.00m

5建立逻辑卷lv
lv 不能超过逻辑卷里面的,最多498,因为逻辑卷组最大498

[root@server15 ~]# lvcreate -L 200M -n westos_lv0 westos_vg
  Logical volume "westos_lv0" created.

监控

  LV         VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
 westos_lv0 westos_vg -wi-a----- 200.00m

6设备格式化挂载

[root@server15 ~]# mkfs.xfs /dev/westos_vg/westos_lv0 
meta-data=/dev/westos_vg/westos_lv0 isize=512    agcount=4, agsize=12800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=51200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@server15 ~]# mount /dev/westos_vg/westos_lv0 /weixindata/

监控

Every 1.0s: pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata       Tue Jul  6 22:29:47 2021
  westos_lv0 westos_vg -wi-ao---- 200.00m
/dev/mapper/westos_vg-westos_lv0  197M   11M  187M   6% /weixindata

少了3M,因为lv为10进制,挂载后为2进制,进制问题,2进制更准确

7拉伸(热拉神)设备不停机更新
第2台

[root@server15 ~]# lvextend -L 300M /dev/westos_vg/westos_lv0 
  Size of logical volume westos_vg/westos_lv0 changed from 200.00 MiB (100 extents) to 300.00 MiB (150 extents).
  Logical volume westos_vg/westos_lv0 successfully resized.

第一台监控

Every 1.0s: pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata       Tue Jul  6 22:34:57 2021
     LV         VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
 westos_lv0 westos_vg -wi-ao---- 300.00m
   Filesystem                        Size  Used Avail Use% Mounted on
/dev/mapper/westos_vg-westos_lv0  197M   11M  187M   6% /weixindata

第2台

[root@server15 ~]# xfs_growfs /dev/westos_vg/westos_lv0 
meta-data=/dev/mapper/westos_vg-westos_lv0 isize=512    agcount=4, agsize=12800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=51200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=855, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 51200 to 76800

第1台监控

Every 1.0s: pvs;echo ====;vgs;echo ====;lvs;echo ====;df -h /weixindata       Tue Jul  6 22:35:57 2021
    LV         VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  westos_lv0 westos_vg -wi-ao---- 300.00m
  Filesystem                        Size  Used Avail Use% Mounted on
/dev/mapper/westos_vg-westos_lv0  297M   11M  287M   4% /weixindata

8总结
当VG(物理卷组)不够时做PV(物理卷)
PV不够时买硬盘

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值