你好,游客 登录 注册 搜索
背景:
阅读新闻

配置Oracle网络环境

[日期:2013-09-15] 来源:Linux社区  作者:vnimos [字体:大 中 小]

添加多个监听器:

  • 动态注册

$ vi $TNS_ADMIN/listener.ora                                            //添加监听器"LISTENER1"的配置信息
LISTENER1 =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522))
    )
$ vi $TNS_ADMIN/tnsnames.ora                                            //添加连接到监听器"LISTENER1"的连接字符串
APPLE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1522))
  )
SQL> alter system set local_listener='listener1';
alter system set local_listener='listener1'
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'listener1'
SQL> alter system set local_listener='apple';                                    //修改默认监听程序(必须使用监听程序对应的连接字符串)
System altered.
$ lsnrctl start listener1                                              //启动监听程序"LISTENER1"
---------------省略输出---------------
STATUS of the LISTENER
------------------------
Alias                    listener1
Version                  TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                11-SEP-2013 14:18:13
Uptime                    0 days 0 hr. 0 min. 1 sec
Trace Level              off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File  /u01/app/Oracle/product/11.2.0/dbhome_1//network/admin/listener.ora
Listener Log File        /u01/app/oracle/diag/tnslsnr/ora11g/listener1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.90)(PORT=1522)))
The listener supports no services
The command completed successfully
$ lsnrctl status listener1                                              //查看"LISTENER1"监听程序的状态(动态注册一般会有几秒钟的延迟)
---------------省略输出---------------
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.90)(PORT=1522)))
Services Summary...
Service "orcl.example.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.example.com" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
$ lsnrctl status                                                    //查看"LISTENER"监听程序的状态("LISTENER"监听程序可省略指定)
---------------省略输出---------------
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g.example.com)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM", status READY, has 1 handler(s) for this service...
The command completed successfully
$ sqlplus /nolog               
SQL> conn hr/hr@apple                                                //通过"LISTENER"监听程序连接
Connected.

静态注册

$ vi $TNS_ADMIN/listener.ora
LISTENER2 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.90)(PORT = 1523))
    )
  )
SID_LIST_LISTENER2 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl.example.com)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1/)
      (SID_NAME = orcl)
    )
  )
$ lsnrctl start listener2
---------------省略输出---------------
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.0.90)(PORT=1523)))
Services Summary...
Service "orcl.example.com" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

使用静态注册还可以在远程开启数据库实例,而动态注册由于数据库实例未启动无法注册,所以在数据库开启之前无法通过动态注册监听程序连接到数据库

$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 11 16:30:14 2013
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> conn sys/oracle_4U@apple as sysdba                              //无法连接通过动态注册的监听
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor
SQL> conn sys/oracle_4U@apear as sysdba                              //成功连接静态注册的监听,可实现远程开启数据库
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area  459304960 bytes
Fixed Size                  2214336 bytes
Variable Size            289408576 bytes
Database Buffers          159383552 bytes
Redo Buffers                8298496 bytes
Database mounted.
Database opened.

 

配置连接时客户端故障转移和负载均衡Failover和LoadBalance

配置Oracle网络环境

linux
相关资讯       Oracle配置  Oracle网络配置 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款