Windows下手动配置Oracle Client的要点

Windows下手动配置Oracle Client的要点

我的Windows上原有Oracle 9的客户端, 想使用cx_Oracle和python些点东西, cx_Oracle官网上没有for python2.7和Oracle9的安装包, 但有for oracle10的安装包. 所以需要先安装Oracle 10 client.

可能是因为卸载Oracle 9的客户端失败, 导致安装Oracle 10 client报一些错误. 重装多次, 仍然无法使用

google到一个解决方案. 博客: 免安装oracle客户端连接数据库服务器的方法
http://blog.csdn.net/xutong/article/details/2293857

这个文章很管用, 我照着做完后, 就搞定了. 因为程序文件已经安装完毕, 需要做的仅仅是一些手工配置.

-------------------------
第一步: 编辑oracle.key文件
-------------------------
C://ORACLE/Ora10//bin//oracle.key 指明了在注册表中Oracle程序的存储目录,用记事本便可打开对其进行编辑,通常情况下的设置为:
SOFTWARE\oracle_reg
这样设置后, Oracle连接数据库时会到注册表的 HKEY_LOCAL_MACHINE/SOFTWARE/oracle_reg 的对应项中查找数据库的相关信息.oracle_reg 其实可以是任何字符串, 只要注册表也保持一致就行.

-------------------------
第二步: 注册数据库信息
-------------------------
完成以上工作后,只需在注册表中写入Oracle数据库的语言环境和资源路径,应用程序便可以连接Oracle数据库,无需设置操作系统的环境变量,注册表信息的保存位置应与 oracle.key 文件中设定的项值对应,注册表的清单如下:

[HKEY_LOCAL_MACHINE/SOFTWARE/oracle_reg]
"ORACLE_HOME"="C://ORACLE/Ora10"
"NLS_LANG"="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"

SIMPLIFIED  CHINESE_CHINA.ZHS16GBK                          表示使用简体中文字符集。应用程序和连接Oracle数据库所需的文件存放在C://ORACLE/Ora10目录下,即应用程序的安装目录。

-------------------------
第3步: 配置操作系统的环境
-------------------------
===PATH环境变量(必须)
因为Jdbc等连接技术都用到oci.dll, 所以需要把oci.dll放置到Windows的PATH环境变量中(for Linux is LD_LIBRARY_PATH, for AIX is LIBPATH, for HP-UX is SH_LIB_PATH)
Windows下oci.dll其实已经复制到C://ORACLE/Ora10//bin/了, 所以只需要将该目录加到PATH环境变量中.
****为了不让Windows使用优先使用新版的oci.dll, 一定要将oracle10的路径放在Oracle9路径之前.

===CLASSPATH环境变量
如果使用jdbc的话, 最好设置CLASSPATH环境变量, 将C:\oracle\ora10\jdbc\lib\ojdbc14.jar加入.

===TNS_ADMIN环境变量(不是必须的)
c:\oracle\oraDb10_home1\network\admin

===ORACLE_HOME环境变量(不推荐设置)
按照Oracle官方讲法, 在windows下不推荐使用这个ORACLE_HOME环境变量.
 
之后, 使用tnsping就可以解析了. 


-------------------------
下面附上在Windows/Unix上, 查找tnsnames.ora的搜索路径.
-------------------------
For Windows users, the search order is a bit different.
markrem markrem is offline
Registered User
         
Join Date: Sep 2003
Location: Virginia, USA
Posts: 246
For UNIX users, the order in which Oracle searches locations for Oracle Net files like sqlnet.ora and tnsnames.ora are in this order:
1. $HOME for hidden files only (i.e., .sqlnet.ora and .tnsnames.ora)
2. $TNS_ADMIN
3. $HOME
4. /etc or /var/opt/oracle (depends on platform)
5. $ORACLE_HOME/network/admin

For Windows users, the search order is a bit different. It goes like this,
1. current path (associated with the running client application)
2. Environment variable TNS_ADMIN defined for the session
3. Environment variable TNS_ADMIN defined for the system
4. Windows Registry Key TNS_ADMIN
5. %ORACLE_HOME%\network\admin

Now, from what I've read of the posts you are using Windows. If you do nothing (i.e., don't define TNS_ADMIN anywhere) then Oracle will look in the default location %ORACLE_HOME%\network\admin. On most windows computers this is something like c:\oracle\oraDb10_home1\network\admin. If you are unsure what your Oracle Home is, just look in the registry under HKLM/software/oracle for a hive named either HOME0 for Oracle 9i, or a hive named using the value you supplied during installlation of Oracle. In that hive will be a key named ORACLE_HOME.

I strongly recommend against setting TNS_ADMIN as a system variable. I believe Oracle does too. You really should stick to registry keys, since some Oracle apps won't pickup TNS_ADMIN as a system variable.
__________________
MarkRem
Author, Oracle Database 10g: From Nuts to Soup

posted @ 2011-10-06 10:36  harrychinese  阅读(1684)  评论(0编辑  收藏  举报