zoukankan      html  css  js  c++  java
  • linux 配置LVM

    大型LVM专题,请查看 烂泥行天下 https://www.cnblogs.com/ilanni/tag/LVM/

    pvmove命令搬移PV中的资料(只限于同一VG中)。
    用法
    pvmove [-n ] []
    
    实例
    # pvmove /dev/hda5 /dev/hda6   #将VG中pv hda5的内容搬移到hda6中
    # pvmove /dev/hda5   #也可以这样,lvm决定hda5的内容被复制到哪里

    1. 阿里云挂载LVM目录(创建LVM,以及配置第一块硬盘)

    fdisk /dev/vdb


    输入

    n

    p

    1

    enter

    enter

    wq

    pvcreate /dev/vdb1
    vgcreate lvmgroup /dev/vdb1
    vgchange -ay lvmgroup
    lvcreate -l 100%FREE -n elasticsearch lvmgroup
    fdisk -l
    mkfs.ext4 /dev/mapper/lvmgroup-elasticsearch 
    cd /
    mkdir elasticsearch
    mount /dev/mapper/lvmgroup-elasticsearch /elasticsearch/
    df -h

    把新建的LVM分区挂载到某个目录上,并且设置开机自动挂载

    vi /etc/fstab

    下面这段话放到fstab最下方

    "/dev/mapper/lvmgroup-elasticsearch /elasticsearch ext4 defaults 0 0"

    2. 在已有LVM分区上扩展新的硬盘

    挂在新硬盘

    fdisk -l
    fdisk /dev/vdd

    输入

    n

    p

    1

    回车

    回车

    t

    8e

    wq

    partprobe
    pvcreate /dev/vdd1
    vgextend lvmgroup /dev/vdd1
    lvextend -l +100%free /dev/mapper/lvmgroup-elasticsearch
    resize2fs /dev/mapper/lvmgroup-elasticsearch

     partprobe有些时候需要跑,有些时候不需要,我还是不太了解

     3. 服务器卸载/home目录的庞大LVM空间给 /根目录

    [root@localhost logs]# df -h
    Filesystem               Size  Used Avail Use% Mounted on
    devtmpfs                 7.8G     0  7.8G   0% /dev
    tmpfs                    7.8G     0  7.8G   0% /dev/shm
    tmpfs                    7.8G  832M  7.0G  11% /run
    tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
    /dev/mapper/centos-root   50G   49G  1.8G  97% /
    /dev/mapper/centos-home   42G   33M   42G   1% /home
    /dev/sda1                497M  154M  344M  31% /boot
    tmpfs                    1.6G     0  1.6G   0% /run/user/0
    tmpfs                    1.6G     0  1.6G   0% /run/user/1000
    You have mail in /var/spool/mail/root
    [root@localhost logs]# umount /dev/mapper/centos-home
    Do you really want to remove active logical volume centos/home? [y/n]: y
      Logical volume "home" successfully removed
    You have mail in /var/spool/mail/root
    [root@localhost logs]# lvextend -l +100%free /dev/mapper/centos-root
      Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 91.63 GiB (23458 extents).
      Logical volume centos/root successfully resized.
    [root@localhost logs]# resize2fs /dev/mapper/centos-root
    resize2fs 1.42.9 (28-Dec-2013)
    resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
    Couldn't find valid filesystem superblock.
    [root@localhost logs]# xfs_growfs /dev/mapper/centos-root
    meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=3276800 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=0        finobt=0 spinodes=0
    data     =                       bsize=4096   blocks=13107200, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
    log      =internal               bsize=4096   blocks=6400, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 13107200 to 24020992
    You have mail in /var/spool/mail/root
    [root@localhost logs]# df -h
    Filesystem               Size  Used Avail Use% Mounted on
    devtmpfs                 7.8G     0  7.8G   0% /dev
    tmpfs                    7.8G     0  7.8G   0% /dev/shm
    tmpfs                    7.8G  832M  7.0G  11% /run
    tmpfs                    7.8G     0  7.8G   0% /sys/fs/cgroup
    /dev/mapper/centos-root   92G   49G   44G  53% /
    /dev/sda1                497M  154M  344M  31% /boot
    tmpfs                    1.6G     0  1.6G   0% /run/user/0
    tmpfs                    1.6G     0  1.6G   0% /run/user/1000

    LVM扩容报错以及 xfs_growfs 和 resize2fs 区别请参考

    https://www.cnblogs.com/faberbeta/p/13152477.html

  • 相关阅读:
    iOS 列表三级展开
    iOS 聊天界面
    iOS 地图(添加大头针)
    iOS 地图
    swift 快速创建一些基本控件
    swift
    swift
    swift4.2 打印所有系统字体
    Xcode 去掉控制台无用打印信息
    swift
  • 原文地址:https://www.cnblogs.com/faberbeta/p/linux-shell015.html
Copyright © 2011-2022 走看看