OCM_Session1_2_Server-side Network Configuration

Oracle数据库监听配置详解
本文详细介绍了如何在Oracle数据库环境中创建、配置和启动监听器,包括使用默认监听器名、添加自定义监听器以及配置监听器以支持动态实例注册。
2. Server-side Network Configuration
 2.1 Create a listener using the default listener name. 
  2.1.1 The TCP/IP protocol will be used for all connections. Use the machine name(not the IP address) for host.  
  2.1.2 This listener will listen on the default port.
  2.1.3 Databases: PROD and EMREP(created later) will be serviced by this listener.
 2.2 Add a second listener , named LSNR2,which will listen on port 1526.Configure this listener to support only automatic instance registrations.
   2.2.1 Set up the PROD instance to automatically register with the LSNR2.
  2.3 Start both listeners.

参考联机文档:
Net Services Reference ==> 7 Listener Parameters (listener.ora)

Example 7-1 shows a listener.ora file for a listener named LISTENER, which is the default name of the listener.

Example 7-1 Example listener.ora File

LISTENER
=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=sale-server)(PORT=1521))
      (ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_
LISTENER
=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=sales.us.acme.com)
      (ORACLE_HOME=/oracle10g)
      (SID_NAME=sales))
    (SID_DESC=
      (SID_NAME=plsextproc)
      (ORACLE_HOME=/oracle10g)
      (PROGRAM=extproc)))

 2.1 Create a listener using the default listener name. 创建一个监听,使用缺省的监听名字
  2.1.1 The TCP/IP protocol will be used for all connections. Use the machine name(not the IP address) for host.
             使用TCP/IP协议,使用机器名称,不使用IP地址
  2.1.2 This listener will listen on the default port.缺省端口1521
  2.1.3 Databases: PROD and EMREP(created later) will be serviced by this listener.

  • 修改如下:

  • 1.创建一个监听,使用缺省的监听名字LISTENER,使用TCP/IP协议,使用机器名称(不使用IP地址),缺省端口1521.两个数据库PROD和EMREP
[oracle@ocm1 ~]$ hostname
ocm1.localdomain
[oracle@ocm1 ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/10.2.0/db_1

[root@ocm1 ~]#   su - oracle
[oracle@ocm1 ~]$   cd $ORACLE_HOME/network/admin
[oracle@ocm1 admin]$ ll
total 8
drwxr-x--- 2 oracle oinstall 4096 Mar 16 19:17 samples
-rw-r----- 1 oracle oinstall  172 Dec 26  2003 shrept.lst

[oracle@ocm1 admin]$   vi listener.ora 
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL= tcp)(HOST= ocm1.localdomain)(PORT= 1521))
      (ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME= PROD)
      (ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME= PROD))
    (SID_DESC=
      (GLOBAL_DBNAME= EMREP)
      (ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME= EMREP))
    (SID_DESC=
      (SID_NAME=plsextproc)
      (ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM=extproc)))
~
"listener.ora" 19L, 557C written                                                                                       
[oracle@ocm1 admin]$ 

  • 2.启动刚创建的缺省监听
[oracle@ocm1 admin]$  lsnrctl start

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 18-MAR-2014 12:05:33

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

Starting /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                18-MAR-2014 12:05:33
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc)))
Services Summary...
Service "EMREP" has 1 instance(s).
  Instance "EMREP", status UNKNOWN, has 1 handler(s) for this service...
Service "PROD" has 1 instance(s).
  Instance "PROD", status UNKNOWN, 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
[oracle@ocm1 admin]$ 


 2.2 Add a second listener , named LSNR2,which will listen on port 1526.Configure this listener to support only automatic instance registrations.
            再配置一个监听,名字叫LSNR2,端口是1526,只支持动态监听。


  • 3.追加内容,监听名称为LSNR2,端口为1526,并启动监听LSNR2
这里动态监听即为在listener名称下面没有SID_LIST_LISTENER,注意下面的端口和KEY(与上面的LISTENER的KEY不同)。


[oracle@ocm1 admin]$ vi listener.ora 
LISTENER=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1521))
      (ADDRESS=(PROTOCOL=ipc)(KEY=extproc))))
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=PROD)
      (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME=PROD))
    (SID_DESC=
      (GLOBAL_DBNAME=EMREP)
      (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME=EMREP))
    (SID_DESC=
      (SID_NAME=plsextproc)
      (ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM=extproc)))

LSNR2=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526))
      (ADDRESS=(PROTOCOL=ipc)(KEY=extproc1))))
~
~
~
~
"listener.ora" 25L, 712C written         

    
  2.2.1 Set up the PROD instance to automatically register with the LSNR2.
            将PROD实例自动注册到LSNR2。

  • 4.将PROD实例动态注册到LSNR2中。
这里即是修改local_listener的参数。

SQL> conn /as sysdba
Connected.
SQL> 
SQL> show parameter local

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string
log_archive_local_first              boolean     TRUE

参考联机文档:
Reference ==> LOCAL_LISTENER参数

LOCAL_LISTENER

