熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

Oracle 11g RAC環境下單實例非缺省監聽及端口配置

2013-11-13 15:32:23  來源: Oracle 

  如果在Oracle g RAC環境下使用dbca創建單實例數據庫後Oracle會自動將其注冊到缺省的端口及監聽器大多數情況下我們使用的為非缺省監聽器以及非缺省的監聽端口而且在Oracle g RAC環境中對於集群監聽器的配置由grid用戶來接管了基於這種情形的單實例非缺省監聽及端口該如何配置呢?本文給出了解決方案並且使用了靜態及動態兩種注冊方法

  關於單實例下非缺省監聽及端口的配置可以參考下面的文章實際上參照下列文章依舊可以完成RAC 環境下單實例非缺省監聽及端口的配置

  RAC環境下較之前的單實例環境有些不同所以記錄下了這些個細小的差異

  配置非默認端口的動態服務注冊

  配置sqlnetora限制IP訪問Oracle

  Oracle 監聽器日志配置與管理

  設置 Oracle 監聽器密碼(LISTENER)

  配置ORACLE 客戶端連接到數據庫

  dbca創建單實例數據庫後監聽器的情形

  [sql]

  環境

  [grid@linux ~]$ cat /etc/issue

  Enterprise Linux Enterprise Linux Server release (Carthage)

  Kernel \r on an \m

  [grid@linux ~]$ crsctl query crs activeversion

  Oracle Clusterware active version on the cluster is []

  實例cnbo為RAC環境下使用dbca創建當前處於offline狀態

  [oracle@linux ~]$ crsstat | grep cnbo

  bodb database C OFFLINE OFFLINE (linux) Instance Shutdown

  缺省的listener處於offline狀態

  [oracle@linux ~]$ crsstat | grep Listener | grep OFFLINE

  oraLISTENERlsnr Listener L OFFLINE OFFLINE (linux)

  啟動實例及監聽

  [oracle@linux ~]$ srvctl start database d cnbo

  [oracle@linux ~]$ srvctl start listener l LISTENER

  PRCC : LISTENER was already running

  [oracle@linux ~]$ export ORACLE_SID=cnbo

  [oracle@linux ~]$ sqlplus / as sysdba

  SQL> set linesize

  SQL> show parameter cluster_d >此實例為RAC環境下的單實例

  NAME TYPE VALUE

  

  cluster_database boolean FALSE

  cluster_database_instances integer

  下面的lsnrctl status可以看到實例被注冊到的默認端口dbca創建完實例cnbo後並沒有為其配置監聽

  而實例確確實實的被注冊到了缺省的監聽器應該來說這個是dbca是自動添加的

  從Oracle g RAC開始集群監聽器的配置由grid用戶來接管因此可以在$ORA_CRS_HOME/network/admin/目錄下找到對應的listenerora文件

  [grid@linux ~]$ lsnrctl status

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  Services Summary

  Service +ASM has instance(s)

  Instance +ASM status READY has handler(s) for this service

  Service has instance(s) >該服務即是單實例cnbo提供的

  Instance cnbo status READY has handler(s) for this service

  Service has instance(s)

  Instance cnbo status READY has handler(s) for this service

  The command completed successfully

  配置非缺省的監聽器並實現動態注冊

  [sql]

  切換到Oracle用戶下並清空其下的listenerora與tnsnamesora

  [oracle@linux ~]$ cat /dev/null>$ORACLE_HOME/network/admin/listenerora

  [oracle@linux ~]$ cat /dev/null>$ORACLE_HOME/network/admin/tnsnamesora

  下面通過netca來為其配置監聽器及tnsnamesora

  [oracle@linux ~]$ export DISPLAY=:

  [oracle@linux ~]$ netca

   Author : Robinson Cheng

   Blog :

  >下面是使用netca配置後的結果包括listenerora以及tnsnamesora

  [oracle@linux ~]$ more $ORACLE_HOME/network/admin/listenerora

  # listenerora Network Configuration File: /u/app/oracle/db_/network/admin/listenerora

  # Generated by Oracle configuration tools

  ADR_BASE_LISTENER_CNBO = /u/app/oracle

  LISTENER_CNBO = #監聽器的名字為LISTENER_CNBO端口為

  (DESCRIPTION_LIST =

  (DESCRIPTION =

  (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))

  )

  )

  [oracle@linux ~]$ more $ORACLE_HOME/network/admin/tnsnamesora

  # tnsnamesora Network Configuration File: /u/app/oracle/db_/network/admin/tnsnamesora

  # Generated by Oracle configuration tools

  CNBO =

  (DESCRIPTION =

  (ADDRESS_LIST =

  (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))

  )

  (CONNECT_DATA =

  (SERVICE_NAME = )

  )

  )

  提示沒有找到監聽器無法ping通因為我們配置的監聽器並沒有啟動

  盡管服務在缺省的監聽器注冊但無法ping即此路不通

  [oracle@linux ~]$ tnsping cnbo

  TNS Ping Utility for Linux: Version Production on AUG ::

  Copyright (c) Oracle All rights reserved

  Used parameter files:

  Used TNSNAMES adapter to resolve the alias

  Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = )))

  (CONNECT_DATA = (SERVICE_NAME = )))

  TNS: TNS:no listener

  下面我們啟動非缺省的監聽器

  [oracle@linux ~]$ lsnrctl start LISTENER_CNBO

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  The listener supports no services

  The command completed successfully

  [oracle@linux ~]$ lsnrctl status LISTENER_CNBO

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  The listener supports no services >沒有任何服務及實例注冊到監聽器等N久也不會有實例注冊

  The command completed successfully >因為這個是非缺省的而且我們還沒有配置動態注冊

  下面我們來設置動態注冊

  查看參數local_listener此時已經被設置了而且端口是IP用的是虛IP

  這就是為什麼實例創建後會被自動注冊到grid用戶下缺省監聽器的緣故

  SQL> show parameter local_lis

  NAME TYPE VALUE

  

  local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD

  DRESS=(PROTOCOL=TCP)(HOST=linu

  xvip)(PORT=))))

  設置動態注冊收到了錯誤消息

  SQL> alter system set local_listener=LISTENER_CNBO;

  alter system set local_listener=LISTENER_CNBO

  *

  ERROR at line :

  ORA: parameter cannot be modified because specified value is invalid

  ORA: invalid specification for system parameter LOCAL_LISTENER

  ORA: syntax error or unresolved network name LISTENER_CNBO

  對於前面出現的錯誤給出兩種解決方案

  一是按照前面local_listener參數值的格式設置新的ip及端口或者將這個描述信息添加到tnsnamesora文件中

  下面我們選用了第二種解決方案

  [oracle@linux ~]$ echo

  > LISTENER_CNBO =

  > (ADDRESS_LIST =

  > (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))

  > )>>$ORACLE_HOME/network/admin/tnsnamesora

  再次設置參數local_listener

  SQL> alter system set local_listener=LISTENER_CNBO;

  System altered

  下面可以看到實例及服務已經自動注冊到監聽器LISTENER_CNBO

  [oracle@linux ~]$ lsnrctl status LISTENER_CNBO

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  Services Summary

  Service has instance(s)

  Instance cnbo status READY has handler(s) for this service

  Service has instance(s)

  Instance cnbo status READY has handler(s) for this service

  The command completed successfully

  下面查看grid用戶下原來的服務及實例cnbo也不復存在

  [grid@linux ~]$ lsnrctl status

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  Services Summary

  Service +ASM has instance(s)

  Instance +ASM status READY has handler(s) for this service

  The command completed successfully

  配置非缺省的監聽器並實現靜態注冊

  [sql]

  對於非缺省監聽器我們也可以為其配置靜態注冊方式

  首先我們停止監聽器並清空Oracle用戶下的listenerora與tnsnamesora

  [oracle@linux ~]$ lsnrctl stop LISTENER_CNBO

  [oracle@linux ~]$ cat /dev/null>$ORACLE_HOME/network/admin/listenerora

  [oracle@linux ~]$ cat /dev/null>$ORACLE_HOME/network/admin/tnsnamesora

  SQL> alter system set local_listener=;

  下面使用netmgr來配置監聽器及tnsnames

  [oracle@linux ~]$ export DISPLAY=:

  [oracle@linux ~]$ netmgr

  下面是配置後的結果此時我們使用了新的端口號以及新的監聽器名字LISTENER_NEW

  [oracle@linux ~]$ more $ORACLE_HOME/network/admin/listenerora

  # listenerora Network Configuration File: /u/app/oracle/db_/network/admin/listenerora

  # Generated by Oracle configuration tools

  # 我們使用netmgr為其添加了數據庫服務即SID_LIST_LISTENER_NEW項而netca無法完成此項任務

  LISTENER_NEW =

  (DESCRIPTION =

  (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))

  )

  ADR_BASE_LISTENER_NEW = /u/app/oracle

  SID_LIST_LISTENER_NEW =

  (SID_LIST =

  (SID_DESC =

  (GLOBAL_DBNAME = )

  (ORACLE_HOME = /u/app/oracle/db_)

  (SID_NAME = cnbo)

  )

  )

  [oracle@linux ~]$ more $ORACLE_HOME/network/admin/tnsnamesora

  # tnsnamesora Network Configuration File: /u/app/oracle/db_/network/admin/tnsnamesora

  # Generated by Oracle configuration tools

  CNBO =

  (DESCRIPTION =

  (ADDRESS_LIST =

  (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))

  )

  (CONNECT_DATA =

  (SERVICE_NAME = )

  )

  )

  啟動新的監聽器

  [oracle@linux ~]$ lsnrctl start LISTENER_NEW

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  Services Summary

  Service has instance(s)

  Instance cnbo status UNKNOWN has handler(s) for this service 注意狀態為UNKNOWN表明是靜態注冊

  The command completed successfully

  我們看看grid用戶缺省監聽的狀態此時實例cnbo依舊被注冊

  [grid@linux ~]$ lsnrctl status

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  Services Summary

  Service +ASM has instance(s)

  Instance +ASM status READY has handler(s) for this service

  Service has instance(s)

  Instance cnbo status READY has handler(s) for this service

  Service has instance(s)

  Instance cnbo status READY has handler(s) for this service

  The command completed successfully

  下面檢查一下local_listener參數

  SQL> show parameter db_name

  NAME TYPE VALUE

  

  db_name string cnbo

  SQL> show parameter local_lis >參數沒有做任何設置

  NAME TYPE VALUE

  

  local_listener string

  從上面的情形來看盡管沒有設置local_listener參數此時實例依舊被注冊到監聽

  在此時我們已經可以通過tnsnames連接到數據庫也就是說客戶端發起的連接最終還是通過監聽器LISTENER_NEW而不是缺省的監聽器

  對於這個情形在非RAC環境的Oracle gg 可以不用設置local_listener也不會注冊到缺省監聽器

  但grid用戶下的缺省監聽器提供的cnbo服務著實別扭下面為還是添加監聽器信息到tnsnamesora

  [oracle@linux ~]$ echo

  > LISTENER_NEW =

  > (ADDRESS_LIST =

  > (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))

  > )>>$ORACLE_HOME/network/admin/tnsnamesora

  >設置local_listener

  SQL> alter system set local_listener=LISTENER_NEW;

  下面的缺省監聽狀態下不再看到cnbo實例

  [grid@linux ~]$ lsnrctl status

  LSNRCTL for Linux: Version Production on AUG ::

  

  Listening Endpoints Summary

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=)))

  Services Summary

  Service +ASM has instance(s)

  Instance +ASM status READY has handler(s) for this service

  The command completed successfully

  後記

  a在Oracle g RAC環境下使用dbca創建單實例數據庫會自動將實例配置到缺省的監聽器以及缺省端口

  b在Oracle g RAC環境下對於集群監聽的配置需要在grid用戶下來完成這個不同於Oracle g RAC關於g RAC監聽配置可參考尾部鏈接

  c注意netca與netmgr在配置監聽器時的差異由上測試可知netca不能為監聽添加數據庫服務即SID_LIST_<LISTENER_CNBO>項而netmgr可以實現建議使用netmgr

  d動態服務注冊需要配置local_listener參數要麼使用DESCRIPTION等一串描述要麼簡化到tnsnamesora文件之中

  e對於Oracle g RAC環境下單實例的非缺省監聽及端口的靜態注冊如果不設置local_listener盡管會注冊到指定的監聽器但同時也會注冊到缺省監聽器

  f對於上面e點描述的情形在非RAC環境單實例gg未曾出現過此現象應該是Oralce盡可能要求使用動態注冊


From:http://tw.wingwit.com/Article/program/Oracle/201311/16877.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.