Oracle 基础篇 --- Oracle Network配置

早过忘川 提交于 2019-12-09 14:44:51

##第二. Oracle Network配置

配置和管理Oracle Network 的工具:

  • Enterprise Manager 的“Net Services Administration(网络服务管理)”页

1. Oracle Net Manager

  • 提供一个图形用户界面(GUI),通过这个界面可在本地客户机 或服务器主机的Oracle 主目录中配置Oracle Net Services。Oracle Net Manager 允许您在本地客户机或服务器主机的Oracle 主目录中配置Oracle Net Services。可以使用Net Manager 配置以下网络组件: - 命名:定义简单的名称和连接标识符,并将它们映射至连接描述符以确定网络位置和服务标识。Oracle Net Manager 支持在本地tnsnames.ora 文件或集中式目录服务中配置连接描述符。 - 命名方法:配置将连接标识符解析为连接描述符的不同方法。 - 概要文件:配置用于在客户机或服务器上启用和配置Oracle Net 功能的首选项。配置sqlnet.ora 参数。 - 监听程序:创建和配置监听程序以接收客户机连接。listener.ora

2. Oracle Net Configuration Assistant

  • 安装Oracle 软件时通过Oracle Universal Installer来启动。使用Oracle Net Configuration Assistant 可配置Oracle DB 的监听协议地址和服务信息。在典型的数据库安装期间,Oracle Net Configuration Assistant 会自动配置一个名为LISTENER 的监听程序,该监听程序具有数据库的TCP/IP 监听协议地址。 如果执行定制安装,则Oracle Net Configuration Assistant 会提示您配置所选的监听程序名称和协议地址。安装数据库之后,使用Oracle Net Configuration Assistant 进行初始网络配置。然后,可以使用Oracle Enterprise Manager 和Oracle Net Manager 配置和管理您的网络。
  • 命令行 用于启动、停止监听程序进程或查看监听程序进程的状态。

3. 数据库服务注册

  • 动态服务注册:oracle 10g以上 用netca方式建立的都默认为动态注册方式。status READY - listener实时的都知道实例的状态,数据库在关闭的时候会动态的从listener中注销。 - 当数据库关闭的时候,就无法远程的启动数据库。
LSNRCTL> status listener
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                29-MAY-2015 02:40:43
Uptime                    0 days 4 hr. 48 min. 35 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/hzvscmdb/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hzvscmdb.qa.webex.com)(PORT=1521)))
Services Summary...
Service "tonytest.qa.webex.com" has 1 instance(s).
  Instance "tonytest", status READY, has 1 handler(s) for this service...
Service "tonytestXDB.qa.webex.com" has 1 instance(s).
  Instance "tonytest", status READY, has 1 handler(s) for this service...
The command completed successfully

  • 静态服务注册status UNKNOWN - listener不知道实例的状态,只有在进程通过其连接数据库时才能知道,如果你想使用远程管理数据库就使用静态监听。 - 可以远程起数据库。
LSNRCTL> status listener2
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1523)))
STATUS of the LISTENER
------------------------
Alias                     listener2
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                29-MAY-2015 05:05:23
Uptime                    0 days 2 hr. 25 min. 13 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/hzvscmdb/listener2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1523)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1524)))
Services Summary...
Service "tonytest.qa.webex.com" has 1 instance(s).
  Instance "tonytest", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

###################################################################
[oracle@hzvscmdb admin]$ more listener.ora
LISTENER2 =
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1523))
      (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1524))
    )
  )
SID_LIST_LISTENER2=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=tonytest.qa.webex.com)
      (SID_NAME=tonytest)
      (ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
     )
  )

注:LISTENER2 和 SID_LIST_LISTENER2 名字匹配
  • 手工注册监听
alter system register; 
  • 修改动态注册的默认端口1521 方法一
Alter system set local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.200)(PORT = 1522))'

alter system register; 
  • 方法二
[oracle@hzvscmdb admin]$ more listener.ora
LISTENER1 =
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1522))
    )
  )
SID_LIST_LISTENER1=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=tonytest.qa.webex.com)
      (SID_NAME=tonytest)
      (ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1)
     )
  )

[oracle@hzvscmdb admin]$ more tnsnames.ora
LISTENER1=
(DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.200)(PORT = 1522))
)

SQL*Plus: Release 11.2.0.2.0 Production on Fri May 29 09:54:22 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option

SQL> Alter system set local_listener= LISTENER1;

SQL> alter system register; 

SQL> show parameter local_listener;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      LISTENER1

说明:LISTENER2注册的实例和服务器默认的监听一样,listener status,也就是默认的监听状态,我们发现,动态监听没有了,剩下的静态监听。更进一步,我们发现,只要我们成功设置了local_listener的值,包括实例和服务名不和默认监听一样,PMON都会在等待local_listener对应的监听。

LSNRCTL> status listener1
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     listener1
Version                   TNSLSNR for Linux: Version 11.2.0.2.0 - Production
Start Date                29-MAY-2015 09:49:26
Uptime                    0 days 0 hr. 9 min. 2 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/hzvscmdb/listener1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.200)(PORT=1522)))
Services Summary...
Service "tonytest.qa.webex.com" has 2 instance(s).
  Instance "tonytest", status UNKNOWN, has 1 handler(s) for this service...
  Instance "tonytest", status READY, has 1 handler(s) for this service...
Service "tonytestXDB.qa.webex.com" has 1 instance(s).
  Instance "tonytest", status READY, has 1 handler(s) for this service...
The command completed successfully

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!