Advertisement
BrokeDBA

.bash_switch

Nov 7th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.63 KB | None | 0 0
  1. #umask 022
  2. PATH=$PATH:$HOME/bin
  3. # author Kosseila Hd
  4. # Oracle Settings for oracle user
  5.  
  6. export TMP=/tmp
  7. export ORACLE_PATH=/home/oracle/scripts/eclipsys
  8. export TMPDIR=$TMP
  9. export ORACLE_HOSTNAME=$(hostname)
  10. #export ORACLE_UNQNAME=`awk -F: '/^[^#]/ { print $1 } ' /etc/oratab | uniq | grep -m -1  product`
  11. export ORACLE_BASE=/u01/app/oracle
  12. export ORACLE_HOME=`awk -F: '/^[^#]/ { print $2 } ' /etc/oratab | uniq | grep -m 1  product`
  13. #export ORACLE_SID=db12c
  14. export GRID_HOME=`awk -F: '/^[^#]/ && /^+ASM/ { print $2 }' /etc/oratab | uniq`
  15. export PATH=/usr/sbin:$PATH
  16. export PATH=$PATH:$ORACLE_HOME/bin
  17. export PATH=$PATH:$GRID_HOME/bin
  18. export PATH=/usr/sbin:$PATH
  19. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
  20. export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
  21.  
  22. # switch database
  23. echo Please Choose the DB or GRID HOME you wish to manage
  24. echo ' oratab source '
  25. awk -F: '/^[^#]/ { print " -- " $1 }' /etc/oratab | uniq
  26. echo ' current processes'
  27. ps -ef | awk '$8 ~ /_pmon_/ {print $8}'| cut -c 10-|sed  -e 's/^/ -- /'
  28. read sid
  29. export ORACLE_SID=$sid
  30. if [[ "$sid" == *"+ASM"* ]];
  31.   then  export ORACLE_BASE=/u01/app/grid;
  32.         export ORACLE_HOME=$GRID_HOME
  33.    else
  34.        v=`awk -F: '/^[^#]/ { print $1 } ' /etc/oratab | uniq | grep -m 1  $sid`
  35.         if [[ "$sid" == "$v" ]];
  36.           then  export ORACLE_HOME=`awk -F: '/^[^#]/ { print } ' /etc/oratab |grep -m 1  $sid|awk -F: '{print $2}'`
  37.        fi
  38. fi
  39.  
  40. if [ ! -n "$GRID_HOME" ] ;
  41. then echo "==== There is no GRID installed in this server ===="
  42. else
  43. /home/oracle/scripts/eclipsys/check_crs.sh
  44. fi
  45. /home/oracle/scripts/eclipsys/rac_status.sh -e
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement