逻辑卷扩容

问题:

要求对服务器生产环境根目录大小为100G或以上,以防出现根目录日志过大导致服务异常的情况。
当前进行了检查,目前根目录为25G,与建议的空间100G相差过多,希望按照建议空间调整目前服务器配置,保证服务稳定运行

操作步骤:

[root@localhost-5 ~]# lsblk 
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   64G  0 disk 
├─sda1              8:1    0    1G  0 part /boot
└─sda2              8:2    0   63G  0 part 
  ├─rootvg-lvroot 253:0    0   26G  0 lvm  /
  ├─rootvg-lvswap 253:1    0   10G  0 lvm  
  ├─rootvg-lvvar  253:3    0   16G  0 lvm  /var
  ├─rootvg-lvopt  253:4    0   10G  0 lvm  /opt
  └─rootvg-lvhome 253:5    0    1G  0 lvm  /home
sdb                 8:16   0  500G  0 disk 
└─sdb1              8:17   0  500G  0 part 
  └─vgdata-lvdata 253:2    0  500G  0 lvm  /data
sdc                 8:32   0  500G  0 disk    #申请下来的盘
sdd                 8:48   0  500G  0 disk 
sr0                11:0    1 1024M  0 rom  
[root@localhost-5 ~]# fdisk /dev/sdc 
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 0xd3ab1736.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

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): +200G  
Partition 1 of type Linux and of size 200 GiB is set

Command (m for help): p

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: 0xd3ab1736

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048   419432447   209715200   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

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: 0xd3ab1736

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048   419432447   209715200   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost-5 ~]# lsblk 
NAME              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                 8:0    0   64G  0 disk 
├─sda1              8:1    0    1G  0 part /boot
└─sda2              8:2    0   63G  0 part 
  ├─rootvg-lvroot 253:0    0   26G  0 lvm  /
  ├─rootvg-lvswap 253:1    0   10G  0 lvm  
  ├─rootvg-lvvar  253:3    0   16G  0 lvm  /var
  ├─rootvg-lvopt  253:4    0   10G  0 lvm  /opt
  └─rootvg-lvhome 253:5    0    1G  0 lvm  /home
sdb                 8:16   0  500G  0 disk 
└─sdb1              8:17   0  500G  0 part 
  └─vgdata-lvdata 253:2    0  500G  0 lvm  /data
sdc                 8:32   0  500G  0 disk 
└─sdc1              8:33   0  200G  0 part 
sdd                 8:48   0  500G  0 disk 
sr0                11:0    1 1024M  0 rom  
[root@localhost-5 ~]# vgs
  VG     #PV #LV #SN Attr   VSize    VFree
  rootvg   1   5   0 wz--n-  <63.00g    0 
  vgdata   1   1   0 wz--n- <500.00g    0 
[root@localhost-5 ~]# df -h /
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lvroot   26G  4.9G   22G  19% /
[root@localhost-5 ~]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
[root@localhost-5 ~]# pvs
  PV         VG     Fmt  Attr PSize    PFree  
  /dev/sda2  rootvg lvm2 a--   <63.00g      0 
  /dev/sdb1  vgdata lvm2 a--  <500.00g      0 
  /dev/sdc1         lvm2 ---   200.00g 200.00g
[root@localhost-5 ~]# vgextend 
rootvg  vgdata  
[root@localhost-5 ~]# vgextend rootvg /dev/sdc1
  Volume group "rootvg" successfully extended
[root@localhost-5 ~]# vgs
  VG     #PV #LV #SN Attr   VSize    VFree   
  rootvg   2   5   0 wz--n-  262.99g <200.00g
  vgdata   1   1   0 wz--n- <500.00g       0 
[root@localhost-5 ~]# lvresize -r -L 100G /dev/rootvg/lvroot 
  Size of logical volume rootvg/lvroot changed from 26.00 GiB (6656 extents) to 100.00 GiB (25600 extents).
  Logical volume rootvg/lvroot successfully resized.
meta-data=/dev/mapper/rootvg-lvroot isize=512    agcount=4, agsize=1703936 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=6815744, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=3328, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 6815744 to 26214400

[root@localhost-5 ~]# df -h /
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lvroot  100G  4.9G   96G   5% /

你可能感兴趣的:(系统运维,运维)