代码改变世界

Oracle 11g静默安装软件+手工创建数据库

2015-07-10 23:37  AlfredZhao  阅读(8488)  评论(0编辑  收藏  举报

由于是二次跳转+远程操作,无法使用图形界面,不能直接图形界面安装。采用静默安装软件+手工创建数据库的方式完成需求。

  1. 静默模式安装Oracle软件,配置监听程序
  2. 手工建库
  3. 检查各组件是否符合要求

1. 静默模式安装Oracle软件,配置监听程序

这里默认已经安装了所有Oracle软件依赖的安装包,调整了操作系统的相关参数。 安装软件前的准备工作不清楚可参见:[Linux平台oracle 11g单实例 安装部署配置 快速参考](http://www.cnblogs.com/jyzhao/p/3891769.html)

解压的数据库安装包,在database文件夹中的response文件夹下,有配置文件db_install.rsp,根据需求修改这个配置文件。

cd ./database/response/
db_install.rsp //安装数据库软件

注意这个选项DECLINE_SECURITY_UPDATES=true,默认值为false,要改为true。

$ ./runInstaller -silent -force -ignorePrereq -ignoreSysPrereqs -responseFile /data/database/response/db_install.rsp 
正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。   实际为 8122 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 255999 MB    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2015-07-09_01-40-01PM. 请稍候...[oracle@CRNOPHQDW12 database]$ [WARNING] [INS-32055] 主产品清单位于 Oracle 基目录中。
   原因: 主产品清单位于 Oracle 基目录中。
   操作: Oracle 建议将此主产品清单放置在 Oracle 基目录之外的位置中。
可以在以下位置找到本次安装会话的日志:
 /opt/app/oracle/oraInventory/logs/installActions2015-07-09_01-40-01PM.log
Oracle Database 11g 的 安装 已成功。
请查看 '/opt/app/oracle/oraInventory/logs/silentInstall2015-07-09_01-40-01PM.log' 以获取详细资料。

以 root 用户的身份执行以下脚本:
        1. /opt/app/oracle/oraInventory/orainstRoot.sh
        2. /opt/app/oracle/product/11.2.0/dbhome_1/root.sh

Successfully Setup Software.

然后按提示root用户执行2个脚本,第2个脚本执行结果参见屏幕提示给出的日志文件。

db_install.rsp修改的内容参考(由于是只安装软件,有关数据库的未修改):

#------------------------------------------------------------------------------
# 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:
#   - INSTALL_DB_SWONLY
#   - INSTALL_DB_AND_CONFIG
#   - 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=CRNOPHQDW12

#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.  
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/opt/app/oracle/oraInventory

#-------------------------------------------------------------------------------
# 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

#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#------------------------------------------------------------------------------
ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base. 
#------------------------------------------------------------------------------
ORACLE_BASE=/opt/app/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=false

#------------------------------------------------------------------------------
# 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.4.0 - Oracle OLAP
#              oracle.rdbms.dm:11.2.0.4.0 - Oracle Data Mining
#              oracle.rdbms.dv:11.2.0.4.0 - Oracle Database Vault
#              oracle.rdbms.lbac:11.2.0.4.0 - Oracle Label Security
#              oracle.rdbms.partitioning:11.2.0.4.0 - Oracle Partitioning
#              oracle.rdbms.rat:11.2.0.4.0 - Oracle Real Application Testing
#------------------------------------------------------------------------------
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,or
acle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
#------------------------------------------------------------------------------
# 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=

#------------------------------------------------------------------------------
# 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

netca.rsp不需要修改,直接建立监听

netca -silent -responsefile /data/database/response/netca.rsp
netca静默创建监听:

$ netca -silent -responsefile /data/database/response/netca.rsp 

正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /data/database/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle Net Services 配置:
完成概要文件配置。
Oracle Net 监听程序启动:
    正在运行监听程序控制: 
      /opt/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
    监听程序控制完成。
    监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置。退出代码是0

2. 手工建库

新建参数文件 $ORACLE_HOME/dbs/initcrnophq.ora
db_name=crnophq
memory_target=100G

建库脚本:

CREATE DATABASE crnophq
     USER SYS IDENTIFIED BY oracle
     USER SYSTEM IDENTIFIED BY oracle
     LOGFILE GROUP 1 ('/opt/app/oracle/oradata/crnophq/redo01a.log') SIZE 2000M BLOCKSIZE 512,
             GROUP 2 ('/opt/app/oracle/oradata/crnophq/redo02a.log') SIZE 2000M BLOCKSIZE 512,
             GROUP 3 ('/opt/app/oracle/oradata/crnophq/redo03a.log') SIZE 2000M BLOCKSIZE 512
     MAXLOGFILES 5
     MAXLOGMEMBERS 5
     MAXLOGHISTORY 1
     MAXDATAFILES 1000
     CHARACTER SET ZHS16GBK
     NATIONAL CHARACTER SET AL16UTF16
     EXTENT MANAGEMENT LOCAL
     DATAFILE '/opt/app/oracle/oradata/crnophq/system01.dbf' SIZE 300M REUSE
     SYSAUX DATAFILE '/opt/app/oracle/oradata/crnophq/sysaux01.dbf' SIZE 300M REUSE
     DEFAULT TABLESPACE users
     DATAFILE '/opt/app/oracle/oradata/crnophq/users01.dbf'
        SIZE 5M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
     DEFAULT TEMPORARY TABLESPACE temp
        TEMPFILE '/opt/app/oracle/oradata/crnophq/temp01.dbf'
        SIZE 20M REUSE
     UNDO TABLESPACE undotbs
        DATAFILE '/opt/app/oracle/oradata/crnophq/undotbs01.dbf'
        SIZE 20M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;

执行下面脚本,创建数据字典和存储过程等

SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL> @?/sqlplus/admin/pupbld.sql   --system用户执行

关于手工建库,更多可以参见转载的文章:Oracle 11g 手工建库

3. 检查各组件是否符合要求

col comp_name for a40
set linesize 1000
select comp_id, comp_name, version, status from sys.dba_registry;