• oraenv Oracle_SID for sid in


    Oracle 环境变量获取

    for SID    in `ps -ef | grep pmon | grep -v grep | grep -v ASM |   cut -d"_" -f3,4 `
    do
    #export ORACLE_BASE=/u01/app/grid
    #export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_2
    #export ORACLE_SID=noexist
    #export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    #export PATH=$ORACLE_HOME/bin:$PATH
    export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'

    export ORACLE_SID=$SID
    export ORAENV_ASK=NO
    . oraenv

    echo Database instance checking is : $SID
    echo " <(----------Blank Represents DB Run perfect----------)>"

    value=`sqlplus -s / as sysdba <  set pagesize 0 feedback off verify off heading off echo off numwidth 9 ;
     select count(*) from gv\\\$database a where a.OPEN_MODE in ('READ WRITE') and rownum<2;
    exit;
    EOF`
    if [ $value == 1 ];
    then
    echo "THIS IS PRIMARY DATABASE"
    sqlplus  -s  ' / as sysdba' <

    1. oraenv的设置
    2. ORAENV便于设置oracle环境
    3. 存储路径:$ORACLE_HOME/bin
    4. ORAENV_ASK:设置是否需要交互
    5. 复制代码
    6. 交互式:
    7. $ . oraenv
    8. ORACLE_SID = [] ? orcl
    9. 非交互式
    10. $ export ORACLE_SID=orcl
    11. $ export ORAENV_ASK=NO
    12. $ . oraenv
    13. 复制代码
    14. 代码,网上找的:
    15. 复制代码
    16. #!/bin/sh
    17. #
    18. # Get the machine type and then set up ORATAB and TNS_ADMIN variables
    19. #
    20. MACH_TYPE=`uname -s`
    21. case ${MACH_TYPE} in
    22. "SunOS" ) ORATAB=/var/opt/oracle/oratab
    23. TNS_ADMIN=/var/opt/oracle
    24. ORA_ORAENV=/opt/bin/ora_oraenv
    25. ;;
    26. "HP-UX" ) ORATAB=/etc/oratab
    27. TNS_ADMIN=/etc
    28. ORA_ORAENV=/usr/local/bin/ora_oraenv
    29. ;;
    30. * ) ORATAB=/etc/oratab
    31. TNS_ADMIN=/etc
    32. ORA_ORAENV=/usr/local/bin/ora_oraenv
    33. ;;
    34. esac
    35. export TNS_ADMIN ORA_ORAENV
    36. #
    37. # Extract a list of Oracle SID's that are defined with the oratab file
    38. #
    39. SIDLIST=`awk -F: '/^[^#]/{printf "\n %s",$1}' ${ORATAB}`
    40. case "${ORAENV_ASK:-''}" in
    41. NO ) ;;
    42. * ) clear
    43. echo "SIDs on this machine are; ${SIDLIST}
    44. "
    45. ;;
    46. esac
    47. #
    48. # This is the official oraenv file as supplied by Oracle
    49. #
    50. . ${ORA_ORAENV}
    51. if [ -d ${ORACLE_HOME} ]; then
    52. ORACLE_BASE=`cd ${ORACLE_HOME}/../..; pwd`
    53. else
    54. ORACLE_BASE=${HOME}
    55. echo
    56. echo "Warning - Oracle HOME not valid, Oracle BASE not set correctly"
    57. fi
    58. export ORACLE_BASE
    59. LOCAL=${ORACLE_BASE}/local
    60. DBA=${ORACLE_BASE}/admin
    61. DB=${ORACLE_BASE}/admin/${ORACLE_SID}
    62. ORACLE_PATH=${DB}/adhoc:${LOCAL}:.
    63. export DBA DB LOCAL ORACLE_PATH
    64. case ${PATH} in
    65. *${LOCAL}* ) ;;
    66. *: ) PATH=${PATH}${LOCAL}:
    67. ;;
    68. * ) PATH=${PATH}:${LOCAL}:
    69. ;;
    70. esac
    71. export PATH
    72. echo "
    73. Oracle SID = ${ORACLE_SID}
    74. Oracle BASE = ${ORACLE_BASE}
    75. Oracle HOME = ${ORACLE_HOME}
    76. SQL*Net TNS = ${TNS_ADMIN}
    77. "

  • 相关阅读:
    [数据结构]~堆
    《SpringBoot篇》05.超详细日志配置介绍
    Learn Prompt-ChatGPT基本功:Prompt
    趣味算法图解,高清无码图免费下载
    2022-04-25-ElasticSearch
    Proteus的编译运行(以AT89C51为例)
    基于Django+MySQL的智慧校园系统
    TG Pro for Mac强大的硬件温度检测、风扇控制工具测评
    php反序列化
    业务用例元模型-软件方法(下)第9章分析类图案例篇Part08
  • 原文地址:https://blog.csdn.net/jnrjian/article/details/133225859