首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

当我用相同的DB实例名设置了2台Unix机器时,我如何在tnsnames.ora文件中写入TNS字符串?

在tnsnames.ora文件中,您可以按照以下格式写入TNS字符串:

代码语言:txt
复制
<DB实例名> =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = <主机名或IP地址>)(PORT = <端口号>))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = <服务名>)
    )
  )

其中,您需要替换以下内容:

  • <DB实例名>:您设置的DB实例名。
  • <主机名或IP地址>:Unix机器的主机名或IP地址。
  • <端口号>:DB实例的端口号。
  • <服务名>:DB实例的服务名。

例如,如果您设置的DB实例名为"mydb",Unix机器的主机名为"example.com",DB实例的端口号为1521,服务名为"orcl",则TNS字符串的写入如下:

代码语言:txt
复制
mydb =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = example.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

请注意,以上示例中的内容仅供参考,实际情况可能会有所不同。另外,腾讯云提供了云数据库 TencentDB for MySQL,您可以通过以下链接了解更多信息:

TencentDB for MySQL产品介绍

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

  • 一次访问问题排查-涉及TNS-03505、ORA-12154、TNS-12560、动态注册、防火墙、tnsping跟踪等

    建了一个库,想通过Oracle Net访问,需要配置监听器和tnsnames.ora,接下来碰到一系列的问题。。。 1. 添加监听器配置,listener.ora文件默认包括: LISTENER =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))     )   ) ADR_BASE_LISTENER = /opt/app/ora11g 为了新建监听器名称,添加如下: DCSOPEN =   (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = 172.101.19.57)(Port = 1521))) 或 DCSOPEN =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS = (PROTOCOL = TCP)(HOST = dcsopen2Node)(PORT = 1521))     )   ) ADR_BASE_DCSOPEN = /opt/app/ora11g 或 DCSOPEN =   (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(Host = 172.101.19.57)(Port = 1521))) SID_LIST_DCSOPEN =   (SID_LIST =     (SID_DESC =       (SID_NAME = PLSExtProc)       (ORACLE_HOME = /opt/app/ora11g/product/11.2.0/dcsopen)       (PROGRAM = extproc)     )     (SID_DESC =       (GLOBAL_DBNAME = dcsopen)       (ORACLE_HOME = /opt/app/ora11g/product/11.2.0/dcsopen)       (SID_NAME = dcsopen)     )   ) ADR_BASE_DCSOPEN = /opt/app/ora11g 或 DCSOPEN =   (DESCRIPTION_LIST =     (DESCRIPTION =       (ADDRESS_LIST =         (ADDRESS = (PROTOCOL = TCP)(HOST = 172.101.19.57)(PORT = 1521))       )       (ADDRESS_LIST =         (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))       )     )   ) SID_LIST_DCSOPEN =   (SID_LIST =     (SID_DESC =       (SID_NAME = PLSExtProc)       (ORACLE_HOME = /opt/app/ora11g/product/11.2.0/dcsopen)       (PROGRAM = extproc)     )   ) ADR_BASE_DCSOPEN = /opt/app/ora11g 2. 添加本机的tnsnames.ora文件配置: dcsopen =   (DESCRIPTION =     (ADDRESS_LIST =       (ADDRESS = (PROTOCOL = TCP)(HOST = 172.101.19.57)(PORT = 1521))     )     (CONNECT_DATA =       (SERVICE_NAME = dcsopen)     )   ) 3. 使用tnsping dcsopen测试,报错: ora11g>tnsping dcsopen TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 08-JAN-2015 00:38:55 Copyright (c) 1997, 2009, Oracle.  All rights reserved. Used parameter files: /opt/app/ora11g/product/11.2.0/dcsopen/network/admin/sqlnet.ora TNS-03505: Failed to resolve name 4. 使用sqlplus登

    03
    领券