`

Oracle Default Listener

阅读更多

042 第23题 关于动态注册监听器

23.Your database is started with SPFILE. You want the database instance to be dynamically
registered with a listener L2 with the following details:
Protocol: TCP
Host: indl151e
Port: 1525
Which is the correct order of the steps that you would follow to achieve this?
1. Set the LOCAL_LISTENER parameter to L2 dynamically.
2. Make an entry for L2 in tnsnames.ora on the database server.
3. Restart L2.
4. Modify the listener.ora file to add the instance name in SID_LIST of L2.
A: 1, 2, 4, 3
B: 1, 2, 3; 4 is not required.
C: 2, 1; 3 and 4 are not required.
D: 1, 2; 3 and 4 are not required.

Oracle Default Listener

by Nidhi Jain

Prior to Oracle 8i, a listener was statically configured (listener.ora) to service a given set of SIDs. From 8i, PMON dynamically registers a database service with the listener.Further, if the listener is running on the default TCP port of 1521, then there is no need to configure a listener.ora at all.

USING A DEFAULT LISTENER

A listener.ora file is not required in order to use the default listener.
The listener is started in the conventional manner:

$lsnrctl start

This listener will listen on two addresses:

   (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY))
   (ADDRESS=(PROTOCOL=tcp)(PORT=1521))

 

In order to change parameters to non default values (such as enabling listener tracing), a listener.ora should be created with the relevant parameters specified. The listener then needs to be restarted.

By default, PMON will register the database service with the listener on port 1521.

USING A NON DEFAULT LISTENER

When a non-default listener is used, then a listener.ora must be configured with the relevant listener address. For example,

 

LISTENER =
 (ADDRESS_LIST =
   (ADDRESS = (PROTOCOL=TCP) (HOST=uksn115) (PORT=2500))
 )

 

This would start a listener on port 2500.

In order for PMON to be able to register the database service(s) with this listener, the init.ora parameter LOCAL_LISTENER must be set.

eg, LOCAL_LISTENER=listener_A

PMON will attempt to resolve LOCAL_LISTENER using some naming method. For example, this may be resolved in tnsnames.ora, as follows:

 

listener_A =
  (DESCRIPTION =
    (ADDRESS=(PROTOCOL=TCP)(HOST=uksn155)(PORT=2500))
  )

 

PMON will search for tnsnames.ora in the following order:

  • $HOME/.tnsnames.ora
  • $TNS_ADMIN/tnsnames.ora
  • /var/opt/oracle/tnsnames.ora or /etc/tnsnames.ora (depending on platform)
  • $ORACLE_HOME/network/admin/tnsnames.ora

 

If a tnsnames.ora cannot be found or if LOCAL_LISTENER cannot be resolved, the alert.log will show:

 

PMON started with pid=2
Syntax error in listener string

 

If LOCAL_LISTENER can be resolved, but there is a syntax error in the tnsnames.ora specification, the alert log will show:

 

PMON started with pid=2
Syntax error in listener string (DESCRIPTION =)

 

The instance will start regardless of PMON errors during registration, unless MTS is enabled. If MTS enabled, then both of the above error scenarios will give:

 

ORA-00101: invalid specification for system parameter
MTS_DISPATCHERS

 

in addition to the relevant alert log message. The instance will not start.

Note that if 'NAMES.DEFAULT_DOMAIN' is set in sqlnet.ora, then the tnsnames.ora entry should be of the form NAME.DOMAIN. The domain will be appended to LOCAL_LISTENER if not already specified.

eg,

init.ora:           LOCAL_LISTENER=listener_A (or listener_A.uk.oracle.com)
sqlnet.ora:         NAMES.DEFAULT_DOMAIN=uk.oracle.com
tnsnames.ora:       listener_A.uk.oracle.com=(...)

 

The search order for the 'system' sqlnet.ora is:

  • $TNS_ADMIN/sqlnet.ora
  • $ORACLE_HOME/network/admin/sqlnet.ora

Additionally, the 'local' sqlnet.ora is always read from:

  • $HOME/.sqlnet.ora

If this file exists, then any parameters defined here will override the ones in the 'system' sqlnet.ora.

Note, /etc or /var/opt/oracle is not searched for the 'system' sqlnet.ora unless TNS_ADMIN happens to be set to this directory.

WHAT INFO IS REGISTERED?

The easiest way to check the information registered by PMON is to enable level 16 (SUPPORT) listener tracing.

Oracle 8.1.5 Registration

In 8.1.5, the listener trace shows that the 'register' command is actually a CONNECT packet. This is of the form:

 

  (CONNECT_DATA=
   (COMMAND=service_register)
   ...
   (SERVICE=)
   ...
   (INFO=LOCAL SERVER)
   (DISPLAY=DEDICATED SERVER)
   (GLOBAL_NAME=.)
   ...
   (ENVS='')
   ....
 )

 

Oracle 8.1.6 Registration

In 8.1.6, this process has changed slightly. PMON initiates registration by sending the following CONNECT packet

 

  (CONNECT_DATA=
   (COMMAND=service_register_NSGR)
  )

 

The listener responds with an ACKnowledgement. PMON and the listener then exchange DATA packets to complete the registration.

Compatibility

The listener is backwards compatible. Therefore, an 8.1.5 instance can register with a 8.1.6 listener.

However, it is not possible to register an 8.1.6 instance with an 8.1.5 listener. This is due to the 8.1.5 listener not recognising the 'service_register_NSGR' command.

This can be seen from a listener trace:

 

 ...
 (CONNECT_DATA=
   (COMMAND=service_register_NSGR)
 )                                <-- extracted from packet dump
 nscon: got NSPTCN packet         <-- a CONNECT packet is rxed
 ...
 nsglfc: The command was not recognized
 ...
 nscon: sending NSPTRF packet     <-- a REFUSE packet is sent

 

SPECIFYING MULTIPLE LOCAL_LISTENERS

Multiple LOCAL_LISTENERs can be specified in one of two ways in the init.ora:

  • local_listener=listener_A, listener_B
  • local_listener=listener_A
    local_listener=listener_B

In both cases, v$parameter will show: local_listener=listener_A, listener_B

PMON will register ONLY with the listener that appears first in the v$parameter value for local_listener (ie, listener_A in the above).

The correct method is to specify one local_listener in the init.ora, and to specify multiple listener ADDRESSes in the connect descriptor.

For example,

 

init.ora:
   local_listener=all_listeners

tnsnames.ora:
   all_listeners.uk.oracle.com=
    (DESCRIPTION =
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
    )

 

In non-MTS mode, all listeners must be on the same host as the instance (unless pre-spawned servers are used on the remote host). However, even in dedicated mode and no pre-spawned servers, PMON still registers with listeners on another node. But this does not make any sense, as the remote listener will not be able to fork/exec oracle.

Registration in an MTS Environment

Service registration is more flexible if the instance is running in MTS mode. For example,

  • PMON can register services with listeners on more than one node
  • the dispatchers can register with a different listener than dedicated services
  • different dispatchers can register with different listeners

 

This is illustrated by way of the following examples.

Example 1

init.ora on host1:

  local_listener=all_listeners
   mts_dispatchers="(protocol=tcp)"

 

tnsnames.ora on host1:

    all_listeners.uk.oracle.com=
    (DESCRIPTION =
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
    )

 

output of 'lsnrctl services':

 

  host1, listener on port 2500:
  -----------------------------
     Services Summary...
       V816         has 2 service handler(s)
         DEDICATED SERVER established:0 refused:0
           LOCAL SERVER
         DISPATCHER established:0 refused:0 current:0 max:1022 state:ready
         D000 
         (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59155))

 

host1, listener on port 2600:

   Services Summary...
     V816         has 2 service handler(s)
       DEDICATED SERVER established:0 refused:0
         LOCAL SERVER
       DISPATCHER established:0 refused:0 current:0 max:1022 state:ready

         D000 
         (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59155))

 

In this case, the dispatcher has registered with the listeners specified by the local_listener parameter.

Example 2

init.ora on host1:

 

  mts_dispatchers="(protocol=tcp)(listener=listener_host2.uk.oracle.com)"
   local_listener=listener_host1.uk.oracle.com

 

tnsnames.ora on host1:

   listener_host2.uk.oracle.com=
    (DESCRIPTION =
      (ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=2500))
    )
   listener_host1.uk.oracle.com=
    (DESCRIPTION =
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
    )

 

output of 'lsnrctl services':

host1:

    Services Summary...
       Nov10         has 1 service handler(s)
         DEDICATED SERVER established:0 refused:0
           LOCAL SERVER

 

host2:

     Services Summary...
       V816         has 1 service handler(s)
         DISPATCHER established:0 refused:0 current:0 max:1022
state:ready
           D000 
           (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59165))

 

In this case, the dispatcher explicitly registers with a different listener than the one for the dedicated service.

Example 3

init.ora on host1:

   mts_dispatchers="(protocol=tcp)(listener=listenerA.uk.oracle.com)"
   local_listener=all_listeners

 

tnsnames.ora on host1:

   all_listeners.uk.oracle.com=
    (DESCRIPTION =
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2500))
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
    )
   listenerA.uk.oracle.com=
    (DESCRIPTION =
      (ADDRESS=(PROTOCOL=TCP)(HOST=host1)(PORT=2600))
    )

 

output of 'lsnrctl services':

host1, listener on port 2500:

     Services Summary...
       V816         has 1 service handler(s)
         DEDICATED SERVER established:0 refused:0
           LOCAL SERVER

 

host1, listener on port 2600:

     Services Summary...
       V816         has 2 service handler(s)
         DEDICATED SERVER established:0 refused:0
           LOCAL SERVER
         DISPATCHER established:0 refused:0 current:0 max:1022 state:ready
           D000 
           (ADDRESS=(PROTOCOL=tcp)(HOST=host1)(PORT=59160))

 

This illustrates that the 'listener=' part of mts_dispatchers overrides local_listener when registering dispatchers.

Static Info Overwrite

If a listener.ora is used, and a SID_DESC entry exists for an instance, the data within the SID_DESC section is referred to as 'static information' for that instance.

In 8.1.6, all static information in the listener.ora is overwritten when the instance is dynamically registered with the listener.

Therefore, any environment variables set within the listener.ora will not be visible unless the variable is set in the environment used to start the instance (and thus inherited by PMON).

This behaviour is different from 8.1.5. In 8.1.5, the existance of a SID_DESC section results in the listener NOT registering PMON's (and therefore the instances' environment (note that the instance is still registered).

Therefore, in 8.1.5, any environment variables set in the listener.ora would be retained even after dynamic registration.

If there is no SID_DESC section, then the listener WILL register PMON's environment (ie, behaves as 8.1.6).



About the author:

Nidhi Jain is a Senior DBA at Totality.com. He is a certified Oracle and DB2 database administrator.

分享到:
评论

相关推荐

    Oracle Database Listener Security Guide

    The default installation of the Oracle Database prior to Oracle 10g, allows any client to remotely administer a Listener using the "lsnrctl" program or by issuing commands directly to the Listener....

    Oracle 数据库攻防 英文原版

    Chapter 3 - Attacking the TNS Listener and Dispatchers Chapter 4 - Attacking the Authentication Process Chapter 5 - Oracle and PL/SQL Chapter 6 - Triggers Chapter 7 - Indirect Privilege ...

    Oracle 主要配置文件介绍

    监听配置文件 listener.ora 的存放路径为 $ORACLE_HOME/network/admin 以下是一个示例 LISTENER = #监听器名称 (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL ...

    最全的oracle常用命令大全.txt

    SQL&gt;select username,default_tablespace from user_users; 查看当前用户的角色 SQL&gt;select * from user_role_privs; 查看当前用户的系统权限和表级权限 SQL&gt;select * from user_sys_privs; SQL&gt;select * ...

    linux系统给oracle数据库增加新的实例.pdf

    5、建监听 cd $ORACLE_BASE/product/10.2.0/db_1/network/admin vim listener.ora 增加节点: (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /oracle/app/product/10.2.0/db) (SID_NAME = orcl) ) 重启监听 ...

    Oracle9i的init.ora参数中文说明

    值范围: ALWAYS | DEFAULT | INTENT 默认值: ALWAYS shared_servers 说明 : 指定在启动例程后, 要为共享服务器环境创建的服务器进程的数量。 值范围: 根据操作系统而定。 默认值 : 1 circuits: 说明 : 指定可...

    linux系统给oracle数据库增加新的实例(1).pdf

    5、建监听 cd $ORACLE_BASE/product/10.2.0/db_1/network/admin vim listener.ora 增加节点: (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /oracle/app/product/10.2.0/db) (SID_NAME = orcl) ) 重启监听 ...

    CIS_Oracle_Database_12c_Benchmark_v2.0.0.pdf

    1.2 Ensure All Default Passwords Are Changed (Scored) ..................................................... 16 1.3 Ensure All Sample Data And Users Have Been Removed (Scored) ............................

    PLSQL Developer 10.0.5.1710 中文版

    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 Character Sets Character size: 2 byte(s) CharSetID: 852 NCharSetID: 2000 Unicode Support: True NLS_LANG: SIMPLIFIED CHINESE_CHINA.ZHS...

    SQL21日自学通

    TNS:listener Could Not Resolve SID Given in Connect Descriptor 484 Insufficient Privileges During Grants484 Escape Character in Your Statement--Invalid Character 485 Cannot Create Operating System ...

    Citrix_XenApp5

     ICA uses port 1494 by default, or 2598  What Is Actually Being Sent between an ICA Client and a XenApp Server?  ICA works by essentially piggybacking on top of other protocols such as TCP/IP、 ...

    hydra 7.2 win32

    MS-SQL, MYSQL, NCP, NNTP, Oracle Listener, Oracle SID, Oracle, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, Rexec, Rlogin, Rsh, SAP/R3, SIP, SMB, SMTP, SMTP Enum, SNMP, SOCKS5, SSH (v1 and v2), ...

    springmybatis

    ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; Insert INTO `user` VALUES ('1', 'summer', '100', 'shanghai,pudong'); 到此为止,前期准备工作就完成了。下面开始真正配置mybatis项目了。 1. 在...

    21天学习SQL V1.0

    21天学习SQL V1.0.pdf 66 SQL 21 日自学通(V1.0) 翻译人笨猪 ...日期/时间函数............................................................................................................ADD_MONTHS..................

Global site tag (gtag.js) - Google Analytics