メモリ容量チェック
物理的なメモリ容量からカーネルが使用しているメモリ容量、
# sysctl hw | grep mem hw.physmem: 8493203456 hw.usermem: 8131624960 hw.realmem: 8589934592 hw.pci.host_mem_start: 2147483648 hw.cbb.start_memory: 2281701376 #
hw.
システム全体のメモリ利用状況を知るにはvmstat(8)コマンドがわかりやすいです。freの項目が多いとメモリの使用状況に余裕があることを示しています。srの項目が多いと利用率が高くなっていることを示し、
# vmstat 1 procs memory page disks faults cpu r b w avm fre flt re pi po fr sr mf0 mf1 in sy cs us sy id 0 0 0 770M 7.3G 25 0 0 0 30 4 0 0 6 230 109 0 0 100 0 0 0 770M 7.3G 2 0 0 0 0 3 0 0 6 132 96 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 4 132 86 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 14 126 186 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 126 93 0 0 100 0 0 0 770M 7.3G 2 0 0 0 0 3 0 0 2 132 81 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 126 85 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 14 132 193 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 126 76 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 130 95 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 133 97 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 16 127 188 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 133 84 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 126 82 0 0 100 0 0 0 770M 7.3G 4 0 0 0 0 3 0 0 14 126 188 0 0 100 0 0 0 770M 7.3G 4 0 0 0 0 3 15 0 14 138 117 0 0 100 0 0 0 770M 7.3G 0 0 0 0 0 3 0 0 2 126 86 0 0 100 ^C #
プロセスごとのメモリ使用量も知りたい場合にはtop(1)コマンドが便利です。Mem:の項目にはシステム全体のメモリの使用状況が表示され、
# top -o res last pid: 4411; load averages: 0.41, 0.21, 0.18 up 0+04:18:36 17:09:32 43 processes: 1 running, 42 sleeping CPU: 0.0% user, 0.0% nice, 0.0% system, 0.0% interrupt, 100% idle Mem: 8488K Active, 52M Inact, 344M Wired, 80M Buf, 7467M Free ARC: 63M Total, 9115K MFU, 48M MRU, 16K Anon, 839K Header, 4902K Other Swap: 4096M Total, 4096M Free PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND 2350 root 1 20 0 20536K 12448K select 3 0:01 0.00% ntpd 4147 daichi 1 20 0 83092K 8312K select 3 0:00 0.00% sshd 4145 root 1 25 0 83092K 8260K select 0 0:00 0.00% sshd 2412 root 1 20 0 55676K 7556K select 3 0:00 0.00% sshd 2375 daichi 1 52 0 25412K 6992K kqread 2 0:00 0.00% nginx 2376 daichi 1 20 0 25412K 6988K kqread 1 0:01 0.01% nginx 4148 daichi 1 52 0 34628K 6768K wait 0 0:00 0.00% fish 2415 root 1 20 0 20600K 6712K select 2 0:00 0.00% sendmail 2374 root 1 52 0 25412K 6524K pause 3 0:00 0.00% nginx 2418 smmsp 1 20 0 20600K 6460K pause 2 0:00 0.00% sendmail 2589 root 1 20 0 24104K 5468K select 3 0:00 0.00% sendmail 2044 root 1 20 0 9512K 4984K select 3 0:00 0.00% devd 2592 smmsp 1 20 0 24104K 4948K pause 3 0:00 0.00% sendmail 2369 root 1 20 0 26744K 4636K nanslp 1 0:00 0.00% smartd 4404 root 1 52 0 46356K 3576K select 2 0:00 0.00% sudo 4411 root 1 20 0 20120K 3404K CPU0 0 0:00 0.06% top 2297 root 1 20 0 12516K 3328K select 3 0:00 0.00% mountd
Wiredの値が大きくなる場合、
top(1)で得られる情報は、
# ps auxw USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 11 400.0 0.0 0 64 - RL 12:51 1037:15.55 [idle] root 0 0.0 0.1 0 4192 - DLs 12:51 0:00.91 [kernel] root 1 0.0 0.0 5388 984 - ILs 12:51 0:00.01 /sbin/init -- root 2 0.0 0.0 0 16 - DL 12:51 0:00.00 [crypto] root 3 0.0 0.0 0 16 - DL 12:51 0:00.00 [crypto returns] root 4 0.0 0.0 0 32 - DL 12:51 0:00.00 [cam] root 5 0.0 0.0 0 16 - DL 12:51 0:00.00 [sctp_iterator] root 6 0.0 0.0 0 16 - DL 12:51 0:03.82 [rand_harvestq] root 7 0.0 0.0 0 16 - DL 12:51 0:00.00 [soaiod1] root 8 0.0 0.0 0 16 - DL 12:51 0:00.00 [soaiod2] root 9 0.0 0.0 0 16 - DL 12:51 0:00.00 [soaiod3] root 10 0.0 0.0 0 16 - DL 12:51 0:00.00 [audit] root 12 0.0 0.0 0 240 - WL 12:51 0:03.84 [intr] root 13 0.0 0.0 0 48 - DL 12:51 0:00.10 [geom] root 14 0.0 0.0 0 240 - DL 12:51 0:02.29 [usb] root 15 0.0 0.0 0 16 - DL 12:51 0:00.00 [soaiod4] root 16 0.0 0.0 0 32 - DL 12:51 0:00.12 [pagedaemon] root 17 0.0 0.0 0 16 - DL 12:51 0:00.00 [vmdaemon] root 18 0.0 0.0 0 16 - DL 12:51 0:00.00 [pagezero] root 19 0.0 0.0 0 48 - DL 12:51 0:00.47 [bufdaemon] root 20 0.0 0.0 0 16 - DL 12:51 0:00.08 [bufspacedaemon] root 21 0.0 0.0 0 16 - DL 12:51 0:00.38 [syncer] root 22 0.0 0.0 0 16 - DL 12:51 0:00.09 [vnlru] root 41 0.0 0.0 0 144 - DL 12:51 0:01.16 [zfskern] root 138 0.0 0.0 8296 1916 - Is 12:51 0:00.00 adjkerntz -i root 2027 0.0 0.0 12688 2224 - Is 12:51 0:00.00 /usr/sbin/moused -p /dev/ums0 -t auto -I /var/run/moused.ums0.pid root 2044 0.0 0.1 9512 4984 - Is 12:51 0:00.01 /sbin/devd root 2244 0.0 0.0 10464 2388 - Is 12:51 0:00.03 /usr/sbin/syslogd -s root 2263 0.0 0.0 10424 2304 - Ss 12:51 0:00.02 /usr/sbin/rpcbind root 2297 0.0 0.0 12516 3328 - Is 12:51 0:00.01 /usr/sbin/mountd -r -S /etc/exports /etc/zfs/exports root 2303 0.0 0.0 10352 3016 - Is 12:51 0:00.01 nfsd: master (nfsd) root 2304 0.0 0.0 8304 2036 - S 12:51 0:00.02 nfsd: server (nfsd) root 2307 0.0 0.0 274592 3184 - Ss 12:51 0:00.01 /usr/sbin/rpc.statd root 2310 0.0 0.0 12500 3180 - Ss 12:51 0:00.02 /usr/sbin/rpc.lockd root 2329 0.0 0.0 8380 2244 - Is 12:51 0:00.00 /usr/sbin/lpd root 2350 0.0 0.2 20536 12448 - Ss 12:51 0:00.77 /usr/sbin/ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntp root 2353 0.0 0.0 10436 2044 - Ss 12:51 0:01.68 /usr/sbin/powerd root 2369 0.0 0.1 26744 4636 - I 12:51 0:00.05 /usr/local/sbin/smartd -c /usr/local/etc/smartd.conf -p /var/run/sm root 2374 0.0 0.1 25412 6524 - Is 12:51 0:00.00 nginx: master process /usr/local/sbin/nginx daichi 2375 0.0 0.1 25412 6992 - I 12:51 0:00.00 nginx: worker process (nginx) daichi 2376 0.0 0.1 25412 6988 - S 12:51 0:00.83 nginx: worker process (nginx) root 2412 0.0 0.1 55676 7556 - Is 12:51 0:00.00 /usr/sbin/sshd root 2415 0.0 0.1 20600 6712 - Ss 12:51 0:00.19 sendmail: accepting connections (sendmail) smmsp 2418 0.0 0.1 20600 6460 - Is 12:51 0:00.00 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue (sendma root 2422 0.0 0.0 12564 2564 - Is 12:51 0:00.04 /usr/sbin/cron -s root 2526 0.0 0.0 14492 2184 - SsJ 12:51 0:00.03 /usr/sbin/syslogd -s root 2589 0.0 0.1 24104 5468 - SsJ 12:51 0:00.19 sendmail: accepting connections (sendmail) smmsp 2592 0.0 0.1 24104 4948 - IsJ 12:51 0:00.01 sendmail: Queue runner@00:30:00 for /var/spool/clientmqueue (sendma root 2596 0.0 0.0 16592 2292 - IsJ 12:51 0:00.04 /usr/sbin/cron -s root 2664 0.0 0.0 10476 2252 - Is 12:51 0:00.00 /usr/sbin/autounmountd root 2669 0.0 0.0 10476 2212 - Is 12:51 0:00.00 /usr/sbin/automountd root 4145 0.0 0.1 83092 8260 - Is 17:05 0:00.03 sshd: daichi [priv] (sshd) daichi 4147 0.0 0.1 83092 8312 - S 17:05 0:00.04 sshd: daichi@pts/0 (sshd) root 2685 0.0 0.0 10460 2204 u1 Is+ 12:51 0:00.00 /usr/libexec/getty 3wire ttyu1 root 2677 0.0 0.0 10460 2208 v0 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv0 root 2678 0.0 0.0 10460 2208 v1 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv1 root 2679 0.0 0.0 10460 2208 v2 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv2 root 2680 0.0 0.0 10460 2208 v3 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv3 root 2681 0.0 0.0 10460 2208 v4 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv4 root 2682 0.0 0.0 10460 2208 v5 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv5 root 2683 0.0 0.0 10460 2208 v6 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv6 root 2684 0.0 0.0 10460 2208 v7 Is+ 12:51 0:00.00 /usr/libexec/getty Pc ttyv7 daichi 4148 0.0 0.1 34628 6768 0 Is 17:05 0:00.50 -fish (fish) root 4404 0.0 0.0 46356 3576 0 I 17:05 0:00.01 sudo HOME=/root su -l root 4405 0.0 0.0 43708 3048 0 I 17:05 0:00.01 su -l root 4406 0.0 0.0 13144 3012 0 S 17:05 0:00.01 -su (sh) root 4417 0.0 0.0 21164 2780 0 R+ 17:10 0:00.00 ps auxw #
メモリの使用量が増えるとスワップアウトする分も増えてきます。この分についてはswapinfo(8)コマンドで取得できます。
# swapinfo Device 1K-blocks Used Avail Capacity /dev/mfid0p3 4194304 0 4194304 0% #
システムが重かったり、
また、
上記とは逆の状況になっている場合には、
勉強会
第58回 11月29日(火) 19:00- FreeBSD勉強会
2016年11月29日(火)には佐藤広生先生をお招きして第58回FreeBSD勉強会をドワンゴセミナールームで開催します。FreeBSD ZFS性能測定とチューニングのお話をしていただく予定です。第58回FreeBSD勉強会では、
参加申請はこちらから。
第59回 12月21日(水) 19:00- FreeBSD勉強会
ストレージシステムの基盤として使われることの多いZFS。いったん運用を開始するとあとはボリュームの管理や、
参加申請はこちらから。