pg_top试用

以前有整理过一些关于pg监控的工具,其中有介绍到pg_top,以下是一个简单的学习使用

环境准备

基于虚拟机部署的,centos8

  • 安装pg
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql13-server
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
  • 修改配置(注意需要重启服务)
    为了测试方便,去掉安全文件 /var/lib/pgsql/13/data/pg_hba.conf
    修改为:
 
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256
  • 安装pg_top
    直接使用dnf安装就可以了
 
dnf  install -y pg_top 
  • 压测工具安装
    压测基于sysbench
 
dnf install -y sysbench

试用

  • 运行pg_top
pg_top -U postgres -h 127.0.0.1
  • 压测
sysbench \
--db-driver=pgsql \
--pgsql-host=127.0.0.1 \
--pgsql-port=5432 \
--pgsql-user=postgres \
--pgsql-db=postgres \
--oltp-table-size=10000 \
--rand-init=on \
--threads=10 \
--time=120 \
--events=0 \
--report-interval=10 \
--percentile=99 \
/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \
prepare
sysbench \
--db-driver=pgsql \
--pgsql-host=127.0.0.1 \
--pgsql-port=5432 \
--pgsql-user=postgres \
--pgsql-db=postgres \
--oltp-table-size=10000 \
--threads=10 \
--time=120 \
--events=0 \
--report-interval=10 \
--percentile=99 \
/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \
run
sysbench \
--db-driver=pgsql \
--pgsql-host=127.0.0.1 \
--pgsql-port=5432 \
--pgsql-user=postgres \
--pgsql-db=postgres \
--oltp-table-size=10000 \
--threads=10 \
--time=120 \
--events=0 \
--report-interval=10 \
--percentile=99 \
/usr/share/sysbench/tests/include/oltp_legacy/oltp.lua \
cleanup
  • 效果

 

 

参考资料

https://www.cnblogs.com/rongfengliang/p/12550071.html

posted on   荣锋亮  阅读(1025)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-11-13 piral 基于typescript 的微前端开发框架
2019-11-13 redhat quay 集成镜像构建
2019-11-13 Quay: Introducing an Application Registry for Kubernetes
2019-11-13 redhat quay 安装试用
2018-11-13 Hasura GraphQL 内部表结构
2018-11-13 Hasura GraphQL schema 生成是如何工作的
2018-11-13 一张方便的graphql schema 语言手册

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示