├── 19.3.0 ├── Checksum.ee ├── Checksum.se2 ├── setPassword.sh ├── checkSpace.sh ├── setupLinuxEnv.sh ├── runUserScripts.sh ├── startDB.sh ├── checkDBStatus.sh ├── installDBBinaries.sh ├── Dockerfile ├── db_inst.rsp ├── runOracle.sh ├── dbca.rsp.tmpl └── createDB.sh ├── config_dataguard.lst ├── tnsnames.ora ├── docker-compose.yml ├── createCompose.sh └── README.md /19.3.0/Checksum.ee: -------------------------------------------------------------------------------- 1 | 1858bd0d281c60f4ddabd87b1c214a4f LINUX.X64_193000_db_home.zip 2 | -------------------------------------------------------------------------------- /19.3.0/Checksum.se2: -------------------------------------------------------------------------------- 1 | 1858bd0d281c60f4ddabd87b1c214a4f LINUX.X64_193000_db_home.zip 2 | -------------------------------------------------------------------------------- /config_dataguard.lst: -------------------------------------------------------------------------------- 1 | # Host | ID | Role | DG Cfg | SID | DB_UNQNAME | DG_TARGET | ORACLE_PWD 2 | DG11 | 1 | PRIMARY | DG1 | DG11 | DG11 | DG21 | oracle 3 | DG21 | 2 | STANDBY | DG1 | DG11 | DG21 | DG11 | oracle 4 | -------------------------------------------------------------------------------- /tnsnames.ora: -------------------------------------------------------------------------------- 1 | # tnsnames.ora extension for Data Guard demo 2 | DG11= 3 | (DESCRIPTION = 4 | (ADDRESS = (PROTOCOL = TCP)(HOST = DG11)(PORT = 1521)) 5 | (CONNECT_DATA = 6 | (SERVER = DEDICATED) 7 | (SID = DG11) 8 | ) 9 | ) 10 | DG21= 11 | (DESCRIPTION = 12 | (ADDRESS = (PROTOCOL = TCP)(HOST = DG21)(PORT = 1521)) 13 | (CONNECT_DATA = 14 | (SERVER = DEDICATED) 15 | (SID = DG11) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /19.3.0/setPassword.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: November, 2016 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Sets the password for sys, system and pdb_admin 9 | # 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 11 | # 12 | 13 | ORACLE_PWD=$1 14 | ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`" 15 | ORACLE_PDB="`ls -dl $ORACLE_BASE/oradata/$ORACLE_SID/*/ | grep -v pdbseed | awk '{print $9}' | cut -d/ -f6`" 16 | ORAENV_ASK=NO 17 | source oraenv 18 | 19 | sqlplus / as sysdba << EOF 20 | ALTER USER SYS IDENTIFIED BY "$ORACLE_PWD"; 21 | ALTER USER SYSTEM IDENTIFIED BY "$ORACLE_PWD"; 22 | ALTER SESSION SET CONTAINER=$ORACLE_PDB; 23 | ALTER USER PDBADMIN IDENTIFIED BY "$ORACLE_PWD"; 24 | exit; 25 | EOF 26 | 27 | -------------------------------------------------------------------------------- /19.3.0/checkSpace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: January, 2017 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Checks the available space of the system. 9 | # 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 11 | # 12 | 13 | REQUIRED_SPACE_GB=18 14 | AVAILABLE_SPACE_GB=`df -PB 1G / | tail -n 1 | awk '{ print $4 }'` 15 | 16 | if [ $AVAILABLE_SPACE_GB -lt $REQUIRED_SPACE_GB ]; then 17 | script_name=`basename "$0"` 18 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 19 | echo "$script_name: ERROR - There is not enough space available in the docker container." 20 | echo "$script_name: The container needs at least $REQUIRED_SPACE_GB GB, but only $AVAILABLE_SPACE_GB GB are available." 21 | echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" 22 | exit 1; 23 | fi; 24 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | DG11: 4 | image: oracle/database:19.3.0-ee 5 | container_name: DG11 6 | volumes: 7 | - "~/oradata/DG11:/opt/oracle/oradata" 8 | - "~/docker-dataguard:/opt/oracle/scripts" 9 | environment: 10 | CONTAINER_NAME: DG11 11 | DG_CONFIG: DG1 12 | DG_TARGET: DG21 13 | ORACLE_PDB: DG11PDB1 14 | ORACLE_PWD: oracle 15 | ORACLE_SID: DG11 16 | DB_UNQNAME: DG11 17 | ROLE: PRIMARY 18 | ports: 19 | - "1211:1521" 20 | 21 | DG21: 22 | image: oracle/database:19.3.0-ee 23 | container_name: DG21 24 | volumes: 25 | - "~/oradata/DG21:/opt/oracle/oradata" 26 | - "~/docker-dataguard:/opt/oracle/scripts" 27 | environment: 28 | CONTAINER_NAME: DG21 29 | DG_CONFIG: DG1 30 | DG_TARGET: DG11 31 | ORACLE_PDB: DG11PDB1 32 | ORACLE_PWD: oracle 33 | ORACLE_SID: DG11 34 | DB_UNQNAME: DG21 35 | ROLE: STANDBY 36 | ports: 37 | - "1212:1521" 38 | 39 | -------------------------------------------------------------------------------- /19.3.0/setupLinuxEnv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: December, 2016 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Sets up the unix environment for DB installation. 9 | # 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 11 | # 12 | 13 | # Setup filesystem and oracle user 14 | # Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with Oracle installation 15 | # ------------------------------------------------------------ 16 | mkdir -p $ORACLE_BASE/scripts/setup && \ 17 | mkdir $ORACLE_BASE/scripts/startup && \ 18 | ln -s $ORACLE_BASE/scripts /docker-entrypoint-initdb.d && \ 19 | mkdir $ORACLE_BASE/oradata && \ 20 | mkdir -p $ORACLE_HOME && \ 21 | chmod ug+x $ORACLE_BASE/*.sh && \ 22 | yum -y install oracle-database-preinstall-19c openssl vi less && \ 23 | rm -rf /var/cache/yum && \ 24 | ln -s $ORACLE_BASE/$PWD_FILE /home/oracle/ && \ 25 | echo oracle:oracle | chpasswd && \ 26 | chown -R oracle:dba $ORACLE_BASE 27 | -------------------------------------------------------------------------------- /19.3.0/runUserScripts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: July, 2017 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Runs user shell and SQL scripts 9 | # 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 11 | # 12 | 13 | SCRIPTS_ROOT="$1"; 14 | 15 | # Check whether parameter has been passed on 16 | if [ -z "$SCRIPTS_ROOT" ]; then 17 | echo "$0: No SCRIPTS_ROOT passed on, no scripts will be run"; 18 | exit 1; 19 | fi; 20 | 21 | # Execute custom provided files (only if directory exists and has files in it) 22 | if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A $SCRIPTS_ROOT)" ]; then 23 | 24 | echo ""; 25 | echo "Executing user defined scripts" 26 | 27 | for f in $SCRIPTS_ROOT/*; do 28 | case "$f" in 29 | *.sh) echo "$0: running $f"; . "$f" ;; 30 | *.sql) echo "$0: running $f"; echo "exit" | $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" @"$f"; echo ;; 31 | *) echo "$0: ignoring $f" ;; 32 | esac 33 | echo ""; 34 | done 35 | 36 | echo "DONE: Executing user defined scripts" 37 | echo ""; 38 | 39 | fi; -------------------------------------------------------------------------------- /19.3.0/startDB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: November, 2016 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Starts the Listener and Oracle Database. 9 | # The ORACLE_HOME and the PATH has to be set. 10 | # 11 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 12 | # 13 | 14 | # Check that ORACLE_HOME is set 15 | if [ "$ORACLE_HOME" == "" ]; then 16 | script_name=`basename "$0"` 17 | echo "$script_name: ERROR - ORACLE_HOME is not set. Please set ORACLE_HOME and PATH before invoking this script." 18 | exit 1; 19 | fi; 20 | 21 | # Start Listener 22 | lsnrctl start 23 | 24 | # Startup mount 25 | sqlplus / as sysdba << EOF 26 | startup mount 27 | EOF 28 | 29 | # Determine the database role 30 | database_role=$(sqlplus -S / as sysdba << EOF 31 | select database_role from v\$database; 32 | EOF 33 | ) 34 | 35 | # The expected output is either: 36 | # DATABASE_ROLE ---------------- PRIMARY 37 | # DATABASE_ROLE ---------------- PHYSICAL STANDBY 38 | # Determine the role: 39 | 40 | if [[ $database_role =~ PRIMARY ]] 41 | then export ROLE="PRIMARY" 42 | elif [[ $database_role =~ STANDBY ]] 43 | then export ROLE="STANDBY" 44 | else export ROLE="$ROLE" 45 | fi 46 | 47 | 48 | if [ "$ROLE" = "STANDBY" ] 49 | then # Start standby databases in managed recovery 50 | sqlplus / as sysdba << EOF 51 | alter database recover managed standby database disconnect from session; 52 | exit 53 | EOF 54 | 55 | else # Open the database 56 | sqlplus / as sysdba << EOF 57 | alter database open; 58 | exit 59 | EOF 60 | 61 | fi 62 | -------------------------------------------------------------------------------- /createCompose.sh: -------------------------------------------------------------------------------- 1 | # Set variables for environment if not present 2 | export DG_DIR="${DG_DIR:-~/docker-dataguard}" 3 | export ORADATA_VOLUME="${ORADATA_VOLUME:-~/oradata}" 4 | 5 | # Set variables used by Docker, Compose if not present: 6 | export DB_VERSION="${DB_VERSION:-19.3.0}" 7 | export COMPOSE_YAML="${COMPOSE_YAML:-docker-compose.yml}" 8 | export IMAGE_NAME="${IMAGE_NAME:-oracle/database:${DB_VERSION}-ee}" 9 | 10 | # Create a docker-compose file and dynamically build the tnsnames.ora file 11 | # Initialize the docker-compose file: 12 | cat << EOF > $COMPOSE_YAML 13 | version: '3' 14 | services: 15 | EOF 16 | 17 | # Initialize the TNSNames file: 18 | cat << EOF > $DG_DIR/tnsnames.ora 19 | # tnsnames.ora extension for Data Guard demo 20 | EOF 21 | 22 | # Populate the docker-compose.yml file: 23 | egrep -v "^$|^#" $DG_DIR/config_dataguard.lst | sed -e 's/[[:space:]]//g' | sort | while IFS='|' read CONTAINER_NAME CONTAINER_ID ROLE DG_CONFIG ORACLE_SID DB_UNQNAME DG_TARGET ORACLE_PWD 24 | do 25 | 26 | # Write the Docker compose file entry: 27 | cat << EOF >> $COMPOSE_YAML 28 | $CONTAINER_NAME: 29 | image: $IMAGE_NAME 30 | container_name: $CONTAINER_NAME 31 | volumes: 32 | - "$ORADATA_VOLUME/$CONTAINER_NAME:/opt/oracle/oradata" 33 | - "$DG_DIR:/opt/oracle/scripts" 34 | environment: 35 | CONTAINER_NAME: $CONTAINER_NAME 36 | DG_CONFIG: $DG_CONFIG 37 | DG_TARGET: $DG_TARGET 38 | ORACLE_PDB: ${ORACLE_SID}PDB1 39 | ORACLE_PWD: $ORACLE_PWD 40 | ORACLE_SID: $ORACLE_SID 41 | DB_UNQNAME: $DB_UNQNAME 42 | ROLE: $ROLE 43 | ports: 44 | - "121$CONTAINER_ID:1521" 45 | 46 | EOF 47 | 48 | # Write a tnsnames.ora entry for each instance in the configuration file: 49 | cat << EOF >> $DG_DIR/tnsnames.ora 50 | $CONTAINER_NAME= 51 | (DESCRIPTION = 52 | (ADDRESS = (PROTOCOL = TCP)(HOST = $CONTAINER_NAME)(PORT = 1521)) 53 | (CONNECT_DATA = 54 | (SERVER = DEDICATED) 55 | (SID = $ORACLE_SID) 56 | ) 57 | ) 58 | EOF 59 | 60 | done 61 | 62 | -------------------------------------------------------------------------------- /19.3.0/checkDBStatus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: May, 2017 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Checks the status of Oracle Database. 9 | # Return codes: 0 = PDB is open and ready to use 10 | # 1 = PDB is not open 11 | # 2 = Sql Plus execution failed 12 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 13 | # 14 | # Updated: August 2019 15 | # Author: oracle.sean@gmail.com 16 | # Description: Modifications for handling Data Guard container environments. 17 | 18 | ORACLE_SID="`grep $ORACLE_HOME /etc/oratab | cut -d: -f1`" 19 | OPEN_MODE="READ WRITE" 20 | ORAENV_ASK=NO 21 | source oraenv 22 | 23 | # Check Oracle at least one PDB has open_mode "READ WRITE" and store it in status 24 | db_role=`sqlplus -s / as sysdba << EOF 25 | set heading off; 26 | set pagesize 0; 27 | select database_role from v\\$database; 28 | exit; 29 | EOF` 30 | 31 | # Store return code from SQL*Plus 32 | ret=$? 33 | 34 | # SQL Plus execution was successful and the database is PRIMARY: 35 | if [ $ret -eq 0 ] && [ "$db_role" = "PRIMARY" ]; then 36 | 37 | # DB Role is PRIMARY; check for an open PDB 38 | status=`sqlplus -s / as sysdba << EOF 39 | set heading off; 40 | set pagesize 0; 41 | SELECT DISTINCT open_mode FROM v\\$pdbs WHERE open_mode = '$OPEN_MODE'; 42 | exit; 43 | EOF` 44 | 45 | # Store return code from SQL*Plus 46 | ret=$? 47 | 48 | # SQL Plus execution was successful and PDB is open 49 | if [ $ret -eq 0 ] && [ "$status" = "$OPEN_MODE" ]; then 50 | exit 0; 51 | # PDB is not open 52 | elif [ "$status" != "$OPEN_MODE" ]; then 53 | exit 1; 54 | # SQL Plus execution failed 55 | else 56 | exit 2; 57 | fi; 58 | 59 | elif [ "$db_role" = "PHYSICAL STANDBY" ]; then 60 | # DB Role is STANDBY; check for DB state 61 | status=`sqlplus -s / as sysdba << EOF 62 | set heading off; 63 | set pagesize 0; 64 | select 'HEALTHY' from v\\$database where open_mode in ('MOUNTED', 'READ ONLY', 'READ ONLY WITH APPLY'); 65 | exit; 66 | EOF` 67 | 68 | # Store return code from SQL*Plus 69 | ret=$? 70 | 71 | # SQL Plus execution was successful and mode is in the list 72 | if [ $ret -eq 0 ] && [ "$status" = "HEALTHY" ]; then 73 | exit 0; 74 | # Database mode is not in the list 75 | elif [ "$status" != "HEALTHY" ]; then 76 | exit 1; 77 | # SQL Plus execution failed 78 | else 79 | exit 2; 80 | fi; 81 | 82 | else 83 | exit 2; 84 | fi 85 | -------------------------------------------------------------------------------- /19.3.0/installDBBinaries.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: December, 2016 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Sets up the unix environment for DB installation. 9 | # 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 11 | # 12 | 13 | # Convert $1 into upper case via "^^" (bash version 4 onwards) 14 | EDITION=${1^^} 15 | 16 | # Check whether edition has been passed on 17 | if [ "$EDITION" == "" ]; then 18 | echo "ERROR: No edition has been passed on!" 19 | echo "Please specify the correct edition!" 20 | exit 1; 21 | fi; 22 | 23 | # Check whether correct edition has been passed on 24 | if [ "$EDITION" != "EE" -a "$EDITION" != "SE2" ]; then 25 | echo "ERROR: Wrong edition has been passed on!" 26 | echo "Edition $EDITION is no a valid edition!" 27 | exit 1; 28 | fi; 29 | 30 | # Check whether ORACLE_BASE is set 31 | if [ "$ORACLE_BASE" == "" ]; then 32 | echo "ERROR: ORACLE_BASE has not been set!" 33 | echo "You have to have the ORACLE_BASE environment variable set to a valid value!" 34 | exit 1; 35 | fi; 36 | 37 | # Check whether ORACLE_HOME is set 38 | if [ "$ORACLE_HOME" == "" ]; then 39 | echo "ERROR: ORACLE_HOME has not been set!" 40 | echo "You have to have the ORACLE_HOME environment variable set to a valid value!" 41 | exit 1; 42 | fi; 43 | 44 | 45 | # Replace place holders 46 | # --------------------- 47 | sed -i -e "s|###ORACLE_EDITION###|$EDITION|g" $INSTALL_DIR/$INSTALL_RSP && \ 48 | sed -i -e "s|###ORACLE_BASE###|$ORACLE_BASE|g" $INSTALL_DIR/$INSTALL_RSP && \ 49 | sed -i -e "s|###ORACLE_HOME###|$ORACLE_HOME|g" $INSTALL_DIR/$INSTALL_RSP 50 | 51 | # Install Oracle binaries 52 | cd $ORACLE_HOME && \ 53 | mv $INSTALL_DIR/$INSTALL_FILE_1 $ORACLE_HOME/ && \ 54 | unzip $INSTALL_FILE_1 && \ 55 | rm $INSTALL_FILE_1 && \ 56 | $ORACLE_HOME/runInstaller -silent -force -waitforcompletion -responsefile $INSTALL_DIR/$INSTALL_RSP -ignorePrereqFailure && \ 57 | cd $HOME 58 | 59 | # Remove not needed components 60 | # APEX 61 | rm -rf $ORACLE_HOME/apex && \ 62 | # ORDS 63 | rm -rf $ORACLE_HOME/ords && \ 64 | # SQL Developer 65 | rm -rf $ORACLE_HOME/sqldeveloper && \ 66 | # UCP connection pool 67 | rm -rf $ORACLE_HOME/ucp && \ 68 | # All installer files 69 | rm -rf $ORACLE_HOME/lib/*.zip && \ 70 | # OUI backup 71 | rm -rf $ORACLE_HOME/inventory/backup/* && \ 72 | # Network tools help 73 | rm -rf $ORACLE_HOME/network/tools/help && \ 74 | # Database upgrade assistant 75 | rm -rf $ORACLE_HOME/assistants/dbua && \ 76 | # Database migration assistant 77 | rm -rf $ORACLE_HOME/dmu && \ 78 | # Remove pilot workflow installer 79 | rm -rf $ORACLE_HOME/install/pilot && \ 80 | # Support tools 81 | rm -rf $ORACLE_HOME/suptools && \ 82 | # Temp location 83 | rm -rf /tmp/* && \ 84 | # Database files directory 85 | rm -rf $INSTALL_DIR/database 86 | -------------------------------------------------------------------------------- /19.3.0/Dockerfile: -------------------------------------------------------------------------------- 1 | # LICENSE UPL 1.0 2 | # 3 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 4 | # 5 | # ORACLE DOCKERFILES PROJECT 6 | # -------------------------- 7 | # This is the Dockerfile for Oracle Database 19c 8 | # 9 | # REQUIRED FILES TO BUILD THIS IMAGE 10 | # ---------------------------------- 11 | # (1) db_home.zip 12 | # Download Oracle Database 19c Enterprise Edition or Standard Edition 2 for Linux x64 13 | # from http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html 14 | # 15 | # HOW TO BUILD THIS IMAGE 16 | # ----------------------- 17 | # Put all downloaded files in the same directory as this Dockerfile 18 | # Run: 19 | # $ docker build -t oracle/database:19.3.0-${EDITION} . 20 | # 21 | # Pull base image 22 | # --------------- 23 | FROM oraclelinux:7-slim as base 24 | 25 | # Maintainer 26 | # ---------- 27 | MAINTAINER Sean Scott 28 | 29 | # Environment variables required for this build (do NOT change) 30 | # ------------------------------------------------------------- 31 | ENV ORACLE_BASE=/opt/oracle \ 32 | ORACLE_HOME=/opt/oracle/product/19c/dbhome_1 \ 33 | INSTALL_DIR=/opt/install \ 34 | INSTALL_FILE_1="LINUX.X64_193000_db_home.zip" \ 35 | INSTALL_RSP="db_inst.rsp" \ 36 | CONFIG_RSP="dbca.rsp.tmpl" \ 37 | PWD_FILE="setPassword.sh" \ 38 | RUN_FILE="runOracle.sh" \ 39 | START_FILE="startDB.sh" \ 40 | CREATE_DB_FILE="createDB.sh" \ 41 | SETUP_LINUX_FILE="setupLinuxEnv.sh" \ 42 | CHECK_SPACE_FILE="checkSpace.sh" \ 43 | CHECK_DB_FILE="checkDBStatus.sh" \ 44 | USER_SCRIPTS_FILE="runUserScripts.sh" \ 45 | INSTALL_DB_BINARIES_FILE="installDBBinaries.sh" 46 | 47 | # Use second ENV so that variable get substituted 48 | ENV PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:/home/oracle/bin:$PATH \ 49 | LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib \ 50 | CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib 51 | 52 | # Copy files needed during both installation and runtime 53 | # ------------------------------------------------------ 54 | COPY $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DIR/ 55 | COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $CHECK_DB_FILE $USER_SCRIPTS_FILE $ORACLE_BASE/ 56 | 57 | RUN chmod ug+x $INSTALL_DIR/*.sh && \ 58 | sync && \ 59 | $INSTALL_DIR/$CHECK_SPACE_FILE && \ 60 | $INSTALL_DIR/$SETUP_LINUX_FILE && \ 61 | rm -rf $INSTALL_DIR 62 | 63 | ############################################# 64 | # ------------------------------------------- 65 | # Start new stage for installing the database 66 | # ------------------------------------------- 67 | ############################################# 68 | 69 | FROM base AS builder 70 | 71 | ARG DB_EDITION 72 | 73 | # Copy DB install file 74 | COPY --chown=oracle:dba $INSTALL_FILE_1 $INSTALL_RSP $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/ 75 | 76 | # Install DB software binaries 77 | USER oracle 78 | RUN chmod ug+x $INSTALL_DIR/*.sh && \ 79 | sync && \ 80 | $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE $DB_EDITION 81 | 82 | ############################################# 83 | # ------------------------------------------- 84 | # Start new layer for database runtime 85 | # ------------------------------------------- 86 | ############################################# 87 | 88 | FROM base 89 | 90 | USER oracle 91 | COPY --chown=oracle:dba --from=builder $ORACLE_BASE $ORACLE_BASE 92 | 93 | USER root 94 | RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \ 95 | $ORACLE_HOME/root.sh 96 | 97 | USER oracle 98 | WORKDIR /home/oracle 99 | 100 | VOLUME ["$ORACLE_BASE/oradata"] 101 | EXPOSE 1521 5500 102 | HEALTHCHECK --interval=1m --start-period=15m \ 103 | CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1 104 | 105 | # Define default command to start Oracle Database. 106 | CMD exec $ORACLE_BASE/$RUN_FILE 107 | 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-dataguard 2 | 3 | Files for building an Oracle Data Guard database in Docker 4 | 5 | Currently working for version 19.3. 6 | 7 | # Disclaimer 8 | 9 | This is intended as an educational tool for learning and experimenting with Data Guard. 10 | 11 | Want to understand how switchover works? Nice! 12 | Interested in learning more about Data Guard? Welcome! 13 | Need identical labs for students in a class or workshop? Awesome! 14 | Hacking out a preliminary demo solution or proof of concept? Cool! 15 | Want a portable, lightweight, fully functional Data Guard that runs on a laptop in Economy class? Enjoy! 16 | **Use this to protect a production environment? Bad idea.** 17 | 18 | # What does it do? 19 | This creates two containers each hosting Oracle databases and configures them as a Data Guard primary/secondary. 20 | 21 | The primary database is built much the same as in an ordinary Docker build. Additional configurations and parameters are added to satisfy the requirements of Data Guard. Standby redo logs are added. 22 | 23 | Meanwhile the standby database is initiated but does not run DBCA. 24 | 25 | When the database configuration on the primary is complete, it begins an RMAN duplicate and instantiates the standby database. 26 | 27 | Data Guard broker is invoked to create a configuration and add the databases. It also adds static connect identifiers to overcome issues arising from Docker's host-naming. 28 | 29 | The containers are visible across the Docker network by the names assigned in the compose yaml file (default are DG11 and DG21) and all TNS/networking operations can be conduced using those aliases. 30 | 31 | The two containers are built with an environment variable called ROLE. This is initially set to PRIMARY and STANDBY to faciliate the intial installation. Once database is creation is complete the variable has no meaning. The role of a database is determined at startup in the startDB.sh script by querying the current role of the instance. This allows the database to be started/resume the correct role through a start/stop of compose. 32 | 33 | NOTE: Data Guard requires your database to be in archivelog mode. Manage archive log directories accordingly. 34 | 35 | ## Information 36 | The 19.3 database image is 6.65G. 37 | ``` 38 | > docker images 39 | REPOSITORY TAG IMAGE ID CREATED SIZE 40 | oracle/database 19.3.0-ee ea261e0fff26 2 hours ago 6.65GB 41 | ``` 42 | The default build opens ports 1521 and 5500. It translates port 1521 to 1211 on the first host and 1212 on the second. This may be changed in docker-compose.yml. 43 | 44 | The default build maps the data volume to a local directory on the host. Change or remove this in the docker-compose.yml. 45 | 46 | ## Errata 47 | The setupLinuxEnv.sh script for this build includes `vi` and `less` for troubleshooting purposes. If you're looking for a very slightly smaller image, remove them. :) 48 | 49 | ## Setup 50 | 51 | Set Docker's memory limit to at least 8G 52 | 53 | ## Prerequisites 54 | This repo is built on the Oracle Docker repository: https://github.com/oracle/docker-images 55 | 56 | Download the following files from Oracle OTN: 57 | ``` 58 | LINUX.X64_193000_db_home.zip 59 | ``` 60 | 61 | ## Set the environment 62 | The ORADATA_VOLUME is for persisting data for the databases. Each database will inhabit a subdirectory of ORADATA_VOLUME based on the database unique name. DG_DIR is the base directory for this repo. 63 | ``` 64 | export COMPOSE_YAML=docker-compose.yml 65 | export DB_VERSION=19.3.0 66 | export IMAGE_NAME=oracle/database:${DB_VERSION}-ee 67 | export ORADATA_VOLUME=~/oradata 68 | export DG_DIR=~/docker-dataguard 69 | ``` 70 | 71 | ## Copy the downloaded Oracle database installation files to the DG directory: 72 | ``` 73 | cp LINUX.X64_193000_db_home.zip $DG_DIR/$DB_VERSION 74 | ``` 75 | 76 | ## Navigate to the DG directory 77 | `cd $DG_DIR` 78 | 79 | ## Run the build to create the oracle/datbase:19.3.0-ee Docker image 80 | `./buildDockerImage.sh -v 19.3.0 -e` 81 | 82 | ## Run compose (detached) 83 | `docker-compose up -d` 84 | 85 | ## Tail the logs 86 | `docker-compose logs -f` 87 | 88 | # Testing 89 | The build has been tested by starting the databases under docker-compose and running DGMGRL validations and switchover through a variety of scenarios. It correctly resumes the configuration across stops/starts of docker-compose. 90 | 91 | Please report any issues to oracle.sean@gmail.com. Thanks! 92 | 93 | # CUSTOM CONFIGURATION 94 | ## Database configurations 95 | Customize a configuration file for setting up the contaner hosts using the following format if the existing config_dataguard.lst does not meet your needs. This file is used for automated setup of the environment. 96 | 97 | The pluggable database is ${ORACLE_SID}PDB1. The default configuration is: 98 | 99 | ``` 100 | cat << EOF > $DG_DIR/config_dataguard.lst 101 | # Host | ID | Role | DG Cfg | SID | DB_UNQNAME | DG_TARGET | ORACLE_PWD 102 | DG11 | 1 | PRIMARY | DG1 | DG11 | DG11 | DG21 | oracle 103 | DG21 | 2 | STANDBY | DG1 | DG11 | DG21 | DG11 | oracle 104 | EOF 105 | ``` 106 | 107 | ## Docker compose file, TNS configuration 108 | If the ORACLE_SID or host names are changed, the TNS configuration must be update to match. 109 | 110 | ### Create a docker-compose file using a custom configuration and build the tnsnames.ora, listener.ora files 111 | The `createCompose.sh` script will create the yaml file and the necessary TNS entries by reading the config file: 112 | ``` 113 | ./createCompose.sh 114 | ``` 115 | 116 | # Cleanup 117 | ## To stop compose, remove any existing image and prune the images: 118 | ``` 119 | docker-compose down 120 | docker rmi oracle/database:19.3.0-ee 121 | docker image prune <<< y 122 | ``` 123 | 124 | ## Clear out the ORADATA volume 125 | ``` 126 | if [[ "$ORADATA_VOLUME" ]] && [ -d "$ORADATA_VOLUME" ] 127 | then rm -Rf $ORADATA_VOLUME/DG* 128 | fi 129 | #rm -Rf ~/oradata/DG* 130 | ``` 131 | 132 | -------------------------------------------------------------------------------- /19.3.0/db_inst.rsp: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | ## Copyright(c) Oracle Corporation 1998,2017. All rights reserved.## 3 | ## ## 4 | ## Specify values for the variables listed below to customize ## 5 | ## your installation. ## 6 | ## ## 7 | ## Each variable is associated with a comment. The comment ## 8 | ## can help to populate the variables with the appropriate ## 9 | ## values. ## 10 | ## ## 11 | ## IMPORTANT NOTE: This file contains plain text passwords and ## 12 | ## should be secured to have read permission only by oracle user ## 13 | ## or db administrator who owns this installation. ## 14 | ## ## 15 | #################################################################### 16 | 17 | 18 | #------------------------------------------------------------------------------- 19 | # Do not change the following system generated value. 20 | #------------------------------------------------------------------------------- 21 | oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0 22 | 23 | #------------------------------------------------------------------------------- 24 | # Specify the installation option. 25 | # It can be one of the following: 26 | # - INSTALL_DB_SWONLY 27 | # - INSTALL_DB_AND_CONFIG 28 | # - UPGRADE_DB 29 | #------------------------------------------------------------------------------- 30 | oracle.install.option=INSTALL_DB_SWONLY 31 | 32 | #------------------------------------------------------------------------------- 33 | # Specify the Unix group to be set for the inventory directory. 34 | #------------------------------------------------------------------------------- 35 | UNIX_GROUP_NAME=dba 36 | 37 | #------------------------------------------------------------------------------- 38 | # Specify the location which holds the inventory files. 39 | # This is an optional parameter if installing on 40 | # Windows based Operating System. 41 | #------------------------------------------------------------------------------- 42 | INVENTORY_LOCATION=###ORACLE_BASE###/oraInventory 43 | #------------------------------------------------------------------------------- 44 | # Specify the complete path of the Oracle Home. 45 | #------------------------------------------------------------------------------- 46 | ORACLE_HOME=###ORACLE_HOME### 47 | 48 | #------------------------------------------------------------------------------- 49 | # Specify the complete path of the Oracle Base. 50 | #------------------------------------------------------------------------------- 51 | ORACLE_BASE=###ORACLE_BASE### 52 | 53 | #------------------------------------------------------------------------------- 54 | # Specify the installation edition of the component. 55 | # 56 | # The value should contain only one of these choices. 57 | # - EE : Enterprise Edition 58 | # - SE2 : Standard Edition 2 59 | #------------------------------------------------------------------------------- 60 | oracle.install.db.InstallEdition=###ORACLE_EDITION### 61 | 62 | ############################################################################### 63 | # # 64 | # PRIVILEGED OPERATING SYSTEM GROUPS # 65 | # ------------------------------------------ # 66 | # Provide values for the OS groups to which SYSDBA and SYSOPER privileges # 67 | # needs to be granted. If the install is being performed as a member of the # 68 | # group "dba", then that will be used unless specified otherwise below. # 69 | # # 70 | # The value to be specified for OSDBA and OSOPER group is only for UNIX based # 71 | # Operating System. # 72 | # # 73 | ############################################################################### 74 | 75 | #------------------------------------------------------------------------------ 76 | # The OSDBA_GROUP is the OS group which is to be granted SYSDBA privileges. 77 | #------------------------------------------------------------------------------- 78 | oracle.install.db.OSDBA_GROUP=dba 79 | 80 | #------------------------------------------------------------------------------ 81 | # The OSOPER_GROUP is the OS group which is to be granted SYSOPER privileges. 82 | # The value to be specified for OSOPER group is optional. 83 | #------------------------------------------------------------------------------ 84 | oracle.install.db.OSOPER_GROUP=dba 85 | 86 | #------------------------------------------------------------------------------ 87 | # The OSBACKUPDBA_GROUP is the OS group which is to be granted SYSBACKUP privileges. 88 | #------------------------------------------------------------------------------ 89 | oracle.install.db.OSBACKUPDBA_GROUP=dba 90 | 91 | #------------------------------------------------------------------------------ 92 | # The OSDGDBA_GROUP is the OS group which is to be granted SYSDG privileges. 93 | #------------------------------------------------------------------------------ 94 | oracle.install.db.OSDGDBA_GROUP=dba 95 | 96 | #------------------------------------------------------------------------------ 97 | # The OSKMDBA_GROUP is the OS group which is to be granted SYSKM privileges. 98 | #------------------------------------------------------------------------------ 99 | oracle.install.db.OSKMDBA_GROUP=dba 100 | 101 | #------------------------------------------------------------------------------ 102 | # The OSRACDBA_GROUP is the OS group which is to be granted SYSRAC privileges. 103 | #------------------------------------------------------------------------------ 104 | oracle.install.db.OSRACDBA_GROUP=dba 105 | 106 | #------------------------------------------------------------------------------ 107 | # Specify whether to enable the user to set the password for 108 | # My Oracle Support credentials. The value can be either true or false. 109 | # If left blank it will be assumed to be false. 110 | # 111 | # Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true 112 | #------------------------------------------------------------------------------ 113 | SECURITY_UPDATES_VIA_MYORACLESUPPORT=false 114 | 115 | #------------------------------------------------------------------------------ 116 | # Specify whether user doesn't want to configure Security Updates. 117 | # The value for this variable should be true if you don't want to configure 118 | # Security Updates, false otherwise. 119 | # 120 | # The value can be either true or false. If left blank it will be assumed 121 | # to be true. 122 | # 123 | # Example : DECLINE_SECURITY_UPDATES=false 124 | #------------------------------------------------------------------------------ 125 | DECLINE_SECURITY_UPDATES=true -------------------------------------------------------------------------------- /19.3.0/runOracle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: November, 2016 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Runs the Oracle Database inside the container 9 | # 10 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 11 | # 12 | 13 | ########### Move DB files ############ 14 | function moveFiles { 15 | 16 | if [ ! -d $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID ]; then 17 | mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 18 | fi; 19 | 20 | mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 21 | mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 22 | mv $ORACLE_HOME/network/admin/sqlnet.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 23 | mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 24 | mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 25 | 26 | # oracle user does not have permissions in /etc, hence cp and not mv 27 | cp /etc/oratab $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 28 | 29 | symLinkFiles; 30 | } 31 | 32 | ########### Symbolic link DB files ############ 33 | function symLinkFiles { 34 | 35 | if [ ! -L $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then 36 | if [ -f $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora ]; then 37 | mv $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 38 | fi; 39 | ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/spfile$ORACLE_SID.ora $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora 40 | fi; 41 | 42 | if [ ! -L $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then 43 | if [ -f $ORACLE_HOME/dbs/orapw$ORACLE_SID ]; then 44 | mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 45 | fi; 46 | ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID 47 | fi; 48 | 49 | if [ ! -L $ORACLE_HOME/network/admin/sqlnet.ora ]; then 50 | if [ -f $ORACLE_HOME/network/admin/sqlnet.ora ]; then 51 | mv $ORACLE_HOME/network/admin/sqlnet.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 52 | fi; 53 | ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/sqlnet.ora $ORACLE_HOME/network/admin/sqlnet.ora 54 | fi; 55 | 56 | if [ ! -L $ORACLE_HOME/network/admin/listener.ora ]; then 57 | if [ -f $ORACLE_HOME/network/admin/listener.ora ]; then 58 | mv $ORACLE_HOME/network/admin/listener.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 59 | fi; 60 | ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/listener.ora $ORACLE_HOME/network/admin/listener.ora 61 | fi; 62 | 63 | if [ ! -L $ORACLE_HOME/network/admin/tnsnames.ora ]; then 64 | if [ -f $ORACLE_HOME/network/admin/tnsnames.ora ]; then 65 | mv $ORACLE_HOME/network/admin/tnsnames.ora $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/ 66 | fi; 67 | ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/tnsnames.ora $ORACLE_HOME/network/admin/tnsnames.ora 68 | fi; 69 | 70 | # oracle user does not have permissions in /etc, hence cp and not ln 71 | if [ -f $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab ]; then 72 | cp $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/oratab /etc/oratab 73 | fi; 74 | 75 | } 76 | 77 | ########### SIGINT handler ############ 78 | function _int() { 79 | echo "Stopping container." 80 | echo "SIGINT received, shutting down database!" 81 | sqlplus / as sysdba <. - when database domain isn't NULL 28 | # - when database domain is NULL 29 | # Default value : None 30 | # Mandatory : Yes 31 | #----------------------------------------------------------------------------- 32 | gdbName=###ORACLE_SID### 33 | 34 | #----------------------------------------------------------------------------- 35 | # Name : sid 36 | # Datatype : String 37 | # Description : System identifier (SID) of the database 38 | # Valid values : Check Oracle12c Administrator's Guide 39 | # Default value : specified in GDBNAME 40 | # Mandatory : No 41 | #----------------------------------------------------------------------------- 42 | sid=###ORACLE_SID### 43 | 44 | #----------------------------------------------------------------------------- 45 | # Name : createAsContainerDatabase 46 | # Datatype : boolean 47 | # Description : flag to create database as container database 48 | # Valid values : Check Oracle12c Administrator's Guide 49 | # Default value : false 50 | # Mandatory : No 51 | #----------------------------------------------------------------------------- 52 | createAsContainerDatabase=true 53 | 54 | #----------------------------------------------------------------------------- 55 | # Name : numberOfPDBs 56 | # Datatype : Number 57 | # Description : Specify the number of pdb to be created 58 | # Valid values : 0 to 4094 59 | # Default value : 0 60 | # Mandatory : No 61 | #----------------------------------------------------------------------------- 62 | numberOfPDBs=1 63 | 64 | #----------------------------------------------------------------------------- 65 | # Name : pdbName 66 | # Datatype : String 67 | # Description : Specify the pdbname/pdbanme prefix if one or more pdb need to be created 68 | # Valid values : Check Oracle12c Administrator's Guide 69 | # Default value : None 70 | # Mandatory : No 71 | #----------------------------------------------------------------------------- 72 | pdbName=###ORACLE_PDB### 73 | 74 | #----------------------------------------------------------------------------- 75 | # Name : pdbAdminPassword 76 | # Datatype : String 77 | # Description : PDB Administrator user password 78 | # Valid values : Check Oracle12c Administrator's Guide 79 | # Default value : None 80 | # Mandatory : No 81 | #----------------------------------------------------------------------------- 82 | pdbAdminPassword=###ORACLE_PWD### 83 | 84 | #----------------------------------------------------------------------------- 85 | # Name : templateName 86 | # Datatype : String 87 | # Description : Name of the template 88 | # Valid values : Template file name 89 | # Default value : None 90 | # Mandatory : Yes 91 | #----------------------------------------------------------------------------- 92 | templateName=General_Purpose.dbc 93 | 94 | #----------------------------------------------------------------------------- 95 | # Name : sysPassword 96 | # Datatype : String 97 | # Description : Password for SYS user 98 | # Valid values : Check Oracle12c Administrator's Guide 99 | # Default value : None 100 | # Mandatory : Yes 101 | #----------------------------------------------------------------------------- 102 | sysPassword=###ORACLE_PWD### 103 | 104 | #----------------------------------------------------------------------------- 105 | # Name : systemPassword 106 | # Datatype : String 107 | # Description : Password for SYSTEM user 108 | # Valid values : Check Oracle12c Administrator's Guide 109 | # Default value : None 110 | # Mandatory : Yes 111 | #----------------------------------------------------------------------------- 112 | systemPassword=###ORACLE_PWD### 113 | 114 | #----------------------------------------------------------------------------- 115 | # Name : emConfiguration 116 | # Datatype : String 117 | # Description : Enterprise Manager Configuration Type 118 | # Valid values : CENTRAL|DBEXPRESS|BOTH|NONE 119 | # Default value : NONE 120 | # Mandatory : No 121 | #----------------------------------------------------------------------------- 122 | emConfiguration=DBEXPRESS 123 | 124 | #----------------------------------------------------------------------------- 125 | # Name : emExpressPort 126 | # Datatype : Number 127 | # Description : Enterprise Manager Configuration Type 128 | # Valid values : Check Oracle12c Administrator's Guide 129 | # Default value : NONE 130 | # Mandatory : No, will be picked up from DBEXPRESS_HTTPS_PORT env variable 131 | # or auto generates a free port between 5500 and 5599 132 | #----------------------------------------------------------------------------- 133 | emExpressPort=5500 134 | 135 | #----------------------------------------------------------------------------- 136 | # Name : dbsnmpPassword 137 | # Datatype : String 138 | # Description : Password for DBSNMP user 139 | # Valid values : Check Oracle12c Administrator's Guide 140 | # Default value : None 141 | # Mandatory : Yes, if emConfiguration is specified or 142 | # the value of runCVUChecks is TRUE 143 | #----------------------------------------------------------------------------- 144 | dbsnmpPassword=###ORACLE_PWD### 145 | 146 | #----------------------------------------------------------------------------- 147 | # Name : characterSet 148 | # Datatype : String 149 | # Description : Character set of the database 150 | # Valid values : Check Oracle12c National Language Support Guide 151 | # Default value : "US7ASCII" 152 | # Mandatory : NO 153 | #----------------------------------------------------------------------------- 154 | characterSet=###ORACLE_CHARACTERSET### 155 | 156 | #----------------------------------------------------------------------------- 157 | # Name : nationalCharacterSet 158 | # Datatype : String 159 | # Description : National Character set of the database 160 | # Valid values : "UTF8" or "AL16UTF16". For details, check Oracle12c National Language Support Guide 161 | # Default value : "AL16UTF16" 162 | # Mandatory : No 163 | #----------------------------------------------------------------------------- 164 | nationalCharacterSet=AL16UTF16 165 | 166 | #----------------------------------------------------------------------------- 167 | # Name : initParams 168 | # Datatype : String 169 | # Description : comma separated list of name=value pairs. Overrides initialization parameters defined in templates 170 | # Default value : None 171 | # Mandatory : NO 172 | #----------------------------------------------------------------------------- 173 | initParams=audit_trail=none,audit_sys_operations=false 174 | 175 | #----------------------------------------------------------------------------- 176 | # Name : listeners 177 | # Datatype : String 178 | # Description : Specifies list of listeners to register the database with. 179 | # By default the database is configured for all the listeners specified in the 180 | # $ORACLE_HOME/network/admin/listener.ora 181 | # Valid values : The list should be comma separated like "listener1,listener2". 182 | # Mandatory : NO 183 | #----------------------------------------------------------------------------- 184 | #listeners=LISTENER 185 | 186 | #----------------------------------------------------------------------------- 187 | # Name : automaticMemoryManagement 188 | # Datatype : Boolean 189 | # Description : flag to indicate Automatic Memory Management is used 190 | # Valid values : TRUE/FALSE 191 | # Default value : TRUE 192 | # Mandatory : NO 193 | #----------------------------------------------------------------------------- 194 | automaticMemoryManagement=FALSE 195 | 196 | #----------------------------------------------------------------------------- 197 | # Name : totalMemory 198 | # Datatype : String 199 | # Description : total memory in MB to allocate to Oracle 200 | # Valid values : 201 | # Default value : 202 | # Mandatory : NO 203 | #----------------------------------------------------------------------------- 204 | totalMemory=2048 -------------------------------------------------------------------------------- /19.3.0/createDB.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # LICENSE UPL 1.0 3 | # 4 | # Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved. 5 | # 6 | # Since: November, 2016 7 | # Author: gerald.venzl@oracle.com 8 | # Description: Creates an Oracle Database based on following parameters: 9 | # $ORACLE_SID: The Oracle SID and CDB name 10 | # $ORACLE_PDB: The PDB name 11 | # $ORACLE_PWD: The Oracle password 12 | # 13 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 14 | # 15 | 16 | set -e 17 | 18 | # Check whether ORACLE_SID is passed on 19 | export ORACLE_SID=${1:-ORCLCDB} 20 | 21 | # Check whether ORACLE_PDB is passed on 22 | export ORACLE_PDB=${2:-ORCLPDB1} 23 | 24 | # Auto generate ORACLE PWD if not passed on 25 | export ORACLE_PWD=${3:-"`openssl rand -base64 8`1"} 26 | echo "ORACLE PASSWORD FOR SYS, SYSTEM AND PDBADMIN: $ORACLE_PWD"; 27 | 28 | # Replace place holders in response file 29 | cp $ORACLE_BASE/$CONFIG_RSP $ORACLE_BASE/dbca.rsp 30 | sed -i -e "s|###ORACLE_SID###|$ORACLE_SID|g" $ORACLE_BASE/dbca.rsp 31 | sed -i -e "s|###ORACLE_PDB###|$ORACLE_PDB|g" $ORACLE_BASE/dbca.rsp 32 | sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" $ORACLE_BASE/dbca.rsp 33 | sed -i -e "s|###ORACLE_BASE###|$ORACLE_BASE|g" $ORACLE_BASE/dbca.rsp 34 | sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" $ORACLE_BASE/dbca.rsp 35 | 36 | # If there is greater than 8 CPUs default back to dbca memory calculations 37 | # dbca will automatically pick 40% of available memory for Oracle DB 38 | # The minimum of 2G is for small environments to guarantee that Oracle has enough memory to function 39 | # However, bigger environment can and should use more of the available memory 40 | # This is due to Github Issue #307 41 | if [ `nproc` -gt 8 ]; then 42 | sed -i -e "s|totalMemory=2048||g" $ORACLE_BASE/dbca.rsp 43 | fi; 44 | 45 | # Create directories: 46 | mkdir -p $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID 47 | mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/archivelog 48 | mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/autobackup 49 | mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/flashback 50 | mkdir -p $ORACLE_BASE/oradata/$ORACLE_SID/fast_recovery_area 51 | mkdir -p $ORACLE_BASE/admin/$ORACLE_SID/adump 52 | 53 | # Add aliases to set up the environment: 54 | cat << EOF >> $HOME/env 55 | alias $(echo $ORACLE_SID | tr [A-Z] [a-z])="export ORACLE_SID=$ORACLE_SID; export ORACLE_HOME=$ORACLE_HOME; export LD_LIBRARY_PATH=$ORACLE_HOME/lib; export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 56 | EOF 57 | 58 | chmod ug+x $HOME/env 59 | 60 | # Create network related config files (sqlnet.ora, tnsnames.ora, listener.ora) 61 | mkdir -p $ORACLE_HOME/network/admin 62 | echo "NAME.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)" > $ORACLE_HOME/network/admin/sqlnet.ora 63 | 64 | # Listener.ora 65 | cat << EOF > $ORACLE_HOME/network/admin/listener.ora 66 | #DEDICATED_THROUGH_BROKER_LISTENER=ON 67 | #DIAG_ADR_ENABLED = off 68 | 69 | SID_LIST_LISTENER = 70 | (SID_LIST = 71 | (SID_DESC = 72 | (GLOBAL_DBNAME = $DB_UNQNAME) 73 | (ORACLE_HOME = $ORACLE_HOME) 74 | (SID_NAME = $DB_UNQNAME) 75 | ) 76 | (SID_DESC = 77 | (GLOBAL_DBNAME = ${ORACLE_SID}_DGMGRL) 78 | (ORACLE_HOME = $ORACLE_HOME) 79 | (SID_NAME = $ORACLE_SID) 80 | ) 81 | ) 82 | EOF 83 | 84 | # TNSnames.ora 85 | echo "$ORACLE_PDB= 86 | (DESCRIPTION = 87 | (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) 88 | (CONNECT_DATA = 89 | (SERVER = DEDICATED) 90 | (SERVICE_NAME = $ORACLE_PDB) 91 | ) 92 | )" > $ORACLE_HOME/network/admin/tnsnames.ora 93 | 94 | # Copy the generated list of TNS entries to the local TNS file: 95 | cat $ORACLE_BASE/scripts/tnsnames.ora >> $ORACLE_HOME/network/admin/tnsnames.ora 96 | 97 | echo " " 98 | echo " Container name is: $CONTAINER_NAME" 99 | echo " Container role is: $ROLE" 100 | echo " Container DG Target is: $DG_TARGET" 101 | echo " DB SID is: $ORACLE_SID" 102 | echo "Database Unique Name is: $DB_UNQNAME" 103 | echo " " 104 | 105 | if [[ "$ROLE" = "PRIMARY" ]]; then 106 | 107 | # ############################################################# 108 | # Prepare a primary database # 109 | # ############################################################# 110 | 111 | # Start LISTENER and run DBCA 112 | lsnrctl start 113 | 114 | dbca -silent -createDatabase -responseFile $ORACLE_BASE/dbca.rsp \ 115 | || cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log \ 116 | || cat /opt/oracle/cfgtoollogs/dbca/$ORACLE_SID.log 117 | 118 | # Remove second control file, fix local_listener, make PDB auto open, enable EM global port 119 | sqlplus / as sysdba << EOF 120 | ALTER SYSTEM SET control_files='$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl' scope=spfile; 121 | ALTER SYSTEM SET local_listener=''; 122 | ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE; 123 | EXEC DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE); 124 | exit; 125 | EOF 126 | 127 | echo "###########################################" 128 | echo " Running modifications to PRIMARY database" 129 | echo "###########################################" 130 | echo " " 131 | 132 | sqlplus / as sysdba << EOF 133 | alter database force logging; 134 | --alter system set db_create_file_dest='/opt/oracle/oradata/$ORACLE_SID' scope=both; 135 | alter system set db_recovery_file_dest_size=5g scope=both; 136 | alter system set db_recovery_file_dest='$ORACLE_BASE/oradata/$ORACLE_SID/fast_recovery_area' scope=both; 137 | alter system set dg_broker_start=true scope=both; 138 | --alter system set open_links=16 scope=spfile; 139 | --alter system set open_links_per_instance=16 scope=spfile; 140 | --alter system set event='10798 trace name context forever, level 7' SCOPE=spfile; 141 | shutdown immediate 142 | startup mount 143 | alter database archivelog; 144 | alter database flashback on; 145 | alter database open; 146 | alter session set container=$ORACLE_PDB; 147 | EOF 148 | 149 | # Remove auditing 150 | # noaudit all; 151 | # noaudit all on default; 152 | 153 | # If this database has a DG Target assigned, create the standby redo logs: 154 | if [[ ! -z "$DG_TARGET" ]]; then 155 | 156 | echo "#############################################" 157 | echo " Preparing $ORACLE_SID standby configuration" 158 | echo "#############################################" 159 | echo " " 160 | 161 | # Add standby logs 162 | sqlplus "/ as sysdba" <> /etc/oratab 243 | ${ORACLE_SID}:${ORACLE_HOME}:N 244 | EOF 245 | 246 | # Create a pfile for startup of the DG replication target: 247 | cat << EOF > $ORACLE_HOME/dbs/initDG.ora 248 | *.db_name='$ORACLE_SID' 249 | EOF 250 | 251 | # Create a password file on the replication target. 252 | $ORACLE_HOME/bin/orapwd file=${ORACLE_BASE}/oradata/dbconfig/${ORACLE_SID}/orapw${ORACLE_SID} force=yes format=12 <<< $(echo $ORACLE_PWD) 253 | ln -s $ORACLE_BASE/oradata/dbconfig/$ORACLE_SID/orapw$ORACLE_SID $ORACLE_HOME/dbs 254 | 255 | # Start the DG target database in nomount 256 | sqlplus / as sysdba <