Docker中安装oracle 11.2.0.4

发布时间:2020-07-31 17:51:08 作者:求索之路
来源:网络 阅读:4385

环境准备

宿主机:CentOS Linux release 7.3.1611

Docker Version: 1.12.5

Oracle 11.2.0.4

基础镜像: docker.io/centos

主要步骤

1. 使用centos镜像运行容器

docker run -it -p 192.168.10.51:1521:1521 --name os4oracle -v /container_data/oracle_data:/oracle docker.io/centos

PS: 已在宿主机上解压Oracle安装文件到/container_data/oracle_data/database中

2. 在容器中执行如下操作

groupadd dba

groupadd oinstall

useradd -m -g oinstall -G dba oracle

passwd oracle

useradd nobody

mkdir -p /opt/oracle

mkdir -p /opt/oracle/product/11.2.0/db_1

chown -R oracle:dba /opt

chmod -R 775 /opt


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


/etc/security/limits.conf

oracle soft nproc 2047

oracle hard nproc 16384

oracle soft nofile 1024

oracle hard nofile 65536


/etc/sysctl.conf

fs.aio-max-nr = 1048576

fs.file-max = 6815744

kernel.shmall = 2097152

kernel.shmmax = 936870912

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576


/home/oracle/.bash_profile

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1

export ORACLE_SID=orcl

export ORACLE_TERM=xterm

export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export LANG=en_US

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

3.准备静默安装需要的应答文件和创建数据库需要的模板文件(在可视化的环境中生成)

本例中db_install.rsp 内容如下:

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0

oracle.install.option=INSTALL_DB_SWONLY

ORACLE_HOSTNAME

UNIX_GROUP_NAME=dba

INVENTORY_LOCATION=/opt/oraInventory

SELECTED_LANGUAGES=en,zh_CN

ORACLE_HOME=/opt/oracle/product/11.2.0/db_1

ORACLE_BASE=/opt/oracle

oracle.install.db.InstallEdition=EE

oracle.install.db.EEOptionsSelection=true

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

oracle.install.db.DBA_GROUP=dba

oracle.install.db.OPER_GROUP=dba

oracle.install.db.CLUSTER_NODES=

oracle.install.db.isRACOneInstall=

oracle.install.db.racOneServiceName=

oracle.install.db.config.starterdb.type=GENERAL_PURPOSE

oracle.install.db.config.starterdb.globalDBName=orcl

oracle.install.db.config.starterdb.SID=orcl

oracle.install.db.config.starterdb.characterSet=ZHS16GBK

oracle.install.db.config.starterdb.memoryOption=true

oracle.install.db.config.starterdb.memoryLimit=512

oracle.install.db.config.starterdb.installExampleSchemas=false

oracle.install.db.config.starterdb.enableSecuritySettings=true

oracle.install.db.config.starterdb.password.ALL=oracle

oracle.install.db.config.starterdb.password.SYS=

oracle.install.db.config.starterdb.password.SYSTEM=

oracle.install.db.config.starterdb.password.SYSMAN=

oracle.install.db.config.starterdb.password.DBSNMP=

oracle.install.db.config.starterdb.control=DB_CONTROL

oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=

oracle.install.db.config.starterdb.automatedBackup.enable=false

oracle.install.db.config.starterdb.automatedBackup.osuid=

oracle.install.db.config.starterdb.automatedBackup.ospwd=

oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE

oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/oracle/oracle_data

oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=

oracle.install.db.config.asm.diskGroup=

oracle.install.db.config.asm.ASMSNMPPassword=

MYORACLESUPPORT_USERNAME=

MYORACLESUPPORT_PASSWORD=

SECURITY_UPDATES_VIA_MYORACLESUPPORT=

DECLINE_SECURITY_UPDATES=true

PROXY_HOST=

PROXY_PORT=

PROXY_USER=

PROXY_PWD=

PROXY_REALM=

COLLECTOR_SUPPORTHUB_URL=

oracle.installer.autoupdates.option=

oracle.installer.autoupdates.downloadUpdatesLoc=

AUTOUPDATES_MYORACLESUPPORT_USERNAME=

AUTOUPDATES_MYORACLESUPPORT_PASSWORD=

 

建库模板文件

在可视化的环境中通过dbca生成,重点注意修改参数 JAVA_JIT_ENABLED 为false

Docker中安装oracle 11.2.0.4


Docker中安装oracle 11.2.0.4


本例生成模板文件内容如下:

[root@srv5 oracle_data]# cat orcl.dbc

<?xml version = '1.0'?>

