当前位置: 首页 > news >正文

网站租房做公寓长沙官网网站推广优化

网站租房做公寓,长沙官网网站推广优化,滨湖区建设局官方网站,图纸之家2019独角兽企业重金招聘Python工程师标准>>> shallow丿ove LVM介绍 物理分区(Phycical Partions) 物理存储介质(PhysicalStorageMedia) 指系统的物理存储设备:磁盘,如:/dev/hda、/d…

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

shallow丿ove


LVM介绍

  • 物理分区(Phycical Partions)

  • 物理存储介质(PhysicalStorageMedia)
    指系统的物理存储设备:磁盘,如:/dev/hda、/dev/sda等,是存储系统最底层的存储单元

  • 物理卷(Physical Volume,PV)
    物理卷是指磁盘分区或者从逻辑上看起来和磁盘分区类似得设备(比如RAID设备)

  • 逻辑卷(Logical Volume,LV)
    一个或多个物理卷组成一个逻辑卷。对于LVM而言,逻辑卷类似于非LVM系统中的磁盘分区。逻辑卷可以包含一个文件系统(比如/home或者/usr)

  • 卷组(Volume Group,VG)
    一个或者多个逻辑卷组成一个卷组。对于LVM而言,逻辑卷类似于非LVM系统中的物理磁盘。卷组把多个逻辑卷组合再一起,形成了一个可管理的单元。

  • 物理块(Physical Extent,PE)
    物理卷按大小相等的“块”为单位存储,块的大小与卷组中逻辑块的大小相同。

  • 逻辑块(Logical Extent,LE)
    逻辑卷按“块”为单位存储,再一卷组中的所有逻辑卷的块大小是相同的。

LVM实现过程:物理磁盘分区->物理卷->卷组->逻辑卷->格式化->挂载

准备磁盘分区

  • fdisk /dev/sdb
  • n 创建三个新分区,分别1G
  • t 改变分区类型为8e
