欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Oracle 配置远程访问教程

程序员文章站 2022-06-24 23:03:06
服务端配置 如果不想自己写,可以通过 net manager 来配置. 以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问. 1.网络监听配置...

服务端配置

如果不想自己写,可以通过 net manager 来配置.

以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问.

1.网络监听配置

# listener.ora network configuration file: c:\app\administrator\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 = c:\app\administrator\product\11.2.0\dbhome_1)
  (program = extproc)
  (envs = "extproc_dlls=only:c:\app\administrator\product\11.2.0\dbhome_1\bin\oraclr11.dll")
 )
 )
listener =
 (description_list =
 (description =
  (address = (protocol = ipc)(key = extproc1521))
  (address = (protocol = tcp)(host = localhost)(port = 1521))
 )
 )
adr_base_listener = c:\app\administrator

多个ip时,如下:

listener =
 (description_list =
 (description =
  (address = (protocol = ipc)(key = extproc1521))
 )
 (description =
  (address = (protocol = tcp)(host = 172.24.226.2)(port = 1521))
 )
 (description =
  (address = (protocol = tcp)(host = 172.24.226.3)(port = 1521))
 )
 )

2.tns 配置

# tnsnames.ora network configuration file: c:\app\administrator\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# generated by oracle configuration tools.
orcl=
 (description =
 (address = (protocol = tcp)(host = localhost)(port = 1521))
 (connect_data =
  (server = dedicated)
  (service_name = orcl)
 )
 )
oraclr_connection_data =
 (description =
 (address_list =
  (address = (protocol = ipc)(key = extproc1521))
 )
 (connect_data =
  (sid = clrextproc)
  (presentation = ro)
 )
 )
listener_orcl =
 (address = (protocol = tcp)(host = localhost)(port = 1521))

多个ip时,如下:

orcl =
 (description =
 (address_list =
  (address = (protocol = tcp)(host = 172.24.226.2)(port = 1521))
  (address = (protocol = tcp)(host = 172.24.226.3)(port = 1521))
 )
 (source_route = yes)
 (connect_data =
  (server = dedicated)
  (service_name = orcl)
 )
 )

3.停止和启动服务

先停止以下服务,然后再启动.

oracleoradb11g_hometnslistener
oracleservice*

客户端配置

1.下载 odac 压缩包.

2.解压下载的 odac 压缩包.

3.执行安装命令

示例:

install.bat all d:\program\odac\12040x64 oraclehome true

4.添加环境变量

oracle_home : 是 odac 安装的目录.

tns_admin : 是文件 tnsnames.ora 所在的目录,一般为 odac 安装目录下的 network\admin 中.

注: tns_admin 可以不用添加,直接将 tnsnames.ora 文件复制到 odac 安装目录下即可

将 %oracle_home% 添加到 path 环境变量中.

5.配置 tns

在配置文件 tnsnames.ora 中加入

dborcl =
 (description =
 (address = (protocol = tcp)(host = <db-host>)(port = 1521))
 (connect_data =
  (server = dedicated)
  (service_name = <db-name>)
 )
 )

说明:

<db-host> : 数据库电脑的ip或者是计算机名
<db-name> : 数据库tns配置的名称

总结

以上所述是小编给大家介绍的oracle 配置远程访问教程,希望对大家有所帮助