zoukankan      html  css  js  c++  java
  • Oracle的listener.ora、tnsnames.ora的配置

    使用DBCA建库,Global Database Name为:prod.origtec.com      SID:prod

    An Oracle database is uniquely identified by a Global Database Name,typically of the form “name.domain”

    Global Database Name:

    A database is referenced by at least one Oracle instance which is uniquely identified form any other instance on this computer by an Oracle System identifier(SID).

    image

    Configure Enterprise Manager这里不选择,安装完数据库后,使用netca创建监听。

    image

    下面使用netca创建监听,每一步我都截图吧;

    image

                                       图1

    image

                                        图2

    image 

    (For remote connections to be made to your Oracle database you must have at least one Oracle Net listener)

                                         图3

    image

                                       图4

    image

                                      图5

    image

                                      图6

    image

                                      图7

    image

                                        图8

    image

                                          图9

    image

    Each Oracle database or service has a service name. An Oracle database’s service name is normally its global database name.Enter the service name of the database or other service you want to access.

                                         图10

    image

                                            图11

    image

                                        图12

    image

                                      图13

    image

                                    图14

    image

    Change Login,输入Password 

                                         图15

    image

                                       图16

    image

    Enter a name for this net service name.

    The Oracle Net Configuration Assistant has default the net service name to be the same as the service name you entered earlier.

                                                 图17

    image

                                                 图18

    image

                                             图19

    image

                                            图20

    image

    主机名为secondary.origtec.com

    使用netca创建了监听和本地网络服务,会在$ORACLE_HOME/network/admin下分别生成listener.ora和tnsnames.ora

    开始创建完数据库,这下面是没有listener.ora和tnsnames.ora的;当然如果选择configuration Enterprise Manager的话必须要创建监听,创建监听了就会生成listener.ora.

    Oracle的版本为:

    image

    先来测试下网络配置是否正常吧

    1).监听要启动

    2).使用sys和system账户

    sqlplus sys/oracle@prod as sysdba

    sqlplus system/oracle@prod

    image

    image

    成功!!!

    conn sys/oracle@prod.origtec.com  as sysdba

    conn system/oracle@prod.origtec.com

    image

    image

    失败!!!

    那现在,我们来看看listener.ora和tnsnames.ora的具体内容

    listener.ora

    image

    LISTENER 这是默认的名字,其他的好像也没啥,ADDRESS中的PROTOCOL和HOST、PORT很容易理解

    最后有个ADR_BASE_LISTENER = /u01/app/oracle

    官方文档的解释:

    (http://docs.oracle.com/cd/E11882_01/network.112/e10835/listener.htm#NETRF420)

    ADR_BASE_listener_name

    Purpose

    To specify the base directory in to which tracing and logging incidents are stored when ADR is enabled.

    Defult

    The default is ORACLE_BASE, or ORACLE_HOME/log if ORACLE_BASE is not defined.

    Values

    Any valid directory path to a directory with write permisson.

    Example

    ADR_BASE=/oracle/network/trace

    关于ADR的enabled查看:

    SELECT NAME,VALUE FROM V$DIAG_INFO;

    image

    再来看看tnsnames.ora

    image

    第10行(SERVICE_NAME = prod.origtec.com),这里的prod.origtec.com就是Global Database Name,上面图10所示,Service Name

    第4行的PROD是图17中的Net Service Name

    所以conn sys/oracle@prod as sysdba中的prod是Net Service Name,当然大小写不同,换成大写试下,应该也是可以的。

    正确语法:

    connect  username/password@net_service_name

    image

    image

    我一直的错误是建立tnsnames.ora时,Service Name直接写成prod,其实没在意我建库时Global Database Name是prod.origtec.com,和SID不同,SID是prod

    Global Database Name=数据库名+数据库域名

    image

    SID:

    image

    查询数据库服务名:

    图10中的Service Name

    image

    Net_Service_Name除了在tnsnames.ora查看,暂时没找到其他方法查看。

    下面这段来源于:http://www.2cto.com/database/201110/108457.html

    介绍了全局数据库名(Global Database Name)和SID、服务名的等等

    数据库实例名与ORACLE_SID

    虽然两者都表是oracle实例,但两者是有区别的。instance_name是oracle数据库参数。而ORACLE_SID是操作系统的环境变量。ORACLD_SID用于与操作系统交互,也就是说,从操作系统的角度访问实例名,必须通过ORACLE_SID。在winnt不台,ORACLE_SID还需存在于注册表中。

    且ORACLE_SID必须与instance_name的值一致,否则,你将会收到一个错误,在unix平台,是“ORACLE not available”,在winnt平台,是“TNS:协议适配器错误”。

    以上使用的origtec.com域名,拥有者是苏州溯源天成信息技术服务有限公司。

  • 相关阅读:
    生产力-能力-生产工具
    window.location.Reload()和window.location.href 区别
    getAttribute() 与 attr() 的区别
    清空标签间的内容(innerHTML)和 value
    使用 data-* 属性来嵌入自定义数据:
    JS-jquery 获取当前点击的对象
    Redis深度历险——核心原理与应用实践
    PhpStorm 配置 Xdebug调试工具
    phpCOW机制详解
    rel=nofollow 是什么意思
  • 原文地址:https://www.cnblogs.com/cnmarkao/p/5336635.html
Copyright © 2011-2022 走看看