• PostgreSQL Monitor pg_activity


    PostgreSQL Monitor pg_activity

    Command line tool for PostgreSQL server activity monitoring.

    https://github.com/julmon/pg_activity/

    依赖的包

    • python ≥ 2.6
    • psycopg2 ≥ 2.2.1
    • psutil ≥ 0.5.1

    软件包

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

    安装 python2.7

    [root@node3 soft_bak]# tar jxvf Python-2.7.tar.bz2

    [root@node3 soft_bak]# cd Python-2.7

    [root@node3 Python-2.7]# ./configure --prefix=/usr/local/python2.7/

    [root@node3 Python-2.7]# make

    [root@node3 Python-2.7]# make install

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

    [root@node3 bin]# echo $PATH

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

    [root@node3 bin]# PATH="$PATH":/usr/local/python2.7/bin/

    [root@node3 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创建连接

    [root@node3 bin]# cd /usr/bin/

    [root@node3 bin]# rm -rf python

    [root@node3 bin]# ln -s /usr/local/python2.7/bin/python ./python

    [root@node3 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

    [root@node3 soft_bak]# tar zxvf psutil-3.2.2.tar.gz

    [root@node3 PGMonitor]# cd psutil-3.2.2

    [root@node3 psutil-3.2.2]# python setup.py install

    安装psycopg2

    [root@node3 soft_bak]# tar zxvf psycopg2-2.6.1.tar.gz

    [root@node3 PGMonitor]# cd psycopg2-2.6.1

    [root@node3 psycopg2-2.6.1]# python setup.py build_ext --pg-config /usr/local/pg945/bin/pg_config  build

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

    安装setuptools

    [root@node3 soft_bak]# tar zxvf setuptools-19.2.tar.gz

    [root@node3 setuptools-19.2]# cd setuptools-19.2

    [root@node3 setuptools-19.2]# python setup.py install

    安装pg_activity

    [root@node3 soft_bak]# unzip pg_activity-master.zip

    [root@node3 soft_bak]# cd pg_activity-master

    [root@node3 pg_activity-master]# python setup.py install

    在python2.7安装目录下会产生如下pg_activity命令

    [root@node3 pg_activity-master]# cd /usr/local/python2.7/bin/

    [root@node3 bin]# ls

    2to3  easy_install  easy_install-2.7  idle  pg_activity  pydoc  python  python2.7  python2.7-config  python-config  smtpd.py

    启动PostgreSQL

    [postgres@node3 bin]$ ./pg_ctl -D ../data/ start

    server starting

    监控PostgreSQL数据库状态

    [postgres@node3 ~]$ cd /usr/local/python2.7/bin/

    [postgres@node3 bin]$ ./pg_activity

    生成少量数据

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

     

    进行pgbench测试

    [postgres@node3 bin]$ ./pgbench -h localhost -p 5432 -d postgres -c 10 -j 10 -r -T 600

     

     

     

     

  • 相关阅读:
    jQuery知识总结
    WEB架构师成长之路之2
    利用Travis CI 让你的github项目持续构建(Node.js为例)
    C#实现UDP分包组包
    win7下安装32位GoSublime Package
    爬虫部分技术要点浅析
    如何使用“依赖注入”的
    分布式ACM Online Judge 架构设计
    “容器组件服务”模型
    Maven学习
  • 原文地址:https://www.cnblogs.com/songyuejie/p/5132488.html
Copyright © 2020-2023  润新知