环境本地win 10系统不装oracle数据库 ,远端:本地VM 虚拟机安装的win7 系统,网络为桥接模式【最好路由器配置固定IP给虚拟机,或者直接在虚拟机系统里面写好固定的IP】 服务端: VM里面的oracle监听配置tnsnames.ora,注意所有改动必须都要重启oracle数据库,只重启监听是没有用的:
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.116)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.116)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
本地instantclient里面instantclient里面的network\ADMIN的tnsnames.ora和上面的一样的即可,如果没有,则下载instantclient后新建两个文件夹,一个是network,并在其里面新建admin,两个文件夹忽略大小写。在admin里面直接拷贝tnsnames.ora过来,里面的IP为虚拟机里面系统获取到的IP。之后在PL SQL 的首选项里面配置instantclient相应的oci.dll ,然后关闭pl sql重新打开即可链接远端的oracle 。 如果使用PLSQL时出现出现中文乱码,则 添加本地系统的环境变量NLS_LANG ,值为SIMPLIFIED CHINESE_CHINA.ZHS16GBK
服务端配置
如果不想自己写,可以通过 Net Manager 来配置.
以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问.
1.网络监听配置
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 = 192.168.0.116)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.117)(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 = )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = )
)
)
说明:
-
数据库电脑的IP或者是计算机名
-
数据库TNS配置的名称
https://blog.csdn.net/asdfghzqlj/article/details/69666610 https://blog.csdn.net/weixin_30563917/article/details/101077851 https://blog.csdn.net/zhige_j/article/details/80832654
|