docker下安装 Oracle11gR2

这是第二次安装,在第一次安装过程部分内容参考自如下:

http://blog.sina.com.cn/s/blog_d840ff330102v4j0.html docker下oracle11g安装

http://blog.csdn.net/yangyinbo/article/details/6221220 HP-UX静默安装oracle11g过程

http://www.linuxidc.com/Linux/2012-03/56606p4.htm  CentOS 6.2 X64上64位Oracle 11gR2 静默安装

但是并没一次成功,中途遇到好多问题,一个一个逐步解决,最终安装成功。在这里只是做一个总结,欢迎指点和纠正。

这次是在安装的过程中同时记录,以备后续参考。

系统环境:

虚拟机Centos7 64位

docker:1.13.1

oracle:11gR2

容器:centos:6.6

第一次安装时最后能够保证连网,如不能连网需要提前准备好相应的包。

保证虚拟机ok,docker已经安装好,同时将oracle包拷贝至centos6.6的容器中的 /oracle_package目录下。

[root@bogon install_package]# docker cp linux.x64_11gR2_database_1of2.zip 22edf28f349d:/oracle_package
[root@bogon install_package]# docker cp linux.x64_11gR2_database_2of2.zip 22edf28f349d:/oracle_package
[root@22edf28f349d oracle_package]# ls
linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip

开始安装

1.安装oracle所需要的 gcc* 、glibc*相关的包 

gcc*在装的时候看到有很多个,每个都不是很大,只要网速不是特别差还是很快的。

[root@22edf28f349d oracle_package]# yum -y install gcc*
[root@22edf28f349d oracle_package]# yum -y install glibc*

也可以指安装所需的包,并且要注意顺序:

Oracle 对GCC的顺序:

glibc-common-2.12-1.80.el6.x86_64.rpm
kernel-headers-2.6.32-279.el6.x86_64.rpm
libgcc-4.4.6-4.el6.x86_64.rpm
glibc-2.12-1.80.el6.x86_64.rpm
libgomp-4.4.6-4.el6.x86_64.rpm
nscd-2.12-1.80.el6.x86_64.rpm
glibc-headers-2.12-1.80.el6.x86_64.rpm
glibc-devel-2.12-1.80.el6.x86_64.rpm
mpfr-2.4.1-6.el6.x86_64.rpm
ppl-0.10.2-11.el6.x86_64.rpm
cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
cpp-4.4.6-4.el6.x86_64.rpm
gcc-4.4.6-4.el6.x86_64.rpm
注:以上是安装gcc,软件安装顺序不能错
libstdc++-4.4.6-4.el6.x86_64.rpm
libstdc++-devel-4.4.6-4.el6.x86_64.rpm
gcc-c++-4.4.6-4.el6.x86_64.rpm
注:以上是安装gcc-c++

也可以使用yum的方式进行安装

 #yum -y install gcc
 #yum -y install make
 #yum -y install binutils
 #yum -y install gcc-c++
 #yum -y install compat-libstdc++-33
 #yum -y install elfutils-libelf-devel
 #yum -y install elfutils-libelf-devel-static
 #yum -y install ksh
 #yum -y install libaio
 #yum -y install libaio-devel
 #yum -y install numactl-devel
 #yum -y install sysstat
 #yum -y install unixODBC
 #yum -y install unixODBC-devel
 #yum -y install pcre-devel

注意:  

在使用yum安装时如果出现如下错误:

[root@d0361c82ec77 oracle_package]# yum -y install gcc*
Loaded plugins: fastestmirror
Setting up Install Process
Examining gcc-4.4.7-4.el6.x86_64.rpm: gcc-4.4.7-4.el6.x86_64
Marking gcc-4.4.7-4.el6.x86_64.rpm to be installed
base                                                     | 3.7 kB     00:00     
base/primary_db                                          | 4.7 MB     00:05     
epel                                                     | 4.3 kB     00:00     
epel/primary_db                                          | 4.6 MB     00:10     
Error: xz compression not available
[root@d0361c82ec77 oracle_package]# 

这个错误主要意思是没有epel或者存在错误的epel,可以这样来解决:

  1.remove 错误的epel

有可能会出现如下:说明系统还没有epel

