Oracle環境變數、監聽listener.ora、tnsnames.ora、sqlnet.ora配置

lhrbest發表於2017-03-11

Oracle環境變數、監聽listener.ora、tnsnames.ora、sqlnet.ora配置


點選(此處)摺疊或開啟

  1. NLS_DATE_FORMAT=YYYY-MM-DD HH24:mi:ss
  2. NLS_LANG=AMERICAN_CHINA.ZHS16GBK
  3. ORACLE10G=D:\Program files\app\oracle\product\10.2.0\db_1
  4. ORACLE11G=D:\Program files\app\oracle\product\11.2.0.1\dbhome_1
  5. ORACLE8I=D:\Program files\app\oracle\product\ora8i
  6. ORACLE9I=D:\Program files\app\oracle\product\ora92
  7. ORACLE_HOME=D:\Program files\app\oracle\product\11.2.0.1\dbhome_1
  8. PATH=%ORACLE_HOME%\bin
  9. TNS_ADMIN=%ORACLE_HOME%\NETWORK\ADMIN




  10. ---------cmd下設定使用者環境變數
  11. SETX "NLS_DATE_FORMAT" "YYYY-MM-DD HH24:MI:SS"
  12. SETX "NLS_LANG" "AMERICAN_CHINA.ZHS16GBK"
  13. SETX "ORACLE10G" "D:\Program files\app\oracle\product\10.2.0\db_1"
  14. SETX "ORACLE11G" "D:\Program files\app\oracle\product\11.2.0.1\dbhome_1"
  15. SETX "ORACLE8I" "D:\Program files\app\oracle\product\ora8i"
  16. SETX "ORACLE9I" "D:\Program files\app\oracle\product\ora92"
  17. SETX "ORACLE_HOME" "D:\Program files\app\oracle\product\11.2.0.1\dbhome_1"
  18. SETX "TNS_ADMIN" "%ORACLE_HOME%\NETWORK\ADMIN"
  19. SETX "Path" "%ORACLE_HOME%\bin"
  20. SETX "VBOX_MSI_INSTALL_PATH" "D:\Program Files\Oracle\VirtualBox"



  21. alter session set nls_language='SIMPLIFIED CHINESE';
  22. alter system set nls_language='AMERICAN' scope=spfile;




  23. ------------------------------------ sqlnet.ora----------------------------------------------
  24. ---------- windows
  25. SQLNET.AUTHENTICATION_SERVICES= (NTS)
  26. NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

  27. ---------- linux
  28. SQLNET.AUTHENTICATION_SERVICES= (ALL)
  29. NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)



  30. --------------------------------------------------------------------- oracle
  31. # .bash_profile

  32. # Get the aliases and functions
  33. if [ -f ~/.bashrc ]; then
  34.     . ~/.bashrc
  35. fi

  36. # User specific environment and startup programs

  37. export PATH=$PATH:/sbin/:$HOME/bin

  38.   
  39. # for oracle user

  40. unset USERNAME

  41. export GLOBAL_DB_UNIQUE_NAME=orclasm
  42. export ORACLE_HOSTNAME=192.168.128.134
  43. export ORACLE_UNQNAME=orclasm

  44. export EDITOR=vi
  45. export ORACLE_SID=orclasm
  46. export ORACLE_BASE=/u01/app/oracle
  47. export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
  48. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
  49. export ORACLE_ALERT=$ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace
  50. export PATH=$ORACLE_HOME/bin:$PATH
  51. export TNS_ADMIN=$ORACLE_HOME/network/admin
  52. export ORACLE_PATH=.:$ORACLE_BASE/dba_scripts/sql:$ORACLE_HOME/rdbms/admin
  53. umask 022

  54. #export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"    SELECT userenv('LANGUAGE') db_NLS_LANG FROM DUAL;
  55. export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
  56. export SQLPATH=$ORACLE_HOME/sqlplus/admin
  57. export NLS_DATE_FORMAT='YYYY-MM-DD HH24:mi:ss';

  58. alias sqlplus='rlwrap sqlplus'
  59. alias rman='rlwrap rman'
  60. alias asmcmd='rlwrap asmcmd'
  61. alias alert_log='tail -200f $ORACLE_ALERT/alert_$ORACLE_SID.log'
  62. alias alert_xml='tail -200f $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/alert/log.xml'
  63. alias alert_listener='tail -200f $ORACLE_BASE/diag/tnslsnr/rhel6/listener/trace/listener.log'


  64.  



  65. stty erase ^h
  66. ORACLE_HOME=D:\Program files\app\oracle\product\11.2.0.1\dbhome_1
  67. PATH=%ORACLE_HOME%\bin
  68. TNS_ADMIN=%ORACLE_HOME%\NETWORK\ADMIN
  69. ##NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
  70. NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
  71. #ORACLE_SCRIPT=%ORACLE_HOME%\RDBMS\ADMIN
  72. SQLPATH=.;%ORACLE_BASE%\dba_scripts\sql;%ORACLE_HOME%\rdbms\admin


  73. NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280"
  74. NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
  75. NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
  76. NLS_LANG=AMERICAN_AMERICA.UTF8
  77. NLS_LANG=AMERICAN_AMERICA.AL32UTF8
  78. NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
  79. NLS_LANG=AMERICAN_CHINA.ZHS16GBK


  80. NLS_DATE_FORMAT='YYYY-MM-DD HH24:mi:ss'




  81. --------------------------------------------------------------------- grid

  82. # .bash_profile

  83. # Get the aliases and functions
  84. if [ -f ~/.bashrc ]; then
  85.         . ~/.bashrc
  86. fi

  87. # User specific environment and startup programs

  88. export PATH=$PATH:$HOME/bin


  89. # for grid user
  90. export ORACLE_SID=+ASM
  91. export ORACLE_BASE=/u01/app/grid
  92. export ORACLE_HOME=/u01/app/grid/11.2.0
  93. export LD_LIBRARY_PATH=$ORACLE_HOME/lib
  94. export PATH=$ORACLE_HOME/bin:$PATH
  95. umask 022


  96. alias sqlplus='rlwrap sqlplus'
  97. alias asmcmd='rlwrap asmcmd'
  98. alias alert_log='tail -200f $ORACLE_BASE/diag/asm/+asm/$ORACLE_SID/trace/alert_$ORACLE_SID.log'
  99. alias crsd_log='tail -200f $ORACLE_HOME/log/$HOSTNAME/crsd/crsd.log'



  100. 在linux和unix上有時不知道該使用LD_LIBRARY_PATH還是LIBPATH,經過搜尋和實際使用,實際的情況如下

  101. OS Environment Variable                Name
  102. Linux                        LD_LIBRARY_PATH
  103. Solaris 32-bit ruby                LD_LIBRARY_PATH_32 or LD_LIBRARY_PATH
  104. Solaris 64-bit ruby                LD_LIBRARY_PATH_64 or LD_LIBRARY_PATH
  105. HP-UX PA-RISC 32-bit ruby            SHLIB_PATH
  106. HP-UX PA-RISC 64-bit ruby            LD_LIBRARY_PATH
  107. HP-UX IA64                    LD_LIBRARY_PATH
  108. Mac OS X                    DYLD_LIBRARY_PATH
  109. AIX                        LIBPATH



  110. -----------------------------------------------------------------------------------------------
  111. ------------------------------------listener.ora--------------------------------------------
  112. --動態監聽: alter system set LOCAL_LISTENER='(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.157)(PORT = 1521))';
  113. -----------------------------------------------------------------------------------------------
  114. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  115. # Generated by Oracle configuration tools.

  116. LISTENER =
  117.   (DESCRIPTION_LIST =
  118.     (DESCRIPTION =
  119.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.129)(PORT = 1521))
  120.     )
  121.   )
  122. SID_LIST_LISTENER =
  123.   (SID_LIST =
  124.    (SID_DESC =
  125.       (SID_NAME = PLSExtProc)
  126.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  127.       (PROGRAM = extproc)
  128.     )
  129.    (SID_DESC =
  130.      (GLOBAL_DBNAME = orcl.lhr.com)
  131.      (SID_NAME = orcl)
  132.      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  133.    )
  134.    (SID_DESC =
  135.      (GLOBAL_DBNAME = rman.lhr.com)
  136.      (SID_NAME = rman)
  137.      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  138.    )
  139.   )

  140. LSNR2 =
  141.   (DESCRIPTION_LIST =
  142.     (DESCRIPTION =
  143.       (ADDRESS_LIST =
  144.         (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.129)(PORT = 1526))
  145.       )
  146.     )
  147.   )
  148. SID_LIST_LSNR2 =
  149.   (SID_LIST =
  150.     (SID_DESC =
  151.       (SID_NAME = PLSExtProc)
  152.       (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
  153.       (PROGRAM = extproc)
  154.     )
  155.   )

  156. ADR_BASE_LISTENER = /u01/app/oracle


  157. ------------windows 下
  158. SID_LIST_LISTENER =
  159.   (SID_LIST =
  160.     (SID_DESC =
  161.       (SID_NAME = CLRExtProc)
  162.       (ORACLE_HOME = D:\app\oracle\product\11.2.0.1)
  163.       (PROGRAM = extproc)
  164.       (ENVS = "EXTPROC_DLLS=ONLY:D:\app\oracle\product\11.2.0.1\bin\oraclr11.dll")
  165.     )
  166.     (SID_DESC =
  167.      (GLOBAL_DBNAME = orcl.lhr.com)
  168.      (SID_NAME = orcl)
  169.      (ORACLE_HOME = D:\app\oracle\product\11.2.0.1)
  170.    )
  171.   )


  172. -----------------------/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
  173. # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
  174. # Generated by Oracle configuration tools.

  175. orcl =
  176.   (DESCRIPTION =
  177.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.133)(PORT = 1521))
  178.     (CONNECT_DATA =
  179.       (SERVER = DEDICATED)
  180.       (SERVICE_NAME = orcl.lhr.com)
  181.     )
  182.   )

  183. #### 動態監聽非預設埠
  184. LSNR_ORCL =
  185.   (DESCRIPTION =
  186.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.59.129)(PORT = 1526))
  187.     (CONNECT_DATA =
  188.       (SERVICE_NAME = orcl)
  189.     )
  190.   )


  191. -------------------------------------------------------------------- rac
  192. --- TAF BASIC方式
  193. racdb_vip =
  194.   (DESCRIPTION =
  195.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))
  196.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))
  197.     (LOAD_BALANCE = on)
  198.     (CONNECT_DATA =
  199.       (SERVER = DEDICATED)
  200.       (SERVICE_NAME = jmrac)
  201.       (FAILOVER_MODE =
  202.          (TYPE = SELECT)
  203.          (METHOD = BASIC)
  204.          (RETRIES = 180)
  205.          (DELAY = 5)
  206.       )
  207.     )
  208.   )

  209. --- TAF preconnect方式
  210. racdb_vip1 =
  211.   (DESCRIPTION =
  212.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))
  213.     (CONNECT_DATA =
  214.       (SERVER = DEDICATED)
  215.       (SERVICE_NAME = jmrac)
  216.       (FAILOVER_MODE =
  217.          (TYPE = SELECT)
  218.          (METHOD = BASIC)
  219.          (BACKUP = preconnect)
  220.       )
  221.     )
  222.   )

  223. racdb_vip2 =
  224.   (DESCRIPTION =
  225.     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))
  226.     (CONNECT_DATA =
  227.       (SERVER = DEDICATED)
  228.       (SERVICE_NAME = jmrac)
  229.       (FAILOVER_MODE =
  230.          (TYPE = SELECT)
  231.          (METHOD = BASIC)
  232.          (BACKUP = preconnect)
  233.       )
  234.     )
  235.   )

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26736162/viewspace-2135163/,如需轉載,請註明出處,否則將追究法律責任。

相關文章