標籤:
PostgreSQL Monitor pg_view
https://github.com/zalando/pg_view
Requirements
Linux 2.6, python 2.6, psycopg2, curses
查看系統是否有curses
[[email protected] /]# ls /usr/include/ncurses*
/usr/include/ncurses_dll.h /usr/include/ncurses.h
系統已經安裝了curses,如果沒有下載安裝curses
下載安裝 curses
curses 的GNU實現 ncurses,官網:http://ftp.gnu.org/gnu/ncurses/
下載 ncurses 的最新版本;
[[email protected] soft_bak]tar zxvf ncurses-6.0.tar.gz
[[email protected] soft_bak] cd ncurses-6.0
[[email protected] soft_bak] ./configure
[[email protected] soft_bak] make
[[email protected] soft_bak] make install
預設的安裝,標頭檔在 /usr/include 下,庫在 /usr/lib 下。
也可以使用yum安裝
搜尋 : yum search ncurses
安裝 : yum install ncurses
軟體包
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.
>>>
安裝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
[[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
[[email protected] soft_bak]# unzip pg_view-master.zip
[[email protected] soft_bak]# cd pg_view-master
將opt/soft_bak/pg_view-master目錄下setup.py 中的
第112行 long_description=read(‘README.md‘),改為如下
long_description=read(‘README.rst‘),
[[email protected] pg_view-master]# python setup.py install
[[email protected] soft_bak]# cd /usr/local/python2.7/bin/
[[email protected] bin]# ls
2to3 easy_install easy_install-2.7 idle pg_view pydoc python python2.7 python2.7-config python-config smtpd.py
啟動PostgreSQL
[[email protected] bin]$ ./pg_ctl -D ../data/ start
server starting
postgres 使用者執行 pg_view
[[email protected] ~]$ cd /usr/local/python2.7/bin/
[[email protected] bin]$ ./pg_view
產生少量資料
[[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 -d postgres -U postgres -c 50 -j 10 -T 600
PostgreSQL Monitor pg_view