远程连接Oracle配置

2020-05-11   155 次阅读


今儿开发同事需要连接我的Oracle数据库进行开发,让我设置一下Oracle的远程连接。虽然设置的时候还让Oralce崩了一次,但是问题不大,解决了问题,再次记录一下:

在%ORALCE_PATH%\NETWORK\ADMIN 路径下找到 listener.ora 和 tnsnames.ora 两个文件。本的只新增不修改之前配置的原则,在listener.ora 文件加入 配置:

 (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(DESKTOP-MS3DUV7 = 127.0.0.1)(PORT = 1521))
    )

其中:
DESKTOP-MS3DUV7 是当前电脑的电脑名(桌面--此电脑--右键--属性 -- 计算机全名)
127.0.0.1: 本地地址

完整文件:

# listener.ora Network Configuration File: D:\app\HJ\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = CLRExtProc)
      (ORACLE_HOME = D:\app\HJ\product\11.2.0\dbhome_1)
      (PROGRAM = extproc)
      (ENVS = "EXTPROC_DLLS=ONLY:D:\app\HJ\product\11.2.0\dbhome_1\bin\oraclr11.dll")
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(DESKTOP-MS3DUV7 = 127.0.0.1)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = D:\app\HJ

在tnsnames.ora 文件加入 配置:

TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(DESKTOP-MS3DUV7 = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

其中:
DESKTOP-MS3DUV7 是当前电脑的电脑名(桌面--此电脑--右键--属性 -- 计算机全名)
127.0.0.1: 本地地址
SERVICE_NAME : 指向是ORCL数据库

文件文件内容:

# tnsnames.ora Network Configuration File: D:\software\Oracle\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(DESKTOP-MS3DUV7 = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

Q.E.D.

知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

一个萌新程序猿