RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
oracle的环境配置-监听服务和访问连接原理

监听服务和访问连接原理

端口号范围:1025~6500

[oracle@oracle3 ~]$ lsnrctl   --进入监听管理工具

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 11:13:20

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

Welcome to LSNRCTL, type "help" for information.

LSNRCTL> status   --查看监听器状态

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                05-JUN-2014 09:38:27
Uptime                    0 days 1 hr. 34 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))  --端口号默认是1521,也就是对外提供服务的端口号。
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCLXDB" has 1 instance(s).
  Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCL_XPT" has 1 instance(s).
  Instance "ORCL", 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...
The command completed successfully

SQL> conn system/orcl@ORCL33  --通过监听器访问
已连接。

ORCL33叫做网络服务名(连接描述符),配置文件在客户端,服务器上不需要的。

F:\oracle\product\10.2.0\client_1\NETWORK\ADMIN\tnsnames.ora  --客户端的路径.网络服务名配置文件

文件中:
ORCL33 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.3.3)(PORT = 1521))  --oracle server的IP,端口号,数据库名字
    )
    (CONNECT_DATA =
      (SERVICE_NAME = ORCL)
    )
  )

添加连接串两种方法:1、通过图形界面   2、直接修改这个文件


本地直接访问,不需要经过监听器,宿主机访问是必须通过监听器的。

用xmanager连接:
SQL> conn system/orcl  --本机访问
Connected.

SQL> conn system/orcl@ORCL  --本机通过监听器访问
Connected.

将监听器停止
[oracle@oracle3 admin]$ lsnrctl stop

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 11:28:28

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully

SQL> conn system/orcl  --本机访问不受影响
Connected.
SQL> conn system/orcl@ORCL  --通过监听器访问不能连接
ERROR:
ORA-12541: TNS:no listener


Warning: You are no longer connected to ORACLE.

SQL> conn system/orcl@ORCL2567
ERROR:
ORA-12541: TNS: 无监听程序


警告: 您不再连接到 ORACLE。


启动监听后查看状态:

[oracle@oracle3 admin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 11:31:39

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                05-JUN-2014 11:30:50
Uptime                    0 days 0 hr. 0 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully  --此时还是不能远端访问的,因为数据库还没监听到

此时连接:
SQL> conn system/orcl@ORCL2567
ERROR:
ORA-12541: TNS: 无监听程序

警告: 您不再连接到 ORACLE。

[oracle@oracle3 admin]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 11:31:46

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                05-JUN-2014 11:30:50
Uptime                    0 days 0 hr. 0 min. 55 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status READY, has 1 handler(s) for this service...   --数据库被监听到
Service "ORCLXDB" has 1 instance(s).
  Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCL_XPT" has 1 instance(s).
  Instance "ORCL", 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...
The command completed successfully

SQL> conn system/orcl@ORCL2567  --此时远端访问正常
已连接。

简单的检测方法:
C:\Users\Administrator>tnsping ORCL2567   --ping网路描述符是否是可以访问通的

TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 05-6月 -
2014 11:38:41

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

已使用的参数文件:
F:\oracle\product\10.2.0\client_1\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 10.1.3.3)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ORCL)))
OK (30 毫秒)

[oracle@oracle3 admin]$ tnsping ORCL1

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 11:41:09

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:
/u01/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

TNS-03505: Failed to resolve name  --ping不通的表现

创新互联长期为千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为中宁企业提供专业的成都网站设计、成都网站制作、外贸网站建设中宁网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。


文章名称:oracle的环境配置-监听服务和访问连接原理
文章源于:http://lswzjz.com/article/gsjseo.html