資料庫靜默安裝總結

dbhelper發表於2014-11-26

在學習資料庫的時候,不知道dbca的命令用了多少遍,但是越是安裝也是覺得自己會的越少,因為圖形介面的清晰直白反而不知道哪些準備工作是需要特別準備的,如果在遠端支援的環境中,圖形介面就會受到網路頻寬的影響,如果在本地的環境中學習的時候,總是提示少這個包,那個包的。其實有很多的安裝包如果不使用圖形介面都不是必須的。個人感觸比較深的一個例子就是安裝的時候缺少報了libXp.so相關的錯誤,結果自己折騰了半天,從網上下載安裝包費了很大的周折才算搞定,最後發現使用靜默安裝就不需要這個包了,基於學習的環境,擺脫圖形介面也是一個好的開始,你需要考慮的東西越多,你就學到的越多。

說到靜默安裝,就不得不提到響應檔案,就是所謂的response file。在oracle,db2的安裝中都有提供響應檔案,這個響應檔案其實就是一個配置檔案。裡面可以配置一些安裝的細節,像dbca裡面能夠看到的安裝選項,在響應檔案中都有體現。你可以透過響應檔案來設定安裝企業版,個人版,標準被,安裝的語言包,安裝的字符集等等。

響應檔案可以透過安裝目錄獲得,比如得到解壓後的安裝包。響應檔案的模板就是db_install.rsp

[oracle@rac1 database]$ pwd
/u02/ora11g/database
[oracle@rac1 database]$ ll
total 64
drwxr-xr-x 12 ora11g dba  4096 Sep 18  2011 doc
drwxr-xr-x  4 ora11g dba  4096 Sep 22  2011 install
-rwxr-xr-x  1 ora11g dba 28122 Sep 22  2011 readme.html
drwxr-xr-x  2 ora11g dba  4096 Sep 22  2011 response
drwxr-xr-x  2 ora11g dba  4096 Sep 22  2011 rpm
-rwxr-xr-x  1 ora11g dba  3226 Sep 22  2011 runInstaller
drwxr-xr-x  2 ora11g dba  4096 Sep 22  2011 sshsetup
drwxr-xr-x 14 ora11g dba  4096 Sep 22  2011 stage
-rwxr-xr-x  1 ora11g dba  5466 Aug 22  2011 welcome.html
[oracle@rac1 database]$ cd response
[oracle@rac1 response]$ ll
total 80
-rwxr-xr-x 1 ora11g ora11g 44533 Sep 22  2011 dbca.rsp
-rwxr-xr-x 1 ora11g ora11g 24992 Sep 22  2011 db_install.rsp
-rwxr-xr-x 1 ora11g ora11g  5871 Sep 22  2011 netca.rsp
以下標黃的部分是在響應檔案中需要格外注意的。可以根據自己的需求和環境來設定
####################################################################
## Copyright(c) Oracle Corporation 1998,2011. 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.                                                        ##
##                                                                ##
## IMPORTANT NOTE: This file contains plain text passwords and    ##
## should be secured to have read permission only by oracle user  ##
## or db administrator who owns this installation.                ##
##                                                                ##
####################################################################

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

#------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# 1. INSTALL_DB_SWONLY
# 2. INSTALL_DB_AND_CONFIG
# 3. UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY

#-------------------------------------------------------------------------------
# Specify the hostname of the system as set during the install. 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=rac1

#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory. 
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba

#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/home/oracle

#-------------------------------------------------------------------------------
# Specify the 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                                                  
#
# all_langs   : All languages
#
# Specify value as the following to select any of the languages.
# Example : SELECTED_LANGUAGES=en,fr,ja
#
# Specify value as the following to select all the languages.
# Example : SELECTED_LANGUAGES=all_langs 
#------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN,th,zh_TW

#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#------------------------------------------------------------------------------
ORACLE_HOME=/home/oracle/ORAHOME

#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#------------------------------------------------------------------------------
ORACLE_BASE=/home/oracle

#------------------------------------------------------------------------------
# Specify the installation edition of the component.                       
#                                                            
# The value should contain only one of these choices.       
# EE     : Enterprise Edition                               
# SE     : Standard Edition                                 
# SEONE  : Standard Edition One
# PE     : Personal Edition (WINDOWS ONLY)
#------------------------------------------------------------------------------
oracle.install.db.InstallEdition=EE

#------------------------------------------------------------------------------
# This variable is used to enable or disable custom install and is considered
# only if InstallEdition is EE.
#
# true  : Components mentioned as part of 'optionalComponents' property
#         are considered for install.
# false : Value for 'optionalComponents' is not considered.
#------------------------------------------------------------------------------
oracle.install.db.EEOptionsSelection=true

#------------------------------------------------------------------------------
# This variable is considered only if 'EEOptionsSelection' is set to true.
#
# Description: List of Enterprise Edition Options you would like to enable.
#
#              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 enable.
#       
#              oracle.oraolap:11.2.0.3.0 - Oracle OLAP
#              oracle.rdbms.dm:11.2.0.3.0 - Oracle Data Mining
#              oracle.rdbms.dv:11.2.0.3.0 - Oracle Database Vault
#              oracle.rdbms.lbac:11.2.0.3.0 - Oracle Label Security
#              oracle.rdbms.partitioning:11.2.0.3.0 - Oracle Partitioning
#              oracle.rdbms.rat:11.2.0.3.0 - Oracle Real Application Testing
#------------------------------------------------------------------------------
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.3.0,oracle.oraolap:11.2.0.3.0,oracle.rdbms.dm:11.2.0.3.0,oracle.rdbms.dv:11.2.0.3.0,oracle.rdbms.lbac:11.2.0.3.0,oracle.rdbms.rat:11.2.0.3.0

