Commit f0931cb6 authored by yunjy's avatar yunjy

Initial commit

parents
dd7881a55569d890241f11cd0eeb7d48 oracle-xe-11.2.0-1.0.x86_64.rpm.zip
# LICENSE UPL 1.0
#
# Copyright (c) 2016, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 11g Release 2 Express Edition
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) oracle-xe-11.2.0-1.0.x86_64.rpm.zip
# Download Oracle Database 11g Release 2 Express Edition for Linux x64
# from http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put the downloaded file in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:11.2.0.2-xe .
#
# IMPORTANT
# ---------
# Oracle XE requires Docker 1.10.0 and above:
# Oracle XE uses shared memory for MEMORY_TARGET and needs at least 1 GB.
# Docker only supports --shm-size since Docker 1.10.0
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/u01/app/oracle/oradata" \
"volume.setup.location1"="/u01/app/oracle/scripts/startup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/u01/app/oracle/scripts/setup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.apex"="8080"
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/u01/app/oracle \
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe \
ORACLE_SID=XE \
INSTALL_FILE_1="oracle-xe-11.2.0-1.0.x86_64.rpm.zip" \
INSTALL_DIR="$HOME/install" \
CONFIG_RSP="xe.rsp" \
RUN_FILE="runOracle.sh" \
PWD_FILE="setPassword.sh" \
CHECK_DB_FILE="checkDBStatus.sh"
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$PATH
# Copy binaries
# -------------
COPY $INSTALL_FILE_1 $CONFIG_RSP $RUN_FILE $PWD_FILE $CHECK_DB_FILE $INSTALL_DIR/
# Install Oracle Express Edition
# ------------------------------
RUN yum -y install unzip libaio bc initscripts net-tools openssl compat-libstdc++-33 && \
rm -rf /var/cache/yum && \
cd $INSTALL_DIR && \
unzip $INSTALL_FILE_1 && \
rm $INSTALL_FILE_1 && \
cat() { declare -A PROC=(["/proc/sys/kernel/shmmax"]=4294967295 ["/proc/sys/kernel/shmmni"]=4096 ["/proc/sys/kernel/shmall"]=2097152 ["/proc/sys/fs/file-max"]=6815744); [[ ${PROC[$1]} == "" ]] && /usr/bin/cat $* || echo ${PROC[$1]}; } && \
free() { echo "Swap: 2048 0 2048"; } && \
export -f cat free && \
rpm -i Disk1/*.rpm && \
unset -f cat free && \
mkdir -p $ORACLE_BASE/scripts/setup && \
mkdir $ORACLE_BASE/scripts/startup && \
ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
mkdir $ORACLE_BASE/oradata && \
chown -R oracle:dba $ORACLE_BASE && \
mv $INSTALL_DIR/$CONFIG_RSP $ORACLE_BASE/ && \
mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && \
mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && \
mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ && \
ln -s $ORACLE_BASE/$PWD_FILE / && \
cd $HOME && \
rm -rf $INSTALL_DIR && \
chmod ug+x $ORACLE_BASE/*.sh
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
CMD exec $ORACLE_BASE/$RUN_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
#
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = Database is open and ready to use
# 1 = Database is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
POSITIVE_RETURN="OPEN"
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
# Check Oracle DB status and store it in status
status=`su -p oracle -c "sqlplus -s / as sysdba" << EOF
set heading off;
set pagesize 0;
select status from v\\$instance;
exit;
EOF`
# Store return code from SQL*Plus
ret=$?
# SQL Plus execution was successful and database is open
if [ $ret -eq 0 ] && [ "$status" = "$POSITIVE_RETURN" ]; then
exit 0;
# Database is not open
elif [ "$status" != "$POSITIVE_RETURN" ]; then
exit 1;
# SQL Plus execution failed
else
exit 2;
fi;
#!/bin/bash
############# Execute custom scripts ##############
function runUserScripts {
SCRIPTS_ROOT="$1";
# Check whether parameter has been passed on
if [ -z "$SCRIPTS_ROOT" ]; then
echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run";
exit 1;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then
echo "";
echo "Executing user defined scripts"
for f in $SCRIPTS_ROOT/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; echo "exit" | su -p oracle -c "$ORACLE_HOME/bin/sqlplus / as sysdba @$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo "";
done
echo "DONE: Executing user defined scripts"
echo "";
fi;
}
########### Move DB files ############
function moveFiles {
if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then
su -p oracle -c "mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
fi;
su -p oracle -c "mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
su -p oracle -c "mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
su -p oracle -c "mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
su -p oracle -c "mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
mv /etc/sysconfig/oracle-xe $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
symLinkFiles;
}
########### Symbolic link DB files ############
function symLinkFiles {
if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then
ln -sf $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
ln -sf $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora
fi;
if [ ! -L /etc/sysconfig/oracle-xe ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oracle-xe /etc/sysconfig/oracle-xe
fi;
cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab
}
########### SIGTERM handler ############
function _term() {
echo "Stopping container."
echo "SIGTERM received, shutting down database!"
/etc/init.d/oracle-xe stop
}
############# Create DB ################
function createDB {
# Auto generate ORACLE PWD if not passed on
export ORACLE_PWD=${ORACLE_PWD:-"`openssl rand -hex 8`"}
echo "ORACLE PASSWORD FOR SYS AND SYSTEM: $ORACLE_PWD";
sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" $ORACLE_BASE/$CONFIG_RSP && \
/etc/init.d/oracle-xe configure responseFile=$ORACLE_BASE/$CONFIG_RSP
# Listener
echo "# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = $ORACLE_HOME)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)" > $ORACLE_HOME/network/admin/listener.ora
# TNS Names.ora
echo "# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
" > $ORACLE_HOME/network/admin/tnsnames.ora
su -p oracle -c "sqlplus / as sysdba <<EOF
EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
ALTER DATABASE ADD LOGFILE GROUP 4 ('$ORACLE_BASE/oradata/$ORACLE_SID/redo04.log') SIZE 50m;
ALTER DATABASE ADD LOGFILE GROUP 5 ('$ORACLE_BASE/oradata/$ORACLE_SID/redo05.log') SIZE 50m;
ALTER DATABASE ADD LOGFILE GROUP 6 ('$ORACLE_BASE/oradata/$ORACLE_SID/redo06.log') SIZE 50m;
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM CHECKPOINT;
ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE DROP LOGFILE GROUP 2;
ALTER SYSTEM SET db_recovery_file_dest='';
exit;
EOF"
# Move database operational files to oradata
moveFiles;
}
############# MAIN ################
# Set SIGTERM handler
trap _term SIGTERM
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
symLinkFiles;
# Make sure audit file destination exists
if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
su -p oracle -c "mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump"
fi;
fi;
/etc/init.d/oracle-xe start | grep -qc "Oracle Database 11g Express Edition is not configured"
if [ "$?" == "0" ]; then
# Check whether container has enough memory
if [ `df -Pk /dev/shm | tail -n 1 | awk '{print $2}'` -lt 1048576 ]; then
echo "Error: The container doesn't have enough memory allocated."
echo "A database XE container needs at least 1 GB of shared memory (/dev/shm)."
echo "You currently only have $((`df -Pk /dev/shm | tail -n 1 | awk '{print $2}'`/1024)) MB allocated to the container."
exit 1;
fi;
# Create database
createDB;
# Execute custom provided setup scripts
runUserScripts $ORACLE_BASE/scripts/setup
fi;
# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
# Execute custom provided startup scripts
runUserScripts $ORACLE_BASE/scripts/startup
else
echo "#####################################"
echo "########### E R R O R ###############"
echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
echo "Please check output for further info!"
echo "########### E R R O R ###############"
echo "#####################################"
fi;
echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID
#!/bin/bash
ORACLE_PWD=$1
su -p oracle -c "sqlplus / as sysdba << EOF
ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD";
ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD";
exit;
EOF"
###############################################################################
# #
# HTTP port that will be used to access APEX admin page #
# Default : 8080 #
# #
###############################################################################
ORACLE_HTTP_PORT=8080
###############################################################################
# #
# TNS port that will be used to configure listener #
# Default : 1521 #
# #
###############################################################################
ORACLE_LISTENER_PORT=1521
###############################################################################
# #
# Passwords can be supplied for the following two schemas in the #
# starter database: #
# SYS #
# SYSTEM #
# #
###############################################################################
ORACLE_PASSWORD=###ORACLE_PWD###
###############################################################################
# #
# Passwords can be supplied for the following two schemas in the #
# starter database: #
# SYS #
# SYSTEM #
# #
# ORACLE_CONFIRM_PASSWORD should be same as ORACLE_PASSWORD #
# #
###############################################################################
ORACLE_CONFIRM_PASSWORD=###ORACLE_PWD###
###############################################################################
# #
# To start/stop listener and database instance up on system boot #
# #
###############################################################################
ORACLE_DBENABLE=y
\ No newline at end of file
080435a40bd4c8dff6399b231a808e9a linuxamd64_12102_database_1of2.zip
30f20ef9437442b8282ce3984546c982 linuxamd64_12102_database_2of2.zip
dadbf2cfbc9b53f92d0b07f6677af966 linuxamd64_12102_database_se2_1of2.zip
2bda8cd4883bbd3f892dc152e568fc9e linuxamd64_12102_database_se2_2of2.zip
# LICENSE UPL 1.0
#
# Copyright (c) 2017, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 12c Release 1 Enterprise Edition
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) linuxamd64_12102_database_1of2.zip
# linuxamd64_12102_database_2of2.zip
# Download Oracle Database 12c Release 1 Enterprise Edition for Linux x64
# from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:12.1.0.2-ee .
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim as base
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/12.1.0.2/dbhome_1 \
INSTALL_DIR=/opt/install \
INSTALL_FILE_1="linuxamd64_12102_database_1of2.zip" \
INSTALL_FILE_2="linuxamd64_12102_database_2of2.zip" \
INSTALL_RSP="db_inst.rsp" \
CONFIG_RSP="dbca.rsp.tmpl" \
PWD_FILE="setPassword.sh" \
PERL_INSTALL_FILE="installPerl.sh" \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh"
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH \
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $ORACLE_BASE/
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$CHECK_SPACE_FILE && \
$INSTALL_DIR/$SETUP_LINUX_FILE && \
rm -rf $INSTALL_DIR
#############################################
# -------------------------------------------
# Start new stage for installing the database
# -------------------------------------------
#############################################
FROM base AS builder
ARG DB_EDITION
# Install unzip for unzip operation
RUN yum -y install unzip
# Copy DB install file
COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_FILE_2 $INSTALL_RSP $PERL_INSTALL_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
# Install DB software binaries
USER oracle
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$INSTALL_DB_BINARIES_FILE EE
#############################################
# -------------------------------------------
# Start new layer for database runtime
# -------------------------------------------
#############################################
FROM base
USER oracle
COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE
USER root
RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
$ORACLE_HOME/root.sh
USER oracle
WORKDIR /home/oracle
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
# Define default command to start Oracle Database.
CMD exec $ORACLE_BASE/$RUN_FILE
# LICENSE UPL 1.0
#
# Copyright (c) 2017, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 12c Release 1 Standard Edition 2
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) linuxamd64_12102_database_se2_1of2.zip
# linuxamd64_12102_database_se2_2of2.zip
# Download Oracle Database 12c Release 1 Standard Edition 2 for Linux x64
# from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:12.1.0.2-se2 .
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim as base
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/12.1.0.2/dbhome_1 \
INSTALL_DIR=/opt/install \
INSTALL_FILE_1="linuxamd64_12102_database_se2_1of2.zip" \
INSTALL_FILE_2="linuxamd64_12102_database_se2_2of2.zip" \
INSTALL_RSP="db_inst.rsp" \
CONFIG_RSP="dbca.rsp.tmpl" \
PWD_FILE="setPassword.sh" \
PERL_INSTALL_FILE="installPerl.sh" \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh"
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH \
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $ORACLE_BASE/
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$CHECK_SPACE_FILE && \
$INSTALL_DIR/$SETUP_LINUX_FILE && \
rm -rf $INSTALL_DIR
#############################################
# -------------------------------------------
# Start new stage for installing the database
# -------------------------------------------
#############################################
FROM base AS builder
ARG DB_EDITION
# Install unzip for unzip operation
RUN yum -y install unzip
# Copy DB install file
COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_FILE_2 $INSTALL_RSP $PERL_INSTALL_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
# Install DB software binaries
USER oracle
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$INSTALL_DB_BINARIES_FILE SE2
#############################################
# -------------------------------------------
# Start new layer for database runtime
# -------------------------------------------
#############################################
FROM base
USER oracle
COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE
USER root
RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
$ORACLE_HOME/root.sh
USER oracle
WORKDIR /home/oracle
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
# Define default command to start Oracle Database.
CMD exec $ORACLE_BASE/$RUN_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
source oraenv
# Check Oracle at least one PDB has open_mode "READ WRITE" and store it in status
status=`sqlplus -s / as sysdba << EOF
set heading off;
set pagesize 0;
SELECT DISTINCT open_mode FROM v\\$pdbs WHERE open_mode = '$OPEN_MODE';
exit;
EOF`
# Store return code from SQL*Plus
ret=$?
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$OPEN_MODE" ]; then
exit 0;
# PDB is not open
elif [ "$status" != "$OPEN_MODE" ]; then
exit 1;
# SQL Plus execution failed
else
exit 2;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
#
# Since: January, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the available space of the system.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
REQUIRED_SPACE_GB=12
AVAILABLE_SPACE_GB=`df -PB 1G / | tail -n 1 | awk '{ print $4 }'`
if [ $AVAILABLE_SPACE_GB -lt $REQUIRED_SPACE_GB ]; then
script_name=`basename "$0"`
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "$script_name: ERROR - There is not enough space available in the container."
echo "$script_name: The container needs at least $REQUIRED_SPACE_GB GB, but only $AVAILABLE_SPACE_GB GB are available."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Creates an Oracle Database based on following parameters:
# $ORACLE_SID: The Oracle SID and CDB name
# $ORACLE_PDB: The PDB name
# $ORACLE_PWD: The Oracle password
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
set -e
# Check whether ORACLE_SID is passed on
export ORACLE_SID=${1:-ORCLCDB}
# Check whether ORACLE_PDB is passed on
export ORACLE_PDB=${2:-ORCLPDB1}
# Auto generate ORACLE PWD if not passed on
export ORACLE_PWD=${3:-"`openssl rand -base64 8`1"}
echo "ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: $ORACLE_PWD";
# Replace place holders in response file
cp $ORACLE_BASE/$CONFIG_RSP $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_SID###|$ORACLE_SID|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PDB###|$ORACLE_PDB|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" $ORACLE_BASE/dbca.rsp
# If there is greater than 8 CPUs default back to dbca memory calculations
# dbca will automatically pick 40% of available memory for Oracle DB
# The minimum of 2G is for small environments to guarantee that Oracle has enough memory to function
# However, bigger environment can and should use more of the available memory
# This is due to Github Issue #307
if [ `nproc` -gt 8 ]; then
sed -i -e 's|TOTALMEMORY = "2048"||g' $ORACLE_BASE/dbca.rsp
fi;
# Create network related config files (sqlnet.ora, tnsnames.ora, listener.ora)
mkdir -p $ORACLE_HOME/network/admin
echo "NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)" > $ORACLE_HOME/network/admin/sqlnet.ora
# Listener.ora
echo "LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
DEDICATED_THROUGH_BROKER_LISTENER=ON
DIAG_ADR_ENABLED = off
" > $ORACLE_HOME/network/admin/listener.ora
# Start LISTENER and run DBCA
lsnrctl start &&
dbca -silent -responseFile $ORACLE_BASE/dbca.rsp ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID.log
echo "$ORACLE_SID=localhost:1521/$ORACLE_SID" > $ORACLE_HOME/network/admin/tnsnames.ora
echo "$ORACLE_PDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = $ORACLE_PDB)
)
)" >> $ORACLE_HOME/network/admin/tnsnames.ora
# Remove second control file, make PDB auto open
sqlplus / as sysdba << EOF
ALTER SYSTEM SET control_files='$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl' scope=spfile;
ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE;
exit;
EOF
# Remove temporary response file
rm $ORACLE_BASE/dbca.rsp
####################################################################
## Copyright(c) Oracle Corporation 1998,2014. 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_v12.1.0
#-------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# - INSTALL_DB_SWONLY
# - INSTALL_DB_AND_CONFIG
# - UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#-------------------------------------------------------------------------------
# Specify the hostname of the system as set during the install. It can be used
# to force the installation to use an alternative hostname rather than using the
# first hostname found on the system. (e.g., for systems with multiple hostnames
# and network interfaces)
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=localhost
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=###ORACLE_BASE###/oraInventory
#-------------------------------------------------------------------------------
# Specify the languages in which the components will be installed.
#
# en : English ja : Japanese
# fr : French ko : Korean
# ar : Arabic es : Latin American Spanish
# bn : Bengali lv : Latvian
# pt_BR: Brazilian Portuguese lt : Lithuanian
# bg : Bulgarian ms : Malay
# fr_CA: Canadian French es_MX: Mexican Spanish
# ca : Catalan no : Norwegian
# hr : Croatian pl : Polish
# cs : Czech pt : Portuguese
# da : Danish ro : Romanian
# nl : Dutch ru : Russian
# ar_EG: Egyptian zh_CN: Simplified Chinese
# en_GB: English (Great Britain) sk : Slovak
# et : Estonian sl : Slovenian
# fi : Finnish es_ES: Spanish
# de : German sv : Swedish
# el : Greek th : Thai
# iw : Hebrew zh_TW: Traditional Chinese
# hu : Hungarian tr : Turkish
# is : Icelandic uk : Ukrainian
# in : Indonesian vi : Vietnamese
# it : Italian
#
# all_langs : All languages
#
# Specify value as the following to select any of the languages.
# Example : SELECTED_LANGUAGES=en,fr,ja
#
# Specify value as the following to select all the languages.
# Example : SELECTED_LANGUAGES=all_langs
#-------------------------------------------------------------------------------
SELECTED_LANGUAGES=en
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#------------------------------------------------------------------------------
ORACLE_HOME=###ORACLE_HOME###
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=###ORACLE_BASE###
#-------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# - EE : Enterprise Edition
# - SE2 : Standard Edition Two
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=###ORACLE_EDITION###
###############################################################################
# #
# 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
#------------------------------------------------------------------------------
# The BACKUPDBA_GROUP is the OS group which is to be granted OSBACKUPDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.BACKUPDBA_GROUP=dba
#------------------------------------------------------------------------------
# The DGDBA_GROUP is the OS group which is to be granted OSDGDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.DGDBA_GROUP=dba
#------------------------------------------------------------------------------
# The KMDBA_GROUP is the OS group which is to be granted OSKMDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.KMDBA_GROUP=dba
#------------------------------------------------------------------------------
# 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=false
#------------------------------------------------------------------------------
# Specify whether user doesn't want to configure Security Updates.
# The value for this variable should be true if you don't want to configure
# Security Updates, false otherwise.
#
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
##############################################################################
## ##
## DBCA response file ##
## ------------------ ##
## Copyright 1998, 2014, Oracle Corporation. All Rights Reserved. ##
## ##
## Specify values for the variables listed below to customize Oracle ##
## Database Configuration installation. ##
## ##
## Each variable is associated with a comment. The comment identifies the ##
## variable type. ##
## ##
## Please specify the values in the following format : ##
## Type : Example ##
## String : "<value>" ##
## Boolean : True or False ##
## Number : <numeric value> ##
## StringList : {"<value1>","<value2>"} ##
## ##
## Examples : ##
## 1. dbca -progress_only -responseFile <response file> ##
## Display a progress bar depicting progress of database creation ##
## process. ##
## ##
## 2. dbca -silent -responseFile <response file> ##
## Creates database silently. No user interface is displayed. ##
## ##
## 3. dbca -silent -createDatabase -cloneTemplate ##
## -responseFile <response file> ##
## Creates database silently with clone template. The template in ##
## responsefile is a clone template. ##
## ##
## 4. dbca -silent -deleteDatabase -responseFile <response file> ##
## Deletes database silently. ##
##############################################################################
#-----------------------------------------------------------------------------
# GENERAL section is required for all types of database creations.
#-----------------------------------------------------------------------------
[GENERAL]
#-----------------------------------------------------------------------------
# Name : RESPONSEFILE_VERSION
# Datatype : String
# Description : Version of the database to create
# Valid values : "12.1.0"
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
RESPONSEFILE_VERSION = "12.1.0"
#-----------------------------------------------------------------------------
# Name : OPERATION_TYPE
# Datatype : String
# Description : Type of operation
# Valid values : "createDatabase" \ "createTemplateFromDB" \ "createCloneTemplate" \ "deleteDatabase" \ "configureDatabase" \ "addInstance" (RAC-only) \ "deleteInstance" (RAC-only) \ "createPluggableDatabase" \ "unplugDatabase" \ "deletePluggableDatabase" \ "configurePluggableDatabase"
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
OPERATION_TYPE = "createDatabase"
#-----------------------*** End of GENERAL section ***------------------------
#-----------------------------------------------------------------------------
# CREATEDATABASE section is used when OPERATION_TYPE is defined as "createDatabase".
#-----------------------------------------------------------------------------
[CREATEDATABASE]
#-----------------------------------------------------------------------------
# Name : GDBNAME
# Datatype : String
# Description : Global database name of the database
# Valid values : <db_name>.<db_domain> - when database domain isn't NULL
# <db_name> - when database domain is NULL
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
GDBNAME = "###ORACLE_SID###"
#-----------------------------------------------------------------------------
# Name : DATABASECONFTYPE
# Datatype : String
# Description : database conf type as Single Instance, Real Application Cluster or Real Application Cluster One Nodes database
# Valid values : SI\RAC\RACONENODE
# Default value : SI
# Mandatory : No
#-----------------------------------------------------------------------------
#DATABASECONFTYPE = "SI"
#-----------------------------------------------------------------------------
# Name : SID
# Datatype : String
# Description : System identifier (SID) of the database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory : No
#-----------------------------------------------------------------------------
SID = "###ORACLE_SID###"
#-----------------------------------------------------------------------------
# Name : CREATEASCONTAINERDATABASE
# Datatype : boolean
# Description : flag to create database as container database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : false
# Mandatory : No
#-----------------------------------------------------------------------------
CREATEASCONTAINERDATABASE = "true"
#-----------------------------------------------------------------------------
# Name : NUMBEROFPDBS
# Datatype : Number
# Description : Specify the number of pdb to be created
# Valid values : 0 to 252
# Default value : 0
# Mandatory : No
#-----------------------------------------------------------------------------
NUMBEROFPDBS = 1
#-----------------------------------------------------------------------------
# Name : PDBNAME
# Datatype : String
# Description : Specify the pdbname/pdbanme prefix if one or more pdb need to be created
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
PDBNAME = "###ORACLE_PDB###"
#-----------------------------------------------------------------------------
# Name : PDBADMINPASSWORD
# Datatype : String
# Description : PDB Administrator user password
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
PDBADMINPASSWORD = "###ORACLE_PWD###"
#-----------------------------------------------------------------------------
# Name : TEMPLATENAME
# Datatype : String
# Description : Name of the template
# Valid values : Template file name
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
TEMPLATENAME = "General_Purpose.dbc"
#-----------------------------------------------------------------------------
# Name : SYSPASSWORD
# Datatype : String
# Description : Password for SYS user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
SYSPASSWORD = "###ORACLE_PWD###"
#-----------------------------------------------------------------------------
# Name : SYSTEMPASSWORD
# Datatype : String
# Description : Password for SYSTEM user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
SYSTEMPASSWORD = "###ORACLE_PWD###"
#-----------------------------------------------------------------------------
# Name : SERVICEUSERPASSWORD
# Datatype : String
# Description : Password for Windows Service user
# Default value : None
# Mandatory : If Oracle home is installed with windows service user
#-----------------------------------------------------------------------------
#SERVICEUSERPASSWORD = "password"
#-----------------------------------------------------------------------------
# Name : EMCONFIGURATION
# Datatype : String
# Description : Enterprise Manager Configuration Type
# Valid values : CENTRAL|DBEXPRESS|ALL|NONE
# Default value : NONE
# Mandatory : No
#-----------------------------------------------------------------------------
EMCONFIGURATION = "DBEXPRESS"
#-----------------------------------------------------------------------------
# Name : EMEXPRESSPORT
# Datatype : Number
# Description : Enterprise Manager Configuration Type
# Valid values : Check Oracle12c Administrator's Guide
# Default value : NONE
# Mandatory : No, will be picked up from DBEXPRESS_HTTPS_PORT env variable
# or auto generates a free port between 5500 and 5599
#-----------------------------------------------------------------------------
EMEXPRESSPORT = "5500"
#-----------------------------------------------------------------------------
# Name : DBSNMPPASSWORD
# Datatype : String
# Description : Password for DBSNMP user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes, if EMCONFIGURATION is specified or
# the value of RUNCVUCHECKS is TRUE
#-----------------------------------------------------------------------------
DBSNMPPASSWORD = "###ORACLE_PWD###"
#-----------------------------------------------------------------------------
# Name : STORAGETYPE
# Datatype : String
# Description : Specifies the storage on which the database is to be created
# Valid values : FS (CFS for RAC), ASM
# Default value : FS
# Mandatory : No
#-----------------------------------------------------------------------------
#STORAGETYPE=FS
#-----------------------------------------------------------------------------
# Name : CHARACTERSET
# Datatype : String
# Description : Character set of the database
# Valid values : Check Oracle12c National Language Support Guide
# Default value : "US7ASCII"
# Mandatory : NO
#-----------------------------------------------------------------------------
CHARACTERSET = "###ORACLE_CHARACTERSET###"
#-----------------------------------------------------------------------------
# Name : NATIONALCHARACTERSET
# Datatype : String
# Description : National Character set of the database
# Valid values : "UTF8" or "AL16UTF16". For details, check Oracle12c National Language Support Guide
# Default value : "AL16UTF16"
# Mandatory : No
#-----------------------------------------------------------------------------
NATIONALCHARACTERSET= "AL16UTF16"
#-----------------------------------------------------------------------------
# Name : INITPARAMS
# Datatype : String
# Description : comma separated list of name=value pairs. Overrides initialization parameters defined in templates
# Default value : None
# Mandatory : NO
#-----------------------------------------------------------------------------
INITPARAMS = db_recovery_file_dest=/opt/oracle/oradata/fast_recovery_area,audit_trail=none,audit_sys_operations=false
#-----------------------------------------------------------------------------
# Name : AUTOMATICMEMORYMANAGEMENT
# Datatype : Boolean
# Description : flag to indicate Automatic Memory Management is used
# Valid values : TRUE/FALSE
# Default value : TRUE
# Mandatory : NO
#-----------------------------------------------------------------------------
AUTOMATICMEMORYMANAGEMENT = "FALSE"
#-----------------------------------------------------------------------------
# Name : TOTALMEMORY
# Datatype : String
# Description : total memory in MB to allocate to Oracle
# Valid values :
# Default value :
# Mandatory : NO
#-----------------------------------------------------------------------------
TOTALMEMORY = "2048"
#-----------------------*** End of CREATEDATABASE section ***------------------------
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
EDITION=$1
# Check whether edition has been passed on
if [ "$EDITION" == "" ]; then
echo "ERROR: No edition has been passed on!"
echo "Please specify the correct edition!"
exit 1;
fi;
# Check whether correct edition has been passed on
if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then
echo "ERROR: Wrong edition has been passed on!"
echo "Edition $EDITION is no a valid edition!"
exit 1;
fi;
# Check whether ORACLE_BASE is set
if [ "$ORACLE_BASE" == "" ]; then
echo "ERROR: ORACLE_BASE has not been set!"
echo "You have to have the ORACLE_BASE environment variable set to a valid value!"
exit 1;
fi;
# Check whether ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
echo "ERROR: ORACLE_HOME has not been set!"
echo "You have to have the ORACLE_HOME environment variable set to a valid value!"
exit 1;
fi;
# Replace place holders
# ---------------------
sed -i -e "s|###ORACLE_EDITION###|$EDITION|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_BASE###|$ORACLE_BASE|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_HOME###|$ORACLE_HOME|g" $INSTALL_DIR/$INSTALL_RSP
# Install Oracle binaries
cd $INSTALL_DIR && \
unzip $INSTALL_FILE_1 && \
rm $INSTALL_FILE_1 && \
unzip $INSTALL_FILE_2 && \
rm $INSTALL_FILE_2 && \
$INSTALL_DIR/database/runInstaller -silent -force -waitforcompletion -responsefile $INSTALL_DIR/$INSTALL_RSP -ignoresysprereqs -ignoreprereq && \
cd $HOME
# Remove not needed components
# APEX
rm -rf $ORACLE_HOME/apex && \
# ORDS
rm -rf $ORACLE_HOME/ords && \
# SQL Developer
rm -rf $ORACLE_HOME/sqldeveloper && \
# UCP connection pool
rm -rf $ORACLE_HOME/ucp && \
# All installer files
rm -rf $ORACLE_HOME/lib/*.zip && \
# OUI backup
rm -rf $ORACLE_HOME/inventory/backup/* && \
# Network tools help
rm -rf $ORACLE_HOME/network/tools/help && \
# Database upgrade assistant
rm -rf $ORACLE_HOME/assistants/dbua && \
# Database migration assistant
rm -rf $ORACLE_HOME/dmu && \
# Remove pilot workflow installer
rm -rf $ORACLE_HOME/install/pilot && \
# Support tools
rm -rf $ORACLE_HOME/suptools && \
# Temp location
rm -rf /tmp/* && \
# Database files directory
rm -rf $INSTALL_DIR/database
# Check whether Perl is working
chmod ug+x $INSTALL_DIR/$PERL_INSTALL_FILE && \
$ORACLE_HOME/perl/bin/perl -v || \
$INSTALL_DIR/$PERL_INSTALL_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Installs new Perl binaries if not present
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Install latest Perl
# Exit immediately if any command exits non-zero
set -e
cd $INSTALL_DIR
mv $ORACLE_HOME/perl $ORACLE_HOME/perl.old
curl -o perl.tar.gz http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz
tar -xzf perl.tar.gz
cd perl-*
./Configure -des -Dprefix=$ORACLE_HOME/perl -Doptimize=-O3 -Dusethreads -Duseithreads -Duserelocatableinc
make clean
make
make install
# Copy old binaries into new Perl dir
cd $ORACLE_HOME/perl
rm -rf lib/ man/
cp -r ../perl.old/lib/ .
cp -r ../perl.old/man/ .
cp ../perl.old/bin/dbilogstrip bin/
cp ../perl.old/bin/dbiprof bin/
cp ../perl.old/bin/dbiproxy bin/
cp ../perl.old/bin/ora_explain bin/
cd $ORACLE_HOME/lib
ln -sf ../javavm/jdk/jdk7/lib/libjavavm12.a
# Relink Oracle
cd $ORACLE_HOME/bin
if ! relink all; then
echo "Relink all failed"
cat "$ORACLE_HOME/install/relink.log"
exit 1
fi
# Cleanup
rm -rf $ORACLE_HOME/perl.old
rm -rf $INSTALL_DIR/perl-*
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Runs the Oracle Database inside the container
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
########### Move DB files ############
function moveFiles {
if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then
mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
fi;
mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/sqlnet.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
# oracle user does not have permissions in /etc, hence cp and not mv
cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
symLinkFiles;
}
########### Symbolic link DB files ############
function symLinkFiles {
if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ ! -L $ORACLE_HOME/network/admin/sqlnet.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/sqlnet.ora $ORACLE_HOME/network/admin/sqlnet.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora
fi;
# oracle user does not have permissions in /etc, hence cp and not ln
cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab
}
########### SIGINT handler ############
function _int() {
echo "Stopping container."
echo "SIGINT received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
########### SIGTERM handler ############
function _term() {
echo "Stopping container."
echo "SIGTERM received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
###################################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
############# MAIN ################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
###################################
# Check whether container has enough memory
# Github issue #219: Prevent integer overflow,
# only check if memory digits are less than 11 (single GB range and below)
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes | wc -c` -lt 11 ]; then
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes` -lt 2147483648 ]; then
echo "Error: The container doesn't have enough memory allocated."
echo "A database container needs at least 2 GB of memory."
echo "You currently only have $((`cat /sys/fs/cgroup/memory/memory.limit_in_bytes`/1024/1024/1024)) GB allocated to the container."
exit 1;
fi;
fi;
# Check that hostname doesn't container any "_"
# Github issue #711
if hostname | grep -q "_"; then
echo "Error: The hostname must not container any '_'".
echo "Your current hostname is '$(hostname)'"
fi;
# Set SIGINT handler
trap _int SIGINT
# Set SIGTERM handler
trap _term SIGTERM
# Default for ORACLE SID
if [ "$ORACLE_SID" == "" ]; then
export ORACLE_SID=ORCLCDB
else
# Make ORACLE_SID upper case
# Github issue # 984
export ORACLE_SID=${ORACLE_SID^^}
# Check whether SID is no longer than 12 bytes
# Github issue #246: Cannot start OracleDB image
if [ "${#ORACLE_SID}" -gt 12 ]; then
echo "Error: The ORACLE_SID must only be up to 12 characters long."
exit 1;
fi;
# Check whether SID is alphanumeric
# Github issue #246: Cannot start OracleDB image
if [[ "$ORACLE_SID" =~ [^a-zA-Z0-9] ]]; then
echo "Error: The ORACLE_SID must be alphanumeric."
exit 1;
fi;
fi;
# Default for ORACLE PDB
export ORACLE_PDB=${ORACLE_PDB:-ORCLPDB1}
# Make ORACLE_PDB upper case
# Github issue # 984
export ORACLE_PDB=${ORACLE_PDB^^}
# Default for ORACLE CHARACTERSET
export ORACLE_CHARACTERSET=${ORACLE_CHARACTERSET:-AL32UTF8}
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
symLinkFiles;
# Make sure audit file destination exists
if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
fi;
# Start database
$ORACLE_BASE/$START_FILE;
else
# Remove database config files, if they exist
rm -f $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
rm -f $ORACLE_HOME/dbs/orapw$ORACLE_SID
rm -f $ORACLE_HOME/network/admin/sqlnet.ora
rm -f $ORACLE_HOME/network/admin/listener.ora
rm -f $ORACLE_HOME/network/admin/tnsnames.ora
# Create database
$ORACLE_BASE/$CREATE_DB_FILE $ORACLE_SID $ORACLE_PDB $ORACLE_PWD;
# Move database operational files to oradata
moveFiles;
# Execute custom provided setup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/setup
fi;
# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
# Execute custom provided startup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/startup
else
echo "#####################################"
echo "########### E R R O R ###############"
echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
echo "Please check output for further info!"
echo "########### E R R O R ###############"
echo "#####################################"
fi;
# Tail on alert log and wait (otherwise container will exit)
echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
#
# Since: July, 2017
# Author: gerald.venzl@oracle.com
# Description: Runs user shell and SQL scripts
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
SCRIPTS_ROOT="$1";
# Check whether parameter has been passed on
if [ -z "$SCRIPTS_ROOT" ]; then
echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run";
exit 1;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then
echo "";
echo "Executing user defined scripts"
for f in $SCRIPTS_ROOT/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; echo "exit" | $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" @"$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo "";
done
echo "DONE: Executing user defined scripts"
echo "";
fi;
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets the password for sys, system and pdb_admin
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_PWD=$1
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
ORAENV_ASK=NO
source oraenv
sqlplus / as sysdba << EOF
ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD";
ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD";
ALTER SESSION SET CONTAINER=$ORACLE_PDB;
ALTER USER PDBADMIN IDENTIFIED BY "$ORACLE_PWD";
exit;
EOF
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Setup filesystem and oracle user
# Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with Oracle installation
# ------------------------------------------------------------
mkdir -p $ORACLE_BASE/scripts/setup && \
mkdir $ORACLE_BASE/scripts/startup && \
ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
mkdir $ORACLE_BASE/oradata && \
mkdir -p $ORACLE_HOME && \
chmod ug+x $ORACLE_BASE/*.sh && \
yum -y install oracle-rdbms-server-12cR1-preinstall tar openssl && \
rm -rf /var/cache/yum && \
ln -s $ORACLE_BASE/$PWD_FILE /home/oracle/ && \
echo oracle:oracle | chpasswd && \
chown -R oracle:dba $ORACLE_BASE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Starts the Listener and Oracle Database.
# The ORACLE_HOME and the PATH has to be set.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Check that ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
script_name=`basename "$0"`
echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script."
exit 1;
fi;
# Start Listener
lsnrctl start
# Start database
sqlplus / as sysdba << EOF
STARTUP;
exit;
EOF
1841f2ce7709cf909db4c064d80aae79 linuxx64_12201_database.zip
1841f2ce7709cf909db4c064d80aae79 linuxx64_12201_database.zip
# LICENSE UPL 1.0
#
# Copyright (c) 2017, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 12c Release 2
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) linuxx64_12201_database.zip
# Download Oracle Database 12c Release 12 Enterprise Edition or Standard Edition 2 for Linux x64
# from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:12.2.0.1-${EDITION} .
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim as base
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/12.2.0.1/dbhome_1 \
INSTALL_DIR=/opt/install \
INSTALL_FILE_1="linuxx64_12201_database.zip" \
INSTALL_RSP="db_inst.rsp" \
CONFIG_RSP="dbca.rsp.tmpl" \
PWD_FILE="setPassword.sh" \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh"
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH \
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $ORACLE_BASE/
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$CHECK_SPACE_FILE && \
$INSTALL_DIR/$SETUP_LINUX_FILE && \
rm -rf $INSTALL_DIR
#############################################
# -------------------------------------------
# Start new stage for installing the database
# -------------------------------------------
#############################################
FROM base AS builder
ARG DB_EDITION
# Install unzip for unzip operation
RUN yum -y install unzip
# Copy DB install file
COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
# Install DB software binaries
USER oracle
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$INSTALL_DB_BINARIES_FILE $DB_EDITION
#############################################
# -------------------------------------------
# Start new layer for database runtime
# -------------------------------------------
#############################################
FROM base
USER oracle
COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE
USER root
RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
$ORACLE_HOME/root.sh
USER oracle
WORKDIR /home/oracle
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
# Define default command to start Oracle Database.
CMD exec $ORACLE_BASE/$RUN_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
source oraenv
# Check Oracle at least one PDB has open_mode "READ WRITE" and store it in status
status=`sqlplus -s / as sysdba << EOF
set heading off;
set pagesize 0;
SELECT DISTINCT open_mode FROM v\\$pdbs WHERE open_mode = '$OPEN_MODE';
exit;
EOF`
# Store return code from SQL*Plus
ret=$?
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$OPEN_MODE" ]; then
exit 0;
# PDB is not open
elif [ "$status" != "$OPEN_MODE" ]; then
exit 1;
# SQL Plus execution failed
else
exit 2;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
#
# Since: January, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the available space of the system.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
REQUIRED_SPACE_GB=15
AVAILABLE_SPACE_GB=`df -PB 1G / | tail -n 1 | awk '{ print $4 }'`
if [ $AVAILABLE_SPACE_GB -lt $REQUIRED_SPACE_GB ]; then
script_name=`basename "$0"`
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "$script_name: ERROR - There is not enough space available in the container."
echo "$script_name: The container needs at least $REQUIRED_SPACE_GB GB, but only $AVAILABLE_SPACE_GB GB are available."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Creates an Oracle Database based on following parameters:
# $ORACLE_SID: The Oracle SID and CDB name
# $ORACLE_PDB: The PDB name
# $ORACLE_PWD: The Oracle password
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
set -e
# Check whether ORACLE_SID is passed on
export ORACLE_SID=${1:-ORCLCDB}
# Check whether ORACLE_PDB is passed on
export ORACLE_PDB=${2:-ORCLPDB1}
# Auto generate ORACLE PWD if not passed on
export ORACLE_PWD=${3:-"`openssl rand -base64 8`1"}
echo "ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: $ORACLE_PWD";
# Replace place holders in response file
cp $ORACLE_BASE/$CONFIG_RSP $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_SID###|$ORACLE_SID|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PDB###|$ORACLE_PDB|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" $ORACLE_BASE/dbca.rsp
# If there is greater than 8 CPUs default back to dbca memory calculations
# dbca will automatically pick 40% of available memory for Oracle DB
# The minimum of 2G is for small environments to guarantee that Oracle has enough memory to function
# However, bigger environment can and should use more of the available memory
# This is due to Github Issue #307
if [ `nproc` -gt 8 ]; then
sed -i -e "s|totalMemory=2048||g" $ORACLE_BASE/dbca.rsp
fi;
# Create network related config files (sqlnet.ora, tnsnames.ora, listener.ora)
mkdir -p $ORACLE_HOME/network/admin
echo "NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)" > $ORACLE_HOME/network/admin/sqlnet.ora
# Listener.ora
echo "LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
DEDICATED_THROUGH_BROKER_LISTENER=ON
DIAG_ADR_ENABLED = off
" > $ORACLE_HOME/network/admin/listener.ora
# Start LISTENER and run DBCA
lsnrctl start &&
dbca -silent -createDatabase -responseFile $ORACLE_BASE/dbca.rsp ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID.log
echo "$ORACLE_SID=localhost:1521/$ORACLE_SID" > $ORACLE_HOME/network/admin/tnsnames.ora
echo "$ORACLE_PDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = $ORACLE_PDB)
)
)" >> $ORACLE_HOME/network/admin/tnsnames.ora
# Remove second control file, fix local_listener, make PDB auto open, enable EM global port
sqlplus / as sysdba << EOF
ALTER SYSTEM SET control_files='$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl' scope=spfile;
ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE;
EXEC DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE);
exit;
EOF
# Remove temporary response file
rm $ORACLE_BASE/dbca.rsp
####################################################################
## Copyright(c) Oracle Corporation 1998,2017. 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_v12.2.0
#-------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# - INSTALL_DB_SWONLY
# - INSTALL_DB_AND_CONFIG
# - UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=###ORACLE_BASE###/oraInventory
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#-------------------------------------------------------------------------------
ORACLE_HOME=###ORACLE_HOME###
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=###ORACLE_BASE###
#-------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# - EE : Enterprise Edition
# - SE2 : Standard Edition 2
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=###ORACLE_EDITION###
###############################################################################
# #
# PRIVILEGED OPERATING SYSTEM GROUPS #
# ------------------------------------------ #
# Provide values for the OS groups to which SYSDBA and SYSOPER 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 OSDBA_GROUP is the OS group which is to be granted SYSDBA privileges.
#-------------------------------------------------------------------------------
oracle.install.db.OSDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSOPER_GROUP is the OS group which is to be granted SYSOPER privileges.
# The value to be specified for OSOPER group is optional.
#------------------------------------------------------------------------------
oracle.install.db.OSOPER_GROUP=dba
#------------------------------------------------------------------------------
# The OSBACKUPDBA_GROUP is the OS group which is to be granted SYSBACKUP privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSBACKUPDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSDGDBA_GROUP is the OS group which is to be granted SYSDG privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSDGDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSKMDBA_GROUP is the OS group which is to be granted SYSKM privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSKMDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSRACDBA_GROUP is the OS group which is to be granted SYSRAC privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSRACDBA_GROUP=dba
#------------------------------------------------------------------------------
# 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=false
#------------------------------------------------------------------------------
# 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 true.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
\ No newline at end of file
##############################################################################
## ##
## DBCA response file ##
## ------------------ ##
## Copyright(c) Oracle Corporation 1998,2017. 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.
#-------------------------------------------------------------------------------
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0
#-----------------------------------------------------------------------------
# Name : gdbName
# Datatype : String
# Description : Global database name of the database
# Valid values : <db_name>.<db_domain> - when database domain isn't NULL
# <db_name> - when database domain is NULL
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
gdbName=###ORACLE_SID###
#-----------------------------------------------------------------------------
# Name : sid
# Datatype : String
# Description : System identifier (SID) of the database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory : No
#-----------------------------------------------------------------------------
sid=###ORACLE_SID###
#-----------------------------------------------------------------------------
# Name : createAsContainerDatabase
# Datatype : boolean
# Description : flag to create database as container database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : false
# Mandatory : No
#-----------------------------------------------------------------------------
createAsContainerDatabase=true
#-----------------------------------------------------------------------------
# Name : numberOfPDBs
# Datatype : Number
# Description : Specify the number of pdb to be created
# Valid values : 0 to 4094
# Default value : 0
# Mandatory : No
#-----------------------------------------------------------------------------
numberOfPDBs=1
#-----------------------------------------------------------------------------
# Name : pdbName
# Datatype : String
# Description : Specify the pdbname/pdbname prefix if one or more pdb need to be created
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
pdbName=###ORACLE_PDB###
#-----------------------------------------------------------------------------
# Name : pdbAdminPassword
# Datatype : String
# Description : PDB Administrator user password
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
pdbAdminPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : templateName
# Datatype : String
# Description : Name of the template
# Valid values : Template file name
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
templateName=General_Purpose.dbc
#-----------------------------------------------------------------------------
# Name : sysPassword
# Datatype : String
# Description : Password for SYS user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
sysPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : systemPassword
# Datatype : String
# Description : Password for SYSTEM user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
systemPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : emConfiguration
# Datatype : String
# Description : Enterprise Manager Configuration Type
# Valid values : CENTRAL|DBEXPRESS|BOTH|NONE
# Default value : NONE
# Mandatory : No
#-----------------------------------------------------------------------------
emConfiguration=DBEXPRESS
#-----------------------------------------------------------------------------
# Name : emExpressPort
# Datatype : Number
# Description : Enterprise Manager Configuration Type
# Valid values : Check Oracle12c Administrator's Guide
# Default value : NONE
# Mandatory : No, will be picked up from DBEXPRESS_HTTPS_PORT env variable
# or auto generates a free port between 5500 and 5599
#-----------------------------------------------------------------------------
emExpressPort=5500
#-----------------------------------------------------------------------------
# Name : dbsnmpPassword
# Datatype : String
# Description : Password for DBSNMP user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes, if emConfiguration is specified or
# the value of runCVUChecks is TRUE
#-----------------------------------------------------------------------------
dbsnmpPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : characterSet
# Datatype : String
# Description : Character set of the database
# Valid values : Check Oracle12c National Language Support Guide
# Default value : "US7ASCII"
# Mandatory : NO
#-----------------------------------------------------------------------------
characterSet=###ORACLE_CHARACTERSET###
#-----------------------------------------------------------------------------
# Name : nationalCharacterSet
# Datatype : String
# Description : National Character set of the database
# Valid values : "UTF8" or "AL16UTF16". For details, check Oracle12c National Language Support Guide
# Default value : "AL16UTF16"
# Mandatory : No
#-----------------------------------------------------------------------------
nationalCharacterSet=AL16UTF16
#-----------------------------------------------------------------------------
# Name : initParams
# Datatype : String
# Description : comma separated list of name=value pairs. Overrides initialization parameters defined in templates
# Default value : None
# Mandatory : NO
#-----------------------------------------------------------------------------
initParams=audit_trail=none,audit_sys_operations=false
#-----------------------------------------------------------------------------
# Name : listeners
# Datatype : String
# Description : Specifies list of listeners to register the database with.
# By default the database is configured for all the listeners specified in the
# $ORACLE_HOME/network/admin/listener.ora
# Valid values : The list should be comma separated like "listener1,listener2".
# Mandatory : NO
#-----------------------------------------------------------------------------
#listeners=LISTENER
#-----------------------------------------------------------------------------
# Name : automaticMemoryManagement
# Datatype : Boolean
# Description : flag to indicate Automatic Memory Management is used
# Valid values : TRUE/FALSE
# Default value : TRUE
# Mandatory : NO
#-----------------------------------------------------------------------------
automaticMemoryManagement=FALSE
#-----------------------------------------------------------------------------
# Name : totalMemory
# Datatype : String
# Description : total memory in MB to allocate to Oracle
# Valid values :
# Default value :
# Mandatory : NO
#-----------------------------------------------------------------------------
totalMemory=2048
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Convert $1 into upper case via "^^" (bash version 4 onwards)
EDITION=${1^^}
# Check whether edition has been passed on
if [ "$EDITION" == "" ]; then
echo "ERROR: No edition has been passed on!"
echo "Please specify the correct edition!"
exit 1;
fi;
# Check whether correct edition has been passed on
if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then
echo "ERROR: Wrong edition has been passed on!"
echo "Edition $EDITION is no a valid edition!"
exit 1;
fi;
# Check whether ORACLE_BASE is set
if [ "$ORACLE_BASE" == "" ]; then
echo "ERROR: ORACLE_BASE has not been set!"
echo "You have to have the ORACLE_BASE environment variable set to a valid value!"
exit 1;
fi;
# Check whether ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
echo "ERROR: ORACLE_HOME has not been set!"
echo "You have to have the ORACLE_HOME environment variable set to a valid value!"
exit 1;
fi;
# Replace place holders
# ---------------------
sed -i -e "s|###ORACLE_EDITION###|$EDITION|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_BASE###|$ORACLE_BASE|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_HOME###|$ORACLE_HOME|g" $INSTALL_DIR/$INSTALL_RSP
# Install Oracle binaries
cd $INSTALL_DIR && \
unzip $INSTALL_FILE_1 && \
rm $INSTALL_FILE_1 && \
$INSTALL_DIR/database/runInstaller -silent -force -waitforcompletion -responsefile $INSTALL_DIR/$INSTALL_RSP -ignoresysprereqs -ignoreprereq && \
cd $HOME
# Remove not needed components
# APEX
rm -rf $ORACLE_HOME/apex && \
# ORDS
rm -rf $ORACLE_HOME/ords && \
# SQL Developer
rm -rf $ORACLE_HOME/sqldeveloper && \
# UCP connection pool
rm -rf $ORACLE_HOME/ucp && \
# All installer files
rm -rf $ORACLE_HOME/lib/*.zip && \
# OUI backup
rm -rf $ORACLE_HOME/inventory/backup/* && \
# Network tools help
rm -rf $ORACLE_HOME/network/tools/help && \
# Database upgrade assistant
rm -rf $ORACLE_HOME/assistants/dbua && \
# Database migration assistant
rm -rf $ORACLE_HOME/dmu && \
# Remove pilot workflow installer
rm -rf $ORACLE_HOME/install/pilot && \
# Support tools
rm -rf $ORACLE_HOME/suptools && \
# Temp location
rm -rf /tmp/* && \
# Database files directory
rm -rf $INSTALL_DIR/database
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Runs the Oracle Database inside the container
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
########### Move DB files ############
function moveFiles {
if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then
mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
fi;
mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/sqlnet.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
# oracle user does not have permissions in /etc, hence cp and not mv
cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
symLinkFiles;
}
########### Symbolic link DB files ############
function symLinkFiles {
if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ ! -L $ORACLE_HOME/network/admin/sqlnet.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/sqlnet.ora $ORACLE_HOME/network/admin/sqlnet.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora
fi;
# oracle user does not have permissions in /etc, hence cp and not ln
cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab
}
########### SIGINT handler ############
function _int() {
echo "Stopping container."
echo "SIGINT received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
########### SIGTERM handler ############
function _term() {
echo "Stopping container."
echo "SIGTERM received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
###################################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
############# MAIN ################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
###################################
# Check whether container has enough memory
# Github issue #219: Prevent integer overflow,
# only check if memory digits are less than 11 (single GB range and below)
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes | wc -c` -lt 11 ]; then
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes` -lt 2147483648 ]; then
echo "Error: The container doesn't have enough memory allocated."
echo "A database container needs at least 2 GB of memory."
echo "You currently only have $((`cat /sys/fs/cgroup/memory/memory.limit_in_bytes`/1024/1024/1024)) GB allocated to the container."
exit 1;
fi;
fi;
# Check that hostname doesn't container any "_"
# Github issue #711
if hostname | grep -q "_"; then
echo "Error: The hostname must not container any '_'".
echo "Your current hostname is '$(hostname)'"
fi;
# Set SIGINT handler
trap _int SIGINT
# Set SIGTERM handler
trap _term SIGTERM
# Default for ORACLE SID
if [ "$ORACLE_SID" == "" ]; then
export ORACLE_SID=ORCLCDB
else
# Make ORACLE_SID upper case
# Github issue # 984
export ORACLE_SID=${ORACLE_SID^^}
# Check whether SID is no longer than 12 bytes
# Github issue #246: Cannot start OracleDB image
if [ "${#ORACLE_SID}" -gt 12 ]; then
echo "Error: The ORACLE_SID must only be up to 12 characters long."
exit 1;
fi;
# Check whether SID is alphanumeric
# Github issue #246: Cannot start OracleDB image
if [[ "$ORACLE_SID" =~ [^a-zA-Z0-9] ]]; then
echo "Error: The ORACLE_SID must be alphanumeric."
exit 1;
fi;
fi;
# Default for ORACLE PDB
export ORACLE_PDB=${ORACLE_PDB:-ORCLPDB1}
# Make ORACLE_PDB upper case
# Github issue # 984
export ORACLE_PDB=${ORACLE_PDB^^}
# Default for ORACLE CHARACTERSET
export ORACLE_CHARACTERSET=${ORACLE_CHARACTERSET:-AL32UTF8}
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
symLinkFiles;
# Make sure audit file destination exists
if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
fi;
# Start database
$ORACLE_BASE/$START_FILE;
else
# Remove database config files, if they exist
rm -f $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
rm -f $ORACLE_HOME/dbs/orapw$ORACLE_SID
rm -f $ORACLE_HOME/network/admin/sqlnet.ora
rm -f $ORACLE_HOME/network/admin/listener.ora
rm -f $ORACLE_HOME/network/admin/tnsnames.ora
# Create database
$ORACLE_BASE/$CREATE_DB_FILE $ORACLE_SID $ORACLE_PDB $ORACLE_PWD;
# Move database operational files to oradata
moveFiles;
# Execute custom provided setup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/setup
fi;
# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
# Execute custom provided startup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/startup
else
echo "#####################################"
echo "########### E R R O R ###############"
echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
echo "Please check output for further info!"
echo "########### E R R O R ###############"
echo "#####################################"
fi;
# Tail on alert log and wait (otherwise container will exit)
echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2017 Oracle and/or its affiliates. All rights reserved.
#
# Since: July, 2017
# Author: gerald.venzl@oracle.com
# Description: Runs user shell and SQL scripts
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
SCRIPTS_ROOT="$1";
# Check whether parameter has been passed on
if [ -z "$SCRIPTS_ROOT" ]; then
echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run";
exit 1;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then
echo "";
echo "Executing user defined scripts"
for f in $SCRIPTS_ROOT/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; echo "exit" | $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" @"$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo "";
done
echo "DONE: Executing user defined scripts"
echo "";
fi;
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets the password for sys, system and pdb_admin
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_PWD=$1
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
ORAENV_ASK=NO
source oraenv
sqlplus / as sysdba << EOF
ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD";
ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD";
ALTER SESSION SET CONTAINER=$ORACLE_PDB;
ALTER USER PDBADMIN IDENTIFIED BY "$ORACLE_PWD";
exit;
EOF
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Setup filesystem and oracle user
# Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with Oracle installation
# ------------------------------------------------------------
mkdir -p $ORACLE_BASE/scripts/setup && \
mkdir $ORACLE_BASE/scripts/startup && \
ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
mkdir $ORACLE_BASE/oradata && \
mkdir -p $ORACLE_HOME && \
chmod ug+x $ORACLE_BASE/*.sh && \
yum -y install oracle-database-server-12cR2-preinstall openssl && \
rm -rf /var/cache/yum && \
ln -s $ORACLE_BASE/$PWD_FILE /home/oracle/ && \
echo oracle:oracle | chpasswd && \
chown -R oracle:dba $ORACLE_BASE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2016 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Starts the Listener and Oracle Database.
# The ORACLE_HOME and the PATH has to be set.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Check that ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
script_name=`basename "$0"`
echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script."
exit 1;
fi;
# Start Listener
lsnrctl start
# Start database
sqlplus / as sysdba << EOF
STARTUP;
exit;
EOF
99a7c4a088a8a502c261e741a8339ae8 LINUX.X64_180000_db_home.zip
99a7c4a088a8a502c261e741a8339ae8 LINUX.X64_180000_db_home.zip
# LICENSE UPL 1.0
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 18c
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) db_home.zip
# Download Oracle Database 18c Enterprise Edition or Standard Edition 2 for Linux x64
# from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:18.3.0-${EDITION} .
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim as base
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/18c/dbhome_1 \
INSTALL_DIR=/opt/install \
INSTALL_FILE_1="LINUX.X64_180000_db_home.zip" \
INSTALL_RSP="db_inst.rsp" \
CONFIG_RSP="dbca.rsp.tmpl" \
PWD_FILE="setPassword.sh" \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh"
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH \
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $ORACLE_BASE/
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$CHECK_SPACE_FILE && \
$INSTALL_DIR/$SETUP_LINUX_FILE && \
rm -rf $INSTALL_DIR
#############################################
# -------------------------------------------
# Start new stage for installing the database
# -------------------------------------------
#############################################
FROM base AS builder
ARG DB_EDITION
# Install unzip for unzip operation
RUN yum -y install unzip
# Copy DB install file
COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
# Install DB software binaries
USER oracle
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$INSTALL_DB_BINARIES_FILE $DB_EDITION
#############################################
# -------------------------------------------
# Start new layer for database runtime
# -------------------------------------------
#############################################
FROM base
USER oracle
COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE
USER root
RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
$ORACLE_HOME/root.sh
USER oracle
WORKDIR /home/oracle
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
# Define default command to start Oracle Database.
CMD exec $ORACLE_BASE/$RUN_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
source oraenv
# Check Oracle at least one PDB has open_mode "READ WRITE" and store it in status
status=`sqlplus -s / as sysdba << EOF
set heading off;
set pagesize 0;
SELECT DISTINCT open_mode FROM v\\$pdbs WHERE open_mode = '$OPEN_MODE';
exit;
EOF`
# Store return code from SQL*Plus
ret=$?
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$OPEN_MODE" ]; then
exit 0;
# PDB is not open
elif [ "$status" != "$OPEN_MODE" ]; then
exit 1;
# SQL Plus execution failed
else
exit 2;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: January, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the available space of the system.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
REQUIRED_SPACE_GB=18
AVAILABLE_SPACE_GB=`df -PB 1G / | tail -n 1 | awk '{ print $4 }'`
if [ $AVAILABLE_SPACE_GB -lt $REQUIRED_SPACE_GB ]; then
script_name=`basename "$0"`
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "$script_name: ERROR - There is not enough space available in the container."
echo "$script_name: The container needs at least $REQUIRED_SPACE_GB GB, but only $AVAILABLE_SPACE_GB GB are available."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Creates an Oracle Database based on following parameters:
# $ORACLE_SID: The Oracle SID and CDB name
# $ORACLE_PDB: The PDB name
# $ORACLE_PWD: The Oracle password
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
set -e
# Check whether ORACLE_SID is passed on
export ORACLE_SID=${1:-ORCLCDB}
# Check whether ORACLE_PDB is passed on
export ORACLE_PDB=${2:-ORCLPDB1}
# Auto generate ORACLE PWD if not passed on
export ORACLE_PWD=${3:-"`openssl rand -base64 8`1"}
echo "ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: $ORACLE_PWD";
# Replace place holders in response file
cp $ORACLE_BASE/$CONFIG_RSP $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_SID###|$ORACLE_SID|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PDB###|$ORACLE_PDB|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" $ORACLE_BASE/dbca.rsp
# If there is greater than 8 CPUs default back to dbca memory calculations
# dbca will automatically pick 40% of available memory for Oracle DB
# The minimum of 2G is for small environments to guarantee that Oracle has enough memory to function
# However, bigger environment can and should use more of the available memory
# This is due to Github Issue #307
if [ `nproc` -gt 8 ]; then
sed -i -e "s|totalMemory=2048||g" $ORACLE_BASE/dbca.rsp
fi;
# Create network related config files (sqlnet.ora, tnsnames.ora, listener.ora)
mkdir -p $ORACLE_HOME/network/admin
echo "NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)" > $ORACLE_HOME/network/admin/sqlnet.ora
# Listener.ora
echo "LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
DEDICATED_THROUGH_BROKER_LISTENER=ON
DIAG_ADR_ENABLED = off
" > $ORACLE_HOME/network/admin/listener.ora
# Start LISTENER and run DBCA
lsnrctl start &&
dbca -silent -createDatabase -responseFile $ORACLE_BASE/dbca.rsp ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID.log
echo "$ORACLE_SID=localhost:1521/$ORACLE_SID" > $ORACLE_HOME/network/admin/tnsnames.ora
echo "$ORACLE_PDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = $ORACLE_PDB)
)
)" >> $ORACLE_HOME/network/admin/tnsnames.ora
# Remove second control file, fix local_listener, make PDB auto open, enable EM global port
sqlplus / as sysdba << EOF
ALTER SYSTEM SET control_files='$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl' scope=spfile;
ALTER SYSTEM SET local_listener='';
ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE;
EXEC DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE);
exit;
EOF
# Remove temporary response file
rm $ORACLE_BASE/dbca.rsp
####################################################################
## Copyright(c) Oracle Corporation 1998,2017. 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_v18.0.0
#-------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# - INSTALL_DB_SWONLY
# - INSTALL_DB_AND_CONFIG
# - UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=###ORACLE_BASE###/oraInventory
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#-------------------------------------------------------------------------------
ORACLE_HOME=###ORACLE_HOME###
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=###ORACLE_BASE###
#-------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# - EE : Enterprise Edition
# - SE2 : Standard Edition 2
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=###ORACLE_EDITION###
###############################################################################
# #
# PRIVILEGED OPERATING SYSTEM GROUPS #
# ------------------------------------------ #
# Provide values for the OS groups to which SYSDBA and SYSOPER 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 OSDBA_GROUP is the OS group which is to be granted SYSDBA privileges.
#-------------------------------------------------------------------------------
oracle.install.db.OSDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSOPER_GROUP is the OS group which is to be granted SYSOPER privileges.
# The value to be specified for OSOPER group is optional.
#------------------------------------------------------------------------------
oracle.install.db.OSOPER_GROUP=dba
#------------------------------------------------------------------------------
# The OSBACKUPDBA_GROUP is the OS group which is to be granted SYSBACKUP privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSBACKUPDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSDGDBA_GROUP is the OS group which is to be granted SYSDG privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSDGDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSKMDBA_GROUP is the OS group which is to be granted SYSKM privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSKMDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSRACDBA_GROUP is the OS group which is to be granted SYSRAC privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSRACDBA_GROUP=dba
#------------------------------------------------------------------------------
# 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=false
#------------------------------------------------------------------------------
# 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 true.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
\ No newline at end of file
##############################################################################
## ##
## DBCA response file ##
## ------------------ ##
## Copyright(c) Oracle Corporation 1998,2017. 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.
#-------------------------------------------------------------------------------
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v18.0.0
#-----------------------------------------------------------------------------
# Name : gdbName
# Datatype : String
# Description : Global database name of the database
# Valid values : <db_name>.<db_domain> - when database domain isn't NULL
# <db_name> - when database domain is NULL
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
gdbName=###ORACLE_SID###
#-----------------------------------------------------------------------------
# Name : sid
# Datatype : String
# Description : System identifier (SID) of the database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory : No
#-----------------------------------------------------------------------------
sid=###ORACLE_SID###
#-----------------------------------------------------------------------------
# Name : createAsContainerDatabase
# Datatype : boolean
# Description : flag to create database as container database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : false
# Mandatory : No
#-----------------------------------------------------------------------------
createAsContainerDatabase=true
#-----------------------------------------------------------------------------
# Name : numberOfPDBs
# Datatype : Number
# Description : Specify the number of pdb to be created
# Valid values : 0 to 4094
# Default value : 0
# Mandatory : No
#-----------------------------------------------------------------------------
numberOfPDBs=1
#-----------------------------------------------------------------------------
# Name : pdbName
# Datatype : String
# Description : Specify the pdbname/pdbanme prefix if one or more pdb need to be created
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
pdbName=###ORACLE_PDB###
#-----------------------------------------------------------------------------
# Name : pdbAdminPassword
# Datatype : String
# Description : PDB Administrator user password
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
pdbAdminPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : templateName
# Datatype : String
# Description : Name of the template
# Valid values : Template file name
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
templateName=General_Purpose.dbc
#-----------------------------------------------------------------------------
# Name : sysPassword
# Datatype : String
# Description : Password for SYS user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
sysPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : systemPassword
# Datatype : String
# Description : Password for SYSTEM user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
systemPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : emConfiguration
# Datatype : String
# Description : Enterprise Manager Configuration Type
# Valid values : CENTRAL|DBEXPRESS|BOTH|NONE
# Default value : NONE
# Mandatory : No
#-----------------------------------------------------------------------------
emConfiguration=DBEXPRESS
#-----------------------------------------------------------------------------
# Name : emExpressPort
# Datatype : Number
# Description : Enterprise Manager Configuration Type
# Valid values : Check Oracle12c Administrator's Guide
# Default value : NONE
# Mandatory : No, will be picked up from DBEXPRESS_HTTPS_PORT env variable
# or auto generates a free port between 5500 and 5599
#-----------------------------------------------------------------------------
emExpressPort=5500
#-----------------------------------------------------------------------------
# Name : dbsnmpPassword
# Datatype : String
# Description : Password for DBSNMP user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes, if emConfiguration is specified or
# the value of runCVUChecks is TRUE
#-----------------------------------------------------------------------------
dbsnmpPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : characterSet
# Datatype : String
# Description : Character set of the database
# Valid values : Check Oracle12c National Language Support Guide
# Default value : "US7ASCII"
# Mandatory : NO
#-----------------------------------------------------------------------------
characterSet=###ORACLE_CHARACTERSET###
#-----------------------------------------------------------------------------
# Name : nationalCharacterSet
# Datatype : String
# Description : National Character set of the database
# Valid values : "UTF8" or "AL16UTF16". For details, check Oracle12c National Language Support Guide
# Default value : "AL16UTF16"
# Mandatory : No
#-----------------------------------------------------------------------------
nationalCharacterSet=AL16UTF16
#-----------------------------------------------------------------------------
# Name : initParams
# Datatype : String
# Description : comma separated list of name=value pairs. Overrides initialization parameters defined in templates
# Default value : None
# Mandatory : NO
#-----------------------------------------------------------------------------
initParams=audit_trail=none,audit_sys_operations=false
#-----------------------------------------------------------------------------
# Name : listeners
# Datatype : String
# Description : Specifies list of listeners to register the database with.
# By default the database is configured for all the listeners specified in the
# $ORACLE_HOME/network/admin/listener.ora
# Valid values : The list should be comma separated like "listener1,listener2".
# Mandatory : NO
#-----------------------------------------------------------------------------
#listeners=LISTENER
#-----------------------------------------------------------------------------
# Name : automaticMemoryManagement
# Datatype : Boolean
# Description : flag to indicate Automatic Memory Management is used
# Valid values : TRUE/FALSE
# Default value : TRUE
# Mandatory : NO
#-----------------------------------------------------------------------------
automaticMemoryManagement=FALSE
#-----------------------------------------------------------------------------
# Name : totalMemory
# Datatype : String
# Description : total memory in MB to allocate to Oracle
# Valid values :
# Default value :
# Mandatory : NO
#-----------------------------------------------------------------------------
totalMemory=2048
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Convert $1 into upper case via "^^" (bash version 4 onwards)
EDITION=${1^^}
# Check whether edition has been passed on
if [ "$EDITION" == "" ]; then
echo "ERROR: No edition has been passed on!"
echo "Please specify the correct edition!"
exit 1;
fi;
# Check whether correct edition has been passed on
if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then
echo "ERROR: Wrong edition has been passed on!"
echo "Edition $EDITION is no a valid edition!"
exit 1;
fi;
# Check whether ORACLE_BASE is set
if [ "$ORACLE_BASE" == "" ]; then
echo "ERROR: ORACLE_BASE has not been set!"
echo "You have to have the ORACLE_BASE environment variable set to a valid value!"
exit 1;
fi;
# Check whether ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
echo "ERROR: ORACLE_HOME has not been set!"
echo "You have to have the ORACLE_HOME environment variable set to a valid value!"
exit 1;
fi;
# Replace place holders
# ---------------------
sed -i -e "s|###ORACLE_EDITION###|$EDITION|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_BASE###|$ORACLE_BASE|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_HOME###|$ORACLE_HOME|g" $INSTALL_DIR/$INSTALL_RSP
# Install Oracle binaries
cd $ORACLE_HOME && \
mv $INSTALL_DIR/$INSTALL_FILE_1 $ORACLE_HOME/ && \
unzip $INSTALL_FILE_1 && \
rm $INSTALL_FILE_1 && \
$ORACLE_HOME/runInstaller -silent -force -waitforcompletion -responsefile $INSTALL_DIR/$INSTALL_RSP -ignorePrereqFailure && \
cd $HOME
# Remove not needed components
# APEX
rm -rf $ORACLE_HOME/apex && \
# ORDS
rm -rf $ORACLE_HOME/ords && \
# SQL Developer
rm -rf $ORACLE_HOME/sqldeveloper && \
# UCP connection pool
rm -rf $ORACLE_HOME/ucp && \
# All installer files
rm -rf $ORACLE_HOME/lib/*.zip && \
# OUI backup
rm -rf $ORACLE_HOME/inventory/backup/* && \
# Network tools help
rm -rf $ORACLE_HOME/network/tools/help && \
# Database upgrade assistant
rm -rf $ORACLE_HOME/assistants/dbua && \
# Database migration assistant
rm -rf $ORACLE_HOME/dmu && \
# Remove pilot workflow installer
rm -rf $ORACLE_HOME/install/pilot && \
# Support tools
rm -rf $ORACLE_HOME/suptools && \
# Temp location
rm -rf /tmp/* && \
# Database files directory
rm -rf $INSTALL_DIR/database
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Runs the Oracle Database inside the container
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
########### Move DB files ############
function moveFiles {
if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then
mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
fi;
mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/sqlnet.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
# oracle user does not have permissions in /etc, hence cp and not mv
cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
symLinkFiles;
}
########### Symbolic link DB files ############
function symLinkFiles {
if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ ! -L $ORACLE_HOME/network/admin/sqlnet.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/sqlnet.ora $ORACLE_HOME/network/admin/sqlnet.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora
fi;
# oracle user does not have permissions in /etc, hence cp and not ln
cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab
}
########### SIGINT handler ############
function _int() {
echo "Stopping container."
echo "SIGINT received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
########### SIGTERM handler ############
function _term() {
echo "Stopping container."
echo "SIGTERM received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
###################################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
############# MAIN ################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
###################################
# Check whether container has enough memory
# Github issue #219: Prevent integer overflow,
# only check if memory digits are less than 11 (single GB range and below)
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes | wc -c` -lt 11 ]; then
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes` -lt 2147483648 ]; then
echo "Error: The container doesn't have enough memory allocated."
echo "A database container needs at least 2 GB of memory."
echo "You currently only have $((`cat /sys/fs/cgroup/memory/memory.limit_in_bytes`/1024/1024/1024)) GB allocated to the container."
exit 1;
fi;
fi;
# Check that hostname doesn't container any "_"
# Github issue #711
if hostname | grep -q "_"; then
echo "Error: The hostname must not container any '_'".
echo "Your current hostname is '$(hostname)'"
fi;
# Set SIGINT handler
trap _int SIGINT
# Set SIGTERM handler
trap _term SIGTERM
# Default for ORACLE SID
if [ "$ORACLE_SID" == "" ]; then
export ORACLE_SID=ORCLCDB
else
# Make ORACLE_SID upper case
# Github issue # 984
export ORACLE_SID=${ORACLE_SID^^}
# Check whether SID is no longer than 12 bytes
# Github issue #246: Cannot start OracleDB image
if [ "${#ORACLE_SID}" -gt 12 ]; then
echo "Error: The ORACLE_SID must only be up to 12 characters long."
exit 1;
fi;
# Check whether SID is alphanumeric
# Github issue #246: Cannot start OracleDB image
if [[ "$ORACLE_SID" =~ [^a-zA-Z0-9] ]]; then
echo "Error: The ORACLE_SID must be alphanumeric."
exit 1;
fi;
fi;
# Default for ORACLE PDB
export ORACLE_PDB=${ORACLE_PDB:-ORCLPDB1}
# Make ORACLE_PDB upper case
# Github issue # 984
export ORACLE_PDB=${ORACLE_PDB^^}
# Default for ORACLE CHARACTERSET
export ORACLE_CHARACTERSET=${ORACLE_CHARACTERSET:-AL32UTF8}
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
symLinkFiles;
# Make sure audit file destination exists
if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
fi;
# Start database
$ORACLE_BASE/$START_FILE;
else
# Remove database config files, if they exist
rm -f $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
rm -f $ORACLE_HOME/dbs/orapw$ORACLE_SID
rm -f $ORACLE_HOME/network/admin/sqlnet.ora
rm -f $ORACLE_HOME/network/admin/listener.ora
rm -f $ORACLE_HOME/network/admin/tnsnames.ora
# Create database
$ORACLE_BASE/$CREATE_DB_FILE $ORACLE_SID $ORACLE_PDB $ORACLE_PWD;
# Move database operational files to oradata
moveFiles;
# Execute custom provided setup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/setup
fi;
# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
# Execute custom provided startup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/startup
else
echo "#####################################"
echo "########### E R R O R ###############"
echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
echo "Please check output for further info!"
echo "########### E R R O R ###############"
echo "#####################################"
fi;
# Tail on alert log and wait (otherwise container will exit)
echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: July, 2017
# Author: gerald.venzl@oracle.com
# Description: Runs user shell and SQL scripts
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
SCRIPTS_ROOT="$1";
# Check whether parameter has been passed on
if [ -z "$SCRIPTS_ROOT" ]; then
echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run";
exit 1;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then
echo "";
echo "Executing user defined scripts"
for f in $SCRIPTS_ROOT/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; echo "exit" | $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" @"$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo "";
done
echo "DONE: Executing user defined scripts"
echo "";
fi;
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets the password for sys, system and pdb_admin
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_PWD=$1
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
ORAENV_ASK=NO
source oraenv
sqlplus / as sysdba << EOF
ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD";
ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD";
ALTER SESSION SET CONTAINER=$ORACLE_PDB;
ALTER USER PDBADMIN IDENTIFIED BY "$ORACLE_PWD";
exit;
EOF
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Setup filesystem and oracle user
# Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with Oracle installation
# ------------------------------------------------------------
mkdir -p $ORACLE_BASE/scripts/setup && \
mkdir $ORACLE_BASE/scripts/startup && \
ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
mkdir $ORACLE_BASE/oradata && \
mkdir -p $ORACLE_HOME && \
chmod ug+x $ORACLE_BASE/*.sh && \
yum -y install oracle-database-preinstall-18c openssl && \
rm -rf /var/cache/yum && \
ln -s $ORACLE_BASE/$PWD_FILE /home/oracle/ && \
echo oracle:oracle | chpasswd && \
chown -R oracle:dba $ORACLE_BASE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Starts the Listener and Oracle Database.
# The ORACLE_HOME and the PATH has to be set.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Check that ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
script_name=`basename "$0"`
echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script."
exit 1;
fi;
# Start Listener
lsnrctl start
# Start database
sqlplus / as sysdba << EOF
STARTUP;
exit;
EOF
# LICENSE UPL 1.0
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 18c Express Edition
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# None
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Run:
# $ docker build -t oracle/database:18.4.0-xe -f Dockerfile.xe .
#
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500" \
"port.apex"="8080"
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE \
ORACLE_SID=XE \
INSTALL_FILE_1="https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm" \
RUN_FILE="runOracle.sh" \
PWD_FILE="setPassword.sh" \
CONF_FILE="oracle-xe-18c.conf" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
INSTALL_DIR="$HOME/install" \
ORACLE_DOCKER_INSTALL="true"
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$PATH
# Copy binaries
# -------------
COPY $CHECK_SPACE_FILE $RUN_FILE $PWD_FILE $CHECK_DB_FILE $CONF_FILE $INSTALL_DIR/
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$CHECK_SPACE_FILE && \
cd $INSTALL_DIR && \
yum -y install openssl oracle-database-preinstall-18c && \
sed -i -e 's/\(oracle\s\+hard\s\+nofile\)/# \1/' /etc/security/limits.d/oracle-database-preinstall-18c.conf && \
yum -y localinstall $INSTALL_FILE_1 && \
rm -rf /var/cache/yum && \
rm -rf /var/tmp/yum-* && \
mkdir -p $ORACLE_BASE/scripts/setup && \
mkdir $ORACLE_BASE/scripts/startup && \
ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
mkdir -p $ORACLE_BASE/oradata /home/oracle && \
chown -R oracle:oinstall $ORACLE_BASE /home/oracle && \
mv $INSTALL_DIR/$RUN_FILE $ORACLE_BASE/ && \
mv $INSTALL_DIR/$PWD_FILE $ORACLE_BASE/ && \
mv $INSTALL_DIR/$CHECK_DB_FILE $ORACLE_BASE/ && \
mv $INSTALL_DIR/$CONF_FILE /etc/sysconfig/ && \
ln -s $ORACLE_BASE/$PWD_FILE / && \
cd $HOME && \
rm -rf $INSTALL_DIR && \
chmod ug+x $ORACLE_BASE/*.sh
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
CMD exec $ORACLE_BASE/$RUN_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
source oraenv
[ -f "$ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab" ] || exit 1;
# Check Oracle at least one PDB has open_mode "READ WRITE" and store it in status
status=`su -p oracle -c "sqlplus -s / as sysdba" << EOF
set heading off;
set pagesize 0;
SELECT DISTINCT open_mode FROM v\\$pdbs WHERE open_mode = '$OPEN_MODE';
exit;
EOF`
# Store return code from SQL*Plus
ret=$?
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$OPEN_MODE" ]; then
exit 0;
# PDB is not open
elif [ "$status" != "$OPEN_MODE" ]; then
exit 1;
# SQL Plus execution failed
else
exit 2;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: January, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the available space of the system.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
REQUIRED_SPACE_GB=13
AVAILABLE_SPACE_GB=`df -PB 1G / | tail -n 1 | awk '{ print $4 }'`
if [ $AVAILABLE_SPACE_GB -lt $REQUIRED_SPACE_GB ]; then
script_name=`basename "$0"`
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "$script_name: ERROR - There is not enough space available in the container."
echo "$script_name: The container needs at least $REQUIRED_SPACE_GB GB, but only $AVAILABLE_SPACE_GB GB are available."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1;
fi;
# This is a configuration file to setup the Oracle Database.
# It is used when running '/etc/init.d/oracle-xe-18c configure'.
# LISTENER PORT used Database listener, Leave empty for automatic port assignment
LISTENER_PORT=1521
# EM_EXPRESS_PORT Oracle EM Express URL port
EM_EXPRESS_PORT=5500
# Character set of the database
CHARSET=###ORACLE_CHARACTERSET###
# Database file directory
# If not specified, database files are stored under Oracle base/oradata
DBFILE_DEST=
# SKIP Validations, memory, space
SKIP_VALIDATIONS=false
#!/bin/bash
############# Execute custom scripts ##############
function runUserScripts {
SCRIPTS_ROOT="$1";
# Check whether parameter has been passed on
if [ -z "$SCRIPTS_ROOT" ]; then
echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run";
exit 1;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then
echo "";
echo "Executing user defined scripts"
for f in $SCRIPTS_ROOT/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; echo "exit" | su -p oracle -c "$ORACLE_HOME/bin/sqlplus / as sysdba @$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo "";
done
echo "DONE: Executing user defined scripts"
echo "";
fi;
}
########### Move DB files ############
function moveFiles {
if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then
su -p oracle -c "mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
fi;
su -p oracle -c "mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
su -p oracle -c "mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
su -p oracle -c "mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
su -p oracle -c "mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/"
cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
symLinkFiles;
}
########### Symbolic link DB files ############
function symLinkFiles {
if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then
ln -sf $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
ln -sf $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora
fi;
cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab
}
########### Opposite of the above ############
function undoSymLinkFiles {
if [ -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
rm $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
rm $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ -L $ORACLE_HOME/network/admin/listener.ora ]; then
rm $ORACLE_HOME/network/admin/listener.ora
fi;
if [ -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
rm $ORACLE_HOME/network/admin/tnsnames.ora
fi;
sed -i "\|${ORACLE_SID}:${ORACLE_HOME}|d" /etc/oratab
}
########### SIGTERM handler ############
function _term() {
echo "Stopping container."
echo "SIGTERM received, shutting down database!"
/etc/init.d/oracle-xe-18c stop
}
############# Create DB ################
function createDB {
# Auto generate ORACLE PWD if not passed on
export ORACLE_PWD=${ORACLE_PWD:-"`openssl rand -hex 8`"}
echo "ORACLE PASSWORD FOR SYS AND SYSTEM: $ORACLE_PWD";
# Set character set
export ORACLE_CHARACTERSET=${ORACLE_CHARACTERSET:-AL32UTF8}
sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" /etc/sysconfig/$CONF_FILE
(echo "$ORACLE_PWD"; echo "$ORACLE_PWD";) | /etc/init.d/oracle-xe-18c configure
# Listener
echo "# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = $ORACLE_HOME)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)" > $ORACLE_HOME/network/admin/listener.ora
# TNS Names.ora
echo "# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
LISTENER_XE =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
XEPDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XEPDB1)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
" > $ORACLE_HOME/network/admin/tnsnames.ora
# Move database operational files to oradata
moveFiles;
}
############# MAIN ################
# Set SIGTERM handler
trap _term SIGTERM
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
symLinkFiles;
# Make sure audit file destination exists
if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
su -p oracle -c "mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump"
fi;
else
# If the oradata folder is missing/empty, but db was previously set up,
# allow a new db to be set up in its place
undoSymLinkFiles;
fi;
/etc/init.d/oracle-xe-18c start | grep -qc "Oracle Database is not configured"
if [ "$?" == "0" ]; then
# Create database
createDB;
# Execute custom provided setup scripts
runUserScripts $ORACLE_BASE/scripts/setup
fi;
# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
# Execute custom provided startup scripts
runUserScripts $ORACLE_BASE/scripts/startup
else
echo "#####################################"
echo "########### E R R O R ###############"
echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
echo "Please check output for further info!"
echo "########### E R R O R ###############"
echo "#####################################"
fi;
echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets the password for sys, system and pdb_admin
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_PWD=$1
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
ORAENV_ASK=NO
source oraenv
su -p oracle -c "sqlplus / as sysdba << EOF
ALTER USER SYS IDENTIFIED BY \"$ORACLE_PWD\";
ALTER USER SYSTEM IDENTIFIED BY \"$ORACLE_PWD\";
ALTER SESSION SET CONTAINER=$ORACLE_PDB;
ALTER USER PDBADMIN IDENTIFIED BY \"$ORACLE_PWD\";
exit;
EOF"
1858bd0d281c60f4ddabd87b1c214a4f LINUX.X64_193000_db_home.zip
1858bd0d281c60f4ddabd87b1c214a4f LINUX.X64_193000_db_home.zip
# LICENSE UPL 1.0
#
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This is the Dockerfile for Oracle Database 19c
#
# REQUIRED FILES TO BUILD THIS IMAGE
# ----------------------------------
# (1) db_home.zip
# Download Oracle Database 19c Enterprise Edition or Standard Edition 2 for Linux x64
# from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run:
# $ docker build -t oracle/database:19.3.0-${EDITION} .
#
# Pull base image
# ---------------
FROM oraclelinux:7-slim as base
# Labels
# ------
LABEL "provider"="Oracle" \
"issues"="https://github.com/oracle/docker-images/issues" \
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"
# Argument to control removal of components not needed after db software installation
ARG SLIMMING=true
# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
ENV ORACLE_BASE=/opt/oracle \
ORACLE_HOME=/opt/oracle/product/19c/dbhome_1 \
INSTALL_DIR=/opt/install \
INSTALL_FILE_1="LINUX.X64_193000_db_home.zip" \
INSTALL_RSP="db_inst.rsp" \
CONFIG_RSP="dbca.rsp.tmpl" \
PWD_FILE="setPassword.sh" \
RUN_FILE="runOracle.sh" \
START_FILE="startDB.sh" \
CREATE_DB_FILE="createDB.sh" \
SETUP_LINUX_FILE="setupLinuxEnv.sh" \
CHECK_SPACE_FILE="checkSpace.sh" \
CHECK_DB_FILE="checkDBStatus.sh" \
USER_SCRIPTS_FILE="runUserScripts.sh" \
INSTALL_DB_BINARIES_FILE="installDBBinaries.sh" \
RELINK_BINARY_FILE="relinkOracleBinary.sh" \
SLIMMING=$SLIMMING
# Use second ENV so that variable get substituted
ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH \
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
# Copy files needed during both installation and runtime
# -------------
COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/
COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $RELINK_BINARY_FILE $ORACLE_BASE/
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$CHECK_SPACE_FILE && \
$INSTALL_DIR/$SETUP_LINUX_FILE && \
rm -rf $INSTALL_DIR
#############################################
# -------------------------------------------
# Start new stage for installing the database
# -------------------------------------------
#############################################
FROM base AS builder
ARG DB_EDITION
# Copy DB install file
COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
# Install DB software binaries
USER oracle
RUN chmod ug+x $INSTALL_DIR/*.sh && \
sync && \
$INSTALL_DIR/$INSTALL_DB_BINARIES_FILE $DB_EDITION
#############################################
# -------------------------------------------
# Start new layer for database runtime
# -------------------------------------------
#############################################
FROM base
USER oracle
COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE
USER root
RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
$ORACLE_HOME/root.sh
USER oracle
WORKDIR /home/oracle
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
# Define default command to start Oracle Database.
CMD exec $ORACLE_BASE/$RUN_FILE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: May, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the status of Oracle Database.
# Return codes: 0 = PDB is open and ready to use
# 1 = PDB is not open
# 2 = Sql Plus execution failed
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
OPEN_MODE="READ WRITE"
ORAENV_ASK=NO
source oraenv
# Check Oracle at least one PDB has open_mode "READ WRITE" and store it in status
status=`sqlplus -s / as sysdba << EOF
set heading off;
set pagesize 0;
SELECT DISTINCT open_mode FROM v\\$pdbs WHERE open_mode = '$OPEN_MODE';
exit;
EOF`
# Store return code from SQL*Plus
ret=$?
# SQL Plus execution was successful and PDB is open
if [ $ret -eq 0 ] && [ "$status" = "$OPEN_MODE" ]; then
exit 0;
# PDB is not open
elif [ "$status" != "$OPEN_MODE" ]; then
exit 1;
# SQL Plus execution failed
else
exit 2;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: January, 2017
# Author: gerald.venzl@oracle.com
# Description: Checks the available space of the system.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
REQUIRED_SPACE_GB=18
AVAILABLE_SPACE_GB=`df -PB 1G / | tail -n 1 | awk '{ print $4 }'`
if [ $AVAILABLE_SPACE_GB -lt $REQUIRED_SPACE_GB ]; then
script_name=`basename "$0"`
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "$script_name: ERROR - There is not enough space available in the container."
echo "$script_name: The container needs at least $REQUIRED_SPACE_GB GB, but only $AVAILABLE_SPACE_GB GB are available."
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
exit 1;
fi;
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Creates an Oracle Database based on following parameters:
# $ORACLE_SID: The Oracle SID and CDB name
# $ORACLE_PDB: The PDB name
# $ORACLE_PWD: The Oracle password
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
set -e
# Check whether ORACLE_SID is passed on
export ORACLE_SID=${1:-ORCLCDB}
# Check whether ORACLE_PDB is passed on
export ORACLE_PDB=${2:-ORCLPDB1}
# Checking if only one of INIT_SGA_SIZE & INIT_PGA_SIZE is provided by the user
if [[ "${INIT_SGA_SIZE}" != "" && "${INIT_PGA_SIZE}" == "" ]] || [[ "${INIT_SGA_SIZE}" == "" && "${INIT_PGA_SIZE}" != "" ]]; then
echo "ERROR: Provide both the values, INIT_SGA_SIZE and INIT_PGA_SIZE or neither of them. Exiting.";
exit 1;
fi;
# Auto generate ORACLE PWD if not passed on
export ORACLE_PWD=${3:-"`openssl rand -base64 8`1"}
echo "ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: $ORACLE_PWD";
# Replace place holders in response file
cp $ORACLE_BASE/$CONFIG_RSP $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_SID###|$ORACLE_SID|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PDB###|$ORACLE_PDB|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" $ORACLE_BASE/dbca.rsp
# If both INIT_SGA_SIZE & INIT_PGA_SIZE aren't provided by user
if [[ "${INIT_SGA_SIZE}" == "" && "${INIT_PGA_SIZE}" == "" ]]; then
# If there is greater than 8 CPUs default back to dbca memory calculations
# dbca will automatically pick 40% of available memory for Oracle DB
# The minimum of 2G is for small environments to guarantee that Oracle has enough memory to function
# However, bigger environment can and should use more of the available memory
# This is due to Github Issue #307
if [ `nproc` -gt 8 ]; then
sed -i -e "s|totalMemory=2048||g" $ORACLE_BASE/dbca.rsp
fi;
else
sed -i -e "s|totalMemory=2048||g" $ORACLE_BASE/dbca.rsp
sed -i -e "s|initParams=.*|&,sga_target=${INIT_SGA_SIZE}M,pga_aggregate_target=${INIT_PGA_SIZE}M|g" $ORACLE_BASE/dbca.rsp
fi;
# Create network related config files (sqlnet.ora, tnsnames.ora, listener.ora)
mkdir -p $ORACLE_HOME/network/admin
echo "NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)" > $ORACLE_HOME/network/admin/sqlnet.ora
# Listener.ora
echo "LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
DEDICATED_THROUGH_BROKER_LISTENER=ON
DIAG_ADR_ENABLED = off
" > $ORACLE_HOME/network/admin/listener.ora
# Start LISTENER and run DBCA
lsnrctl start &&
dbca -silent -createDatabase -responseFile $ORACLE_BASE/dbca.rsp ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log ||
cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID.log
echo "$ORACLE_SID=localhost:1521/$ORACLE_SID" > $ORACLE_HOME/network/admin/tnsnames.ora
echo "$ORACLE_PDB=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = $ORACLE_PDB)
)
)" >> $ORACLE_HOME/network/admin/tnsnames.ora
# Remove second control file, fix local_listener, make PDB auto open, enable EM global port
sqlplus / as sysdba << EOF
ALTER SYSTEM SET control_files='$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl' scope=spfile;
ALTER SYSTEM SET local_listener='';
ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE;
EXEC DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE);
exit;
EOF
# Remove temporary response file
rm $ORACLE_BASE/dbca.rsp
####################################################################
## Copyright(c) Oracle Corporation 1998,2017. 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_v19.0.0
#-------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# - INSTALL_DB_SWONLY
# - INSTALL_DB_AND_CONFIG
# - UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=dba
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=###ORACLE_BASE###/oraInventory
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#-------------------------------------------------------------------------------
ORACLE_HOME=###ORACLE_HOME###
#-------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#-------------------------------------------------------------------------------
ORACLE_BASE=###ORACLE_BASE###
#-------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# - EE : Enterprise Edition
# - SE2 : Standard Edition 2
#-------------------------------------------------------------------------------
oracle.install.db.InstallEdition=###ORACLE_EDITION###
###############################################################################
# #
# PRIVILEGED OPERATING SYSTEM GROUPS #
# ------------------------------------------ #
# Provide values for the OS groups to which SYSDBA and SYSOPER 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 OSDBA_GROUP is the OS group which is to be granted SYSDBA privileges.
#-------------------------------------------------------------------------------
oracle.install.db.OSDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSOPER_GROUP is the OS group which is to be granted SYSOPER privileges.
# The value to be specified for OSOPER group is optional.
#------------------------------------------------------------------------------
oracle.install.db.OSOPER_GROUP=dba
#------------------------------------------------------------------------------
# The OSBACKUPDBA_GROUP is the OS group which is to be granted SYSBACKUP privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSBACKUPDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSDGDBA_GROUP is the OS group which is to be granted SYSDG privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSDGDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSKMDBA_GROUP is the OS group which is to be granted SYSKM privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSKMDBA_GROUP=dba
#------------------------------------------------------------------------------
# The OSRACDBA_GROUP is the OS group which is to be granted SYSRAC privileges.
#------------------------------------------------------------------------------
oracle.install.db.OSRACDBA_GROUP=dba
#------------------------------------------------------------------------------
# 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=false
#------------------------------------------------------------------------------
# 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 true.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
\ No newline at end of file
##############################################################################
## ##
## DBCA response file ##
## ------------------ ##
## Copyright(c) Oracle Corporation 1998,2017. 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.
#-------------------------------------------------------------------------------
responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v19.0.0
#-----------------------------------------------------------------------------
# Name : gdbName
# Datatype : String
# Description : Global database name of the database
# Valid values : <db_name>.<db_domain> - when database domain isn't NULL
# <db_name> - when database domain is NULL
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
gdbName=###ORACLE_SID###
#-----------------------------------------------------------------------------
# Name : sid
# Datatype : String
# Description : System identifier (SID) of the database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : <db_name> specified in GDBNAME
# Mandatory : No
#-----------------------------------------------------------------------------
sid=###ORACLE_SID###
#-----------------------------------------------------------------------------
# Name : createAsContainerDatabase
# Datatype : boolean
# Description : flag to create database as container database
# Valid values : Check Oracle12c Administrator's Guide
# Default value : false
# Mandatory : No
#-----------------------------------------------------------------------------
createAsContainerDatabase=true
#-----------------------------------------------------------------------------
# Name : numberOfPDBs
# Datatype : Number
# Description : Specify the number of pdb to be created
# Valid values : 0 to 4094
# Default value : 0
# Mandatory : No
#-----------------------------------------------------------------------------
numberOfPDBs=1
#-----------------------------------------------------------------------------
# Name : pdbName
# Datatype : String
# Description : Specify the pdbname/pdbanme prefix if one or more pdb need to be created
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
pdbName=###ORACLE_PDB###
#-----------------------------------------------------------------------------
# Name : pdbAdminPassword
# Datatype : String
# Description : PDB Administrator user password
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : No
#-----------------------------------------------------------------------------
pdbAdminPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : templateName
# Datatype : String
# Description : Name of the template
# Valid values : Template file name
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
templateName=General_Purpose.dbc
#-----------------------------------------------------------------------------
# Name : sysPassword
# Datatype : String
# Description : Password for SYS user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
sysPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : systemPassword
# Datatype : String
# Description : Password for SYSTEM user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes
#-----------------------------------------------------------------------------
systemPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : emConfiguration
# Datatype : String
# Description : Enterprise Manager Configuration Type
# Valid values : CENTRAL|DBEXPRESS|BOTH|NONE
# Default value : NONE
# Mandatory : No
#-----------------------------------------------------------------------------
emConfiguration=DBEXPRESS
#-----------------------------------------------------------------------------
# Name : emExpressPort
# Datatype : Number
# Description : Enterprise Manager Configuration Type
# Valid values : Check Oracle12c Administrator's Guide
# Default value : NONE
# Mandatory : No, will be picked up from DBEXPRESS_HTTPS_PORT env variable
# or auto generates a free port between 5500 and 5599
#-----------------------------------------------------------------------------
emExpressPort=5500
#-----------------------------------------------------------------------------
# Name : dbsnmpPassword
# Datatype : String
# Description : Password for DBSNMP user
# Valid values : Check Oracle12c Administrator's Guide
# Default value : None
# Mandatory : Yes, if emConfiguration is specified or
# the value of runCVUChecks is TRUE
#-----------------------------------------------------------------------------
dbsnmpPassword=###ORACLE_PWD###
#-----------------------------------------------------------------------------
# Name : characterSet
# Datatype : String
# Description : Character set of the database
# Valid values : Check Oracle12c National Language Support Guide
# Default value : "US7ASCII"
# Mandatory : NO
#-----------------------------------------------------------------------------
characterSet=###ORACLE_CHARACTERSET###
#-----------------------------------------------------------------------------
# Name : nationalCharacterSet
# Datatype : String
# Description : National Character set of the database
# Valid values : "UTF8" or "AL16UTF16". For details, check Oracle12c National Language Support Guide
# Default value : "AL16UTF16"
# Mandatory : No
#-----------------------------------------------------------------------------
nationalCharacterSet=AL16UTF16
#-----------------------------------------------------------------------------
# Name : initParams
# Datatype : String
# Description : comma separated list of name=value pairs. Overrides initialization parameters defined in templates
# Default value : None
# Mandatory : NO
#-----------------------------------------------------------------------------
initParams=audit_trail=none,audit_sys_operations=false
#-----------------------------------------------------------------------------
# Name : listeners
# Datatype : String
# Description : Specifies list of listeners to register the database with.
# By default the database is configured for all the listeners specified in the
# $ORACLE_HOME/network/admin/listener.ora
# Valid values : The list should be comma separated like "listener1,listener2".
# Mandatory : NO
#-----------------------------------------------------------------------------
#listeners=LISTENER
#-----------------------------------------------------------------------------
# Name : automaticMemoryManagement
# Datatype : Boolean
# Description : flag to indicate Automatic Memory Management is used
# Valid values : TRUE/FALSE
# Default value : TRUE
# Mandatory : NO
#-----------------------------------------------------------------------------
automaticMemoryManagement=FALSE
#-----------------------------------------------------------------------------
# Name : totalMemory
# Datatype : String
# Description : total memory in MB to allocate to Oracle
# Valid values :
# Default value :
# Mandatory : NO
#-----------------------------------------------------------------------------
totalMemory=2048
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Convert $1 into upper case via "^^" (bash version 4 onwards)
EDITION=${1^^}
# Check whether edition has been passed on
if [ "$EDITION" == "" ]; then
echo "ERROR: No edition has been passed on!"
echo "Please specify the correct edition!"
exit 1;
fi;
# Check whether correct edition has been passed on
if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then
echo "ERROR: Wrong edition has been passed on!"
echo "Edition $EDITION is no a valid edition!"
exit 1;
fi;
# Check whether ORACLE_BASE is set
if [ "$ORACLE_BASE" == "" ]; then
echo "ERROR: ORACLE_BASE has not been set!"
echo "You have to have the ORACLE_BASE environment variable set to a valid value!"
exit 1;
fi;
# Check whether ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
echo "ERROR: ORACLE_HOME has not been set!"
echo "You have to have the ORACLE_HOME environment variable set to a valid value!"
exit 1;
fi;
# Replace place holders
# ---------------------
sed -i -e "s|###ORACLE_EDITION###|$EDITION|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_BASE###|$ORACLE_BASE|g" $INSTALL_DIR/$INSTALL_RSP && \
sed -i -e "s|###ORACLE_HOME###|$ORACLE_HOME|g" $INSTALL_DIR/$INSTALL_RSP
# Install Oracle binaries
cd $ORACLE_HOME && \
mv $INSTALL_DIR/$INSTALL_FILE_1 $ORACLE_HOME/ && \
unzip $INSTALL_FILE_1 && \
rm $INSTALL_FILE_1 && \
$ORACLE_HOME/runInstaller -silent -force -waitforcompletion -responsefile $INSTALL_DIR/$INSTALL_RSP -ignorePrereqFailure && \
cd $HOME
if $SLIMMING; then
# Remove not needed components
# APEX
rm -rf $ORACLE_HOME/apex && \
# ORDS
rm -rf $ORACLE_HOME/ords && \
# SQL Developer
rm -rf $ORACLE_HOME/sqldeveloper && \
# UCP connection pool
rm -rf $ORACLE_HOME/ucp && \
# All installer files
rm -rf $ORACLE_HOME/lib/*.zip && \
# OUI backup
rm -rf $ORACLE_HOME/inventory/backup/* && \
# Network tools help
rm -rf $ORACLE_HOME/network/tools/help && \
# Database upgrade assistant
rm -rf $ORACLE_HOME/assistants/dbua && \
# Database migration assistant
rm -rf $ORACLE_HOME/dmu && \
# Remove pilot workflow installer
rm -rf $ORACLE_HOME/install/pilot && \
# Support tools
rm -rf $ORACLE_HOME/suptools && \
# Temp location
rm -rf /tmp/* && \
# Database files directory
rm -rf $INSTALL_DIR/database
fi
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
#
# Since: March, 2020
# Author: rishabh.y.gupta@oracle.com
# Description: Relinks oracle binary in accordance with the edition passed by the user.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
LIB_EDITION="$(/usr/bin/ar t $ORACLE_HOME/lib/libedtn$($ORACLE_HOME/bin/oraversion -majorVersion).a)"
LIB_EDITION=$(echo ${LIB_EDITION} | cut -d. -f1)
LIB_EDITION=${LIB_EDITION: -3}
if [ "${LIB_EDITION}" == "ent" ]; then
CURRENT_EDITION="ENTERPRISE"
fi
if [ "${LIB_EDITION}" == "std" ]; then
CURRENT_EDITION="STANDARD"
fi
# If datafiles already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
datafiles_edition=$(ls $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/.docker_* | rev | cut -d_ -f1 | rev)
if [ "${ORACLE_EDITION}" != "" ] && [ "${ORACLE_EDITION,,}" != $datafiles_edition ]; then
echo "The datafiles being used were created with $datafiles_edition edition software home. Please pass -e ORACLE_EDITION=$datafiles_edition to the docker run cmd.";
exit 1;
elif [ "${ORACLE_EDITION}" == "" ] && [ "${CURRENT_EDITION,,}" != $datafiles_edition ]; then
echo "The current software home is of ${CURRENT_EDITION,,} edition whereas the datafiles being used were created with $datafiles_edition edition software home. Please pass -e ORACLE_EDITION=$datafiles_edition to the docker run cmd.";
exit 1;
fi
fi
if [ "${ORACLE_EDITION}" != "" ]; then
if [ "${CURRENT_EDITION}" != "${ORACLE_EDITION^^}" ]; then
echo "Relinking oracle binary for edition: ${ORACLE_EDITION}";
cmd="make -f ${ORACLE_HOME}/rdbms/lib/ins_rdbms.mk edition_${ORACLE_EDITION,,} ioracle";
echo "$cmd";
$cmd;
CURRENT_EDITION=${ORACLE_EDITION^^}
fi
fi
echo "ORACLE EDITION: ${CURRENT_EDITION}"
touch $ORACLE_HOME/install/.docker_${CURRENT_EDITION,,}
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Runs the Oracle Database inside the container
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
########### Move DB files ############
function moveFiles {
if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then
mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
fi;
mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/sqlnet.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
mv $ORACLE_HOME/install/.docker_* $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
# oracle user does not have permissions in /etc, hence cp and not mv
cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/
symLinkFiles;
}
########### Symbolic link DB files ############
function symLinkFiles {
if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
fi;
if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID
fi;
if [ ! -L $ORACLE_HOME/network/admin/sqlnet.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/sqlnet.ora $ORACLE_HOME/network/admin/sqlnet.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora
fi;
if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then
ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora
fi;
# oracle user does not have permissions in /etc, hence cp and not ln
cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab
}
########### SIGINT handler ############
function _int() {
echo "Stopping container."
echo "SIGINT received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
########### SIGTERM handler ############
function _term() {
echo "Stopping container."
echo "SIGTERM received, shutting down database!"
sqlplus / as sysdba <<EOF
shutdown immediate;
exit;
EOF
lsnrctl stop
}
###################################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
############# MAIN ################
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
###################################
# Check whether container has enough memory
# Github issue #219: Prevent integer overflow,
# only check if memory digits are less than 11 (single GB range and below)
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes | wc -c` -lt 11 ]; then
if [ `cat /sys/fs/cgroup/memory/memory.limit_in_bytes` -lt 2147483648 ]; then
echo "Error: The container doesn't have enough memory allocated."
echo "A database container needs at least 2 GB of memory."
echo "You currently only have $((`cat /sys/fs/cgroup/memory/memory.limit_in_bytes`/1024/1024/1024)) GB allocated to the container."
exit 1;
fi;
fi;
# Check that hostname doesn't container any "_"
# Github issue #711
if hostname | grep -q "_"; then
echo "Error: The hostname must not container any '_'".
echo "Your current hostname is '$(hostname)'"
fi;
# Set SIGINT handler
trap _int SIGINT
# Set SIGTERM handler
trap _term SIGTERM
# Default for ORACLE SID
if [ "$ORACLE_SID" == "" ]; then
export ORACLE_SID=ORCLCDB
else
# Make ORACLE_SID upper case
# Github issue # 984
export ORACLE_SID=${ORACLE_SID^^}
# Check whether SID is no longer than 12 bytes
# Github issue #246: Cannot start OracleDB image
if [ "${#ORACLE_SID}" -gt 12 ]; then
echo "Error: The ORACLE_SID must only be up to 12 characters long."
exit 1;
fi;
# Check whether SID is alphanumeric
# Github issue #246: Cannot start OracleDB image
if [[ "$ORACLE_SID" =~ [^a-zA-Z0-9] ]]; then
echo "Error: The ORACLE_SID must be alphanumeric."
exit 1;
fi;
fi;
# Default for ORACLE PDB
export ORACLE_PDB=${ORACLE_PDB:-ORCLPDB1}
# Make ORACLE_PDB upper case
# Github issue # 984
export ORACLE_PDB=${ORACLE_PDB^^}
# Default for ORACLE CHARACTERSET
export ORACLE_CHARACTERSET=${ORACLE_CHARACTERSET:-AL32UTF8}
# Call relinkOracleBinary.sh before the database is created or started
. "$ORACLE_BASE/$RELINK_BINARY_FILE"
# Check whether database already exists
if [ -d $ORACLE_BASE/oradata/$ORACLE_SID ]; then
symLinkFiles;
# Make sure audit file destination exists
if [ ! -d $ORACLE_BASE/admin/$ORACLE_SID/adump ]; then
mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump
fi;
# Start database
$ORACLE_BASE/$START_FILE;
else
# Remove database config files, if they exist
rm -f $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora
rm -f $ORACLE_HOME/dbs/orapw$ORACLE_SID
rm -f $ORACLE_HOME/network/admin/sqlnet.ora
rm -f $ORACLE_HOME/network/admin/listener.ora
rm -f $ORACLE_HOME/network/admin/tnsnames.ora
# Create database
$ORACLE_BASE/$CREATE_DB_FILE $ORACLE_SID $ORACLE_PDB $ORACLE_PWD || exit 1;
# Move database operational files to oradata
moveFiles;
# Execute custom provided setup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/setup
fi;
# Check whether database is up and running
$ORACLE_BASE/$CHECK_DB_FILE
if [ $? -eq 0 ]; then
echo "#########################"
echo "DATABASE IS READY TO USE!"
echo "#########################"
# Execute custom provided startup scripts
$ORACLE_BASE/$USER_SCRIPTS_FILE $ORACLE_BASE/scripts/startup
else
echo "#####################################"
echo "########### E R R O R ###############"
echo "DATABASE SETUP WAS NOT SUCCESSFUL!"
echo "Please check output for further info!"
echo "########### E R R O R ###############"
echo "#####################################"
fi;
# Tail on alert log and wait (otherwise container will exit)
echo "The following output is now a tail of the alert.log:"
tail -f $ORACLE_BASE/diag/rdbms/*/*/trace/alert*.log &
childPID=$!
wait $childPID
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: July, 2017
# Author: gerald.venzl@oracle.com
# Description: Runs user shell and SQL scripts
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
SCRIPTS_ROOT="$1";
# Check whether parameter has been passed on
if [ -z "$SCRIPTS_ROOT" ]; then
echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run";
exit 1;
fi;
# Execute custom provided files (only if directory exists and has files in it)
if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then
echo "";
echo "Executing user defined scripts"
for f in $SCRIPTS_ROOT/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; echo "exit" | $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" @"$f"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo "";
done
echo "DONE: Executing user defined scripts"
echo "";
fi;
\ No newline at end of file
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets the password for sys, system and pdb_admin
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
ORACLE_PWD=$1
ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`"
ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`"
ORAENV_ASK=NO
source oraenv
sqlplus / as sysdba << EOF
ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD";
ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD";
ALTER SESSION SET CONTAINER=$ORACLE_PDB;
ALTER USER PDBADMIN IDENTIFIED BY "$ORACLE_PWD";
exit;
EOF
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: December, 2016
# Author: gerald.venzl@oracle.com
# Description: Sets up the unix environment for DB installation.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Setup filesystem and oracle user
# Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with Oracle installation
# ------------------------------------------------------------
mkdir -p $ORACLE_BASE/scripts/setup && \
mkdir $ORACLE_BASE/scripts/startup && \
ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \
mkdir $ORACLE_BASE/oradata && \
mkdir -p $ORACLE_HOME && \
chmod ug+x $ORACLE_BASE/*.sh && \
yum -y install oracle-database-preinstall-19c openssl && \
rm -rf /var/cache/yum && \
ln -s $ORACLE_BASE/$PWD_FILE /home/oracle/ && \
echo oracle:oracle | chpasswd && \
chown -R oracle:dba $ORACLE_BASE
#!/bin/bash
# LICENSE UPL 1.0
#
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
#
# Since: November, 2016
# Author: gerald.venzl@oracle.com
# Description: Starts the Listener and Oracle Database.
# The ORACLE_HOME and the PATH has to be set.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Check that ORACLE_HOME is set
if [ "$ORACLE_HOME" == "" ]; then
script_name=`basename "$0"`
echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script."
exit 1;
fi;
# Start Listener
lsnrctl start
# Start database
sqlplus / as sysdba << EOF
STARTUP;
exit;
EOF
#!/bin/bash -e
#
# Since: April, 2016
# Author: gerald.venzl@oracle.com
# Description: Build script for building Oracle Database container images.
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#
# Copyright (c) 2014,2021 Oracle and/or its affiliates.
#
usage() {
cat << EOF
Usage: buildContainerImage.sh -v [version] [-e | -s | -x] [-i] [-o] [container build option]
Builds a container image for Oracle Database.
Parameters:
-v: version to build
Choose one of: $(for i in */; do echo -n "${i%%/} "; done)
-e: creates image based on 'Enterprise Edition'
-s: creates image based on 'Standard Edition 2'
-x: creates image based on 'Express Edition'
-i: ignores the MD5 checksums
-o: passes on container build option
* select one edition only: -e, -s, or -x
LICENSE UPL 1.0
Copyright (c) 2014,2021 Oracle and/or its affiliates.
EOF
}
# Validate packages
checksumPackages() {
if hash md5sum 2>/dev/null; then
echo "Checking if required packages are present and valid..."
if ! md5sum -c "Checksum.${EDITION}"; then
echo "MD5 for required packages to build this image did not match!"
echo "Make sure to download missing files in folder ${VERSION}."
exit 1;
fi
else
echo "Ignored MD5 sum, 'md5sum' command not available.";
fi
}
# Check container runtime
checkContainerRuntime() {
CONTAINER_RUNTIME=$(which docker 2>/dev/null) ||
CONTAINER_RUNTIME=$(which podman 2>/dev/null) ||
{
echo "No docker or podman executable found in your PATH"
exit 1
}
if "${CONTAINER_RUNTIME}" info | grep -i -q buildahversion; then
checkPodmanVersion
else
checkDockerVersion
fi
}
# Check Podman version
checkPodmanVersion() {
# Get Podman version
echo "Checking Podman version."
PODMAN_VERSION=$("${CONTAINER_RUNTIME}" info --format '{{.host.BuildahVersion}}' 2>/dev/null ||
"${CONTAINER_RUNTIME}" info --format '{{.Host.BuildahVersion}}')
# Remove dot in Podman version
PODMAN_VERSION=${PODMAN_VERSION//./}
if [ -z "${PODMAN_VERSION}" ]; then
exit 1;
elif [ "${PODMAN_VERSION}" -lt "${MIN_PODMAN_VERSION//./}" ]; then
echo "Podman version is below the minimum required version ${MIN_PODMAN_VERSION}"
echo "Please upgrade your Podman installation to proceed."
exit 1;
fi
}
# Check Docker version
checkDockerVersion() {
# Get Docker Server version
echo "Checking Docker version."
DOCKER_VERSION=$("${CONTAINER_RUNTIME}" version --format '{{.Server.Version | printf "%.5s" }}'|| exit 0)
# Remove dot in Docker version
DOCKER_VERSION=${DOCKER_VERSION//./}
if [ "${DOCKER_VERSION}" -lt "${MIN_DOCKER_VERSION//./}" ]; then
echo "Docker version is below the minimum required version ${MIN_DOCKER_VERSION}"
echo "Please upgrade your Docker installation to proceed."
exit 1;
fi;
}
##############
#### MAIN ####
##############
# Parameters
ENTERPRISE=0
STANDARD=0
EXPRESS=0
VERSION="19.3.0"
SKIPMD5=0
declare -a BUILD_OPTS
MIN_DOCKER_VERSION="17.09"
MIN_PODMAN_VERSION="1.6.0"
DOCKERFILE="Dockerfile"
if [ "$#" -eq 0 ]; then
usage;
exit 1;
fi
while getopts "hesxiv:o:" optname; do
case "${optname}" in
"h")
usage
exit 0;
;;
"i")
SKIPMD5=1
;;
"e")
ENTERPRISE=1
;;
"s")
STANDARD=1
;;
"x")
EXPRESS=1
;;
"v")
VERSION="${OPTARG}"
;;
"o")
eval "BUILD_OPTS=(${OPTARG})"
;;
"?")
usage;
exit 1;
;;
*)
# Should not occur
echo "Unknown error while processing options inside buildContainerImage.sh"
;;
esac
done
# Check that we have a container runtime installed
checkContainerRuntime
# Which Edition should be used?
if [ $((ENTERPRISE + STANDARD + EXPRESS)) -gt 1 ]; then
usage
elif [ ${ENTERPRISE} -eq 1 ]; then
EDITION="ee"
elif [ ${STANDARD} -eq 1 ]; then
EDITION="se2"
elif [ ${EXPRESS} -eq 1 ]; then
if [ "${VERSION}" == "18.4.0" ]; then
EDITION="xe"
SKIPMD5=1
elif [ "${VERSION}" == "11.2.0.2" ]; then
EDITION="xe"
BUILD_OPTS=("--shm-size=1G" "${BUILD_OPTS[@]}")
else
echo "Version ${VERSION} does not have Express Edition available.";
exit 1;
fi;
fi;
# Which Dockerfile should be used?
if [ "${VERSION}" == "12.1.0.2" ] || [ "${VERSION}" == "11.2.0.2" ] || [ "${VERSION}" == "18.4.0" ]; then
DOCKERFILE="${DOCKERFILE}.${EDITION}"
fi;
# Oracle Database image Name
IMAGE_NAME="oracle/database:${VERSION}-${EDITION}"
# Go into version folder
cd "${VERSION}" || {
echo "Could not find version directory '${VERSION}'";
exit 1;
}
if [ ! "${SKIPMD5}" -eq 1 ]; then
checksumPackages
else
echo "Ignored MD5 checksum."
fi
echo "=========================="
echo "Container runtime info:"
"${CONTAINER_RUNTIME}" info
echo "=========================="
# Proxy settings
declare -a PROXY_SETTINGS
# shellcheck disable=SC2154
if [ "${http_proxy}" != "" ]; then
PROXY_SETTINGS=("${PROXY_SETTINGS[@]}" "--build-arg" "http_proxy=${http_proxy}")
fi
# shellcheck disable=SC2154
if [ "${https_proxy}" != "" ]; then
PROXY_SETTINGS=("${PROXY_SETTINGS[@]}" "--build-arg" "https_proxy=${https_proxy}")
fi
# shellcheck disable=SC2154
if [ "${ftp_proxy}" != "" ]; then
PROXY_SETTINGS=("${PROXY_SETTINGS[@]}" "--build-arg" "ftp_proxy=${ftp_proxy}")
fi
# shellcheck disable=SC2154
if [ "${no_proxy}" != "" ]; then
PROXY_SETTINGS=("${PROXY_SETTINGS[@]}" "--build-arg" "no_proxy=${no_proxy}")
fi
if [ ${#PROXY_SETTINGS[@]} -gt 0 ]; then
echo "Proxy settings were found and will be used during the build."
fi
# ################## #
# BUILDING THE IMAGE #
# ################## #
echo "Building image '${IMAGE_NAME}' ..."
# BUILD THE IMAGE (replace all environment variables)
BUILD_START=$(date '+%s')
"${CONTAINER_RUNTIME}" build --force-rm=true --no-cache=true \
"${BUILD_OPTS[@]}" "${PROXY_SETTINGS[@]}" --build-arg DB_EDITION=${EDITION} \
-t "${IMAGE_NAME}" -f "${DOCKERFILE}" . || {
echo ""
echo "ERROR: Oracle Database container image was NOT successfully created."
echo "ERROR: Check the output and correct any reported problems with the build operation."
exit 1
}
# Remove dangling images (intermitten images with tag <none>)
yes | "${CONTAINER_RUNTIME}" image prune > /dev/null
BUILD_END=$(date '+%s')
BUILD_ELAPSED=$(( BUILD_END - BUILD_START ))
echo ""
echo ""
cat << EOF
Oracle Database container image for '${EDITION}' version ${VERSION} is ready to be extended:
--> ${IMAGE_NAME}
Build completed in ${BUILD_ELAPSED} seconds.
EOF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment