绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
PostgreSQL环境变量
2019-09-16 11:26:10

  1. [postgres@SZD-L0292622:d0pdas:9220 ~]$ more profile
  2. #profile
  3. #!/bin/bash
  4. DBLIST="/paic/postgres/etc/db_info.txt"
  5. if [ ! "$1" = "" ];then
  6.     PORT=$1
  7. else
  8.     awk -F: '{print $1":"$2":"$3}' $DBLIST |sort -n
  9.     echo -n "Please Enter pg port:";
  10.     read PORT;
  11. fi

  12. if [ "$PORT" = "" ];then
  13.     echo "ERROR: Input can not be empty."
  14. elif [ `awk -F: '{print $1}' $DBLIST|grep -w $PORT|wc -l` -gt 0 ]; then
  15.     PG_SERVER_NAME=`awk -F: '{if ($1 == "'$PORT'") {print $2; exit}}' $DBLIST`
  16.     export PG_SERVER_NAME

  17.     PGHOME=`awk -F: '{if ($1 == "'$PORT'") {print $3; exit}}' $DBLIST`
  18.     export PGHOME

  19.     export PGNAME=`echo $PG_SERVER_NAME`
  20.     export PGPORT=$PORT
  21.     export PGDATA=/paic/pg$PORT/data
  22.     export ARCLOG_PATH=/paic/pgbackup/$PGNAME/archlog
  23.     export BACKUP_PATH=/paic/pgbackup/$PGNAME/pgrman
  24.     export GGS_HOME=/paic/pg$PORT/app/goldengate
  25.     export LD_LIBRARY_PATH=$PGHOME/lib:$PGHOME/stackbuilderplus/lib:$GGS_HOME/lib:$LD_LIBRARY_PATH
  26.     export PATH=$GGS_HOME:$PATH
  27.     export ODBCINI=$GGS_HOME/odbc.ini
  28.     export PERL5LIB=/paic/postgres/tools/lib/perl5
  29.     if [[ $PGHOME =~ 'ppas' ]];then
  30.         export PYTHONHOME=$HOME/python
  31.     else
  32.         unset PYTHONHOME
  33.     fi

  34.     alias pgdata="cd $PGDATA"
  35.     alias pglog="cd $PGDATA/pg_log"
  36.     alias pgxlog="cd $PGDATA/pg_xlog"
  37.     alias pgbak="cd $BACKUP_PATH"
  38.     alias pgarc="cd $ARCLOG_PATH"
  39.     alias pggg="cd /paic/pg$PORT/app"
  40.     alias vcs='sudo /opt/VRTS/bin/hastatus -sum'
  41.     alias cgall='/opt/cgtools/cginfo -t perf'
  42.     alias cg="/opt/cgtools/cginfo -t perf -s cpu|awk 'BEGIN{IGNORECASE=1}{if (NR < 4 || \$2 == \"'$PGNAME'\") print \$0}\';echo '';/opt/cgtools/cginfo -t perf -s mem|awk 'BEGIN{IGNORECASE=1}{if (NR < 4 || \$2 == \"'$PGNAME'\") print \$
  43. 0}';echo '';/opt/cgtools/cginfo -t perf -s proc|awk 'BEGIN{IGNORECASE=1}{if (NR < 4 || \$2 == \"'$PGNAME'\")print \$1,\$2,\$3,\$4,\$5}'|column -t"

  44.     PATH=$PGHOME/bin:$PATH:$HOME/bin
  45.     export PATH

  46.     LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PGHOME/lib
  47.     export LD_LIBRARY_PATH
  48. else
  49.     echo "ERROR: Can not found input port."
  50. fi
  51. export PS1='[\u@\h:\[\e[35m\]$PG_SERVER_NAME\[\e[m\]:\[\e[32m\]$PGPORT\[\e[m\] \w]\$ '

  1. [postgres@SZD-L0292622:d0pdas:9220 ~]$ more /paic/postgres/etc/db_info.txt
  2. 9220:d0pdas:/paic/postgres/base/11.3:dev:master


戳我,来吐槽~