ocm 配置网络

本文详细介绍如何配置Oracle数据库的监听器listener.ora及tnsnames.ora文件,包括修改监听地址、端口和服务名等关键步骤,并展示了启动监听器和服务的状态检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

cd   $ORACLE_HOME/network/admin/sample
配置监听
# LISTENER =
#  (ADDRESS_LIST=
#       (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
#       (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
# SID_LIST_
#   List of services the listener knows about and can connect
#   clients to.  There is no default.  See the Net8 Administrator's
#   Guide for more information.
#
# SID_LIST_LISTENER=
#   (SID_LIST=
#       (SID_DESC=
#                       #BEQUEATH CONFIG
#          (GLOBAL_DBNAME=salesdb.mycompany)
#          (SID_NAME=sid1)
#          (ORACLE_HOME=/private/app/oracle/product/8.0.3)
#                       #PRESPAWN CONFIG
#         (PRESPAWN_MAX=20)
#         (PRESPAWN_LIST=
#           (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
#         )
#        )
#       )
 

把sample 下的 上面的东西CP 到 listener.ora  
修改
1. 去掉 
#                       #PRESPAWN CONFIG
#         (PRESPAWN_MAX=20)
#         (PRESPAWN_LIST=
#           (PRESPAWN_DESC=(PROTOCOL=tcp)(POOL_SIZE=2)(TIMEOUT=1))
#         )

2.  修改   
     (SID_NAME=sid1)   ----修改为   (SID_NAME=orcl) 
     (GLOBAL_DBNAME=salesdb.mycompany)  ----修改为 (GLOBAL_DBNAME=orcl)
     (ORACLE_HOME=/private/app/oracle/product/8.0.3)   ----修改为  (ORACLE_HOME=/oracle/product/10.2.0)

3. 去掉 
# SID_LIST_
#   List of services the listener knows about and can connect
#   clients to.  There is no default.  See the Net8 Administrator's
#   Guide for more information.
#
4. 修改
HOST=localhost   ---修改为 HOST=192.168.1.10
5. 把所有的# 去掉
:%s/#//g

stty  erase  按住 ctl 加 vh       就可以用退格键代替DELETE