[root@localhost ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000c37f3Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048      411647      204800   83  Linux/dev/sda2          411648     4605951     2097152   82  Linux swap / Solaris/dev/sda3         4605952    62914559    29154304   83  LinuxDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes[root@localhost ~]# fdisk /dev/sdbWelcome to fdisk (util-linux 2.23.2).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Device does not contain a recognized partition tableBuilding a new DOS disklabel with disk identifier 0xe4f99297.Command (m for help): pDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0xe4f99297Device Boot      Start         End      Blocks   Id  SystemCommand (m for help): nPartition type:p   primary (0 primary, 0 extended, 4 free)e   extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-20971519, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +1GPartition 1 of type Linux and of size 1 GiB is setCommand (m for help): nPartition type:p   primary (1 primary, 0 extended, 3 free)e   extendedSelect (default p): pPartition number (2-4, default 2): 2First sector (2099200-20971519, default 2099200): Using default value 2099200Last sector, +sectors or +size{K,M,G} (2099200-20971519, default 20971519): +1GPartition 2 of type Linux and of size 1 GiB is setCommand (m for help): n  Partition type:p   primary (2 primary, 0 extended, 2 free)e   extendedSelect (default p): pPartition number (3,4, default 3): 3First sector (4196352-20971519, default 4196352): Using default value 4196352Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519): +1GPartition 3 of type Linux and of size 1 GiB is setCommand (m for help): pDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0xe4f99297Device Boot      Start         End      Blocks   Id  System/dev/sdb1            2048     2099199     1048576   83  Linux/dev/sdb2         2099200     4196351     1048576   83  Linux/dev/sdb3         4196352     6293503     1048576   83  LinuxCommand (m for help): 
	Command (m for help): tPartition number (1-3, default 3): 1Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'Command (m for help): tPartition number (1-3, default 3): 2Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'Command (m for help): tPartition number (1-3, default 3): 3Hex code (type L to list all codes): 8e   Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): pDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x5ec6916aDevice Boot      Start         End      Blocks   Id  System/dev/sdb1            2048     2099199     1048576   8e  Linux LVM/dev/sdb2         2099200     4196351     1048576   8e  Linux LVM/dev/sdb3         4196352     6293503     1048576   8e  Linux LVMCommand (m for help): w[root@localhost ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000c37f3Device Boot      Start         End      Blocks   Id  System/dev/sda1   *        2048      411647      204800   83  Linux/dev/sda2          411648     4605951     2097152   82  Linux swap / Solaris/dev/sda3         4605952    62914559    29154304   83  LinuxDisk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x5ec6916aDevice Boot      Start         End      Blocks   Id  System/dev/sdb1            2048     2099199     1048576   8e  Linux LVM/dev/sdb2         2099200     4196351     1048576   8e  Linux LVM/dev/sdb3         4196352     6293503     1048576   8e  Linux LVM

准备物理卷

  • pvcreate /dev/sdb1

  • pvcreate /dev/sdb2

  • pvcreate /dev/sdb3

  • pvdisplay 列出当前的物理卷

  • pvremove /dev/sdb3 删除物理卷

安装lvm包

[root@localhost ~]# yum install -y lvm
Loaded plugins: fastestmirror
base                                                                        | 3.6 kB  00:00:00     
extras                                                                      | 3.4 kB  00:00:00     
updates                                                                     | 3.4 kB  00:00:00     
(1/2): extras/7/x86_64/primary_db                                           | 129 kB  00:00:00     
(2/2): updates/7/x86_64/primary_db                                          | 3.6 MB  00:00:24     
Loading mirror speeds from cached hostfile* base: mirrors.shuosc.org* extras: mirrors.nju.edu.cn* updates: mirrors.nju.edu.cn
No package lvm available.
Error: Nothing to do

上面安装lvm时出现了问题,说明lvm软件包名不是为lvm,当我们知道某一个软件包里的某一个命令时,可以使用yum provides “路径”来查询到软件包
例如:[root@localhost ~]# yum provides "/*/pvcreate"

[root@localhost ~]#  yum install -y lvm2Loaded plugins: fastestmirrorbase                                                                        | 3.6 kB  00:00:00     extras                                                                      | 3.4 kB  00:00:00     updates                                                                     | 3.4 kB  00:00:00     Determining fastest mirrors* base: mirrors.btte.net* extras: ftp.sjtu.edu.cn* updates: mirrors.btte.netResolving Dependencies--> Running transaction check---> Package lvm2.x86_64 7:2.02.171-8.el7 will be installed--> Processing Dependency: lvm2-libs = 7:2.02.171-8.el7 for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: device-mapper-persistent-data >= 0.7.0-0.1.rc6 for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: liblvm2app.so.2.2(Base)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_138)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_135)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_133)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_128)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_113)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_110)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_107)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_104)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_103)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_101)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper.so.1.02(DM_1_02_100)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper-event.so.1.02(Base)(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: liblvm2app.so.2.2()(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Processing Dependency: libdevmapper-event.so.1.02()(64bit) for package: 7:lvm2-2.02.171-8.el7.x86_64--> Running transaction check---> Package device-mapper-event-libs.x86_64 7:1.02.140-8.el7 will be installed---> Package device-mapper-libs.x86_64 7:1.02.84-14.el7 will be updated--> Processing Dependency: device-mapper-libs = 7:1.02.84-14.el7 for package: 7:device-mapper-1.02.84-14.el7.x86_64---> Package device-mapper-libs.x86_64 7:1.02.140-8.el7 will be an update---> Package device-mapper-persistent-data.x86_64 0:0.7.0-0.1.rc6.el7 will be installed--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64--> Processing Dependency: libaio.so.1()(64bit) for package: device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64---> Package lvm2-libs.x86_64 7:2.02.171-8.el7 will be installed--> Processing Dependency: device-mapper-event = 7:1.02.140-8.el7 for package: 7:lvm2-libs-2.02.171-8.el7.x86_64--> Running transaction check---> Package device-mapper.x86_64 7:1.02.84-14.el7 will be updated---> Package device-mapper.x86_64 7:1.02.140-8.el7 will be an update---> Package device-mapper-event.x86_64 7:1.02.140-8.el7 will be installed---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved===================================================================================================Package                               Arch           Version                   Repository    Size===================================================================================================Installing:lvm2                                  x86_64         7:2.02.171-8.el7          base         1.3 MInstalling for dependencies:device-mapper-event                   x86_64         7:1.02.140-8.el7          base         180 kdevice-mapper-event-libs              x86_64         7:1.02.140-8.el7          base         179 kdevice-mapper-persistent-data         x86_64         0.7.0-0.1.rc6.el7         base         400 klibaio                                x86_64         0.3.109-13.el7            base          24 klvm2-libs                             x86_64         7:2.02.171-8.el7          base         1.0 MUpdating for dependencies:device-mapper                         x86_64         7:1.02.140-8.el7          base         280 kdevice-mapper-libs                    x86_64         7:1.02.140-8.el7          base         312 kTransaction Summary===================================================================================================Install  1 Package  (+5 Dependent packages)Upgrade             ( 2 Dependent packages)Total download size: 3.6 MDownloading packages:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.(1/8): device-mapper-event-1.02.140-8.el7.x86_64.rpm                        | 180 kB  00:00:00     (2/8): libaio-0.3.109-13.el7.x86_64.rpm                                     |  24 kB  00:00:00     (3/8): device-mapper-1.02.140-8.el7.x86_64.rpm                              | 280 kB  00:00:01     (4/8): device-mapper-libs-1.02.140-8.el7.x86_64.rpm                         | 312 kB  00:00:01     (5/8): device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64.rpm           | 400 kB  00:00:02     (6/8): device-mapper-event-libs-1.02.140-8.el7.x86_64.rpm                   | 179 kB  00:00:02     (7/8): lvm2-libs-2.02.171-8.el7.x86_64.rpm                                  | 1.0 MB  00:00:02     (8/8): lvm2-2.02.171-8.el7.x86_64.rpm                                       | 1.3 MB  00:00:03     ---------------------------------------------------------------------------------------------------Total                                                              912 kB/s | 3.6 MB  00:00:04     Running transaction checkRunning transaction testTransaction test succeededRunning transactionUpdating   : 7:device-mapper-libs-1.02.140-8.el7.x86_64                                     1/10 Updating   : 7:device-mapper-1.02.140-8.el7.x86_64                                          2/10 Installing : 7:device-mapper-event-libs-1.02.140-8.el7.x86_64                               3/10 Installing : 7:device-mapper-event-1.02.140-8.el7.x86_64                                    4/10 Installing : 7:lvm2-libs-2.02.171-8.el7.x86_64                                              5/10 Installing : libaio-0.3.109-13.el7.x86_64                                                   6/10 Installing : device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64                         7/10 Installing : 7:lvm2-2.02.171-8.el7.x86_64                                                   8/10 ln -s '/usr/lib/systemd/system/lvm2-lvmpolld.socket' '/etc/systemd/system/sysinit.target.wants/lvm2-lvmpolld.socket'Cleanup    : 7:device-mapper-libs-1.02.84-14.el7.x86_64                                     9/10 Cleanup    : 7:device-mapper-1.02.84-14.el7.x86_64                                         10/10 Verifying  : 7:device-mapper-event-libs-1.02.140-8.el7.x86_64                               1/10 Verifying  : 7:device-mapper-event-1.02.140-8.el7.x86_64                                    2/10 Verifying  : 7:lvm2-libs-2.02.171-8.el7.x86_64                                              3/10 Verifying  : 7:device-mapper-1.02.140-8.el7.x86_64                                          4/10 Verifying  : 7:device-mapper-libs-1.02.140-8.el7.x86_64                                     5/10 Verifying  : 7:lvm2-2.02.171-8.el7.x86_64                                                   6/10 Verifying  : device-mapper-persistent-data-0.7.0-0.1.rc6.el7.x86_64                         7/10 Verifying  : libaio-0.3.109-13.el7.x86_64                                                   8/10 Verifying  : 7:device-mapper-libs-1.02.84-14.el7.x86_64                                     9/10 Verifying  : 7:device-mapper-1.02.84-14.el7.x86_64                                         10/10 Installed:lvm2.x86_64 7:2.02.171-8.el7                                                                     Dependency Installed:device-mapper-event.x86_64 7:1.02.140-8.el7                                                      device-mapper-event-libs.x86_64 7:1.02.140-8.el7                                                 device-mapper-persistent-data.x86_64 0:0.7.0-0.1.rc6.el7                                         libaio.x86_64 0:0.3.109-13.el7                                                                   lvm2-libs.x86_64 7:2.02.171-8.el7                                                                Dependency Updated:device-mapper.x86_64 7:1.02.140-8.el7         device-mapper-libs.x86_64 7:1.02.140-8.el7        Complete!

partprobe重载分区表

[root@localhost ~]# ls /dev/sdb
[root@localhost ~]# partprobeWarning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.
[root@localhost ~]# pvcreate /dev/sdb1Device /dev/sdb1 not found (or ignored by filtering).
[root@localhost ~]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda3        28G  865M   27G   4% /devtmpfs        909M     0  909M   0% /devtmpfs           914M     0  914M   0% /dev/shmtmpfs           914M   17M  897M   2% /runtmpfs           914M     0  914M   0% /sys/fs/cgroup/dev/sdb         10G   33M   10G   1% /mnt/dev/sda1       197M   75M  123M  38% /boot
[root@localhost ~]# umount /mnt

pvcreate将物理磁盘分区为物理卷

[root@localhost ~]# pvcreate /dev/sdb1WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: yWiping ext4 signature on /dev/sdb1.Physical volume "/dev/sdb1" successfully created.
[root@localhost ~]# pvcreate /dev/sdb2Physical volume "/dev/sdb2" successfully created.
[root@localhost ~]# pvcreate /dev/sdb3Physical volume "/dev/sdb3" successfully created.

pvdisplay显示物理卷属性

[root@localhost ~]# pvdisplay"/dev/sdb3" is a new physical volume of "1.00 GiB"--- NEW Physical volume ---PV Name               /dev/sdb3VG Name               PV Size               1.00 GiBAllocatable           NOPE Size               0   Total PE              0Free PE               0Allocated PE          0PV UUID               JeafFf-5aVO-xNf2-DUv6-17S2-N8Cg-f0E3vX"/dev/sdb1" is a new physical volume of "1.00 GiB"--- NEW Physical volume ---PV Name               /dev/sdb1VG Name               PV Size               1.00 GiBAllocatable           NOPE Size               0   Total PE              0Free PE               0Allocated PE          0PV UUID               DEzGdZ-eZpX-qWYI-XndU-e5X9-SEcT-MsiLCc"/dev/sdb2" is a new physical volume of "1.00 GiB"--- NEW Physical volume ---PV Name               /dev/sdb2VG Name               PV Size               1.00 GiBAllocatable           NOPE Size               0   Total PE              0Free PE               0Allocated PE          0PV UUID               QI4y20-GOdg-8CBJ-PfZF-GO8l-ambD-f7Jikz

创建卷组

pvs输出格式化物理卷信息报表

[root@localhost ~]# pvsPV         VG Fmt  Attr PSize PFree/dev/sdb1     lvm2 ---  1.00g 1.00g/dev/sdb2     lvm2 ---  1.00g 1.00g/dev/sdb3     lvm2 ---  1.00g 1.00g

vgcreate 创建lvm卷组

[root@localhost ~]# vgcreate vg1 /dev/sdb1 /dev/sdb2Volume group "vg1" successfully created
[root@localhost ~]# vgdisplay--- Volume group ---VG Name               vg1System ID             Format                lvm2Metadata Areas        2Metadata Sequence No  1VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                0Open LV               0Max PV                0Cur PV                2Act PV                2VG Size               1.99 GiBPE Size               4.00 MiBTotal PE              510Alloc PE / Size       0 / 0   Free  PE / Size       510 / 1.99 GiBVG UUID               ad3wQ3-M3m1-btaW-ae4b-RhQl-9iPM-xBDFaS

vgs查询lvm卷组

[root@localhost ~]# vgsVG  #PV #LV #SN Attr   VSize VFreevg1   2   0   0 wz--n- 1.99g 1.99g

vgremove 删除卷组

创建逻辑卷

lvcreate创建lvm逻辑卷

[root@localhost ~]# lvcreate -L 100M -n lv1 vg1Logical volume "lv1" created.
[root@localhost ~]# mkfs.ext4 /dev/vg1/lv1mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)Stride=0 blocks, Stripe width=0 blocks25688 inodes, 102400 blocks5120 blocks (5.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=3368550413 block groups8192 blocks per group, 8192 fragments per group1976 inodes per groupSuperblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729Allocating group tables: done                            Writing inode tables: done                            Creating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: done [root@localhost ~]# mount /dev/vg1/lv1 /mnt/
[root@localhost ~]# df -hFilesystem           Size  Used Avail Use% Mounted on/dev/sda3             28G  994M   27G   4% /devtmpfs             903M     0  903M   0% /devtmpfs                912M     0  912M   0% /dev/shmtmpfs                912M  8.6M  904M   1% /runtmpfs                912M     0  912M   0% /sys/fs/cgroup/dev/sda1            197M  113M   85M  58% /boottmpfs                183M     0  183M   0% /run/user/0/dev/mapper/vg1-lv1   93M  1.6M   85M   2% /mnt

这时候我们会发现/dev/mapper/vg1-lv1这个目录,对以下两个路径,其实这个两个目录都是指向同一个目录的

[root@localhost ~]# ls -l /dev/vg1/lv1lrwxrwxrwx. 1 root root 7 Nov  6 09:09 /dev/vg1/lv1 -> ../dm-0
[root@localhost ~]# ls -l /dev/mapper/vg1-lv1lrwxrwxrwx. 1 root root 7 Nov  6 09:09 /dev/mapper/vg1-lv1 -> ../dm-0
[root@localhost ~]# mkdir /mnt/111
[root@localhost ~]# touch /mnt/1.txt
[root@localhost ~]# echo "22222" > /mnt/1.txt 

扩容逻辑卷

  • lvresize -L 300M /dev/vg1/lv1 #重置设置卷大小
  • e2fsck -f /dev/vg1/lv1 #检查磁盘错误(ext4执行)
  • resize2fs /dev/vg1/lv1 #更新逻辑卷信息(ext4执行)
  • xfs_growfs /dev/vg1/lv1 #xfs文件系统需要执行
[root@localhost ~]# lvresize -L 200M /dev/vg1/lv1Size of logical volume vg1/lv1 changed from 100.00 MiB (25 extents) to 200.00 MiB (50 extents).Logical volume vg1/lv1 successfully resized.[root@localhost ~]# df -hFilesystem           Size  Used Avail Use% Mounted on/dev/sda3             28G  993M   27G   4% /devtmpfs             903M     0  903M   0% /devtmpfs                912M     0  912M   0% /dev/shmtmpfs                912M  8.6M  904M   1% /runtmpfs                912M     0  912M   0% /sys/fs/cgroup/dev/sda1            197M  113M   85M  58% /boottmpfs                183M     0  183M   0% /run/user/0/dev/mapper/vg1-lv1   93M  1.6M   85M   2% /mnt

不合规范,应当先

[root@localhost ~]# umount /mnt/
[root@localhost ~]# lvresize -L 200M /dev/vg1/lv1New size (50 extents) matches existing size (50 extents).

检查磁盘是否存在错误

[root@localhost ~]# e2fsck -f /dev/vg1/lv1e2fsck 1.42.9 (28-Dec-2013)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/vg1/lv1: 13/25688 files (7.7% non-contiguous), 8899/102400 blocks

更新逻辑卷

[root@localhost ~]# resize2fs /dev/vg1/lv1resize2fs 1.42.9 (28-Dec-2013)Resizing the filesystem on /dev/vg1/lv1 to 204800 (1k) blocks.The filesystem on /dev/vg1/lv1 is now 204800 blocks long.
[root@localhost ~]# mount /dev/vg1/lv1 /mnt/
[root@localhost ~]# df -hFilesystem           Size  Used Avail Use% Mounted on/dev/sda3             28G  993M   27G   4% /devtmpfs             903M     0  903M   0% /devtmpfs                912M     0  912M   0% /dev/shmtmpfs                912M  8.6M  904M   1% /runtmpfs                912M     0  912M   0% /sys/fs/cgroup/dev/sda1            197M  113M   85M  58% /boottmpfs                183M     0  183M   0% /run/user/0/dev/mapper/vg1-lv1  190M  1.6M  175M   1% /mnt
[root@localhost ~]# ls /mnt/111  1.txt  lost+found
[root@localhost ~]# cat /mnt/1.txt 22222

若扩容导致文件丢失,那么扩容就没有存在的意义

若格式为xfs那么方法有些不一样

缩减逻辑卷

  • 先umount
  • e2fsck -f /dev/vg1/lv1 #检查磁盘错误(ext)
  • resize2fs /dev/vg1/lv1 100M #更新逻辑卷信息(ext)
  • lvresize -L 100M /dev/vg1/lv1 #重新设置卷大小

xfs并不支持

[root@localhost ~]# umount /mnt/
[root@localhost ~]# e2fsck -f /dev/vg1/lv1e2fsck 1.42.9 (28-Dec-2013)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivityPass 4: Checking reference countsPass 5: Checking group summary information/dev/vg1/lv1: 13/49400 files (7.7% non-contiguous), 11887/204800 blocks
[root@localhost ~]# resize2fs /dev/vg1/lv1 100Mresize2fs 1.42.9 (28-Dec-2013)Resizing the filesystem on /dev/vg1/lv1 to 102400 (1k) blocks.The filesystem on /dev/vg1/lv1 is now 102400 blocks long.
[root@localhost ~]# lvresize -L 100M /dev/vg1/lv1WARNING: Reducing active logical volume to 100.00 MiB.THIS MAY DESTROY YOUR DATA (filesystem etc.)Do you really want to reduce vg1/lv1? [y/n]: ySize of logical volume vg1/lv1 changed from 200.00 MiB (50 extents) to 100.00 MiB (25 extents).Logical volume vg1/lv1 successfully resized.
[root@localhost ~]# lvdisplay--- Logical volume ---LV Path                /dev/vg1/lv1LV Name                lv1VG Name                vg1LV UUID                BTZG2e-59Qy-29ls-X6Ko-Dvbm-0zUp-2MTdpkLV Write Access        read/writeLV Creation host, time centos1133, 2017-11-06 09:05:29 +0800LV Status              available# open                 0LV Size                100.00 MiBCurrent LE             25Segments               1Allocation             inheritRead ahead sectors     auto- currently set to     8192Block device           253:0
[root@localhost ~]# lvsLV   VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertlv1  vg1 -wi-a----- 100.00m 
[root@localhost ~]# mount /dev/vg1/lv1 /mnt/
[root@localhost ~]# ls /mnt/111  1.txt  lost+found
[root@localhost ~]# df -hFilesystem           Size  Used Avail Use% Mounted on/dev/sda3             28G  994M   27G   4% /devtmpfs             903M     0  903M   0% /devtmpfs                912M     0  912M   0% /dev/shmtmpfs                912M  8.6M  904M   1% /runtmpfs                912M     0  912M   0% /sys/fs/cgroup/dev/sda1            197M  113M   85M  58% /boottmpfs                183M     0  183M   0% /run/user/0/dev/mapper/vg1-lv1   93M  1.6M   85M   2% /mnt
[root@localhost ~]# umount /mnt/

lvm并不会因为缩容而导致文件丢失

xfs扩容

[root@localhost ~]# mkfs.xfs -f /dev/vg1/lv1meta-data=/dev/vg1/lv1           isize=512    agcount=4, agsize=6400 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0, sparse=0data     =                       bsize=4096   blocks=25600, imaxpct=25=                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal log           bsize=4096   blocks=855, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]# mount /dev/vg1/lv1 /mnt/
[root@localhost ~]# ls /mnt/
[root@localhost ~]# touch /mnt/2.txt
[root@localhost ~]# echo 123 > /mnt/2.txt
[root@localhost ~]# cat !$cat /mnt/2.txt123
[root@localhost ~]# lvsLV   VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertlv1  vg1 -wi-ao---- 100.00m    

xfs扩容时不需要umount

[root@localhost ~]# lvresize -L 300M /dev/vg1/lv1Size of logical volume vg1/lv1 changed from 100.00 MiB (25 extents) to 300.00 MiB (75 extents).Logical volume vg1/lv1 successfully resized.
[root@localhost ~]# lvsLV   VG  Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convertlv1  vg1 -wi-ao---- 300.00m   
[root@localhost ~]# df -hFilesystem           Size  Used Avail Use% Mounted on/dev/sda3             28G  994M   27G   4% /devtmpfs             903M     0  903M   0% /devtmpfs                912M     0  912M   0% /dev/shmtmpfs                912M  8.6M  904M   1% /runtmpfs                912M     0  912M   0% /sys/fs/cgroup/dev/sda1            197M  113M   85M  58% /boottmpfs                183M     0  183M   0% /run/user/0/dev/mapper/vg1-lv1   97M  5.2M   92M   6% /mnt

[root@localhost ~]# xfs_growfs -L 300M /dev/vg1/lv1meta-data=/dev/mapper/vg1-lv1    isize=512    agcount=4, agsize=6400 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=25600, imaxpct=25=                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=855, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0xfs_growfs: XFS_IOC_FSGROWFSLOG xfsctl failed: Invalid argument

无效的参数?

[root@localhost ~]# umount /dev/vg1/lv1
[root@localhost ~]# lvresize -L 310M /dev/vg1/lv1Rounding size to boundary between physical extents: 312.00 MiB.Size of logical volume vg1/lv1 changed from 300.00 MiB (75 extents) to 312.00 MiB (78 extents).Logical volume vg1/lv1 successfully resized.
[root@localhost ~]# xfs_growfs -L 310M /dev/vg1/lv1xfs_growfs: /dev/vg1/lv1 is not a mounted XFS filesystem	#必须挂载
[root@localhost ~]# mount /dev/vg1/lv1 /mnt/
[root@localhost ~]# xfs_growfs -L 310M /dev/vg1/lv1meta-data=/dev/mapper/vg1-lv1    isize=512    agcount=4, agsize=6400 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=25600, imaxpct=25=                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=855, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0xfs_growfs: XFS_IOC_FSGROWFSLOG xfsctl failed: Invalid argument

[root@localhost ~]# xfs_growfs /dev/vg1/lv1meta-data=/dev/mapper/vg1-lv1    isize=512    agcount=4, agsize=6400 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=25600, imaxpct=25=                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=855, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 25600 to 79872
[root@localhost ~]# df -hFilesystem           Size  Used Avail Use% Mounted on/dev/sda3             28G  994M   27G   4% /devtmpfs             903M     0  903M   0% /devtmpfs                912M     0  912M   0% /dev/shmtmpfs                912M  8.6M  904M   1% /runtmpfs                912M     0  912M   0% /sys/fs/cgroup/dev/sda1            197M  113M   85M  58% /boottmpfs                183M     0  183M   0% /run/user/0/dev/mapper/vg1-lv1  309M  5.5M  304M   2% /mnt

扩展卷组

  • fdisk /dev/sdb #新增/dev/sdb5(逻辑分区8e) 2G
  • pvcreate /dev/sdb5 #创建物理卷
  • vgextend vg1 /dev/sdb5 #把物理卷加入卷组中
  • lvresize -L 100M /dev/vg1/lv1 #重新设置卷大小

扩容卷组最高能扩到卷组一样大

[root@localhost ~]# vgsVG  #PV #LV #SN Attr   VSize VFree vg1   2   1   0 wz--n- 1.99g <1.69g

sdb1和sdb2组成卷组,而sdb3是空闲的

[root@localhost ~]# vgextend vg1 /dev/sdb3Volume group "vg1" successfully extended
[root@localhost ~]# vgdisplay--- Volume group ---VG Name               vg1System ID             Format                lvm2Metadata Areas        3Metadata Sequence No  7VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                1Open LV               1Max PV                0Cur PV                3Act PV                3VG Size               <2.99 GiBPE Size               4.00 MiBTotal PE              765Alloc PE / Size       78 / 312.00 MiBFree  PE / Size       687 / 2.68 GiBVG UUID               G7DZt6-wLGz-HqEr-erYp-lDYP-53eM-KBf5NB
[root@localhost ~]# vgsVG  #PV #LV #SN Attr   VSize  VFreevg1   3   1   0 wz--n- <2.99g 2.68g

先扩容卷组,再扩容逻辑卷


转载于:https://my.oschina.net/u/3892756/blog/3053833

http://www.lbrq.cn/news/2394595.html

相关文章:

  • h5手机网站制作打开百度一下网页版
  • 武汉软件开发外包百度seo可能消失
  • 河南平台网站建设公司网店运营培训
  • 电子商务网站的基础建设他达拉非片的作用及功效副作用
  • 微信官网小程序注册网站功能优化的方法
  • 信息手机网站模板下载软件抖音seo系统
  • 做公众号模板的网站网站开发制作培训学校
  • 用蜗牛做logo的网站武汉seo首页优化公司
  • 模板网站的弊端在哪品牌推广方案包括哪些
  • 用vs2005做网站 怎样搭配色彩百度灰色关键词排名代做
  • 苏州模板建站哪家好爱站网排名
  • 网站推广和网站优化seo怎么读
  • wordpress 导出功能seo怎么发外链的
  • 学校网站怎么下载不了打广告去哪个平台免费
  • 深圳网站制作工具怎么快速优化关键词
  • 有什么做视频的免费素材网站搜索排名优化软件
  • 有机大米网站建设方案怎么做谷歌推广
  • 企业网站建设应该怎么做宁波正规优化seo价格
  • 公司建设网站费用会计怎么记网络口碑营销的成功案例
  • seo网站推广作用活动营销推广方案
  • 5G网站建设要多少个四川seo优化
  • 搭配服装网站源码英雄联盟韩国
  • 武汉地区网站建设seo赚钱培训
  • 什么是微网站企业管理培训课程网课免费
  • 皮具网站建设网络营销策划书封面
  • 珠海专业网站制作公司搜索引擎优化工作
  • 注册科技有限公司经营范围百度seo发帖推广
  • 山东seo广西seo搜索引擎优化
  • 西安知名网站建设公司线上网络平台推广
  • 青岛网站建设 上流刚刚发生了一件大事
  • 学习 Python 爬虫需要哪些基础知识?
  • Django母婴商城项目实践(十一)- 用户信息模块之用户登录注册
  • 思维链(CoT)技术全景:原理、实现与前沿应用深度解析
  • 如何用Python并发下载?深入解析concurrent.futures 与期物机制
  • QML vscode语法高亮和颜色区分。
  • 零基础入门:用C++从零实现TCP Socket网络小工具