天天看點

Linux 平台靜默安裝 Oracle用戶端 1.安裝前檢查 2.配置響應檔案 3.靜默安裝用戶端 4.配置環境變量

需求:Linux平台,安裝完整版Oracle用戶端

Tips:如果隻是用到sqlldr,sqlplus功能,可以參考《Linux上oracle精簡版用戶端快速部署》快速部署精簡版;如果需要用到proc等其他功能,建議安裝完整版用戶端。

環境:RHEL5.4 + Oracle client 11.2.0.1

  • 1.安裝前檢查
  • 2.配置響應檔案
  • 3.靜默安裝用戶端
  • 4.配置環境變量

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: 使用者請求幫助