zoukankan      html  css  js  c++  java
  • Centos_Lvm expand capacity without restarting CentOS

    • Rescan the new disk(/dev/sdb):
    #ls /sys/class/scsi_host/
    host0  host1  host2
    [root@db210_13:56:14 /data]  
    #echo "- - -" > /sys/class/scsi_host/host0/scan
    [root@db210_13:57:57 /data]  
    #echo "- - -" > /sys/class/scsi_host/host1/scan
    [root@db210_13:57:57 /data]  
    #echo "- - -" > /sys/class/scsi_host/host2/scan
    [root@db210_13:57:58 /data]  
    #fdisk -l
    
    Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x00084df7
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *        2048     1026047      512000   83  Linux
    /dev/sda2         1026048     5222399     2098176   82  Linux swap / Solaris
    /dev/sda3         5222400    86259711    40518656   83  Linux
    /dev/sda4        86259712   125829119    19784704    5  Extended
    /dev/sda5        86261760   125829119    19783680   83  Linux
    --- new disk is  /dev/sdb ---
    Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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 /dev/sdc: 536.9 GB**, 536870912000 bytes, 1048576000 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: 0xb4f30c82
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1            2048  1048575999   524286976   83  Linux
    
    • format the new disk
    [root@db210_12:15:04 /backup] 
    #fdisk /dev/sdb
    Welcome 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 table
    Building a new DOS disklabel with disk identifier 0xb4f30c82.
    
    Command (m for help): n
    Partition type:
       p   primary (0 primary, 0 extended, 4 free)
       e   extended
    Select (default p): p
    Partition number (1-4, default 1):
    First sector (2048-1048575999, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):
    Using default value 1048575999
    Partition 1 of type Linux and of size 500 GiB is set
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    
    • Create a PV
    [root@db210_12:15:23 /backup] 
    #pvcreate /dev/sdb1
      Physical volume "/dev/sdb1" successfully created.
    [root@db210_12:15:47 /backup] 
    #pvs
      PV         VG Fmt  Attr PSize    PFree  
      /dev/sdb1     lvm2 ---  <500.00g <500.00g
    
    • Gets the existing VG name
    #vgdisplay 
      --- Volume group ---
      VG Name               MySQL
      System ID             
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  3
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                1
      Open LV               1
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               699.99 GiB
      PE Size               4.00 MiB
      Total PE              179198
      Alloc PE / Size       127744 / 499.00 GiB
      Free  PE / Size       51454 / 200.99 GiB
      VG UUID               VkivHp-IPdu-bPwW-kRNx-UUB3-ZWj1-SJ9gjo
       
    
    • Add /dev/sdb1 to VG(MySQL)
    [root@db210_12:39:53 /data]  
    #vgextend MySQL /dev/sdb1
      Volume group "MySQL" successfully extended
    

    -Expand capacity to LV

    #df -h
    Filesystem               Size  Used Avail Use% Mounted on
    /dev/sda3                 39G   12G   28G  30% /
    devtmpfs                 3.9G     0  3.9G   0% /dev
    tmpfs                    3.9G     0  3.9G   0% /dev/shm
    tmpfs                    3.9G  8.6M  3.9G   1% /run
    tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/sda5                 19G   33M   19G   1% /home
    /dev/sda1                497M  119M  379M  24% /boot
    tmpfs                    783M     0  783M   0% /run/user/0
    /dev/mapper/MySQL-lvol0  499G   44G  456G   9% /data
    
    #lvextend -rl +100%FREE /dev/MySQL/lvol0
      Size of logical volume MySQL/lvol0 changed from <500.00 GiB (127999 extents) to 699.99 GiB (179198 extents).
      Logical volume MySQL/lvol0 successfully resized.
    meta-data=/dev/mapper/MySQL-lvol0 isize=256    agcount=4, agsize=32702464 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=0        finobt=0
    data     =                       bsize=4096   blocks=130809856, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
    log      =internal               bsize=4096   blocks=63872, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 130809856 to 183498752
    
    [root@db210_13:49:04 /data]  
    #df -h
    Filesystem               Size  Used Avail Use% Mounted on
    /dev/sda3                 39G   12G   28G  30% /
    devtmpfs                 3.9G     0  3.9G   0% /dev
    tmpfs                    3.9G     0  3.9G   0% /dev/shm
    tmpfs                    3.9G  8.6M  3.9G   1% /run
    tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/sda5                 19G   33M   19G   1% /home
    /dev/sda1                497M  119M  379M  24% /boot
    tmpfs                    783M     0  783M   0% /run/user/0
    /dev/mapper/MySQL-lvol0  700G   44G  657G   7% /data
    
    
  • 相关阅读:
    machine learning学习笔记
    google detection
    检查ftp备份数据完整性及短信告警的shell脚本
    javascript获取url参数的方法
    php随机生成福彩双色球号码
    php 身份证号码获取星座和生肖
    JS将搜索的关键字高亮显示实现代码
    C#保存上传来的图片示例代码
    window.onresize 多次触发的解决方法
    setTimeout和setInterval的深入理解
  • 原文地址:https://www.cnblogs.com/2woods/p/9395410.html
Copyright © 2011-2022 走看看