今天开发人员发过来个问题,如题,现场是64位oracle+64位数据库主机+(32/64位?具体不能确定)应用+64位应用中间件服务器+32位oracle客户端。
这个问题按照字面来理解,就是安装了32位oracle客户端,但是试图以64位模式来运行。
百度了一圈,要么说改path,要么说安装64位客户端。众说纷纭,但是实际上都是针对当时作者所处的应用环境,来解决当时问题的方法,其他人照搬过来不一定能解决自己的问题。因此不能说这些方法错误,但至少没有触及到核心问题。既然让我碰见了,我来试着从从头到尾阐述一遍。
首先,问题的核心是:32位的oracle客户端,但是应用试图以64位的方式来调用。这是导致问题的本质。
然后,我们来说一说原理:
1,oracle数据库与oracle客户端之间没有32与64位版本匹配的问题,也就是说32位客户端可以访问64位数据库,反之亦然。
2,oracle客户端的32位与64位版本,需要与调用方一致。也就是说32位的程序使用32位客户端;64位的程序,使用64位客户端。这里我们需要了解一点,同一个程序,可能在开发的时候,使用32位,在生产部署的时候,会变成使用64位。这个我不是资深开发,不做过多讲解,后文会有专业文档说明。
3,同一个服务器主机,可以安装两个版本(32位/64位)的客户端,但是需要安装在不同oracle_home目录下,并且在安装完成后需要将两个oracle_home路径维护到path路径中。这里特别强调,两个oracle_home出现在path的前后顺序没有要求,任意。安装的时候,不能使用GUI的方式安装,需要使用命令行方式安装。因为GUI不提供设置oracle_home的功能。
这里补充一点:windows通过SYSWOW64子系统,提供了在64位windows系统上运行32位应用的能力,这么变态的行为,是给我们广大程序员造成崩溃的祸乱之源。哈哈。那么怎么看我们的程序是运行在32位或者64位之下呢?真相就藏在任务管理器中:打开进程选项卡,在进程名这一栏,如果进程名后面多了“ *32”,这样的字符,那就表示是跑在32位模式下了。如果没有的话,就是64位模式运行。
好了,原理说完了,其实理解了原理,解决方法也在里面了。各位看官是否理解?
2019年双12更新:
看到有人说问题看懂了但是没法解决,我想补充两点:
1,32位的程序需要安装32位的oracle客户端。这个必须要有,也好理解;
2,如果主机上已经装了64位的客户端,可以按照下文所述的安装方法,通过命令行的方式,指定一个新的oracle_home,将32位的客户端安装到新目录下。这样,同一台主机上就同时存在了64位与32位客户端。像这种共存的情况,需要设置windows环境变量ORACLE_HOME来指向32位的客户端。否则程序运行的时候,可能仍会找到64的客户端,并且问题仍无法解决。
setup.exe ORACLE_HOME_NAME=OraHome11g_client64
这里附上oracle官方对这个问题的说明文档。供有需要的人观看。谢谢!
Considerations Using The Oracle Client With Microsoft Products on 64 bit Windows Operating System (文档 ID 781432.1) | ![]() | ![]() |
In this Document
APPLIES TO:Oracle Database Extensions for .NET - Version 10.2.0.3.0 and laterOracle Provider for OLE DB - Version 9.2.0.1 and later Oracle Data Provider for .NET - Version 9.2.0.2 and later Oracle Providers for ASP.NET - Version 11.1.0.6.20 and later Oracle Objects for OLE - Version 9.2.0.1 and later Microsoft Windows x64 (64-bit) Microsoft Windows Itanium (64-bit) PURPOSEThe purpose of this note is to discuss some of the Oracle specific considerations and issues that occur when using Oracle client with Microsoft products on a 64 bit operating system, their solutions, and notes for further reference. QUESTIONS AND ANSWERSBackground With the introduction of 64 bit Windows operating system, Microsoft provides the ability to run 32 bit applications via the SYSWOW64 subsystem. As both 64 bit and 32 bit applications can be run on a 64 bit operating system, issues may be encountered if the correct bit version of the Oracle client software is not installed to meet your specific requirements. Example: Using Visual Studio and ODP.NET : using Server Explorer inside Visual Studio requires a 32 bit Oracle client install as the Visual Studio IDE is 32 bit. Debugging an application in Visual Studio requires a 64 bit Oracle client install : although you're using the 32 bit IDE, the 64 bit host runtime is invoked. Running the resulting application/executable outside Visual Studio requires the appropriate bit version for the platform you're running the application on; if running on a 64 bit OS, you'll need a 64 bit Oracle client install. The same scenario applies to developing SSIS packages with Oracle's OLEDB provider. IIS applications run as 64 bit on a 64 bit Operating system by default, so 64 bit Oracle client software is needed. In the case of Oracle Objects for Ole for example, which has only a 32 bit version, IIS will need to be configured to run as 32 bit (see below).
64 bit applications require 64 bit Oracle Client software, and 32 bit applications require 32 bit Oracle client software. Oracle does not currently provide a single bundle that will install both 32 bit and 64 bit Oracle client, so in order to run both 32 bit and 64 bit applications on the same operating system both 32 bit and 64 bit Oracle client software will need to be installed as separate steps, and the installs need to go into separate Oracle homes. Please note: that there is currently an issue where installing both 32 bit and 64 bit client on the same box will cause the second installation to overwrite the Start Menu shortcuts of the first installation if separate Oracle Home names are not used. 11.2 does not give you the opportunity to set the Oracle Home names via the OUI, but you can pass it as a command line argument, Additionally, while both homes can share an ORACLE_BASE and function correctly, separate ORACLE_BASEs should be used due to issues when de-installing one client but not the other, as documented in <Bug:10360738>
-The 64 bit Oracle home will be setup in the registry in the following location: Earlier versions of Oracle client software had a known bug that resulted in a ora-6413 or ora-12154 when an application was run from a path containing parenthesis, which is the default location for installation of 32 bit applications on a 64 bit operating system - Program Files (x86). Applying the latest patches to the client install should resolve this issue. For more information refer to Note.334528.1.
Specific considerations regarding specific Oracle Products Oracle ODBC Driver- The 32 bit ODBC driver framework and 64 bit ODBC driver framework are separate and distinct. To use the Oracle ODBC driver with a 32 bit application, the 32 bit driver and Oracle client need to be installed, and the 32 bit ODBC administrator must used to setup a 32 bit DSN. See Note 308645.1for more information. The ODBC administrator will only show you the Data Source Names (DSN) of the appropriate bitness (32 vs 64) when selecting from a list of SYSTEM DSNs, however USER and FILE DSNs are not stored separately based on architecture, Ensure you're trying to use a dsn that is the proper architecture for your application. Note that the driver dll is named sqora32.dll in both 32 bit and 64 bit cases, and there is no sqora64.dll On Windows 7, the 64 bit regsvr32 utility can be used to register both 32 bit and 64 bit ORAOLEDB, but it needs to be done once for each version . Note however that uninstalling ORAOLEDB (via regsvr32 /u) will uninstall BOTH the 32 bit and 64 oledb provider at the same time, so the other version will need to be re-registered. Numerous recent fixes with respect to metadata and the 64 bit Oracle OLEDB provider reports have occurred. If using OraOledb with SQLServer it is highly recommended to use the latest version to have all the available fixes. See Note 191368.1 for more information on configuring a linked server. Oracle Data Provider for .NET (ODP.NET) - While ODP.NET installs policy files to redirect applications looking for older versions of the provider to the currently installed version, the policy files do not include redirection from versions earlier than 2.102.0.2.20, or applications compiled with ODP 1.x, as .NET framework version of 2.x is the minimum 64 bit version. Explicit redirection by the user can be enabled via the use of a .config file, but by default 1.x .NET applications can only run as 32 bit applications since there is no 1.x framework for x64, and as such require 32 bit software. For more information, please refer to the "ODP.NET Publisher Policy Files, .NET Framework 2.0 Support and Breaking Changes" section of Note 761214.1 The first version of ODP.NET for 64 bit operating system is 10.2.0.3.0. A .NET application developed on a 32 bit operating system can be deployed to a 64 bit operating system without changes. In such cases, 64 bit Oracle software will need to be installed on the deployment target as the default compilation target is Any CPU which will cause .NET applications to run as 64 bit on a 64 bit Operating System, and 32 bit on a 32 bit Operating system. If the application is compiled with a target of "x86", then the application will only run as 32 bit will and require 32 bit ODP.NET and Oracle software to be installed. Corflags.exe can be used to determine the compilation flags. Oracle Objects for OLE (OO4O) - The Oracle Objects for OLE product is not available as a 64-bit product. If you plan to migrate your oo4o applications to 64-bit Windows they will be required to run in 32-bit mode with the 32 bit oracle client. If you are deploying an oo4o web application hosted under IIS 6.0, then you will need to be aware that worker processes within IIS 6.0 will have to be configured to run as 32 bit processes. Note however that 32 bit OO4O on a 64 bit OS is not considered a supported configuration by Oracle. We highly recommend you consider the migration path to the Oracle Data Provider for .NET and rewrite the application to run on the .NET platform. Oracle Developer Tools for Visual Studio (ODT.NET) - Visual Studio is a 32 bit product, even when run on a 64 bit operating system. In order to use Oracle Developer Tools for Visual Studio on a 64 bit operating system, the 32 bit ODAC installation will need to be used and installed. 64 bit Oracle software will need to be installed (into a separate home) to run the resulting program outside the IDE. However, as of this writing, due to Bug 7622155, installing 32 bit ODAC onto a 64 bit operating system results in the wrong Machine.config being updated, which can be worked around by following the suggestions in this thread. Oracle COM Automation Feature - The 64 bit database process can only run 64 bit libraries, so the database cannot run a 32 bit VB dll, for example. |