<DatabaseTemplate name="orcl" description="" version="11.2.0.0.0">

   <CommonAttributes>

      <option name="OMS" value="false"/>

      <option name="JSERVER" value="true"/>

      <option name="SPATIAL" value="true"/>

      <option name="IMEDIA" value="true"/>

      <option name="XDB_PROTOCOLS" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="ORACLE_TEXT" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="SAMPLE_SCHEMA" value="false"/>

      <option name="CWMLITE" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="EM_REPOSITORY" value="true">

         <tablespace id="SYSAUX"/>

      </option>

      <option name="APEX" value="true"/>

      <option name="OWB" value="true"/>

      <option name="DV" value="false"/>

   </CommonAttributes>

   <Variables/>

   <CustomScripts Execute="false"/>

   <InitParamAttributes>

      <InitParams>

         <initParam name="db_name" value="orcl"/>

         <initParam name="db_domain" value=""/>

         <initParam name="dispatchers" value="(PROTOCOL=TCP) (SERVICE={SID}XDB)"/>

         <initParam name="audit_file_dest" value="{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump"/>

         <initParam name="compatible" value="11.2.0.4.0"/>

         <initParam name="remote_login_passwordfile" value="EXCLUSIVE"/>

         <initParam name="processes" value="150"/>

         <initParam name="undo_tablespace" value="UNDOTBS1"/>

         <initParam name="control_files" value="(&quot;{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl&quot;, &quot;{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl&quot;)"/>

         <initParam name="diagnostic_dest" value="{ORACLE_BASE}"/>

         <initParam name="db_recovery_file_dest" value="{ORACLE_BASE}/fast_recovery_area"/>

         <initParam name="audit_trail" value="db"/>

         <initParam name="memory_target" value="731" unit="MB"/>

         <initParam name="db_block_size" value="8" unit="KB"/>

         <initParam name="open_cursors" value="300"/>

         <initParam name="db_recovery_file_dest_size" value="4182" unit="MB"/>

      </InitParams>

      <MiscParams>

         <databaseType>MULTIPURPOSE</databaseType>

         <maxUserConn>20</maxUserConn>

         <percentageMemTOSGA>40</percentageMemTOSGA>

         <customSGA>false</customSGA>

         <archiveLogMode>false</archiveLogMode>

         <initParamFileName>{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/pfile/init.ora</initParamFileName>

      </MiscParams>

      <SPfile useSPFile="true">{ORACLE_HOME}/dbs/spfile{SID}.ora</SPfile>

   </InitParamAttributes>

   <StorageAttributes>

      <DataFiles>

         <Location>{ORACLE_HOME}/assistants/dbca/templates/Seed_Database.dfb</Location>

         <SourceDBName>seeddata</SourceDBName>

         <Name id="1" Tablespace="SYSTEM" Contents="PERMANENT" Size="740" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/system01.dbf</Name>

         <Name id="2" Tablespace="SYSAUX" Contents="PERMANENT" Size="470" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/sysaux01.dbf</Name>

         <Name id="3" Tablespace="UNDOTBS1" Contents="UNDO" Size="25" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/undotbs01.dbf</Name>

         <Name id="4" Tablespace="USERS" Contents="PERMANENT" Size="5" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/users01.dbf</Name>

      </DataFiles>

      <TempFiles>

         <Name id="1" Tablespace="TEMP" Contents="TEMPORARY" Size="20">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/temp01.dbf</Name>

      </TempFiles>

      <ControlfileAttributes id="Controlfile">

         <maxDatafiles>100</maxDatafiles>

         <maxLogfiles>16</maxLogfiles>

         <maxLogMembers>3</maxLogMembers>

         <maxLogHistory>1</maxLogHistory>

         <maxInstances>8</maxInstances>

         <p_w_picpath name="control01.ctl" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

         <p_w_picpath name="control02.ctl" filepath="{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/"/>

      </ControlfileAttributes>

      <RedoLogGroupAttributes id="1">

         <reuse>false</reuse>

         <fileSize unit="KB">51200</fileSize>

         <Thread>1</Thread>

         <member ordinal="0" memberName="redo01.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </RedoLogGroupAttributes>

      <RedoLogGroupAttributes id="2">

         <reuse>false</reuse>

         <fileSize unit="KB">51200</fileSize>

         <Thread>1</Thread>

         <member ordinal="0" memberName="redo02.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </RedoLogGroupAttributes>

      <RedoLogGroupAttributes id="3">

         <reuse>false</reuse>

         <fileSize unit="KB">51200</fileSize>

         <Thread>1</Thread>

         <member ordinal="0" memberName="redo03.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>

      </RedoLogGroupAttributes>

   </StorageAttributes>

</DatabaseTemplate>



4.静默安装oracle软件

./runInstaller -ignoreSysPrereqs -ignorePrereq -silent -responseFile /home/oracle/db_install.rsp


5.静默创建数据库

dbca -silent -createDatabase -templateName /home/oracle/orcl.dbc -gdbName orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK

屏幕上输入两次密码后脚本开始运行

Docker中安装oracle 11.2.0.4


6.至此,数据库成功安装,可以自行测试一番。亦可保存次容器为镜像供后续使用。



PS: 如没有执行第3步中修改JAVA_JIT_ENABLED为false,则会遇到如下问题:

建库脚本执行到76%后挂起,查看日志会发现如下错误:

[root@2c9aedc92450 orcl]# cat postDBCreation.log

BEGIN

*

ERROR at line 1:

ORA-29516: Aurora assertion failure: Assertion failure at joez.c:3422

Bulk load of method java/lang/Object.<init> failed; insufficient shm-object space

ORA-06512: at line 3

         IF CatbundleCreateDir(:catbundleLogDir) = 0 THEN

            *

ERROR at line 71:

ORA-06550: line 71, column 14:

PLS-00201: identifier 'CATBUNDLECREATEDIR' must be declared

ORA-06550: line 71, column 11:

PL/SQL: Statement ignored

网上查得该问题的解决办法:

http://blog.csdn.net/xiangsir/article/details/18740803


Docker中安装oracle 11.2.0.4

推荐阅读:
  1. oracle安装GI报错的解决方法
  2. 【Oracle Database】Oracle RAC(三):Grid Infrastructure

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

oracle 容器 docker

上一篇:对URL字符的截取

下一篇:如何实现私有地址访问外网(华为)

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》