PropertyDescription
Parameter type String
Syntax LOCAL_LISTENER = network_name
Default value (ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521)) where hostname is the network name of the local host.
Modifiable ALTER SYSTEM
Basic No

LOCAL_LISTENER specifies a network name that resolves to an address or address list of Oracle Net local listeners (that is, listeners that are running on the same machine as this instance). The address or address list is specified in the TNSNAMES.ORA file or other address repository as configured for your system.


SQL> alter system set local_listener='(ADDRESS = (PROTOCOL=TCP)(HOST=ocm1.localdomain)(PORT=1526))';

System altered.

SQL> show parameter local


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

local_listener                       string      (ADDRESS = (PROTOCOL=TCP)(HOST

                                                 =ocm1.localdomain)(PORT=1526))

log_archive_local_first              boolean     TRUE

SQL> 

  • 5.启动LSNR2监听

[oracle@ocm1 ~]$ lsnrctl status lsnr2

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 18-MAR-2014 13:01:03

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias                     lsnr2
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                18-MAR-2014 12:31:26
Uptime                    0 days 0 hr. 29 min. 36 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/lsnr2.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc1)))
Services Summary...
Service "PROD" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
Service "PROD_XPT" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@ocm1 ~]$ 

  • 6.如果此时查不到PROD,则需要在SQL中再注册一下:
[oracle@ocm1 ~]$ lsnrctl status lsnr2

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 18-MAR-2014 13:02:58

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias                     lsnr2
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                18-MAR-2014 13:02:09
Uptime                    0 days 0 hr. 0 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/lsnr2.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc1)))
The listener supports no services
The command completed successfully

则在SQL中再注册一下:

SQL>   alter system register;

System altered.

再来查看状态:

[oracle@ocm1 ~]$ lsnrctl status lsnr2

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 18-MAR-2014 13:04:20

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias                     lsnr2
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                18-MAR-2014 13:02:09
Uptime                    0 days 0 hr. 2 min. 11 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2.0/db_1/network/log/lsnr2.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ocm1.localdomain)(PORT=1526)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=extproc1)))
Services Summary...
Service "PROD" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
Service "PROD_XPT" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@ocm1 ~]$ 


  2.3 Start both listeners.
之前两个监听都已经启动。
 

### ORACLE_OCM_CONFIG_DIR 的含义与配置方法 #### 含义 ORACLE_OCM_CONFIG_DIR 是 Oracle Configuration Manager (OCM) 用于存储配置文件和数据的目录路径环境变量。该变量用于指定 OCM 收集和存储配置信息的目标位置,这些信息通常用于 Oracle 的支持服务,如 My Oracle Support (MOS) 中的配置分析和问题诊断。如果该目录未正确设置或缺失,可能会导致 OCM 相关操作失败,例如配置作业无法写入数据或部署脚本无法完成执行[^1]。 在某些情况下,OCM 配置任务可能试图访问一个未被自动创建的目录路径,如 ORACLE_OCM_CONFIG_DIR2,这可能导致“ORA-29280: invalid directory path”错误。此类问题通常发生在 Oracle 数据库的内置脚本未创建该目录的情况下,而 OCM 的作业尝试访问它时会触发路径无效的错误[^3]。 #### 设置方法 ORACLE_OCM_CONFIG_DIR 通常由 Oracle Configuration Manager 在配置过程中自动设置。如果需要手动配置或验证该目录,可以按照以下步骤进行: 1. **创建目录**:确保操作系统中存在指定的目录结构,例如 `/u01/app/oracle/ocm/config`。 ```bash mkdir -p /u01/app/oracle/ocm/config ``` 2. **设置权限**:确保 Oracle 软件所有者(如 `oracle` 用户)对该目录具有读写权限。 ```bash chown -R oracle:oinstall /u01/app/oracle/ocm/config chmod -R 750 /u01/app/oracle/ocm/config ``` 3. **配置环境变量**:在 Oracle 的环境配置文件(如 `.bash_profile` 或 `.bashrc`)中设置 ORACLE_OCM_CONFIG_DIR。 ```bash export ORACLE_OCM_CONFIG_DIR=/u01/app/oracle/ocm/config ``` 4. **重新加载环境变量**:执行以下命令以应用更改。 ```bash source ~/.bash_profile ``` 5. **验证配置**:运行 OCM 配置工具以确认目录路径是否正确。 ```bash $ORACLE_HOME/ccr/bin/configCCR ``` 如果 OCM 报告目录结构不完整或未配置,例如提示“OCM is not configured for this host or ORACLE_CONFIG_HOME”,则需要重新运行配置工具以确保所有必要的目录和配置文件被正确生成[^2]。 #### 注意事项 - **一致性**:在多节点环境中,确保所有节点的 ORACLE_OCM_CONFIG_DIR 设置一致,以便于集中管理和支持。 - **备份与监控**:定期备份 OCM 配置目录,并监控其磁盘使用情况,以防止因空间不足导致的配置失败。 - **日志检查**:如果遇到配置错误,可以检查 OCM 的日志文件,通常位于 `$ORACLE_HOME/ccr/log` 目录下,以获取详细的错误信息和诊断线索。 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值