数据库的监控(一)

作者:瀚高PG实验室 (Highgo PG Lab)-海无涯

身为数据库的运维人员在了解数据库状态的时候通常会有一个问题:操作系统正在干什么?

我们如何来知道操作系统到底在做什么呢?通过一些Unix平台自带的工具来分析数据库的状态是一个简单而有效的手段。

可以通过如下几个常用方法:

1、

[highgo@higsin ~]$ ps auxww | grep postgres
highgo   15044  0.0  1.0 354956 19060 ?        S    Mar14   0:00 /data/highgo/4.1.1/bin/postgres
highgo   15046  0.0  0.1 354956  2688 ?        Ss   Mar14   0:00 postgres: checkpointer process  
highgo   15047  0.0  0.1 354956  3496 ?        Ss   Mar14   0:00 postgres: writer process   
highgo   15048  0.0  0.1 354956  2656 ?        Ss   Mar14   0:00 postgres: wal writer process   
highgo   15049  0.0  0.1 355364  3536 ?        Ss   Mar14   0:00 postgres: autovacuum launcher process  
highgo   15050  0.0  0.1 209940  2644 ?        Ss   Mar14   0:01 postgres: stats collector process  
highgo   29837  0.0  0.0 112648   960 pts/2    R+   10:53   0:00 grep --color=auto postgres

2、

[highgo@higsin ~]$ top
top - 10:59:21 up 20:34,  3 users,  load average: 0.00, 0.01, 0.05
Tasks: 163 total,   2 running, 161 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  1884188 total,    99720 free,   534044 used,  1250424 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  1088076 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                             
   10 root      20   0       0      0      0 S  0.3  0.0   0:03.10 rcu_sched                                                                                           
29897 highgo    20   0  146144   2060   1420 R  0.3  0.1   0:00.03 top                                                                                                 
    1 root      20   0  127252   8024   2608 S  0.0  0.4   0:08.79 systemd                                                                                             
    2 root      20   0       0      0      0 S  0.0  0.0   0:00.01 kthreadd                                                                                            
    3 root      20   0       0      0      0 S  0.0  0.0   0:00.40 ksoftirqd/0                                                                                         
    6 root      20   0       0      0      0 S  0.0  0.0   0:02.81 kworker/u2:0                                                                                        
    7 root      rt   0       0      0      0 S  0.0  0.0   0:00.00 migration/0                                                                                         
    8 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcu_bh                                                                                              
    9 root      20   0       0      0      0 S  0.0  0.0   0:00.00 rcuob/0                                                                                             
   11 root      20   0       0      0      0 R  0.0  0.0   0:05.18 rcuos/0                                                                                             
   12 root      rt   0       0      0      0 S  0.0  0.0   0:00.78 watchdog/0                                                                                          
   13 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 khelper                                                                                             
   14 root      20   0       0      0      0 S  0.0  0.0   0:00.00 kdevtmpfs                                                                                           
   15 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 netns                                                                                               
   16 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 perf                                                                                                
   17 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 writeback                                                                                           
   18 root       0 -20       0      0      0 S  0.0  0.0   0:00.00 kintegrit

3、

[highgo@higsin ~]$ iostat
Linux 3.10.0-327.el7.x86_64 (higsin) 	03/15/2018 	_x86_64_	(1 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.25    0.02    0.22    0.13    0.00   99.39

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
scd0              0.02         0.74         0.00      54642          0
sda               1.10        14.76        16.80    1091872    1242195
dm-0              1.14        14.59        16.53    1079259    1222754

4、

[highgo@higsin ~]$ vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 3  0      0 100480   1376 1249136    0    0    15    17   36   64  0  0 99  0  0

 另外,一旦我们发现了一个性能差的查询,可能需要PostgreSQL 的EXPLAIN命令进行进一步的调查。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值