postgresql的实时监控工具pgcenter介绍

前端之家收集整理的这篇文章主要介绍了postgresql的实时监控工具pgcenter介绍前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

最近同事问有没有一款工具可以实时查看postgresql数据库当前的每秒增删改查,翻了一圈,有一款叫pgcenter的工具可以满足需求,而且某些方面更加详细和强大。这款工具目前已经开源,使用也很方便,简介之。

一、环境及下载

  1. OSCentos 6.6
  2. DBPostgresql 9.6
  3. git clone https://github.com/lesovsky/pgcenter

二、安装

需要在/usr/bin下创建可执行文件,需要sudo权限

  1. [root@temp postgres]# upzip pgcenter-master.zip
  2. [root@temp postgres]# cd pgcenter-master
  3. [root@temp postgres]# make
  4. [root@temp postgres]# make install
  5. [root@temp pgcenter-master]# which pgcenter
  6. /usr/bin/pgcenter
  7. [root@temp pgcenter-master]# source /home/postgres/.bash_profile
  8. [root@temp pgcenter-master]# pgcenter -V
  9. pgcenter 0.3.0

三、使用

简单做个压测,看看效果

  1. [postgres@temp ~]$ more test.conf
  2. \set id random(1,2000000)
  3. begin;
  4. insert into tbl_kenyon(id,ctime) values(:id,now());
  5. SELECT id FROM tbl_kenyon WHERE id = :id;
  6. end;
  7. [postgres@temp ~]$ pgbench -M simple -r -c 8 -f /home/postgres/test.conf -j 1 -n -T 120 db_kenyon
  8.  
  9. --开启监控,具体效果图见下
  10. [root@temp ~]# pgcenter db_kenyon postgres

效果图如下,增删改查数每秒会刷新一次:

还有其他的一些监控指标,比如监控表的大小,索引的大小,IO、vacuum、当前进程,等,具体用法见下:

  1. Help for interactive commands - pgcenter version 0.3.0
  2.  
  3. general actions:
  4. a,d,i,f,r mode: 'a' activity,'d' databases,'i' indexes,'f' functions,'r' replication,s,t,T,v 's' tables sizes,'t' tables,'T' tables IO,'v' vacuum progress,x,X 'x' pg_stat_statements switch,'X' pg_stat_statements menu.
  5. Left,Right,/,F 'Left,Right' change column sort,'/' change sort desc/asc,'F' set filter.
  6. C,E,R config: 'C' show config,'E' edit configs,'R' reload config.
  7. p 'p' start psql session.
  8. l 'l' open log file with pager.
  9. N,Ctrl+D,W 'N' add new connection,Ctrl+D close current connection,'W' write connections info.
  10. 1..8 switch between consoles.
  11. subscreen actions:
  12. B,I,L 'B' iostat,'I' nicstat,'L' logtail.
  13. activity actions:
  14. -,_ '-' cancel backend by pid,'_' terminate backend by pid.
  15. >,. '>' set new mask,'.' show current mask.
  16. Del,Shift+Del 'Del' cancel backend group using mask,'Shift+Del' terminate backend group using mask.
  17. A change activity age threshold.
  18. G get report about query using hash.
  19.  
  20. other actions:,Q ',' show system tables on/off,'Q' reset postgresql statistics counters.
  21. z,Z 'z' set refresh interval,'Z' change color scheme.
  22. space pause program execution.
  23. h,F1 show help screen.
  24. q quit.
  25.  
  26. Type 'Esc' to continue.

猜你在找的Postgre SQL相关文章