PostgreSQL自带一款轻量级的压力测试工具:pgbench。pgbench是一种在PostgreSQL上运行基准测试的简单程序。它可以在并发的数据库会话中一遍一遍地运行相同的SQL命令。

安装方法

  1. 执行如下命令在ECS实例中安装PostgreSQL 11。
    yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
    yum install -y postgresql11*
    
    su - postgres
    vi .bash_profile
    export PS1="$USER@`/bin/hostname -s`-> "    
    export LANG=en_US.utf8    
    export PGHOME=/usr/pgsql-11  
    export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH    
    export DATE=`date +"%Y%m%d%H%M"`  
    export PATH=$PGHOME/bin:$PATH:.    
    export MANPATH=$PGHOME/share/man:$MANPATH    
    alias rm='rm -i'    
    alias ll='ls -lh'    
    unalias vi   
    unalias vi