[root@d0361c82ec77 oracle_package]# yum remove epel-release
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: epel-release
Determining fastest mirrors
Error: xz compression not available
[root@d0361c82ec77 oracle_package]# 

或者:移除epel成功

[root@d0361c82ec77 yum]# yum remove epel-release
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch            Version         Repository          Size
================================================================================
Removing:
 epel-release          noarch          6-8             installed           22 k

Transaction Summary
================================================================================
Remove        1 Package(s)

Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Erasing    : epel-release-6-8.noarch                                      1/1 
warning: /etc/yum.repos.d/epel.repo saved as /etc/yum.repos.d/epel.repo.rpmsave
  Verifying  : epel-release-6-8.noarch                                      1/1 

Removed:
  epel-release.noarch 0:6-8                                                     

Complete!

这两种情况都没有问题,接着执行下面步骤

  2.清理epel 缓存

[root@d0361c82ec77 yum]# rm -rf /var/cache/yum/x86_64/6/epel

  3.重新安装正确的epel:

[root@d0361c82ec77 yum]# rpm -ivh http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
Retrieving http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm
warning: /var/tmp/rpm-tmp.M6IbHz: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [100%]

  4.使用 yum search munin 检测是否安装正确

[root@d0361c82ec77 yum]# yum search munin
Loaded plugins: fastestmirror base
| 3.7 kB 00:00 base/primary_db | 4.7 MB 00:14 epel/metalink | 5.4 kB 00:00 epel | 4.3 kB 00:00 epel/primary_db | 5.9 MB 00:27 extras | 3.4 kB 00:00 extras/primary_db | 37 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 5.4 MB 00:09 ============================== N/S Matched: munin ============================== PyMunin.noarch : Python Module for developing Munin Multigraph Monitoring : Plugins munin-java-plugins.noarch : java-plugins for munin munin-ruby-plugins.noarch : ruby-plugins for munin munin.noarch : Network-wide graphing framework (grapher/gatherer) munin-async.noarch : Network-wide graphing framework (asynchronous client tools) munin-cgi.noarch : Network-wide graphing framework (cgi files for apache) munin-common.noarch : Network-wide graphing framework (common files) munin-netip-plugins.noarch : Network-wide graphing framework (dhcpd3 and ntp : plugins) munin-nginx.noarch : Network-wide graphing framework (cgi files for nginx) munin-node.noarch : Network-wide graphing framework (node) Name and summary matches only, use "search all" for everything.

到此这个问题就已经解决了,如果还有问题可以重复上述1.2.3.4步骤。

再次运行:

[root@d0361c82ec77 yum]# yum -y install gcc*
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
 * epel: mirrors.neusoft.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-17.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-17.el6 for package: gcc-4.4.7-17.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-17.el6.x86_64
...

在安装过程中如果提示:

Public key for gcc-objc-4.4.7-17.el6.x86_64.rpm is not installed

在网上找到了解决方法:
此时要导入rpm的签名信息即可
以root登录,执行下面命令
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

根据我的Linux版本是CentOS 6.6
于是我执行下面命令
#rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


安装 unzip指令 vim指令,因为centos6.6容器中没有这两个指令的,后边需要用到,容器中自带了vi,看个人习惯了

[root@22edf28f349d oracle_package]# yum -y install unzip
[root@22edf28f349d oracle_package]# yum -y install vim

2.修改主机名

这里主要将容器id 加入hostname中,如果hostname不正确后边启动监听可能会出现问题。

[root@22edf28f349d oracle_package]# vim /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=hadoop

3.修改host文件

先用hostname查看当前的主机名为:

[root@22edf28f349d oracle_package]# hostname
22edf28f349d

内容如下:

[root@22edf28f349d oracle_package]# vim /etc/hosts
127.0.0.1       hadoop
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
#172.17.0.2     1c0d06324543

4. 创建用户oracle及组dba

[root@22edf28f349d oracle_package]# vim /etc/hosts
[root@22edf28f349d oracle_package]# groupadd dba
[root@22edf28f349d oracle_package]# useradd -g dba oracle
[root@22edf28f349d oracle_package]# passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@22edf28f349d oracle_package]# 

5.创建oracle目录和设置权限

