注:https://github.com/sunrainwater/oracle-11g.git 上已经有完善的安装代码
克隆git代码,生成镜像
直接执行:
docker run -it –privileged –name oracle11g -p 1521:1521 -v /data:/install oracle-11g-scripts
(最后面不加bash,不然不会自动执行,而是进去到容器里了)
1、将oracle安装包上传到宿主机,并解压(例:/data目录下)
[root@localhost data]# ll
total 2487256
drwxr-xr-x. 7 440 200 4096 Aug 27 2013 database
drwx------. 2 root root 16384 Aug 30 23:23 lost+found
-rw-r--r--. 1 root root 1395582860 Aug 30 23:59 p13390677_112040_Linux-x86-64_1of7.zip
-rw-r--r--. 1 root root 1151304589 Aug 30 23:59 p13390677_112040_Linux-x86-64_2of7.zip
2、用Docker官网的镜像启动,并将/data 挂载到/install 下
docker run -it --privileged --name oracle11g -p 1521:1521 -v /data:/install jaspeen/oracle-11g bash
3、将db_install.rsp拷贝到 /assets 下 (因为镜像里的是oracle 11.2.0.1),并授予x权限
[root@37ad936c72bf ~]# cd /install/database/response/
[root@37ad936c72bf response]# ll
total 80
-rw-r--r--. 1 oracle oinstall 25116 Aug 27 2013 db_install.rsp
-rwxr-xr-x. 1 oracle oinstall 44533 Aug 27 2013 dbca.rsp
-rwxr-xr-x. 1 oracle oinstall 5871 Aug 27 2013 netca.rsp
[root@37ad936c72bf assets]chmod +x db_install.rsp
4、修改 db_install.rsp
可将文件修改好,只需要修改其中的主机名即可
sed -i "s/localhost/$HOSTNAME/g" db_install.rsp
或
直接修改文件
####################################################################
## Copyright(c) Oracle Corporation 1998,2013. 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.只装数据库软件 2.安装数据库软件并建库 3.升级数据库
# - 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)
#
# 指定操作系统主机名,通过hostname命令获得
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=bcd668678bfe
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#
# 指定oracle inventory目录的所有者,通常会是oinstall或者dba
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#
# 指定产品清单oracle inventory目录的路径,如果是Win平台下可以省略
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/opt/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
#
# 指定数据库语言,可以选择多个,用逗号隔开。选择en, zh_CN(英文和简体中文)
#------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#
# 设置ORALCE_HOME的路径
#------------------------------------------------------------------------------
ORACLE_HOME=/opt/oracle/app/product/11.2.0/dbhome_1
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#
# 设置ORALCE_BASE的路径
#------------------------------------------------------------------------------
ORACLE_BASE=/opt/oracle/app
#------------------------------------------------------------------------------
# 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安装数据库软件的版本(企业版,标准版,标准版1),不同的版本功能不同
#------------------------------------------------------------------------------
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,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.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 the cluster node names selected during the installation.
# Example : oracle.install.db.CLUSTER_NODES=node1,node2
#
# 如果是RAC的安装,在这里指定所有的节点
#------------------------------------------------------------------------------
oracle.install.db.CLUSTER_NODES=
#------------------------------------------------------------------------------
# This variable is used to enable or disable RAC One Node install.
#
# - true : Value of RAC One Node service name is used.
# - false : Value of RAC One Node service name is not used.
#
# If left blank, it will be assumed to be false
#------------------------------------------------------------------------------
oracle.install.db.isRACOneInstall=
#------------------------------------------------------------------------------
# Specify the name for RAC One Node Service.
#------------------------------------------------------------------------------
oracle.install.db.racOneServiceName=
#------------------------------------------------------------------------------
# Specify the type of database to create.
# It can be one of the following:
# - GENERAL_PURPOSE/TRANSACTION_PROCESSING
# - DATA_WAREHOUSE
#
# 选择数据库的用途,一般用途/事物处理,数据仓库
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
#------------------------------------------------------------------------------
# Specify the Starter Database Global Database Name.
#
# 指定GlobalName
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.globalDBName=orcl
#------------------------------------------------------------------------------
# Specify the Starter Database SID.
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.SID=orcl
#------------------------------------------------------------------------------
# Specify the Starter Database character set.
#
# It can be one of the following:
# AL32UTF8, WE8ISO8859P15, WE8MSWIN1252, EE8ISO8859P2,
# EE8MSWIN1250, NE8ISO8859P10, NEE8ISO8859P4, BLT8MSWIN1257,
# BLT8ISO8859P13, CL8ISO8859P5, CL8MSWIN1251, AR8ISO8859P6,
# AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253, IW8ISO8859P8,
# IW8MSWIN1255, JA16EUC, JA16EUCTILDE, JA16SJIS, JA16SJISTILDE,
# KO16MSWIN949, ZHS16GBK, TH8TISASCII, ZHT32EUC, ZHT16MSWIN950,
# ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254, VN8MSWIN1258
#
# 选择字符集。不正确的字符集会给数据显示和存储带来麻烦无数。很重要
# 通常中文选择的有ZHS16GBK简体中文库,建议选择unicode的AL32UTF8国际字符集
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.characterSet=AL32UTF8
#------------------------------------------------------------------------------
# This variable should be set to true if Automatic Memory Management
# in Database is desired.
# If Automatic Memory Management is not desired, and memory allocation
# is to be done manually, then set it to false.
#
# 11g的新特性自动内存管理,也就是SGA_TARGET和PAG_AGGREGATE_TARGET都不用设置了,Oracle会自动调配两部分大小
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryOption=true
#------------------------------------------------------------------------------
# Specify the total memory allocation for the database. Value(in MB) should be
# at least 256 MB, and should not exceed the total physical memory available
# on the system.
# Example: oracle.install.db.config.starterdb.memoryLimit=512
#
# 指定Oracle自动管理内存的大小,最小是256MB
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryLimit=
#------------------------------------------------------------------------------
# This variable controls whether to load Example Schemas onto
# the starter database or not.
#
# 是否载入模板示例
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.installExampleSchemas=false
#------------------------------------------------------------------------------
# This variable includes enabling audit settings, configuring password profiles
# and revoking some grants to public. These settings are provided by default.
# These settings may also be disabled.
#
# 是否启用安全设置
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.enableSecuritySettings=true
###############################################################################
# #
# Passwords can be supplied for the following four schemas in the #
# starter database: #
# SYS #
# SYSTEM #
# SYSMAN (used by Enterprise Manager) #
# DBSNMP (used by Enterprise Manager) #
# #
# Same password can be used for all accounts (not recommended) #
# or different passwords for each account can be provided (recommended) #
# #
###############################################################################
#------------------------------------------------------------------------------
# This variable holds the password that is to be used for all schemas in the
# starter database.
#
# 设定所有数据库用户使用同一个密码,其它数据库用户就不用单独设置了。
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.ALL=oracle
#-------------------------------------------------------------------------------
# Specify the SYS password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYS=
#-------------------------------------------------------------------------------
# Specify the SYSTEM password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSTEM=
#-------------------------------------------------------------------------------
# Specify the SYSMAN password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.SYSMAN=
#-------------------------------------------------------------------------------
# Specify the DBSNMP password for the starter database.
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.DBSNMP=
#-------------------------------------------------------------------------------
# Specify the management option to be selected for the starter database.
# It can be one of the following:
# - GRID_CONTROL
# - DB_CONTROL
#
# 数据库本地管理工具DB_CONTROL,远程集中管理工具GRID_CONTROL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.control=DB_CONTROL
#-------------------------------------------------------------------------------
# Specify the Management Service to use if Grid Control is selected to manage
# the database.
#
# GRID_CONTROL需要设定grid control的远程路径URL
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
###############################################################################
# #
# SPECIFY BACKUP AND RECOVERY OPTIONS #
# ------------------------------------ #
# Out-of-box backup and recovery options for the database can be mentioned #
# using the entries below. #
# #
###############################################################################
#------------------------------------------------------------------------------
# This variable is to be set to false if automated backup is not required. Else
# this can be set to true.
#
# 设置自动备份,和OUI里的自动备份一样
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.enable=false
#------------------------------------------------------------------------------
# Regardless of the type of storage that is chosen for backup and recovery, if
# automated backups are enabled, a job will be scheduled to run daily to backup
# the database. This job will run as the operating system user that is
# specified in this variable.
#
# 自动备份会启动一个job,指定启动JOB的系统用户ID
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.osuid=
#-------------------------------------------------------------------------------
# Regardless of the type of storage that is chosen for backup and recovery, if
# automated backups are enabled, a job will be scheduled to run daily to backup
# the database. This job will run as the operating system user specified by the
# above entry. The following entry stores the password for the above operating
# system user.
#
# 自动备份会开启一个job,需要指定OSUser的密码
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.automatedBackup.ospwd=
#-------------------------------------------------------------------------------
# Specify the type of storage to use for the database.
# It can be one of the following:
# - FILE_SYSTEM_STORAGE
# - ASM_STORAGE
#
# 自动备份,要求指定使用的文件系统存放数据库文件还是ASM
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
# Specify the database file location which is a directory for datafiles, control
# files, redo logs.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#
# 使用文件系统存放数据库文件才需要指定数据文件、控制文件、Redo log的存放目录
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=
#-------------------------------------------------------------------------------
# Specify the backup and recovery location.
#
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM_STORAGE
#
# 使用文件系统存放数据库文件才需要指定备份恢复目录
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=
#-------------------------------------------------------------------------------
# Specify the existing ASM disk groups to be used for storage.
#
# Applicable only when oracle.install.db.config.starterdb.storage=ASM_STORAGE
#
# 使用ASM存放数据库文件才需要指定存放的磁盘组
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.diskGroup=
#-------------------------------------------------------------------------------
# Specify the password for ASMSNMP user of the ASM instance.
#
# Applicable only when oracle.install.db.config.starterdb.storage=ASM_STORAGE
#
# 使用ASM存放数据库文件才需要指定ASM实例密码
#-------------------------------------------------------------------------------
oracle.install.db.config.asm.ASMSNMPPassword=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username.
#
# Example : MYORACLESUPPORT_USERNAME=abc@oracle.com
#------------------------------------------------------------------------------
MYORACLESUPPORT_USERNAME=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password.
#
# Example : MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
MYORACLESUPPORT_PASSWORD=
#------------------------------------------------------------------------------
# Specify whether to enable the user to set the password for
# My Oracle Support credentials. The value can be either true or false.
# If left blank it will be assumed to be false.
#
# Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
#------------------------------------------------------------------------------
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
#------------------------------------------------------------------------------
# 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
#
# False表示不需要设置安全更新,注意,在11.2的静默安装中疑似有一个BUG
# Response File中必须指定为true,否则会提示错误,不管是否正确填写了邮件地址
# 这里必须为 true 否则会失败
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
#------------------------------------------------------------------------------
# Specify the Proxy server name. Length should be greater than zero.
#
# Example : PROXY_HOST=proxy.domain.com
#------------------------------------------------------------------------------
PROXY_HOST=
#------------------------------------------------------------------------------
# Specify the proxy port number. Should be Numeric and at least 2 chars.
#
# Example : PROXY_PORT=25
#------------------------------------------------------------------------------
PROXY_PORT=
#------------------------------------------------------------------------------
# Specify the proxy user name. Leave PROXY_USER and PROXY_PWD
# blank if your proxy server requires no authentication.
#
# Example : PROXY_USER=username
#------------------------------------------------------------------------------
PROXY_USER=
#------------------------------------------------------------------------------
# Specify the proxy password. Leave PROXY_USER and PROXY_PWD
# blank if your proxy server requires no authentication.
#
# Example : PROXY_PWD=password
#------------------------------------------------------------------------------
PROXY_PWD=
#------------------------------------------------------------------------------
# Specify the proxy realm. This value is used if auto-updates option is selected.
#
# Example : PROXY_REALM=metalink
#------------------------------------------------------------------------------
PROXY_REALM=
#------------------------------------------------------------------------------
# Specify the Oracle Support Hub URL.
#
# Example : COLLECTOR_SUPPORTHUB_URL=https://orasupporthub.company.com:8080/
#------------------------------------------------------------------------------
COLLECTOR_SUPPORTHUB_URL=
#------------------------------------------------------------------------------
# Specify the auto-updates option. It can be one of the following:
# - MYORACLESUPPORT_DOWNLOAD
# - OFFLINE_UPDATES
# - SKIP_UPDATES
#------------------------------------------------------------------------------
oracle.installer.autoupdates.option=
#------------------------------------------------------------------------------
# In case MYORACLESUPPORT_DOWNLOAD option is chosen, specify the location where
# the updates are to be downloaded.
# In case OFFLINE_UPDATES option is chosen, specify the location where the updates
# are present.
#------------------------------------------------------------------------------
oracle.installer.autoupdates.downloadUpdatesLoc=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username which has the patches download privileges
# to be used for software updates.
# Example : AUTOUPDATES_MYORACLESUPPORT_USERNAME=abc@oracle.com
#------------------------------------------------------------------------------
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
#------------------------------------------------------------------------------
# Specify the My Oracle Support Account Username password which has the patches download privileges
# to be used for software updates.
#
# Example : AUTOUPDATES_MYORACLESUPPORT_PASSWORD=password
#------------------------------------------------------------------------------
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
5、安装oracle软件 (在/assets中的install.sh)
[root@37ad936c72bf assets]# ./install.sh
6、dbca静默安装建库 (直接用镜像里面的dbca.rsp 或者自己建)
先修改模板(General_Purpose.dbc) -----很重要,不然会在76%处挂起
vim /opt/oracle/app/product/11.2.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc
添加
<initParam name="java_jit_enabled" value="false"/>
或
将文本插入到文件的40行上面
sed -i "40i \ \ \ \ \ \ \ \ \ <initParam name=\"java_jit_enabled\" value=\"false\"/>" /u01/app/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc
建库
dbca -silent -responseFile /assets/dbca.rsp
删除库
dbca -silent -deleteDatabase -sourceDB orcl -sysDBAUserName sys -sysDBAPassword oracle
7、静默创建监听
netca /silent /responsefile /install/database/response/netca.rsp
注意:有两个报错
1、在 db_install.rsp 中一定设置 DECLINE_SECURITY_UPDATES=true
(一定要设置成true,否则在安装的时候会出现以下的告警:
[WARNING] - My Oracle Support Username/Email Address Not Specified
[SEVERE] - Provide the My Oracle Support password.导致不能成功安装)
2、在 General_Purpose.dbc模板中一定设置 java_jit_enabled 为false
不然dbca建库会在76%挂起
vim /opt/oracle/app/product/11.2.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc
添加
<initParam name="java_jit_enabled" value="false"/>