设为首页 收藏本站
查看: 1171|回复: 0

[经验分享] oracle中tnsnames.ora的作用

[复制链接]

尚未签到

发表于 2018-9-14 08:04:13 | 显示全部楼层 |阅读模式
  1、tnsnames.ora 在listener的作用
  数据库只是在启动的过程中会读到tnsnames.ora中的内容去解析LOCAL_LISTENER,之后tnsnames的变化和侦听无关
  ---设置了LOCAL_LISTENER,1522端口
  SQL> show parameter list
  NAME                 TYPE    VALUE
  ------------------------------------ ----------- ------------------------------
  listener_networks          string
  local_listener            string   LISTENER_1
  remote_listener           string
  ---listener.ora里面的内容
  [oracle@node1 admin]$ more listener.ora
  # listener.ora Network Configuration File: /oracle/app/oracle/db/network/admin/listener.ora
  # Generated by Oracle configuration tools.
  LISTENER_1 =
  (DESCRIPTION =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.10)(PORT = 1522))
  )
  ADR_BASE_LISTENER_1 = /oracle/app/oracle
  ---tnsnames.ora里面的内容
  LISTENER_1 =
  (DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.10)(PORT = 1522))
  )
  )
  目前数据库状态正常
  现在删除tnsnames。ora,启动数据库
  SQL> ORA-00119: invalid specification for system parameter LOCAL_LISTENER
  ORA-00132: syntax error or unresolved network name 'LISTENER_1
  数据库报错,说明数据库在启动的时候是通过tnsnames.ora去解析LOCAL_LISTENER的
  step2:修改tnsnames。ora的内容给他一个错误的IP地址
  [oracle@node1 admin]$ vi tnsnames.ora
  LISTENER_1 =
  (DESCRIPTION =
  (ADDRESS_LIST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 1.1.1.17)(PORT = 1522))
  )
  )
  1.1.1.17为错误的IP
  SQL> startup
  ORACLE instance started.
  Total System Global Area 1054593024 bytes

  Fixed>
  Variable>  Database Buffers     541065216 bytes
  Redo Buffers        4665344 bytes
  Database mounted.
  Database opened.
  SQL>
  数据库能正常启动
  SQL> !ps -ef | grep tns
  oracle  3219   1 0 21:26 ?    00:00:00 /oracle/app/oracle/db/bin/tnslsnr LISTENER_1 -inherit
  oracle  4125 3881 0 21:40 pts/1  00:00:00 /bin/bash -c ps -ef | grep tns
  oracle  4127 4125 0 21:40 pts/1  00:00:00 /bin/bash -c ps -ef | grep tns
  SQL> !lsnrctl status LISTENER_1
  LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2013 21:40:25
  Copyright (c) 1991, 2011, Oracle. All rights reserved.
  Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.10)(PORT=1522)))
  STATUS of the LISTENER
  ------------------------
  Alias           LISTENER_1
  Version          TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  Start Date        30-SEP-2013 21:26:50
  Uptime          0 days 0 hr. 13 min. 34 sec
  Trace Level        off
  Security         ON: Local OS Authentication
  SNMP           OFF
  Listener Parameter File  /oracle/app/oracle/db/network/admin/listener.ora
  Listener Log File     /oracle/app/oracle/diag/tnslsnr/node1/listener_1/alert/log.xml
  Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.1.1.10)(PORT=1522)))
  The listener supports no services
  The command completed successfully
  SQL>
  没有服务注册到listener
  step3:修改tnsnames.ora的内容为正确的IP
  重新启动listener
  [oracle@node1 admin]$ lsnrctl stop LISTENER_1
  [oracle@node1 admin]$ lsnrctl start LISTENER_1

  SQL>>
  System>  SQL> exit

  Disconnected from Oracle Database 11g Enterprise Edition>  With the Partitioning, OLAP, Data Mining and Real Application Testing options
  [oracle@node1 admin]$ lsnrctl status LISTENER_1
  LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2013 21:43:03
  Copyright (c) 1991, 2011, Oracle. All rights reserved.
  Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.10)(PORT=1522)))
  STATUS of the LISTENER
  ------------------------
  Alias           LISTENER_1
  Version          TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  Start Date        30-SEP-2013 21:42:30
  Uptime          0 days 0 hr. 0 min. 32 sec
  Trace Level        off
  Security         ON: Local OS Authentication
  SNMP           OFF
  Listener Parameter File  /oracle/app/oracle/db/network/admin/listener.ora
  Listener Log File     /oracle/app/oracle/diag/tnslsnr/node1/listener_1/alert/log.xml
  Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.1.1.10)(PORT=1522)))
  The listener supports no services
  The command completed successfully
  还是不行
  [oracle@node2 admin]$ sqlplus vic@vic2

  SQL*Plus:>  Copyright (c) 1982, 2011, Oracle. All rights reserved.
  Enter password:
  ERROR:
  ORA-12514: TNS:listener does not currently know of service requested in connect
  descriptor
  客服端也无法连接,说明重启listner对不会读取tnsnames。ora的内容。
  step4:重启数据库
  SQL> shut immediate
  startup
  Database closed.
  Database dismounted.
  ORACLE instance shut down.
  SQL>
  ORACLE instance started.
  Total System Global Area 1054593024 bytes

  Fixed>
  Variable>  Database Buffers     541065216 bytes
  Redo Buffers        4665344 bytes
  Database mounted.
  alter system register;
  Database opened.
  SQL> SQL>

  System>  oracle@node1 admin]$ lsnrctl status LISTENER_1
  LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2013 21:45:38
  Copyright (c) 1991, 2011, Oracle. All rights reserved.
  Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=1.1.1.10)(PORT=1522)))
  STATUS of the LISTENER
  ------------------------
  Alias           LISTENER_1
  Version          TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  Start Date        30-SEP-2013 21:42:30
  Uptime          0 days 0 hr. 3 min. 7 sec
  Trace Level        off
  Security         ON: Local OS Authentication
  SNMP           OFF
  Listener Parameter File  /oracle/app/oracle/db/network/admin/listener.ora
  Listener Log File     /oracle/app/oracle/diag/tnslsnr/node1/listener_1/alert/log.xml
  Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=1.1.1.10)(PORT=1522)))
  Services Summary...
  Service "haha" has 1 instance(s).
  Instance "vicdb", status READY, has 1 handler(s) for this service...
  Service "hehe" has 1 instance(s).
  Instance "vicdb", status READY, has 1 handler(s) for this service...
  Service "vicdb" has 1 instance(s).
  Instance "vicdb", status READY, has 1 handler(s) for this service...
  Service "vicdbXDB" has 1 instance(s).
  Instance "vicdb", status READY, has 1 handler(s) for this service...
  The command completed successfully
  [oracle@node2 admin]$ sqlplus vic@vic2

  SQL*Plus:>  Copyright (c) 1982, 2011, Oracle. All rights reserved.
  Enter password:
  Connected to:

  Oracle Database 11g Enterprise Edition>  With the Partitioning, OLAP, Data Mining and Real Application Testing options
  SQL>

  能正常启动,能正常连接,说明重启数据库时候能重新读取tnsnames。ora,是否有其它办法,可以再试,应该可以使用lsnrctl>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-581562-1-1.html 上篇帖子: Oracle 索引维护 下篇帖子: Oracle 临时表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表