[root@22edf28f349d oracle_package]# mkdir -p /u01/app/oracle
[root@22edf28f349d oracle_package]# mkdir -p /u01/app/product/11.2.0/db_1  //数据库系统安装目录
[root@22edf28f349d oracle]# mkdir /u01/app/oracle/oraInventory  //清单目录
[root@22edf28f349d oracle_package]# chown -R oracle:dba /u01
[root@22edf28f349d oracle_package]# chmod -R 775 /u01
[root@22edf28f349d oracle]# mkdir /opt/oradata  //数据存放目录
[root@22edf28f349d oracle]# mkdir /opt/oradata_back  //数据备份目录

 记录一下:

mkdir -p 中-p 的作用,如果递归创建目录没有-p会报错,同时-p有如下作用:

-p, --parents     no error if existing, make parent directories as needed

 

chown 用户名:组名 文件路径(可以是就对路径也可以是相对路径)

例1:chown oracle:dba /tmp/tmp1
就是把tmp下的tmp1的用户名和用户组改成oracle和dba(只修改了tmp1的属组).
例2:chown -R oracle:dba /tmp/tmp1
就是把tmp下的tmp1下的所有文件的属组都改成oracle和oracle。

chmod -R 775 /u01

chmod用法
用来修改某个目录或文件的访问权限

语法:chmod [who] [+ | - | =] [mode] 文件名
 命令中各选项的含义为: 
操作对象who可是下述字母中的任一个或者它们的组合:
   u 表示“用户(user)”,即文件或目录的所有者。
   g 表示“同组(group)用户”,即与文件属主有相同组ID的所有用户。
   o 表示“其他(others)用户”。
   a 表示“所有(all)用户”。它是系统默认值。
 操作符号可以是:
   + 添加某个权限。
   - 取消某个权限。
   = 赋予给定权限并取消其他所有权限(如果有的话)。
 设置 mode 所表示的权限可用下述字母的任意组合:
   r 可读。
   w 可写。
    x 可执行。
   X 只有目标文件对某些用户是可执行的或该目标文件是目录时才追加x 属性。
   s 在文件执行时把进程的属主或组ID置为该文件的文件属主。
       方式“u+s”设置文件的用户ID位,“g+s”设置组ID位。
   t 保存程序的文本到交换设备上。
   u 与文件属主拥有一样的权限。
   g 与和文件属主同组的用户拥有一样的权限。
   o 与其他用户拥有一样的权限。
 文件名:以空格分开的要改变权限的文件列表,支持通配符。

 

在Unix和Linux的各种操作系统下,每个文件(文件夹也被看作是文件)都按读、写、运行设定权限。
例如我用ls -l命令列文件表时,得到如下输出:
-rw-r--r--  1 bu users  2254 2006-05-20 13:47 tt.htm
从第二个字符起rw-是说用户bu有读、写权,没有运行权,接着的r--表示用户组users只有读权限,没有运行权,最后的r--指其他人(others)只有读权限,没有写权和运行权。
这是系统默认设置,我可以改写tt.htm,同组的人和其他人只有权读,没人有权运行,因为只是一个html文件,不必运行。这在Novell的directory services之前很先进。 读、写、运行三项权限可以用数字表示,就是r
=4,w=2,x=1。所以,上面的例子中的rw-r--r--用数字表示成644。 反过来说777就是rwxrwxrwx,意思是该登录用户(可以用命令id查看)、他所在的组和其他人都有最高权限。 再多说一句。我用chmod o-r tt.htm命令改权限,o-r是others的权限中减掉读。结果是 -rw-r----- 1 bu users 2254 2006-05-20 13:47 tt.htm 如果用命令chmod 777 tt.htm,结果是 -rwxrwxrwx 1 bu users 2254 2006-05-20 13:47
tt.htm 任何人都有读、写、运行三项权限。
理论上就是这样,但实际运用上往往需要加上1执行权,否则执行不了读或写

6.设置环境变量,修改oracle用户的 .bash_profile 文件

[oracle@22edf28f349d ~]# vim .bash_profile 

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$ORACLE_HOME/bin

使环境变量生效 

[root@22edf28f349d ~]# source .bash_profile

7.将oracle的两个安装包解压到同一个目录下,如果不是同一个目录后边会报错

[root@22edf28f349d oracle_package]# unzip linux.x64_11gR2_database_1of2.zip -d ./oracle
[root@22edf28f349d oracle_package]# unzip linux.x64_11gR2_database_2of2.zip -d ./oracle

8.将刚解压后的rsp文件复制到 /home/oracle目录下

[root@22edf28f349d oracle_package]# cp ./oracle/database/response/* /home/oracle/

查看 /home/oracle目录下的rsp文件

[root@22edf28f349d oracle]# ls
dbca.rsp  db_install.rsp  netca.rsp

9.修改db_install.rsp文件的内容:

详细解释来自:http://blog.chinaunix.net/uid-23886490-id-3565908.html

[root@22edf28f349d oracle]# vim db_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.                              ##
##                                                                ##
## 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.#选择安装类型:1.只装数据库软件 2.安装数据库软件并建库 3.升级数据库
# 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=hadoop  #指定操作系统主机名,通过hostname命令获得

#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.  
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba   #指定oracle inventory目录的所有者,通常会是oinstall或者dba

#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/u01/app/oracle/oraInventory  #指定产品清单oracle inventory目录的路径,如果是Win平台下可以省略

#-------------------------------------------------------------------------------
# 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                                                   
#
# Example : SELECTED_LANGUAGES=en,fr,ja
#------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN #指定数据库语言,可以选择多个,用逗号隔开。选择en, zh_CN(英文和简体中文)

#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#------------------------------------------------------------------------------
ORACLE_HOME=/u01/app/product/11.2.0/db_1  #设置ORALCE_HOME的路径

#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base. 
#------------------------------------------------------------------------------
ORACLE_BASE=/u01/app/oracle  #设置ORALCE_BASE的路径

#------------------------------------------------------------------------------
# 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.
#
# true  : Components mentioned as part of 'customComponents' property
#         are considered for install.
# false : Value for 'customComponents' is not considered.
#------------------------------------------------------------------------------

  #是否自定义Oracle的组件,如果选择false,则会使用默认的组件

  #如果选择true否则需要自己在下面一条参数将要安装的组件一一列出。

  #安装相应版权后会安装所有的组件,后期如果缺乏某个组件,再次安装会非常的麻烦。

oracle.install.db.isCustomInstall=true

#------------------------------------------------------------------------------
# This variable is considered only if 'IsCustomInstall' is set to true. 
#
# Description: List of Enterprise Edition Options 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.rdbms.partitioning:11.2.0.1.0 - Oracle Partitioning
#              oracle.rdbms.dm:11.2.0.1.0 - Oracle Data Mining
#              oracle.rdbms.dv:11.2.0.1.0 - Oracle Database Vault 
#              oracle.rdbms.lbac:11.2.0.1.0 - Oracle Label Security
#              oracle.rdbms.rat:11.2.0.1.0 - Oracle Real Application Testing 
#              oracle.oraolap:11.2.0.1.0 - Oracle OLAP
#------------------------------------------------------------------------------
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,
oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,
oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,
oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.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 DBA_GROUP is the OS group which is to be granted OSDBA privileges. #------------------------------------------------------------------------------ oracle.install.db.DBA_GROUP=dba #指定拥有OSDBAOSOPER权限的用户组,通常会是dba #------------------------------------------------------------------------------ # The OPER_GROUP is the OS group which is to be granted OSOPER privileges. #------------------------------------------------------------------------------ oracle.install.db.OPER_GROUP=dba #------------------------------------------------------------------------------ # Specify the cluster node names selected during the installation. #------------------------------------------------------------------------------ oracle.install.db.CLUSTER_NODES= #如果是RAC的安装,在这里指定所有的节点 #------------------------------------------------------------------------------ # 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. #------------------------------------------------------------------------------ oracle.install.db.config.starterdb.globalDBName=orcl #指定GlobalName #------------------------------------------------------------------------------ # 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简体中文库,建议选择unicodeAL32UTF8国际字符集

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_TARGETPAG_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=512 #------------------------------------------------------------------------------ # 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: # 1. GRID_CONTROL # 2. DB_CONTROL #------------------------------------------------------------------------------- oracle.install.db.config.starterdb.control=DB_CONTROL #数据库本地管理工具DB_CONTROL,远程集中管理工具GRID_CONTROL #------------------------------------------------------------------------------- # Specify the Management Service to use if Grid Control is selected to manage # the database. #------------------------------------------------------------------------------- oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL= #GRID_CONTROL需要设定grid control的远程路径URL #------------------------------------------------------------------------------- # This variable indicates whether to receive email notification for critical # alerts when using DB control. #------------------------------------------------------------------------------- oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false #是否启用Email通知启用后会将告警等信息发送到指定邮箱 #------------------------------------------------------------------------------- # Specify the email address to which the notifications are to be sent. #------------------------------------------------------------------------------- oracle.install.db.config.starterdb.dbcontrol.emailAddress= #设置通知EMAIL地址 #------------------------------------------------------------------------------- # Specify the SMTP server used for email notifications. #------------------------------------------------------------------------------- oracle.install.db.config.starterdb.dbcontrol.SMTPServer= ############################################################################### # # # 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. #------------------------------------------------------------------------------ oracle.install.db.config.starterdb.automatedBackup.enable=false #设置自动备份,和OUI里的自动备份一样。 #------------------------------------------------------------------------------ # 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 at # 2:00 AM to backup the database. This job will run as the operating system # user that is specified in this variable. #------------------------------------------------------------------------------ oracle.install.db.config.starterdb.automatedBackup.osuid= #自动备份会启动一个job,指定启动JOB的系统用户ID #------------------------------------------------------------------------------- # 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 at # 2:00 AM 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. #------------------------------------------------------------------------------- oracle.install.db.config.starterdb.automatedBackup.ospwd= #自动备份会开启一个job,需要指定OSUser的密码 #------------------------------------------------------------------------------- # Specify the type of storage to use for the database. # It can be one of the following: # - FILE_SYSTEM_STORAGE # - ASM_STORAGE #------------------------------------------------------------------------------ oracle.install.db.config.starterdb.storageType= #自动备份,要求指定使用的文件系统存放数据库文件还是ASM #------------------------------------------------------------------------------- # 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 #-------------------------------------------------------------------------------
##使用文件系统存放数据库文件才需要指定数据文件、控制文件、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 #-------------------------------------------------------------------------------
##使用文件系统存放数据库文件才需要指定备份恢复目录
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 #-------------------------------------------------------------------------------
##使用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_SYSTEM #-------------------------------------------------------------------------------
##使用ASM存放数据库文件才需要指定ASM实例密码
oracle.install.db.config.asm.ASMSNMPPassword= #------------------------------------------------------------------------------ # Specify the My Oracle Support Account Username. # # Example : MYORACLESUPPORT_USERNAME=metalink #------------------------------------------------------------------------------ MYORACLESUPPORT_USERNAME= ##指定metalink账户用户名 #------------------------------------------------------------------------------ # Specify the My Oracle Support Account Username password. # # Example : MYORACLESUPPORT_PASSWORD=password #------------------------------------------------------------------------------ MYORACLESUPPORT_PASSWORD= ## 指定metalink账户密码 #------------------------------------------------------------------------------ # 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= ## 用户是否可以设置metalink密码 #------------------------------------------------------------------------------ # Specify whether user wants to give any proxy details for connection. # 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 atleast 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=  ##代理服务器密码

10.开始安装oracle11g 容器中没有图形界面,只能静默安装(silent),所以需要配置以上文件

切换到oracle用户下

[root@22edf28f349d oracle]# su oracle
[oracle@22edf28f349d ~]$ cd /

进去刚才解压oracle两个zip包的目标目录,并且进入database目录下 执行安装:

[oracle@22edf28f349d database]$ ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@22edf28f349d database]$ ./runInstaller -ignoreSysPrereqs -ignorePrereq -silent -responseFile /home/oracle/db_install.rsp

安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了。

打开另一个终端,执行
 #tail -100f /home/oracle/inventory/logs/installActions......log
 可以实时跟踪查看安装日志,了解安装的进度。

[root@22edf28f349d /]# tail -100f /tmp/OraInstall2017-03-08_06-02-45PM/installActions2017-03-08_06-02-45PM.log

安装过程比较花时间,慢慢等待吧。

当出现如下语句就表示安装成功了:

[oracle@22edf28f349d database]$ The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/u01/app/oracle/oraInventory/orainstRoot.sh
/u01/app/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
     1. Open a terminal window 
     2. Log in as "root" 
     3. Run the scripts 
     4. Return to this window and hit "Enter" key to continue 

Successfully Setup Software.

11.按照提示在root用户下执行两个脚本

[root@22edf28f349d /]# /u01/app/product/11.2.0/db_1/root.sh
Check /u01/app/product/11.2.0/db_1/install/root_22edf28f349d_2017-03-08_18-45-38.log for the output of root script

查看日志:

[root@22edf28f349d /]# tail -100f /u01/app/product/11.2.0/db_1/install/root_22edf28f349d_2017-03-08_18-45-38.log

Running Oracle 11g root.sh script...

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/product/11.2.0/db_1

Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.

执行脚本:

[root@22edf28f349d /]# /u01/app/oracle/oraInventory/orainstRoot.sh
Changing permissions of /u01/app/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/app/oracle/oraInventory to dba.
The execution of the script is complete.
[root@22edf28f349d /]# 

到此oracle11g软件已经安装成功了。。。

12.安装listener

[oracle@22edf28f349d database]$ netca /silent /responsefile /home/oracle/netca.rsp
UnsatisfiedLinkError exception loading native library: njni11
java.lang.UnsatisfiedLinkError: /u01/app/product/11.2.0/db_1/lib/libnjni11.so: libaio.so.1: cannot open shared object file: No such file or directory
java.lang.UnsatisfiedLinkError: jniGetOracleHome
    at oracle.net.common.NetGetEnv.jniGetOracleHome(Native Method)
    at oracle.net.common.NetGetEnv.getOracleHome(Unknown Source)
    at oracle.net.ca.NetCALogger.getOracleHome(NetCALogger.java:230)
    at oracle.net.ca.NetCALogger.initOracleParameters(NetCALogger.java:215)
    at oracle.net.ca.NetCALogger.initLogger(NetCALogger.java:130)
    at oracle.net.ca.NetCA.main(NetCA.java:404)

Error: jniGetOracleHome
Oracle Net Services configuration failed.  The exit code is 1

安装时报错,按照网上的解决办法:

安装 libaio.so.1 并将 libaio.so.1拷贝到$ORACLE_HOME/lib目录下

[root@22edf28f349d /]# yum -y install libaio*
[oracle@22edf28f349d lib64]$ cp /lib64/libaio.so.1 $ORACLE_HOME/lib

重现安装listener:

[oracle@22edf28f349d lib64]$ netca /silent /responsefile /home/oracle/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /home/oracle/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/product/11.2.0/db_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@22edf28f349d lib64]$ 

显示listener安装成功。

查看listener的状态:

[oracle@22edf28f349d lib64]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-MAR-2017 18:55:11

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                08-MAR-2017 18:54:17
Uptime                    0 days 0 hr. 0 min. 54 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/22edf28f349d/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@22edf28f349d lib64]$ 

13.使用dbca 静默建库(创建数据库实例)

由于我们在安装数据库的时候在db_install.rsp配置了:

#------------------------------------------------------------------------------
# Specify the installation option.#选择安装类型:1.只装数据库软件 2.安装数据库软件并建库 3.升级数据库
# 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

此时还没有数据库和实例,可以通过dbca.rsp 来创建数据库和实例

编辑dbca.rsp文件:

RESPONSEFILE_VERSION = "11.2.0"  //不能更改
 OPERATION_TYPE = "createDatabase"
 GDBNAME = "orcl"  //数据库的名字
 SID = "orcl"    //对应的实例名字
 TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件
 SYSPASSWORD = "oracle"   //SYS管理员密码
 SYSTEMPASSWORD = "oracle"  //SYSTEM管理员密码
 DATAFILEDESTINATION =  //数据文件存放目录 默认为 $ORACLE_BASE/oradata
 RECOVERYAREADESTINATION= //恢复数据存放目录 默认为$ORACLE_BASE/flash_recovery_area
 CHARACTERSET = "UTF8"   //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。
 TOTALMEMORY = "5120"    //oracle内存5120MB
[oracle@22edf28f349d lib64]$ dbca -silent -responseFile /home/oracle/dbca.rsp 
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
/bin/cat: /proc/sys/net/core/wmem_default: No such file or directory
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
/bin/cat: /proc/sys/net/core/wmem_default: No such file or directory
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
/bin/cat: /proc/sys/net/core/wmem_default: No such file or directory
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.

14.再次查看监听:

[oracle@22edf28f349d lib64]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-MAR-2017 19:27:33

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                08-MAR-2017 18:54:17
Uptime                    0 days 0 hr. 33 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/22edf28f349d/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@22edf28f349d lib64]$ 

15.连接sqlplus

[oracle@22edf28f349d lib64]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 8 19:28:08 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options

SQL> select * from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
HOST_NAME
----------------------------------------------------------------
VERSION       STARTUP_T STATUS     PAR    THREAD# ARCHIVE LOG_SWITCH_WAIT
----------------- --------- ------------ --- ---------- ------- ---------------
LOGINS       SHU DATABASE_STATUS     INSTANCE_ROLE        ACTIVE_ST BLO
---------- --- ----------------- ------------------ --------- ---
          1 orcl
22edf28f349d
11.2.0.1.0      08-MAR-17 OPEN     NO          1 STOPPED
ALLOWED    NO  ACTIVE         PRIMARY_INSTANCE   NORMAL    NO


SQL> 

到此docker下成功完成oracle11g实例的安装完成。

16.建立表空间和用户
在创建之前需要目标目录需要存在即:

[root@7a0b6182a059 orcl]# pwd
/opt/oracle/oradata/orcl

并赋予权限:

[root@7a0b6182a059 ~]# chown -R oracle:dba /opt/oracle
[root@7a0b6182a059 ~]# chmod -R 775 /opt/oracle

创建临时表空间:

SQL> create temporary tablespace user_temp tempfile '/opt/oracle/oradata/orcl/user_temp.dbf' size 50m
  2  autoextend on
  3  next 50m maxsize 20480m
  4  extent management local;

Tablespace created.

SQL> 

 创建数据表空间

SQL> create tablespace user_data
  2  logging
  3  datafile '/opt/oracle/oradata/orcl/user_data.dbf'
  4  size 50m
  5  autoextend on
  6  next 50m maxsize 20480m
  7  extent management local;

Tablespace created.

SQL> 

 创建用户并指定表空间

SQL> create user jzptpub identified by jzptpub
   2  default tablespace user_data
  3  temporary tablespace user_temp;

User created.

 给用户授予权限

SQL> grant connect,resource to jzptpub;

Grant succeeded.


 此时在其他机器上可以远程登录这个用户,命令为:
 $sqlplus test/test@ip/orcl

17.用新建的用户连接数据库,并建立一个表

$ export NLS_LANG=American_America.AL32UTF8 

 注意:UTF8是为了使得sqlplus和linux终端环境一致起来,此时发往数据库的是UTF8,数据库存储前会转为ZHS16GBK.
 当读取时,Sqlplus会把收到的ZHS16GBK转换为UTF8发送到Linux终端。

$sqlplus test/test@ip/orcl

 SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 14 08:22:11 2012

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


 Connected to:
 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
 With the Partitioning, OLAP, Data Mining and Real Application Testing options

 SQL> create table STUDENT(ID int, NAME varchar(20));

 Table created.

 SQL> insert into STUDENT values(1, '张三');

 1 row created.

 SQL> select * from student;

   ID NAME
 ---------- ------------------------------------------------------------
    1 张三

需要注意的地方:

客户端连接配置tnsname.ora文件
docker =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.114.130)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oracle11g)
    )
  )

用pl/sql连接

注1:192.168.114.130为宿主机IP,1521也是宿主机端口,而容器中oracle服务端口1521是映射到宿主机的1521端口
注2:在容器中启动listener,要主意$ORACLE_HOME/network/admin下的listener.ora和tnsname.ora文件中的host参数,这个参数不能写成IP,也不能写成/etc/sysconfig/network中的hostname,只能写成
容器启动时的容器ID号,也可在容器中使用命令查看主机信息uname -a
如:
[oracle@d2126eb6637e ~]$ uname -a
Linux d2126eb6637e 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

原文地址:https://www.cnblogs.com/wq3435/p/6523840.html