AIX安装Oracle 11g客户端、Pro*C/C++编译环境
- 安装准备:
- 安装过程:
- 将解压出来的instantclient_11_1目录整个上传至AIX用户目录下。
- 添加ORACLE_HOME等环境变量。
- 建立TNS文件。
- 测试
在.profile中添加如下内容:
export ORACLE_HOME=$HOME/instantclient_11_1 export ORACLE_SID=orcl export LD_LIBRARY_PATH=$ORACLE_HOME:${LD_LIBRARY_PATH} export PATH=$ORACLE_HOME:$ORACLE_HOME/sdk:$PATH
mkdir -p $ORACLE_HOME/network/admin touch $ORACLE_HOME/ network/admin/tnsnames.ora 编辑tnsnames.ora内容大致如下: orcl = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.1.2.202)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
sqlplus unionkms@orcl SQL*Plus: Release 11.1.0.7.0 - Production on Wed Feb 23 16:41:07 2011 Copyright (c) 1982, 2008, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production With the Partitioning, OLAP and Data Mining options SQL> desc branch; Name Null? Type ----------------------------------------- -------- ---------------------------- UNID NOT NULL CHAR(40) UNBRANCHTYPEID NOT NULL CHAR(40) UNBRANCHFIELD NUMBER(38) UNBRANCHID CHAR(50) UNKMCID CHAR(40) UNIDOFMNGSVR CHAR(40) UNSECUSERVICESVRID CHAR(40) UNMONITORSVRID CHAR(40) UNMANAGER CHAR(128) UNPHONE CHAR(128) UNFAX CHAR(128) UNEMAIL CHAR(128) UNHTTPADDR VARCHAR2(256) UNREMARK CHAR(128) UNINPUTTELLER CHAR(20) UNINPUTDATE CHAR(8) UNINPUTTIME CHAR(6) UNUPDATETELLER CHAR(20) UNUPDATEDATE CHAR(8) UNUPDATETIME CHAR(6) SQL>
Pro*C文件pc_test中。
pcscfg.cfg :
sys_include=(/u2/chenlong/instantclient_11_1/sdk/include,/usr/include) ltype=short define=__64BIT__ define=_IBM_C define=_LONG_LONG
a1.pc :
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "sqlca.h" int main(void) { EXEC SQL INCLUDE sqlca; EXEC SQL BEGIN DECLARE SECTION; char *user = "unionkms"; char *passwd = "unionkms"; char *db = "orcl"; EXEC SQL END DECLARE SECTION; EXEC SQL CONNECT :user IDENTIFIED BY :passwd USING :db; if (sqlca.sqlcode == 0) printf("connect success!\n"); else printf("connect fail!\n"); return 0; }
makefile :
all: a1.pc proc config=pcscfg.cfg iname=a1.pc cc -q64 -I /u2/chenlong/instantclient_11_1/sdk/include/ -c a1.c cc -q64 -L/u2/chenlong/instantclient_11_1/ -lclntsh -o a1 a1.o clean: rm a1.lis a1.o
(转载时请注明作者和出处。未经许可,请勿用于商业用途)
更多文章请访问我的Blog: http://www.cnblogs.com/logicbaby
首先需要确定AIX版本是否满足Oracle 11g客户端安装的最低要求,可查看Oracle官网相关文档(http://download.oracle.com/docs/cd/B28359_01/install.111/b32334/toc.htm#CHDFFBIF),处说明了Oracle 11g Release 1客户端对操作系统的最低要求为:
AIX 5L version 5.3, TL 05, Service Pack 06 AIX 6L version 6.1, TL 00, Service Pack 04 or later
文档(http://download.oracle.com/docs/cd/E11882_01/install.112/e18192/toc.htm#CIHFICFD)处说明了Oracle 11g Release 2客户端对操作系统的最低要求为:
AIX 5L V5.3 TL 09 SP1 ("5300-09-01"), 64 bit kernel AIX 6.1 TL 02 SP1 ("6100-02-01), 64-bit kernel AIX 7.1 TL 0 SP1 ("7100-00-01"), 64-bit kernel
AIX上可以使用oslevel或oslevel -s查看 AIX具体版本信息。如果已确认了操作系统版本,但报aio(异步IO)相关错误可参考网上另一篇文章处理,请大家自己google之。公司服务器AIX版本为5300-06-01-0000,故只能安装release 1的客户端此处以安装Oracle 11g release 1 64位客户端为例。
首先需要从http://www.oracle.com/technetwork/topics/aix5lsoft-098883.html 下载
basic-11.1.0.7.0-aix-ppc64.zip sdk-11.1.0.7.0-aix-ppc64.zip sqlplus-11.1.0.7.0-aix-ppc64.zip tools-11.1.0.7.0-aix-ppc64.zip precomp-11.1.0.7.0-aix-ppc64.zip
AIX不自带unzip等程序,可在 windows机器上全部解压,解压后生成文件夹instantclient_11_1。