您好,登錄后才能下訂單哦!
環境準備
宿主機: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
本例生成模板文件內容如下:
[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="("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME}/control02.ctl")"/>
<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
屏幕上輸入兩次密碼后腳本開始運行
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。