ddgg.ksh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/ksh
  2. function is_not_guarded
  3. {
  4. return `${ORACLE_HOME}/bin/sqlplus -S / "as sysdba" <<-EOF
  5. set pagesize 0 feedback off verify off heading off termout off echo off
  6. select count(1) from sys.v\\$archive_dest where status = 'VALID' and target = 'STANDBY';
  7. EOF`
  8. }
  9. get_db_role()
  10. {
  11. db_role=`${ORACLE_HOME}/bin/sqlplus -S / "as sysdba" <<-EOF
  12. set pagesize 0 feedback off verify off heading off termout off echo off
  13. select database_role from v\\$DATABASE;
  14. EOF`
  15. }
  16. get_DB_type()
  17. {
  18. get_db_role
  19. if is_not_guarded
  20. then
  21. if [ "${db_role}" = "PHYSICAL STANDBY" ]; then
  22. echo -e "${db_role}: Physical Standby"
  23. export DB_TYPE=3
  24. else
  25. echo -e "${db_role}: Single Instance."
  26. export DB_TYPE=1
  27. fi
  28. else
  29. echo -e "${db_role}: Primary (Dataguarded)."
  30. export DB_TYPE=2
  31. fi
  32. }
  33. # -------------------------------------------------------------------------------------------------------------------
  34. get_DB_type
  35. echo -e "Output: DEBUG: DB_TYPE is ${DB_TYPE}."