Tuesday, October 21, 2014

Solaris 11 Swap administration

1)To see swap device list
root@solaris1:~# swap -l
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2        16  2097136  2097136
in human redable format (GB/KB)
root@solaris1:~# swap -lh
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2        8K     1.0G     1.0G
root@solaris1:~# swap -lk
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2        8K 1048568K 1048568K

2)To see swap statics
root@solaris1:~# swap -s
total: 106992k bytes allocated + 14888k reserved = 121880k used, 1032376k available
root@solaris1:~# swap -sh
total: 100M allocated + 10M reserved = 110M used, 3.0G available

3)To see all swap FS information
root@solaris1:~# zfs get all rpool/swap
NAME        PROPERTY              VALUE                  SOURCE
rpool/swap  available             4.45G                  -
rpool/swap  checksum              off                    local
rpool/swap  compression           off                    local
rpool/swap  compressratio         1.00x                  -
rpool/swap  copies                1                      default
rpool/swap  creation              Fri Nov  1 16:22 2013  -
rpool/swap  dedup                 off                    local
rpool/swap  encryption            off                    local
rpool/swap  keychangedate         -                      default
rpool/swap  keysource             none                   default
rpool/swap  keystatus             none                   -
rpool/swap  logbias               latency                default
rpool/swap  primarycache          metadata               local
rpool/swap  readonly              off                    default
rpool/swap  referenced            1.00G                  -
rpool/swap  refreservation        1.03G                  local
rpool/swap  rekeydate             -                      default
rpool/swap  reservation           none                   default
rpool/swap  secondarycache        all                    default
rpool/swap  sync                  standard               default
rpool/swap  type                  volume                 -
rpool/swap  used                  1.03G                  -
rpool/swap  usedbychildren        0                      -
rpool/swap  usedbydataset         1.00G                  -
rpool/swap  usedbyrefreservation  32.5M                  -
rpool/swap  usedbysnapshots       0                      -
rpool/swap  volblocksize          1M                     -
rpool/swap  volsize               1G                     local
rpool/swap  zoned                 off                    default

4)To increase swap online
root@solaris1:~# zfs set volsize=2G rpool/swap
root@solaris1:~# zfs get all rpool/swap
NAME        PROPERTY              VALUE                  SOURCE
rpool/swap  available             3.45G                  -
rpool/swap  checksum              off                    local
rpool/swap  compression           off                    local
rpool/swap  compressratio         1.00x                  -
rpool/swap  copies                1                      default
rpool/swap  creation              Fri Nov  1 16:22 2013  -
rpool/swap  dedup                 off                    local
rpool/swap  encryption            off                    local
rpool/swap  keychangedate         -                      default
rpool/swap  keysource             none                   default
rpool/swap  keystatus             none                   -
rpool/swap  logbias               latency                default
rpool/swap  primarycache          metadata               local
rpool/swap  readonly              off                    default
rpool/swap  referenced            2.00G                  -
rpool/swap  refreservation        2.06G                  local
rpool/swap  rekeydate             -                      default
rpool/swap  reservation           none                   default
rpool/swap  secondarycache        all                    default
rpool/swap  sync                  standard               default
rpool/swap  type                  volume                 -
rpool/swap  used                  2.06G                  -
rpool/swap  usedbychildren        0                      -
rpool/swap  usedbydataset         2.00G                  -
rpool/swap  usedbyrefreservation  64.7M                  -
rpool/swap  usedbysnapshots       0                      -
rpool/swap  volblocksize          1M                     -
rpool/swap  volsize               2G                     local
rpool/swap  zoned                 off                    default
root@solaris1:~# swap -sh
total: 100M allocated + 10M reserved = 110M used, 4.0G available
root@solaris1:~# swap -l
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2        16  2097136  2097136
/dev/zvol/dsk/rpool/swap 285,2   2097168  2097136  2097136

5)To decrease swap ????<not posible>
root@solaris1:~# zfs set volsize=1G rpool/swap
cannot set property for 'rpool/swap': volume is busy
root@solaris1:~# swap -d /dev/zvol/dsk/rpool/swap
root@solaris1:~# swap -l
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2   2097168  2097136  2097136
root@solaris1:~# swap -sh
total: 100M allocated + 10M reserved = 110M used, 3.0G available
root@solaris1:~# zfs set volsize=1G rpool/swap
root@solaris1:~# zfs get all rpool/swap
NAME        PROPERTY              VALUE                  SOURCE
rpool/swap  available             5.45G                  -
rpool/swap  checksum              on                     local
rpool/swap  compression           off                    local
rpool/swap  compressratio         1.00x                  -
rpool/swap  copies                1                      default
rpool/swap  creation              Fri Nov  1 16:22 2013  -
rpool/swap  dedup                 off                    local
rpool/swap  encryption            off                    local
rpool/swap  keychangedate         -                      default
rpool/swap  keysource             none                   default
rpool/swap  keystatus             none                   -
rpool/swap  logbias               latency                default
rpool/swap  primarycache          metadata               local
rpool/swap  readonly              off                    default
rpool/swap  referenced            16K                    -
rpool/swap  refreservation        1.03G                  local
rpool/swap  rekeydate             -                      default
rpool/swap  reservation           none                   default
rpool/swap  secondarycache        all                    default
rpool/swap  sync                  standard               default
rpool/swap  type                  volume                 -
rpool/swap  used                  1.03G                  -
rpool/swap  usedbychildren        0                      -
rpool/swap  usedbydataset         16K                    -
rpool/swap  usedbyrefreservation  1.03G                  -
rpool/swap  usedbysnapshots       0                      -
rpool/swap  volblocksize          1M                     -
rpool/swap  volsize               1G                     local
rpool/swap  zoned                 off                    default

6)To delete swap
root@solaris1:~# swap -d /dev/zvol/dsk/rpool/swap
7)to see swap info from top
#top
last pid:  1334;  load avg:  0.01,  0.04,  0.07;  up 0+01:55:02                                                                                     17:25:14
52 processes: 51 sleeping, 1 on cpu
CPU states: 99.5% idle,  0.0% user,  0.5% kernel,  0.0% iowait,  0.0% swap
Kernel: 139 ctxsw, 396 intr, 320 syscall
Memory: 4096M phys mem, 2600M free mem, 1024M total swap, 1024M free swap
   PID USERNAME NLWP PRI NICE  SIZE   RES STATE    TIME    CPU COMMAND
  1333 root        1  50    0 3968K 3056K cpu/2    0:00  0.16% top
   886 root        4  59    0 3456K 1272K sleep    0:00  0.00% devchassisd
   777 root       32  59    0   32M 8768K sleep    0:05  0.00% fmd
   396 root        6  59    0   11M 1848K sleep    0:01  0.00% devfsadm
    13 root       26  59    0   20M   17M sleep    1:09  0.00% svc.configd
    11 root       13  59    0   20M 2128K sleep    0:17  0.00% svc.startd
  1289 root        1  59    0   19M   12M sleep    0:01  0.00% sshd
  1275 root        1  59    0   19M 2800K sleep    0:01  0.00% sshd
  1287 root        1  59    0   11M 2752K sleep    0:01  0.00% zpool
   710 root        4  59    0 7640K 2488K sleep    0:01  0.00% hald
   189 root        5  60  -20 3032K  440K sleep    0:00  0.00% zonestatd
  1288 root        1  59    0   16M 9632K sleep    0:00  0.00% sshd
    76 daemon      3  59    0   15M 9264K sleep    0:00  0.00% kcfd
   670 root       28  59    0   13M 7992K sleep    0:00  0.00% nscd
   193 root        5  59    0   24M 3448K sleep    0:00  0.00% rad
  1290 root        1  59    0   10M 3320K sleep    0:00  0.00% bash
   997 root        1  59    0 7128K 2920K sleep    0:00  0.00% sendmail
   995 smmsp       1  59    0 7232K 2800K sleep    0:00  0.00% sendmail
   900 root        1  59    0   10M 2232K sleep    0:00  0.00% bash
   776 root        1  59    0   14M 2072K sleep    0:00  0.00% sshd
   599 root        8  59    0   11M 2032K sleep    0:00  0.00% picld
   188 root       17  59    0   10M 1936K sleep    0:00  0.00% syseventd
   558 netadm      7  59    0   12M 1792K sleep    0:00  0.00% nwamd
   784 root       12  59    0   11M 1784K sleep    0:00  0.00% syslogd
   745 root        4  59    0   13M 1720K sleep    0:00  0.00% inetd
    61 root        8  59    0 4608K 1536K sleep    0:00  0.00% dlmgmtd
    90 netadm      6  59    0 4760K 1424K sleep    0:00  0.00% ipmgmtd
   100 root        1  59    0   10M 1312K sleep    0:00  0.00% in.mpathd
     1 root        1  59    0 3144K 1272K sleep    0:00  0.00% init
  1274 root        1  59    0   16M 1232K sleep    0:00  0.00% sshd
