PostgreSQL Performance Monitoring Tools

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PostgreSQL Performance Monitoring Tools相关的知识,希望对你有一定的参考价值。

PostgreSQL Performance Monitoring Tools

https://github.com/CloudServer/postgresql-perf-tools

This package includes three useful scripts aimed to help to pinpoint performance issues on systems with PostgreSQL as database backend.

All scritps are written in Python. Requirements:

All scripts require a connect to PostgreSQL database. They take traditional set of DB credentials: host address, port (5432 by default), database name, database user and password.

Note: you may need to modify pg_hba.conf file to allow the scripts to connect to the server. Please refer to official documentaion:http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html

For detailed list of command line options use --help / -h option.

软件包

Python-2.7.tar.bz2   psycopg2-2.6.1.tar.gz   psutil-3.2.2.tar.gz

安装 python2.7

[[email protected] soft_bak]# tar jxvf Python-2.7.tar.bz2

[[email protected] soft_bak]# cd Python-2.7

[[email protected] Python-2.7]# ./configure --prefix=/usr/local/python2.7/

[[email protected] Python-2.7]# make

[[email protected] Python-2.7]# make install

添加/usr/local/python2.7/bin/到Linux的环境变量中

[[email protected] bin]# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[[email protected] bin]# PATH="$PATH":/usr/local/python2.7/bin/

[[email protected] bin]# echo $PATH

/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/python2.7/bin/

删除/usr/bin中的python文件,为python2.7创建连接

[[email protected] bin]# cd /usr/bin/

[[email protected] bin]# rm -rf python

[[email protected] bin]# ln -s /usr/local/python2.7/bin/python ./python

[[email protected] bin]# python

Python 2.7 (r27:82500, Jan 14 2016, 16:13:36)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 

解决Python升级后yum不能用的问题

#修改yum文件

vi /usr/bin/yum

将文件头部的

#!/usr/bin/python

改为如下内容

#!/usr/bin/python2.6

安装psutil

[[email protected] soft_bak]# tar zxvf psutil-3.2.2.tar.gz

[[email protected] PGMonitor]# cd psutil-3.2.2

[[email protected] psutil-3.2.2]# python setup.py install

安装psycopg2

[[email protected] soft_bak]# tar zxvf psycopg2-2.6.1.tar.gz

[[email protected] PGMonitor]# cd psycopg2-2.6.1

[roo[email protected] psycopg2-2.6.1]# python setup.py build_ext --pg-config /usr/local/pg945/bin/pg_config  build

[[email protected] psycopg2-2.6.1]# python setup.py build_ext --pg-config /usr/local/pg945/bin/pg_config  install

安装setuptools

[[email protected] soft_bak]# tar zxvf setuptools-19.2.tar.gz

[[email protected] setuptools-19.2]# cd setuptools-19.2

[[email protected] setuptools-19.2]# python setup.py install

安装postgresql-perf-tools

[[email protected] opt]# git clone https://github.com/CloudServer/postgresql-perf-tools

Initialized empty Git repository in /opt/postgresql-perf-tools/.git/

remote: Counting objects: 22, done.

remote: Total 22 (delta 0), reused 0 (delta 0), pack-reused 22

Unpacking objects: 100% (22/22), done.

[[email protected] opt]# cd postgresql-perf-tools/

启动PostgreSQL

[[email protected] bin]$ ./pg_ctl -D ../data/ start

server starting

生成少量数据

[[email protected] bin]$ ./pgbench -i -F 100 -s 142 -h localhost -p 5432 -U postgres postgres

进程pgbench测试

 [[email protected] bin]$ ./pgbench -h localhost -p 5432 -c 10 -T 600

技术分享

技术分享

技术分享

[[email protected] postgresql-perf-tools]# ./pg-top.py  --db-host=localhost

技术分享

 

以上是关于PostgreSQL Performance Monitoring Tools的主要内容,如果未能解决你的问题,请参考以下文章

Postgresql 序列性能

Postgresql 生成日期系列(性能)

MYSQL 8 上云 performance_schema 里面参数我们打开了那些 5个表调整脚本?(POLARDB 适用)

PostgreSql 或 MongoDb 用于从 REST API 接收的 JSON 数据

zabbix通过pg_monz模板监控postgresql数据库

使用FreeRTOS进行性能和运行时分析