配置 tnsnames.ora  
 
 (DESCRIPTION=
            [ (SDU=2048) ]      # Optional, defaults to 2048
                                # Can take values between 512 and 32K
            [ (ADDRESS_LIST=    # Optional depending on whether u have
                                # one or more addresses
                                # If there is just one address, unnecessary ]
              (ADDRESS=
                [ (COMMUNITY=) ]
                (PROTOCOL=tcp)
                (HOST=)
                (PORT=)
              )
             
             
             
             
         [ (CONNECT_DATA=
                (SID=)
                [ (GLOBAL_NAME=) ]
              )
            ]
           
           
1. 把 tnsnames.ora  上面的文件 CP 过来  
 
 
vi tnsnames.ora  
ORCL =
 (DESCRIPTION=
            [ (SDU=2048) ]      # Optional, defaults to 2048
                                # Can take values between 512 and 32K
            [ (ADDRESS_LIST=    # Optional depending on whether u have
                                # one or more addresses
                                # If there is just one address, unnecessary ]
              (ADDRESS=
                [ (COMMUNITY=) ]
                (PROTOCOL=tcp)
                (HOST=)
                (PORT=)
              )
             
             
             
             
         [ (CONNECT_DATA=
                (SID=)
                [ (GLOBAL_NAME=) ]
              )
            ]

去掉一下几个  
       [ (SDU=2048) ]      # Optional, defaults to 2048
        # Can take values between 512 and 32K
 
  # one or more addresses
  # If there is just one address, unnecessary ]
 
    [ (COMMUNITY=) ]
   
   
 ORCL =
 (DESCRIPTION=
            (ADDRESS_LIST=
              (ADDRESS=
                (PROTOCOL=tcp)
                (HOST=192.168.1.10)
                (PORT=1521)
              )
            )
          (CONNECT_DATA=
                (SID=orcl)
              )
   )
  
  
  
  
  
  
  
  
ORCL =
 (DESCRIPTION=
     (ADDRESS_LIST=
          (ADDRESS=
             (PROTOCOL=tcp) (HOST=192.168.1.10)(PORT=1521)
           )
      )
              
     (CONNECT_DATA=(SID=orcl) )
 )
 
 
 我们可以看出有以下规律
 
 =========================================================
  第一部分
 
   (ADDRESS_LIST=
          (ADDRESS=
             (PROTOCOL=tcp) (HOST=192.168.1.10)(PORT=1521)
           )
      )
     
 ========================================================
 第二部分
 (CONNECT_DATA=(SID=orcl) )
 
 ==========================================
 第三部分
 
 (DESCRIPTION=
  )
 ====================================================
 
 
 
 
     
     
 orcl =
  (DECRIPTION=
             (ADDRESS_LIST=
              (ADDRESS=
                (PROTOCOL=tcp)
                (HOST=192.168.1.10)
                (PORT=1521)
              )
             )
             (CONNECT_DATA=
                (SID=orcl)
              )
)

ORCL =
 (DESCRIPTION=
     (ADDRESS_LIST=
          (ADDRESS=
             (PROTOCOL=tcp) (HOST=192.168.1.10)(PORT=1521)
           )
      )
              
     (CONNECT_DATA=(SID=orcl) )
 )
 
 
 
 在配置的时候,需要注意以下几个问题 : 
 
1. 保证开头的ORCL 中没有空格
 
 
SQL> alter system   set  local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=node1)(PORT=1522))';
System altered.
 
 
[oracle@node1 admin]$ more listener.ora
LISTENER =
  (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522))
       (ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
SID_LIST_LISTENER=
   (SID_LIST=
       (SID_DESC=
          (GLOBAL_DBNAME=orcl)
          (SID_NAME=orcl)
          (ORACLE_HOME=/oracle/product/10.2.0)
        )
       )
      
      
   
   
   
    [oracle@node1 admin]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-MAR-2011 12:23:23
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Starting /oracle/product/10.2.0/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.4.0 - Production
System parameter file is /oracle/product/10.2.0/network/admin/listener.ora
Log messages written to /oracle/product/10.2.0/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-MAR-2011 12:23:23
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/product/10.2.0/network/admin/listener.ora
Listener Log File         /oracle/product/10.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@node1 admin]$
[oracle@node1 admin]$
[oracle@node1 admin]$
[oracle@node1 admin]$
[oracle@node1 admin]$

SQL> startup
ORACLE instance started.
Total System Global Area  524288000 bytes
Fixed Size                  2085256 bytes
Variable Size             155192952 bytes
Database Buffers          360710144 bytes
Redo Buffers                6299648 bytes
Database mounted.
Database opened.
SQL> 

[oracle@node1 admin]$ more tnsnames.ora
orcl =
  (DESCRIPTION=
             (ADDRESS_LIST=
              (ADDRESS=
                (PROTOCOL=tcp)
                (HOST=192.168.1.10)
                (PORT=1522)
              )
             )
             (CONNECT_DATA=
                (SID=orcl)
              )
)
 
[oracle@node1 ~]$ sqlplus  /  as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Thu Mar 24 12:26:12 2011
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter local
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string
log_archive_local_first              boolean     TRUE
SQL> alter system  set  local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522))';
System altered.
SQL>

[oracle@node1 admin]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-MAR-2011 12:36:43
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date                24-MAR-2011 12:32:00
Uptime                    0 days 0 hr. 4 min. 43 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/product/10.2.0/network/admin/listener.ora
Listener Log File         /oracle/product/10.2.0/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.10)(PORT=1522)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
Services Summary...
Service "orcl" has 2 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
  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...
The command completed successfully
 
UNKNOWN  状态是静态注册 
READY    状态是动态注册
 
 

 

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

转载于:http://blog.itpub.net/66233/viewspace-690395/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值