###############################################################################
#                                                                             #
# PRIVILEGED OPERATING SYSTEM GROUPS                                          #
# ------------------------------------------                                  #
# Provide values for the OS groups to which OSDBA and OSOPER privileges       #
# needs to be granted. If the install is being performed as a member of the   #
# group "dba", then that will be used unless specified otherwise below.       #
#                                                                             #
# The value to be specified for OSDBA and OSOPER group is only for UNIX based #
# Operating System.                                                           #
#                                                                             #
###############################################################################

#------------------------------------------------------------------------------
# The DBA_GROUP is the OS group which is to be granted OSDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.DBA_GROUP=dba

#------------------------------------------------------------------------------
# The OPER_GROUP is the OS group which is to be granted OSOPER privileges.
# The value to be specified for OSOPER group is optional.
#------------------------------------------------------------------------------
oracle.install.db.OPER_GROUP=dba

#------------------------------------------------------------------------------
# Specify whether user doesn't want to configure Security Updates.
# The value for this variable should be true if you don't want to configure
# Security Updates, false otherwise.
#
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example    : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true

對於靜默安裝 runInstaller是必須的執行檔案,指令碼本身提供了大量的選項。可以透過./runInstaller -help
來看到
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-11-18_04-00-22AM. Please wait ...[oracle@rac1 database]$ Usage:
runInstaller  [-options] [()*]

Where options include:
  -clusterware oracle.crs, 
        Version of Cluster ready services installed.

  -crsLocation  
        Used only for cluster installs, specifies the path to the crs home location. Specifying this overrides CRS information obtained from central inventory.

  -invPtrLoc  
        Unix only. To point to a different inventory location. The orainst.loc file contains:
inventory_loc=
inst_group=<>

  -jreLoc  
。。。。。


安裝的時候,可以使用如下命令。

[oracle@rac1 database]$ ./runInstaller -silent -responsefile /home/oracle/new.rsp -ignoreSysPrereqs
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB.   Actual 993 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-11-18_04-15-07AM. Please wait ...[oracle@rac1 database]$ [WARNING] [INS-32008] Oracle base location cant be same as the user home directory.
   CAUSE: The specified Oracle base is same as the user home directory.
   ACTION: Provide an Oracle base location other than the user home directory.
[WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /u04/app/oraInventory/logs/installActions2014-11-18_04-15-07AM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /u04/app/oraInventory/logs/installActions2014-11-18_04-15-07AM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:
 /u04/app/oraInventory/logs/installActions2014-11-18_04-15-07AM.log

如果響應檔案出現問題,就會出現類似下面的問題。

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-11-18_04-06-16AM. Please wait ...[oracle@rac1 database]$ [FATAL] [INS-10105] The given response file /home/oracle/new.rsp is not valid.
   CAUSE: Syntactically incorrect response file. Either unexpected variables are specified or expected variables are not specified in the response file.
   ACTION: Refer the latest product specific response file template
   SUMMARY:
       - cvc-enumeration-valid: Value '1' is not facet-valid with respect to enumeration '[INSTALL_DB_SWONLY, INSTALL_DB_AND_CONFIG, UPGRADE_DB]'. It must be a value from the enumeration.
cvc-type.3.1.3: The value '1' of element 'oracle.install.option' is not valid.

 這個問題很明顯就是因為響應檔案中的設定錯誤。有INSTALL_DB_SWONLY, INSTALL_DB_AND_CONFIG, UPGRADE_DB3個選項,但是相應檔案裡設定錯誤。
檢視響應檔案的配置,確實有問題。
# Specify the installation option.
# It can be one of the following:
# 1. INSTALL_DB_SWONLY
# 2. INSTALL_DB_AND_CONFIG
# 3. UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=1  --這個地方設定錯誤,需要寫為INSTALL_DB_SWONLY..不是數字

如果大體沒有問題,就可以看到
一個後臺程式在執行安裝。
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                   
12298 oracle    20   0 1494m 160m  22m R 194.5  8.1   0:40.84 /tmp/OraInstall2014-11-18_04-15-07AM/jdk/jre/bin/java -Doracle.installer.library_loc=/tmp/OraInstall2014-1
透過日誌檔案也能看到安裝的一些細節。

檢視安裝目錄,也會看到在逐漸增大。
 [oracle@rac1 ORAHOME]$ du -sh .
1.8G    .
[oracle@rac1 ORAHOME]$ du -sh .
2.2G    .
[oracle@rac1 ORAHOME]$ du -sh .
4.0G   
如果在日誌檔案中看到如下的內容,證明安裝已經完成。
INFO: Finding the most appropriate exit status for the current application
INFO: Exit Status is 6
INFO: List of warnings encountered in this Application:
INFO: PREREQS_FAILED_WITH_WARNING
INFO: Shutdown Oracle Database 11g Release 2 Installer
INFO: Unloading Setup Driver

同時,也可以透過sqlplus來測試安裝進度
[oracle@rac1 bin]$ ./sqlplus
./sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory  --這個時候說明安裝還在繼續
[oracle@rac1 bin]$ ./sqlplus
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1.msb not found                                   --這個時候說明安裝已經完成,需要設定的就是ORACLE_HOME了
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

[oracle@rac1 ~]$ export ORACLE_SID=A                    --設定ORACLE_HOME以後,可以簡單的測試是否sqlplus一切正常
[oracle@rac1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Tue Nov 18 04:34:08 2014

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8494287/viewspace-1346958/,如需轉載,請註明出處,否則將追究法律責任。

相關文章