8)To see virtual memory statics
root@solaris1:~# vmstat
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr vc vc vc vc   in   sy   cs us sy id
 0 0 0 3464888 2916208 19 25 0  0  0  0  2  0  0  8  0  464  476  389  0  1 99
root@solaris1:~# vmstat -p
     memory           page          executable      anonymous      filesystem
   swap  free  re  mf  fr  de  sr  epi  epo  epf  api  apo  apf  fpi  fpo  fpf
 3468992 2919952 19 26  0   0   2    0    0    0    0    0    0    0    0    0
root@solaris1:~# vmstat -s
        0 swap ins
        0 swap outs
        0 pages swapped in
        0 pages swapped out
   178219 total address trans. faults taken
       19 page ins
        0 page outs
      209 pages paged in
        0 pages paged out
   132252 total reclaims
   132252 reclaims from free list
        0 micro (hat) faults
   178219 minor (as) faults
       10 major faults
   129651 copy-on-write faults
   119414 zero fill page faults
    12284 pages examined by the clock daemon
        0 revolutions of the clock hand
        0 pages freed by the clock daemon
      705 forks
      627 vforks
     1566 execs
  2722908 cpu context switches
  3230263 device interrupts
   486775 traps
  3347248 system calls
  1511930 total name lookups (cache hits 91%)
    16512 user   cpu
    31173 system cpu
  5513420 idle   cpu
        0 wait   cpu
root@solaris1:~# vmstat -q
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr vc vc vc vc   in   sy   cs us sy id
 0 0 0 3468512 2919504 19 26 0  0  0  0  2  0  0  8  0  465  481  392  0  1 99
root@solaris1:~# vmstat -T d
Friday, December  6, 2013 05:26:47 PM UTC
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr vc vc vc vc   in   sy   cs us sy id
 0 0 0 3467864 2918920 19 26 0  0  0  0  2  0  0  8  0  465  480  391  0  1 99
root@solaris1:~# vmstat -i
interrupt         total     rate
--------------------------------
clock            711571      100
--------------------------------
Total            711571      100
9))To add as swap
root@solaris1:~# zfs create -V 1G testpool/swap1
root@solaris1:~# swap -a /dev/zvol/dsk/testpool/swap1
root@solaris1:~# swap -l
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2   2097168  2097136  2097136
/dev/zvol/dsk/testpool/swap1 285,5        16  2097136  2097136

10)To delete swap file
root@solaris1:~# swap -d /dev/zvol/dsk/testpool/swap1
root@solaris1:~# swap -l
swapfile             dev    swaplo   blocks     free
/dev/zvol/dsk/rpool/swap 285,2   2097168  2097136  2097136

11)NO concept of adding file as swap space
root@solaris1:/testpool# swap -a /testpool/swapfile
/testpool/swapfile: Invalid operation for this filesystem type

No comments:

Post a Comment