代码改变世界

Linux 平台静默安装 Oracle客户端

2016-04-25 20:59  AlfredZhao  阅读(...)  评论(... 编辑 收藏

需求:Linux平台,安装完整版Oracle客户端
Tips:如果只是用到sqlldr,sqlplus功能,可以参考《Linux上oracle精简版客户端快速部署》快速部署精简版;如果需要用到proc等其他功能,建议安装完整版客户端。

环境:RHEL5.4 + Oracle client 11.2.0.1

1.安装前检查

1.1 依赖包

比如RHEL5的依赖包需求:

rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat 

建议官方要求的这些依赖包都要安装上。

1.2 其他信息检查

服务器的目录空间和规划、主机CPU、内存等信息。这些一般都符合要求。
主要就是确定接下来的客户端介质的解压目录以及之后客户端安装的目录。
我这里根据实际环境设定的:
客户端安装介质解压目录:/opt/oclient
客户端的安装目录:/opt/app/oracle/11.2/client

2.配置响应文件

默认的响应文件在解压的目录下的client/response目录下,比如这里是/opt/oclient/client/response/client_install.rsp,内容如下:

$ more /opt/oclient/client/response/client_install.rsp
###############################################################################
## Copyright(c) Oracle Corporation 1998,2008. All rights reserved.           ##
##                                                                           ##
## Specify values for the variables listed below to customize                ##
## your installation.                                                        ##
##                                                                           ##
## Each variable is associated with a comment. The comment                   ##
## can help to populate the variables with the appropriate                   ##
## values.                                                                   ##
##                                                                           ##
###############################################################################

#-------------------------------------------------------------------------------
# Do not change the following system generated value. 
#-------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_clientinstall_response_schema_v11_2_0

#-------------------------------------------------------------------------------
# This variable holds the hostname of the system as set by the user. 
# It can be used to force the installation to use an alternative   
# hostname rather than using the first hostname found on the system
# (e.g., for systems with multiple hostnames and network interfaces).
ORACLE_HOSTNAME=ora-client-001
#-------------------------------------------------------------------------------
# Unix group to be set for the inventory directory.  
UNIX_GROUP_NAME=oracle
#-------------------------------------------------------------------------------
# Inventory location.
INVENTORY_LOCATION=/opt/app/oraInventory
#-------------------------------------------------------------------------------
# Languages in which the components will be installed.             
#
# en   : English                  ja   : Japanese                  
# fr   : French                   ko   : Korean                    
# ar   : Arabic                   es   : Latin American Spanish    
# bn   : Bengali                  lv   : Latvian                   
# pt_BR: Brazilian Portuguese     lt   : Lithuanian                
# bg   : Bulgarian                ms   : Malay                     
# fr_CA: Canadian French          es_MX: Mexican Spanish           
# ca   : Catalan                  no   : Norwegian                 
# hr   : Croatian                 pl   : Polish                    
# cs   : Czech                    pt   : Portuguese                
# da   : Danish                   ro   : Romanian                  
# nl   : Dutch                    ru   : Russian                   
# ar_EG: Egyptian                 zh_CN: Simplified Chinese        
# en_GB: English (Great Britain)  sk   : Slovak                    
# et   : Estonian                 sl   : Slovenian                 
# fi   : Finnish                  es_ES: Spanish                   
# de   : German                   sv   : Swedish                   
# el   : Greek                    th   : Thai                      
# iw   : Hebrew                   zh_TW: Traditional Chinese       
# hu   : Hungarian                tr   : Turkish                   
# is   : Icelandic                uk   : Ukrainian                 
# in   : Indonesian               vi   : Vietnamese                
# it   : Italian                                                   
#
# Example : SELECTED_LANGUAGES=en,fr,ja
#-------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN
#-------------------------------------------------------------------------------
# Complete path of the Oracle Home  
ORACLE_HOME=/opt/app/oracle/11.2/client
#-------------------------------------------------------------------------------
# Complete path of the Oracle Base. 
ORACLE_BASE=/opt/app/oracle
#-------------------------------------------------------------------------------
#Name       : INSTALL_TYPE
#Datatype   : String
#Description: Installation type of the component.
#
#             The following choices are available. The value should contain
#             only one of these choices.
#             InstantClient : InstantClient
#             Administrator : Administrator
#             Runtime       : Runtime
#             Custom        : Custom
#
#Example    : INSTALL_TYPE = "Administrator"
#------------------------------------------------------------------------------
oracle.install.client.installType=Administrator
#-------------------------------------------------------------------------------
# Name       : oracle.install.client.customComponents
# Datatype   : StringList
#
# This property is considered only if INSTALL_TYPE is set to "Custom"
#
# Description: List of Client Components you would like to install
#
#   The following choices are available. You may specify any
#   combination of these choices.  The components you choose should
#   be specified in the form "internal-component-name:version"
#   Below is a list of components you may specify to install.
#
# oracle.sqlj:11.2.0.1.0 -- "Oracle SQLJ"
# oracle.rdbms.util:11.2.0.1.0 -- "Oracle Database Utilities"
# oracle.javavm.client:11.2.0.1.0 -- "Oracle Java Client"
# oracle.sqlplus:11.2.0.1.0 -- "SQL*Plus"
# oracle.dbjava.jdbc:11.2.0.1.0 -- "Oracle JDBC/THIN Interfaces"
# oracle.ldap.client:11.2.0.1.0 -- "Oracle Internet Directory Client"
# oracle.rdbms.oci:11.2.0.1.0 -- "Oracle Call Interface (OCI)"
# oracle.precomp:11.2.0.1.0 -- "Oracle Programmer"
# oracle.xdk:11.2.0.1.0 -- "Oracle XML Development Kit"
# oracle.network.aso:11.2.0.1.0 -- "Oracle Advanced Security"
# oracle.assistants.oemlt:11.2.0.1.0 -- "Enterprise Manager Minimal Integration"
# oracle.oraolap.mgmt:11.2.0.1.0 -- "OLAP Analytic Workspace Manager and Worksheet"
# oracle.network.client:11.2.0.1.0 -- "Oracle Net"
# oracle.network.cman:11.2.0.1.0 -- "Oracle Connection Manager"
# oracle.network.listener:11.2.0.1.0 -- "Oracle Net Listener"
# oracle.ordim.client:11.2.0.1.0 -- "Oracle Multimedia Client Option"
# oracle.ons:11.2.0.0.0 -- "Oracle Notification Service"
# oracle.odbc:11.2.0.1.0 -- "Oracle ODBC Driver"
# oracle.has.client:11.2.0.1.0 -- "Oracle Clusterware High Availability API"
# oracle.dbdev:11.2.0.1.0 -- "Oracle SQL Developer"
# oracle.rdbms.scheduler:11.2.0.1.0 -- "Oracle Scheduler Agent"
#
#-------------------------------------------------------------------------------
oracle.install.client.customComponents="oracle.sqlj:11.2.0.1.0","oracle.rdbms.util:11.2.0.1.0","oracle.javavm.client:11.2.0.1.0","oracle.sqlplus:11.2.0.1.0","oracle.db
java.jdbc:11.2.0.1.0","oracle.ldap.client:11.2.0.1.0","oracle.rdbms.oci:11.2.0.1.0","oracle.precomp:11.2.0.1.0","oracle.xdk:11.2.0.1.0","oracle.network.aso:11.2.0.1.0"
,"oracle.assistants.oemlt:11.2.0.1.0","oracle.oraolap.mgmt:11.2.0.1.0","oracle.network.client:11.2.0.1.0","oracle.network.cman:11.2.0.1.0","oracle.network.listener:11.
2.0.1.0","oracle.ordim.client:11.2.0.1.0","oracle.ons:11.2.0.0.0","oracle.odbc:11.2.0.1.0","oracle.has.client:11.2.0.1.0","oracle.dbdev:11.2.0.1.0","oracle.rdbms.sched
uler:11.2.0.1.0"
#-------------------------------------------------------------------------------
#Name       : MTS_PORT
#Datatype   : int 
#Description: Port number to be used for by the Oracle MTS Recovery Service to listen
#             for requests. This needs to be entered in case oracle.ntoramts is 
#             selected in the list of custom components in custom install
#
#
#Example    : MTS_PORT = 2030
#------------------------------------------------------------------------------
oracle.install.client.oramtsPortNumber=

#------------------------------------------------------------------------------
# Host name to be used for by the Oracle Scheduler Agent.
# This needs to be entered in case oracle.rdbms.scheduler is selected in the
# list of custom components during custom install
#
# Example    : oracle.install.client.schedulerAgentHostName = acme.domain.com
#------------------------------------------------------------------------------
oracle.install.client.schedulerAgentHostName=

#------------------------------------------------------------------------------
# Port number to be used for by the Oracle Scheduler Agent.
# This needs to be entered in case oracle.rdbms.scheduler is selected in the
# list of custom components during custom install
#
# Example: oracle.install.client.schedulerAgentPortNumber = 1500
#------------------------------------------------------------------------------
oracle.install.client.schedulerAgentPortNumber=

上面看起来内容较多,实际上主要就根据实际环境修改了这些值,其他默认或不填即可:

ORACLE_HOSTNAME=ora-client-001
UNIX_GROUP_NAME=oracle
INVENTORY_LOCATION=/opt/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/app/oracle/11.2/client
ORACLE_BASE=/opt/app/oracle
oracle.install.client.installType=Administrator

3.静默安装客户端

切换到安装目录下,执行下面的命令静默安装客户端

./runInstaller -silent -responseFile /opt/oclient/client/response/client_install.rsp

根据提示,最后用root用户执行两个脚本,比如这里是:

 # /opt/app/oracle/oraInventory/orainstRoot.sh
 # /opt/app/oracle/11.2/client/root.sh

4.配置环境变量

/bin/csh环境变量: vi ~/.cshrc

setenv ORACLE_HOME /opt/app/oracle/11.2/client
setenv NLS_LANG "simplified chinese_china.ZHS16GBK"
setenv NLS_DATE_FORMAT "YYYY-MM-DD HH24:Mi:SS"
setenv LD_LIBRARY_PATH $ORACLE_HOME/lib
setenv PATH $ORACLE_HOME/bin:$PATH

最后测试下确定proc命令可用。

$ proc

Pro*C/C++: Release 11.2.0.1.0 - Production on 星期一 4月 25 14:04:52 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

系统默认选项值取自于:  /opt/app/oracle/11.2/client/precomp/admin/pcscfg.cfg

选项名称       当前值         说明
-------------------------------------------------------------------------------
auto_connect   否             允许自动连接到 ops$ 帐户
char_map       charz          正在映射字符数组和字符串
close_on_commit否             关闭所有 COMMIT 游标
cmax           100            用于连接池的 CMAX 值
cmin           2              用于连接池的 CMIN 值
cincr          1              用于连接池的 CINCR 值
ctimeout       0              用于连接池的 CTIMEOUT 值
cnowait        0              用于连接池的 CNOWAIT 值
common_parser  否             使用 Common SQL Front End 进行语法分析
code           kr_c           所要生成的代码类型
comp_charset   multi_byte     C 编译器支持的字符集类型
config         default        使用另一配置文件覆盖系统配置文件
cpool          否             支持连接共享
cpp_suffix     *none*         覆盖默认的 C++ 文件名后缀
db2_array      否             支持 DB2 数组插入/选择语法
dbms           native         v6/v7/v8 兼容模式
def_sqlcode    否             生成 '#define SQLCODE sqlca.sqlcode' 宏
define         __x86_64__     定义预处理程序符号
               *none*                                                           
duration       transaction    设置高速缓存中的对象的连接持续时间
dynamic        oracle         指定 Oracle 或 ANSI 动态 SQL 语义
errors         是             错误消息是否发送到终端
errtype        *none*         intype 文件错误的列表文件名
events         否             支持发布-订阅事件通知
fips           none           ANSI 不兼容用法的 FIPS 标志
header         *none*         指定预编译标头的文件扩展名
hold_cursor    否             控制游标高速缓存中的游标存留数
implicit_svpt  否             在缓冲的插入之前的隐式保存点
iname          *none*         输入文件的名称
include        *none*         所含文件的目录路径
intype         *none*         类型信息的输入文件名
lines          否             向生成的代码添加若干行指令
lname          *none*         覆盖默认列表文件名
ltype          short          在列表文件生成的数据量
maxliteral     1024           生成的字符串字面量的最大长度
maxopencursors 10             高速缓存的打开游标的最大数量
max_row_insert 0              要在插入时缓冲的最大行数
mode           oracle         代码对 Oracle 或 ANSI 规则的顺应性
native_types   否             本机浮点/双精度支持
nls_char       *none*         指定国家语言字符变量
nls_local      否             控制如何完成 NLS 字符语义
objects        是             支持对象类型
oname          *none*         输出文件的名称
oraca          否             控制 ORACA 的使用
outline        no             在其中创建大纲的类别 [yes/no/<category name>]
outlnprefix    *none*         大纲名称前缀
pagelen        80             列表文件的页长度
parse          full           控制对哪一 非 SQL 代码进行语法分析
prefetch       1              在游标 OPEN 时预先提取的行数
release_cursor 否             控制从游标高速缓存释放的游标数
runoutline     否             如果是, 则在数据库中创建大纲
select_error   是             控制选择错误的标志
sqlcheck       syntax         编译时 SQL 的检查量
stmt_cache     0              语句高速缓存的大小
sys_include    /usr/lib64/gcc/系统标头文件所在的目录
               /usr/lib64/gcc/x86_64-suse-linux/4.1.0/include                   
               /usr/lib/gcc/x86_64-redhat-linux/4.1.1/include                   
               /usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/include               
               /usr/include                                                     
               $ORACLE_HOME/precomp/public                                      
threads        否             表示多线程的应用程序
type_code      oracle         使用 Oracle 或动态 SQL 的 ANSI 类型代码
unsafe_null    否             允许不使用指示符表列的 NULL 提取
userid         *none*         用户名/口令 [@dbname] 连接字符串
utf16_charset  nchar_charset  由 UTF16 变量使用的字符集表单
varchar        否             允许使用隐式 varchar 结构
version        recent         要返回哪一版本的对象
PCC-F-02135, CMD-LINE: 用户请求帮助