linux swap分区调控(swap分区lvm管理)


linux swap分区调控(swap分区lvm管理)
 
注:linux swap分区 采用lvm管理,调控可以采用下面的方法
 
一.查看 swap    lv
[root@testdb ~]# vgdisplay -v
    Finding all volume groups
    Finding volume group "VolGroup"
  --- Volume group ---
  VG Name               VolGroup
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               357.38 GiB
  PE Size               4.00 MiB
  Total PE              91489
  Alloc PE / Size       34512 / 134.81 GiB
  Free  PE / Size       56977 / 222.57 GiB
  VG UUID               q6q2yf-Isfw-DnkL-JeSN-uTvC-l5m2-M0HEco
  
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_root
  LV Name                lv_root
  VG Name                VolGroup
  LV UUID                0nFC6x-BsP2-7w0r-8bPV-Vw9j-whIz-EWj5Ba
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2013-09-16 08:41:58 +0800
  LV Status              available
  # open                 1
  LV Size                29.30 GiB
  Current LE             7500
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0
  
  --- Logical volume ---
 LV Path                /dev/VolGroup/lv_swap
 LV Name                lv_swap
 VG Name                VolGroup
 LV UUID                OJaxbf-MPay-cjep-L44c-UKDx-ZmGW-v24yUf
 LV Write Access        read/write
 LV Creation host, time localhost.localdomain, 2013-09-16 08:42:00 +0800
 LV Status              available
 # open                 2
 LV Size                7.86 GiB
 Current LE             2012
 Segments               1
 Allocation             inherit
 Read ahead sectors     auto
 - currently set to     256
 Block device           252:1
  
  --- Logical volume ---
  LV Path                /dev/VolGroup/lv_home
  LV Name                lv_home
  VG Name                VolGroup
  LV UUID                HZvOuv-G8NW-2ZyW-3Ffl-H54i-Kmjp-8ndVqo
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2013-09-16 08:42:01 +0800
  LV Status              available
  # open                 1
  LV Size                97.66 GiB
  Current LE             25000
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:2
  
  --- Physical volumes ---
  PV Name               /dev/sda2    
  PV UUID               gQvj3L-kOPV-LILA-KPnD-a8W9-lgdE-09vtlQ
  PV Status             allocatable
  Total PE / Free PE    91489 / 56977
  
 swap  分区 lv   为/dev/VolGroup/lv_swap
 
 
 
 
 
 
 
 
 
二.扩大swap分区
 关闭交换分区
[root@testdb ~]# swapoff /dev/VolGroup/lv_swap
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      14682       1398          0         83      13680
-/+ buffers/cache:        919      15162
Swap:            0          0          0
 
 
 
扩展    /dev/VolGroup/lv_swap,增加8336M
 [root@testdb ~]# lvextend -L +8336M /dev/VolGroup/lv_swap
  Extending logical volume lv_swap to 16.28 GiB
  Logical volume lv_swap successfully resized
 
 
 
 
将 /dev/VolGroup/lv_swap 设置为swap分区
 [root@testdb ~]# mkswap /dev/VolGroup/lv_swap
mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 17072124 KiB
no label, UUID=f5fa0e85-da9e-440c-8f1c-e3ab978c9d6b
 [root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      14683       1398          0         83      13680
-/+ buffers/cache:        918      15162
Swap:            0          0          0
 
 
 
 
启动swap分区
[root@testdb ~]# swapon /dev/VolGroup/lv_swap
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      14695       1386          0         83      13680
-/+ buffers/cache:        931      15150
Swap:        16671          0      16671
 
 
 
 
 
 
 
三.减小swap分区
 
关闭交换分区
[root@testdb ~]# swapoff /dev/VolGroup/lv_swap
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      15141        940          0        255      13953
-/+ buffers/cache:        932      15149
Swap:            0          0          0
 
 
减小  /dev/VolGroup/lv_swap  8000M
[root@testdb ~]# lvreduce -L -8000M /dev/VolGroup/lv_swap
  WARNING: Reducing active logical volume to 8.47 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_swap? [y/n]: y
  Reducing logical volume lv_swap to 8.47 GiB
  Logical volume lv_swap successfully resized
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      15143        938          0        256      13955
-/+ buffers/cache:        931      15149
Swap:            0          0          0
 
将 /dev/VolGroup/lv_swap 设置为swap分区
[root@testdb ~]# mkswap /dev/VolGroup/lv_swap
mkswap: /dev/VolGroup/lv_swap: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 8880124 KiB
no label, UUID=1951f318-e2eb-45d5-b1ed-25a2bf87adea
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      15142        938          0        256      13955
-/+ buffers/cache:        931      15150
Swap:            0          0          0
 
 
 
开启swap分区
[root@testdb ~]# swapon /dev/VolGroup/lv_swap
[root@testdb ~]# free -m
             total       used       free     shared    buffers     cached
Mem:         16081      15149        932          0        256      13955
-/+ buffers/cache:        937      15143
Swap:         8671          0       8671
[root@testdb ~]#
 

相关内容

    暂无相关文章