listener的动态注册与service_name

动态注册的listener.ora,由netca产生:

[oracle@primary admin]$ cat listener.ora
# listener.ora Network Configuration File: /home/db/oracle/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /home/db/oracle/product/10.2.0)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = primary)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )


动态注册是由数据库的pmon进程完成的,如果实例启动时,没有启动listener,那么pmon就无法立即进行service的注册,而是在一定的时间间隔后再次进行注册,这个时间最长达

1分钟,通过一个命令可以立即完成service的注册:

SQL> alter system register;

System altered.


动态注册后,查看监听状态

[oracle@primary admin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 20-JUN-2010 05:38:23

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=primary)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                20-JUN-2010 05:33:49
Uptime                    0 days 0 hr. 4 min. 34 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/db/oracle/product/10.2.0/network/admin/listener.ora
Listener Log File         /home/db/oracle/product/10.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=primary)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "EBANK_B2B" has 1 instance(s).
  Instance "ebank", status READY, has 1 handler(s) for this service...
Service "EBANK_B2C" has 1 instance(s).
  Instance "ebank", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "ebank" has 1 instance(s).
  Instance "ebank", status READY, has 1 handler(s) for this service...
Service "ebank_XPT" has 1 instance(s).
  Instance "ebank", status READY, has 1 handler(s) for this service...
The command completed successfully

可以看出,监听的状态均为READY,这就是动态注册的结果,如果是静态注册,则状态将为UNKOWN.

数据库service name,此处设置了2个service name,其实service name无非就是为了把不同的应用给区分开,其名称与db name或instance name并没有必然联系:

SQL> show parameter service

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      EBANK_B2B,EBANK_B2C

再看客户端如何根据service name连接数据库:

tnsnames.ora:

EBANK =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.52.2)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ebank_b2b)
    )
  )
在tnsnames文件里配置的service_name为ebank_b2b,进行连接测试:

[oracle@primary admin]$ sqlplus scott/tiger@ebank

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Jun 20 05:37:00 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


Session altered.

SQL>

再将service name改为ebank_b2c,测试:

EBANK =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.52.2)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ebank_b2c)
    )
  )

[oracle@primary admin]$ sqlplus scott/tiger@ebank

SQL*Plus: Release 10.2.0.4.0 - Production on Sun Jun 20 05:42:49 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


Session altered.

查看service name为ebank_b2c的状态:

Service "EBANK_B2C" has 1 instance(s).
  Instance "ebank", status READY, has 1 handler(s) for this service...
    Handler(s):
      "DEDICATED" established:1 refused:0 state:ready。
         LOCAL SERVER

显示有一个已建立的连接。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10972173/viewspace-665710/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10972173/viewspace-665710/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值