├── oracle-linux-kickstart └── pandora-ks.cfg ├── README.md ├── mkoradb.sh └── install_db_software.sh /oracle-linux-kickstart/pandora-ks.cfg: -------------------------------------------------------------------------------- 1 | # Kickstart file for Oracle Linux 6 2 | # Part of https://github.com/simonkrenger/oracle-install-scripts 3 | 4 | install 5 | cdrom 6 | key --skip 7 | lang en_US.UTF-8 8 | keyboard sg 9 | network --onboot yes --device eth0 --bootproto dhcp --hostname pandora.krenger.local 10 | # Root password is "pandora" 11 | rootpw --iscrypted $6$50CrGb6B2kCg.dra$IyKJgAKB4BBEUmaHJ.eAOBGLQ1.6eNCcwT8poG9D9dTboR7SLGnT3i7/o5wT2BrrjkL4gXY5doot1fxrEVVBu. 12 | firewall --disabled 13 | authconfig --enableshadow --passalgo=sha512 14 | selinux --permissive 15 | timezone --utc Europe/Zurich 16 | bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" 17 | reboot --eject 18 | 19 | # Partitioning 20 | zerombr 21 | clearpart --initlabel --all --drives=sda 22 | part /boot --fstype=ext4 --size=500 --ondisk=sda 23 | part pv.008002 --size=1 --grow --ondisk=sda 24 | 25 | volgroup vg_pandora --pesize=8192 pv.008002 26 | logvol swap --name=lv_swap --vgname=vg_pandora --size=4032 27 | logvol / --fstype=ext4 --name=lv_root --vgname=vg_pandora --size=1 --grow 28 | 29 | %packages 30 | # Core packages 31 | @core 32 | @server-policy 33 | @uek3-kernel-repo 34 | 35 | # Additional packages (necessary for Oracle installation) 36 | vim 37 | openssh-server 38 | openssh-clients 39 | wget 40 | unzip 41 | oracle-rdbms-server-12cR1-preinstall 42 | ntpdate 43 | ntp 44 | %end 45 | 46 | %post --log=/root/ks-post.log --interpreter=/bin/bash 47 | 48 | ## Execute preinstall-verify 49 | oracle-rdbms-server-12cR1-preinstall-verify 50 | 51 | ## Change oracle password to "oracle4u" 52 | usermod --password FDbFRad3D1Hg6 oracle 53 | 54 | # Get database installation scripts 55 | wget -P /root/ https://raw.github.com/simonkrenger/oracle-install-scripts/master/install_db_software.sh 56 | wget -P /home/oracle/ https://raw.github.com/simonkrenger/oracle-install-scripts/master/mkoradb.sh 57 | chmod +x /root/install_db_software.sh 58 | chmod +x /home/oracle/mkoradb.sh 59 | 60 | %end 61 | 62 | # Now log in as root (password see above) and execute "./install_db_software.sh" 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simons Oracle Installation Scripts 2 | This repository contains scripts to automate an Oracle database installation. The scripts are self-contained and allow you to perform installation and configuration of a new Oracle database on a vanilla Oracle Linux distribution. The scripts install the software according to the Optimal Flexible Architecture (OFA). 3 | 4 | I mainly use these scripts for my own personal database setups. Currently, the following scripts are available (for detailed description, see below): 5 | * pandora-ks.cfg (Kickstart file) 6 | * install_db_software.sh 7 | * mkoradb.sh 8 | 9 | ## Guide 10 | ### Prerequisites 11 | Before starting, make sure you have the following software available: 12 | * An ISO for Oracle Linux 6 (for example V52218-01.iso) 13 | * Oracle Database 12c Release 1 archives ([linuxamd64_12c_database_1of2.zip, linuxamd64_12c_database_2of2.zip](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-linux-download-2240591.html)) 14 | * Oracle Database 12c Release 1 Grid Infrastructure archives ([linuxamd64_12c_grid_1of2.zip, linuxamd64_12c_grid_2of2.zip](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-linux-download-2240591.html)) 15 | 16 | ### How-to 17 | 1. Create a new virtual machine with 1 disk and at least 4GB of RAM 18 | 2. Start the VM and at the initial prompt, press TAB. Then, append the kick start parameter: 19 | 20 | `ks=https://raw.github.com/simonkrenger/oracle-install-scripts/master/oracle-linux-kickstart/pandora-ks.cfg` 21 | 22 | 3. Your VM will now be automatically set up. The following scripts will be automatically downloaded to the machine. 23 | 4. After the installation finished, copy the 4 install ZIP files (linuxamd64_12c_database_1of2.zip, linuxamd64_12c_database_2of2.zip, linuxamd64_12c_grid_1of2.zip, linuxamd64_12c_grid_2of2.zip) to "/home/oracle/". 24 | 5. As "root", execute "/root/install_db_software.sh" 25 | 6. Then, as "oracle", execute "/home/oracle/mkoradb.sh" 26 | 7. Enjoy your newly installed Oracle database 27 | 28 | ## Script Description 29 | ### pandora-ks.cfg 30 | This is a kickstart file to automatically set up an Oracle Linux virtual machine with all prerequisites to install Oracle Database. 31 | 32 | ### install_db_software.sh 33 | In its current form, this script allows you to automatically install the Oracle 12c Grid Infrastructure (GI) and Oracle 12c Database Software on an Oracle Linux server. For prerequisites, see the header of the script itself. Execute this script as the `root` user. There are a few variables that you can tweak: 34 | 35 | Variable | Description 36 | --- | --- 37 | ORACLE_USER | User that will perform the Oracle installation and be the owner of the Oracle software directory 38 | ORACLE_HOME | Installation directory (defaults to OFA) 39 | ORACLE_BASE | Oracle software base directory (defaults to OFA) 40 | ORACLE_BASE_MOUNTS | Mountpoints that are used for the installation (defaults to OFA) 41 | ORACLE_INVENTORY_LOCATION | Location of the Oracle software inventory 42 | ORACLE_INSTALLFILES_LOCATION | Location of the Oracle software ZIP files 43 | GRID_USER | User that will own the GI software directory 44 | GRID_BASE | GI base directory 45 | GRID_HOME | GI Installation directory 46 | ORACLE_MEMORY_SIZE | Size of the shared memory pool (shmfs) 47 | 48 | ### mkoradb.sh 49 | This script allows you to create a new Oracle 12c database or Oracle 11g database on a server where the Oracle software was already installed. The script will create the necessary folders (according to OFA), prepare all necessary files for database configuration and will then create a new database. Execute this script as the `oracle` user. There are a few variables that you can tweak: 50 | 51 | Variable | Description 52 | --- | --- 53 | ORACLE_SID | Name of the database you want to create (will be the name of the instance as well as the DB_NAME) 54 | ORACLE_HOME | Installation directory (defaults to OFA) 55 | ORACLE_BASE | Oracle software base directory (defaults to OFA) 56 | MY_ORACLE_PASSWD | Password for the SYS and SYSTEM user 57 | MY_MEMORY_TARGET | Value for MEMORY_TARGET 58 | MY_REDO_SIZE | Size of a single redo file 59 | MY_CHARSET | Character set to use for the database (default AL32UTF8) 60 | MY_NCHARSET | National character set to use for the database (default AL16UTF16) 61 | 62 | ## Work in progress 63 | These scripts are far from perfect, I just like to keep them handy for my own reference. Use with caution and at your own risk. 64 | -------------------------------------------------------------------------------- /mkoradb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # DB Creation Script for Oracle 12.1 4 | # Simon Krenger 5 | 6 | # Oracle mountpoints. 7 | # OFA defines the following usages (Array indexes): 8 | # Index 0: Software Mountpoint 9 | # Index 1: Datafiles 10 | # Index 2: Redo Logs 11 | # Index 3: Redo Logs 12 | ORACLE_USER=oracle 13 | ORACLE_MOUNTPOINTS=(/u01 /u02 /u03 /u04) 14 | export ORACLE_BASE=/u01/app/oracle 15 | export ORACLE_HOME=${ORACLE_BASE}/product/12.1.0/db_1 16 | export PATH=$PATH:$ORACLE_HOME/bin 17 | export ORACLE_SID=kdb01 18 | export ORACLE_HOSTNAME=$(hostname) 19 | 20 | MY_ORACLE_PASSWD=tiger 21 | MY_MEMORY_TARGET=800M 22 | MY_CHARSET=AL32UTF8 23 | MY_NCHARSET=AL16UTF16 24 | MY_REDO_SIZE=50M 25 | MY_SYSTEM_SIZE=50M 26 | MY_SYSAUX_SIZE=50M 27 | MY_TEMP_SIZE=50M 28 | MY_UNDO_SIZE=50M 29 | 30 | usage() 31 | { 32 | cat << EOF 33 | usage: $0 [-d "dbname"] [-c "charset"] [-n "ncharset"] [-m "memory_size"] 34 | [-p "password"] [-h] 35 | 36 | Database creation script for Oracle 12.1 37 | 38 | OPTIONS: 39 | -h Show this message 40 | -d Database name (defaults to '$ORACLE_SID') 41 | -c Database Character Set (defaults to '$MY_CHARSET') 42 | -n Database National Character Set (defaults to '$MY_NCHARSET') 43 | -m MEMORY_TARGET (defaults to '$MY_MEMORY_TARGET') 44 | -p Password for SYS and SYSTEM (defaults to '$MY_ORACLE_PASSWD') 45 | EOF 46 | } 47 | 48 | while getopts "hd:c:n:m:p:" OPTION 49 | do 50 | case $OPTION in 51 | h) 52 | usage 53 | exit 1 54 | ;; 55 | d) 56 | export ORACLE_SID=$OPTARG 57 | ;; 58 | c) 59 | MY_CHARSET=$OPTARG 60 | ;; 61 | n) 62 | MY_NCHARSET=$OPTARG 63 | ;; 64 | m) 65 | MY_MEMORY_TARGET=$OPTARG 66 | ;; 67 | p) 68 | MY_ORACLE_PASSWD=$OPTARG 69 | ;; 70 | ?) 71 | usage 72 | exit 1 73 | ;; 74 | esac 75 | done 76 | 77 | ### Script start 78 | echo "== Script start ==" 79 | 80 | if [[ $(whoami) != $ORACLE_USER ]]; then 81 | echo "Not $ORACLE_USER, aborting..." 82 | exit 1 83 | fi 84 | 85 | which nproc 86 | if [ $? -eq 0 ]; then 87 | echo "nproc is available" 88 | else 89 | echo "nproc not found, aborting..." 90 | exit 1 91 | fi 92 | 93 | # Create folders 94 | echo "Creating folders..." 95 | mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/{pfile,scripts,dpdump,logbook} 96 | for mountpoint in ${ORACLE_MOUNTPOINTS[*]} 97 | do 98 | mkdir -p $mountpoint/app/oracle/oradata/${ORACLE_SID} 99 | if [ $? -ne 0 ]; then 100 | echo "Error creating $mountpoint/app/oracle/oradata/${ORACLE_SID}" 101 | exit 1 102 | fi 103 | done 104 | mkdir -p /u02/app/oracle/oradata/${ORACLE_SID}/pdbseed 105 | 106 | # Authentication 107 | echo "Executing ORAPWD..." 108 | $ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=$MY_ORACLE_PASSWD 109 | if [ $? -ne 0 ]; then 110 | echo "Error running ORAPWD to create $ORACLE_HOME/dbs/orapw$ORACLE_SID" 111 | exit 1 112 | fi 113 | 114 | # Prepare files 115 | echo "Preparing files..." 116 | 117 | echo "control_files=('/u01/app/oracle/oradata/"${ORACLE_SID}"/control01.ctl', '/u02/app/oracle/oradata/"${ORACLE_SID}"/control02.ctl', '/u03/app/oracle/oradata/"${ORACLE_SID}"/control03.ctl') 118 | db_name="${ORACLE_SID}" 119 | db_domain='${ORACLE_HOSTNAME}' 120 | memory_max_target="${MY_MEMORY_TARGET}" 121 | memory_target="${MY_MEMORY_TARGET}" 122 | remote_login_passwordfile=EXCLUSIVE 123 | enable_pluggable_database=TRUE" > ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora 124 | 125 | echo "CREATE SPFILE FROM PFILE='"${ORACLE_BASE}"/admin/"${ORACLE_SID}"/pfile/init"${ORACLE_SID}".ora'; 126 | STARTUP NOMOUNT; 127 | EXIT;" > ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/01_spfile.sql 128 | 129 | cat < ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/02_create_database.sql 130 | CREATE DATABASE ${ORACLE_SID} 131 | LOGFILE GROUP 1 ('/u03/app/oracle/oradata/${ORACLE_SID}/redo01a.rdo', 132 | '/u04/app/oracle/oradata/${ORACLE_SID}/redo01b.rdo') SIZE ${MY_REDO_SIZE}, 133 | GROUP 2 ('/u03/app/oracle/oradata/${ORACLE_SID}/redo02a.rdo', 134 | '/u04/app/oracle/oradata/${ORACLE_SID}/redo02b.rdo') SIZE ${MY_REDO_SIZE}, 135 | GROUP 3 ('/u03/app/oracle/oradata/${ORACLE_SID}/redo03a.rdo', 136 | '/u04/app/oracle/oradata/${ORACLE_SID}/redo03b.rdo') SIZE ${MY_REDO_SIZE} 137 | CHARACTER SET ${MY_CHARSET} 138 | NATIONAL CHARACTER SET ${MY_NCHARSET} 139 | EXTENT MANAGEMENT LOCAL 140 | DATAFILE '/u02/app/oracle/oradata/${ORACLE_SID}/system01.dbf' 141 | SIZE ${MY_SYSTEM_SIZE} AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED 142 | SYSAUX DATAFILE '/u02/app/oracle/oradata/${ORACLE_SID}/sysaux01.dbf' 143 | SIZE ${MY_SYSAUX_SIZE} AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED 144 | DEFAULT TEMPORARY TABLESPACE temp TEMPFILE '/u02/app/oracle/oradata/${ORACLE_SID}/temp01.dbf' 145 | SIZE ${MY_TEMP_SIZE} AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED 146 | UNDO TABLESPACE undo DATAFILE '/u02/app/oracle/oradata/${ORACLE_SID}/undo01.dbf' 147 | SIZE ${MY_UNDO_SIZE} AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED 148 | ENABLE PLUGGABLE DATABASE 149 | SEED 150 | FILE_NAME_CONVERT = ('/u02/app/oracle/oradata/${ORACLE_SID}/', '/u02/app/oracle/oradata/${ORACLE_SID}/pdbseed/') 151 | SYSTEM DATAFILES SIZE 100M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED 152 | SYSAUX DATAFILES SIZE 100M 153 | USER_DATA TABLESPACE users DATAFILE '/u02/app/oracle/oradata/${ORACLE_SID}/pdbseed/users01.dbf' 154 | SIZE 100M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED; 155 | 156 | CREATE TABLESPACE users DATAFILE '/u02/app/oracle/oradata/${ORACLE_SID}/users01.dbf' 157 | SIZE 100M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED; 158 | EXIT; 159 | EOF 160 | 161 | cat < ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/03_sys_users.sql 162 | ALTER USER SYS IDENTIFIED BY "${MY_ORACLE_PASSWD}"; 163 | ALTER USER SYSTEM IDENTIFIED BY "${MY_ORACLE_PASSWD}"; 164 | EXIT; 165 | EOF 166 | 167 | cat < ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/04_start_pdbs.sql 168 | connect / as sysdba 169 | create or replace trigger sys.after_startup 170 | after startup on database 171 | begin 172 | execute immediate 'alter pluggable database all open'; 173 | end after_startup; 174 | / 175 | EOF 176 | 177 | echo "SHUTDOWN IMMEDIATE; 178 | STARTUP; 179 | EXIT;" > ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/99_restart_db.sql 180 | 181 | echo "Files prepared." 182 | 183 | # Execute 184 | echo "Now executing SQL*Plus scripts..." 185 | echo "NOTE: This might take some time." 186 | 187 | for sql in ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/01_spfile.sql \ 188 | ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/02_create_database.sql \ 189 | ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/03_sys_users.sql \ 190 | ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/04_start_pdbs.sql 191 | do 192 | echo "$sql" 193 | $ORACLE_HOME/bin/sqlplus / as sysdba @$sql 194 | done 195 | 196 | echo "Executed SQL*Plus scripts, now creating the data dictionary." 197 | echo "NOTE: This may take some time." 198 | 199 | PERL5LIB=$ORACLE_HOME/rdbms/admin:$PERL5LIB; export PERL5LIB 200 | perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l ${ORACLE_BASE}/admin/${ORACLE_SID}/logbook -b catalog $ORACLE_HOME/rdbms/admin/catalog.sql; 201 | perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l ${ORACLE_BASE}/admin/${ORACLE_SID}/logbook -b catproc $ORACLE_HOME/rdbms/admin/catproc.sql; 202 | perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l ${ORACLE_BASE}/admin/${ORACLE_SID}/logbook -b pupbld -u SYSTEM/${MY_ORACLE_PASSWD} $ORACLE_HOME/sqlplus/admin/pupbld.sql; 203 | 204 | echo "Finished creating the data dictionary, now recompiling invalid objects..." 205 | 206 | perl $ORACLE_HOME/rdbms/admin/catcon.pl -n 1 -l ${ORACLE_BASE}/admin/${ORACLE_SID}/logbook -b utlrp $ORACLE_HOME/rdbms/admin/utlrp.sql 207 | 208 | echo "Alright, finished everything so far." 209 | echo "Now restarting the database." 210 | $ORACLE_HOME/bin/sqlplus / as sysdba @${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/99_restart_db.sql 211 | 212 | echo "ALTER SYSTEM REGISTER; 213 | EXIT;" > ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/98_system_register.sql 214 | $ORACLE_HOME/bin/sqlplus / as sysdba @${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/98_system_register.sql 215 | 216 | # SRVCTL and ORATAB 217 | echo "Now calling SRVCTL..." 218 | $ORACLE_HOME/bin/srvctl add database -db ${ORACLE_SID} -oraclehome $ORACLE_HOME 219 | echo "${ORACLE_SID}:${ORACLE_HOME}:Y" >> /etc/oratab 220 | 221 | # Cleanup 222 | rm ${ORACLE_BASE}/admin/${ORACLE_SID}/scripts/03_sys_users.sql 223 | 224 | unset MY_ORACLE_PASSWD 225 | 226 | echo DB Setup Finished! 227 | exit 0 228 | -------------------------------------------------------------------------------- /install_db_software.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # DB Software Installation script 4 | # Installs Oracle Grid Infrastructure and Database software 5 | # 6 | # Prerequisites: 7 | # - Installed package "oracle-rdbms-server-12cR1-preinstall.rpm" 8 | # - Executed oracle-rdbms-server-12cR1-preinstall-verify 9 | # - Copied GI and DB software (the following archives) to $ORACLE_INSTALLFILES_LOCATION 10 | # - linuxamd64_*_database_1of2.zip 11 | # - linuxamd64_*_database_2of2.zip 12 | # - linuxamd64_*_grid_1of2.zip 13 | # - linuxamd64_*_grid_2of2.zip 14 | # - (Optional) # passwd oracle 15 | # - Mountpoints $ORACLE_MOUNTPOINTS exist 16 | # 17 | # Simon Krenger 18 | 19 | ORACLE_MOUNTPOINTS=(/u01 /u02 /u03 /u04) 20 | 21 | ORACLE_USER=oracle 22 | ORACLE_BASE=${ORACLE_MOUNTPOINTS[0]}/app/oracle 23 | ORACLE_HOME=${ORACLE_BASE}/product/12.1.0/db_1 24 | ORACLE_INVENTORY_LOCATION=/etc/oraInventory 25 | ORACLE_INSTALLFILES_LOCATION=/home/oracle 26 | 27 | GRID_USER=oracle 28 | GRID_BASE=${ORACLE_MOUNTPOINTS[0]}/app/grid 29 | GRID_HOME=${GRID_BASE}/product/12.1.0/grid_1 30 | 31 | ORACLE_MEMORY_SIZE=2048M 32 | 33 | unset LANG 34 | 35 | ### Script start 36 | 37 | usage() 38 | { 39 | cat << EOF 40 | usage: $0 [-h] [-u ORACLE_USER] [-m ORACLE_MEMORY_SIZE] [-i INSTALLFILES_DIR] 41 | 42 | This script is used to install Oracle Grid Infrastructure and the Oracle 43 | database software. The default settings will install the database software 44 | according to the OFA standard. 45 | 46 | OPTIONS: 47 | -h Show this message 48 | -i Folder that contains the installation ZIP files. Defaults to "$ORACLE_INSTALLFILES_LOCATION" 49 | -u User that owns the Oracle software installation. Defaults to "$ORACLE_USER" 50 | -m Aggregate shared memory size for all databases on this machine. 51 | Defaults to $ORACLE_MEMORY_SIZE. 52 | EOF 53 | } 54 | 55 | # Parse arguments 56 | while getopts "hi:u:m:" OPTION 57 | do 58 | case $OPTION in 59 | h) 60 | usage 61 | exit 1 62 | ;; 63 | i) 64 | ORACLE_INSTALLFILES_LOCATION=$OPTARG 65 | ;; 66 | u) 67 | ORACLE_USER=$OPTARG 68 | ;; 69 | m) 70 | ORACLE_MEMORY_SIZE=$OPTARG 71 | ;; 72 | ?) 73 | usage 74 | exit 75 | ;; 76 | esac 77 | done 78 | 79 | # Check if run as root 80 | if [[ $EUID -ne 0 ]]; then 81 | echo "This script must be run as root" 1>&2 82 | exit 1 83 | fi 84 | 85 | id $ORACLE_USER 2>/dev/null 86 | if [ $? -eq 0 ]; then 87 | echo "User $ORACLE_USER found, proceeding..." 88 | else 89 | echo "User $ORACLE_USER not found, aborting..." 90 | exit 1 91 | fi 92 | 93 | # Check necessary programs installed 94 | which unzip 95 | if [ $? -eq 0 ]; then 96 | echo "unzip is installed" 97 | else 98 | echo "unzip not found, aborting..." 99 | exit 1 100 | fi 101 | 102 | which oracle-rdbms-server-12cR1-preinstall-verify 103 | if [ $? -eq 0 ]; then 104 | echo "oracle-rdbms-server-12cR1-preinstall-verify is installed" 105 | else 106 | echo "oracle-rdbms-server-12cR1-preinstall-verify not found, aborting..." 107 | exit 1 108 | fi 109 | 110 | which ntpd 111 | if [ $? -eq 0 ]; then 112 | echo "ntpd is installed" 113 | else 114 | echo "ntpd not found, aborting..." 115 | exit 1 116 | fi 117 | 118 | 119 | which ntpdate 120 | if [ $? -eq 0 ]; then 121 | echo "ntpdate is installed" 122 | else 123 | echo "ntpdate not found, aborting..." 124 | exit 1 125 | fi 126 | 127 | if [ -d "$ORACLE_INSTALLFILES_LOCATION" ]; then 128 | echo "$ORACLE_INSTALLFILES_LOCATION exists" 129 | if [ `ls -l $ORACLE_INSTALLFILES_LOCATION/linuxamd64_*of2.zip | wc -l` -eq 4 ]; then 130 | echo "Correct amount of ZIPs found, proceeding..." 131 | else 132 | echo "No or wrong installation ZIP files found." 133 | echo "Please make sure linuxamd64_*_database_1of2.zip, linuxamd64_*_database_2of2.zip, linuxamd64_*_grid_1of2.zip, linuxamd64_*_grid_2of2.zip are located in $ORACLE_INSTALLFILES_LOCATION" 134 | exit 1 135 | fi 136 | else 137 | echo "$ORACLE_INSTALLFILES_LOCATION does not exist, aborting..." 138 | exit 1 139 | fi 140 | 141 | 142 | # Prepare filesystem 143 | 144 | # Make sure the mountpoints exist 145 | # This command will create them as folders if necessary 146 | for mountpoint in ${ORACLE_MOUNTPOINTS[*]} 147 | do 148 | mkdir -p $mountpoint 149 | chown -R ${ORACLE_USER}:oinstall $mountpoint 150 | done 151 | 152 | mkdir -p ${ORACLE_HOME} 153 | mkdir -p ${GRID_HOME} 154 | mkdir -p ${ORACLE_INVENTORY_LOCATION} 155 | chown -R ${ORACLE_USER}:oinstall ${ORACLE_BASE} 156 | chown -R ${ORACLE_USER}:oinstall ${GRID_BASE} 157 | chown -R ${ORACLE_USER}:oinstall ${ORACLE_INVENTORY_LOCATION} 158 | 159 | # Prepare groups and users 160 | groupadd asmadmin 161 | groupadd asmoper 162 | groupadd dgdba 163 | groupadd bckpdba 164 | groupadd kmdba 165 | usermod -a -G dba,asmoper,asmadmin,dgdba,bckpdba,kmdba ${ORACLE_USER} 166 | 167 | 168 | # Modify NTPD 169 | service ntpd stop 170 | echo 'OPTIONS="-u ntp:ntp -x -p /var/run/ntpd.pid"' > /etc/sysconfig/ntpd 171 | ntpdate pool.ntp.org 172 | service ntpd start 173 | 174 | # Modify /etc/hosts 175 | cp /etc/hosts /etc/hosts.original 176 | echo "127.0.0.1 `hostname -s` `hostname`" >> /etc/hosts 177 | 178 | # Modify /etc/fstab 179 | mv /etc/fstab /etc/fstab.original 180 | cat /etc/fstab.original | awk '$3~"^tmpfs$"{$4="size='$ORACLE_MEMORY_SIZE'"}1' OFS="\t" > /etc/fstab 181 | mount -t tmpfs shmfs -o size=$ORACLE_MEMORY_SIZE /dev/shm 182 | 183 | # Grid infrastructure 184 | cd ${ORACLE_INSTALLFILES_LOCATION} 185 | unzip ${ORACLE_INSTALLFILES_LOCATION}/linuxamd64_*_grid_1of2.zip 186 | unzip ${ORACLE_INSTALLFILES_LOCATION}/linuxamd64_*_grid_2of2.zip 187 | chown -R ${ORACLE_USER}:oinstall ${ORACLE_INSTALLFILES_LOCATION}/grid 188 | #TODO: Check if everything worked as expected and only remove if no errors occured 189 | 190 | # Installation of Grid Infrastructure 191 | cd ${ORACLE_INSTALLFILES_LOCATION}/grid 192 | echo "oracle.install.responseFileVersion=/oracle/install/rspfmt_crsinstall_response_schema_v12.1.0 193 | ORACLE_HOSTNAME="`hostname`" 194 | INVENTORY_LOCATION="${ORACLE_INVENTORY_LOCATION}" 195 | SELECTED_LANGUAGES=en 196 | oracle.install.option=CRS_SWONLY 197 | ORACLE_BASE="${GRID_BASE}" 198 | ORACLE_HOME="${GRID_HOME}" 199 | oracle.install.asm.OSDBA=oinstall 200 | oracle.install.asm.OSOPER=asmoper 201 | oracle.install.asm.OSASM=asmadmin 202 | oracle.installer.autoupdates.option=SKIP_UPDATES" > ${ORACLE_INSTALLFILES_LOCATION}/grid_install.rsp 203 | 204 | echo "Now installing Grid Infrastructure. This may take a while..." 205 | su ${ORACLE_USER} -c "cd ${ORACLE_INSTALLFILES_LOCATION}/grid; ./runInstaller -silent -waitForCompletion -responseFile ${ORACLE_INSTALLFILES_LOCATION}/grid_install.rsp -ignoreSysPrereqs" 206 | 207 | # Register OraInventory 208 | ${ORACLE_INVENTORY_LOCATION}/orainstRoot.sh 209 | 210 | # Configure GI (run this as root) 211 | ${GRID_HOME}/root.sh 212 | ${GRID_HOME}/perl/bin/perl -I${GRID_HOME}/perl/lib -I${GRID_HOME}/crs/install ${GRID_HOME}/crs/install/roothas.pl 213 | 214 | echo "Finished installing Grid Infrastructure." 215 | 216 | # Installation of Database Software 217 | 218 | # Oracle database software 219 | cd ${ORACLE_INSTALLFILES_LOCATION} 220 | unzip ${ORACLE_INSTALLFILES_LOCATION}/linuxamd64_*_database_1of2.zip 221 | unzip ${ORACLE_INSTALLFILES_LOCATION}/linuxamd64_*_database_2of2.zip 222 | chown -R ${ORACLE_USER}:oinstall ${ORACLE_INSTALLFILES_LOCATION}/database 223 | #TODO: Check if everything worked as expected and only remove if no errors occured 224 | 225 | 226 | cd ${ORACLE_INSTALLFILES_LOCATION}/database 227 | rm -rf ${ORACLE_INSTALLFILES_LOCATION}/grid 228 | 229 | echo "oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v12.1.0 230 | oracle.install.option=INSTALL_DB_SWONLY 231 | ORACLE_HOSTNAME="`hostname`" 232 | UNIX_GROUP_NAME=oinstall 233 | INVENTORY_LOCATION="${ORACLE_INVENTORY_LOCATION}" 234 | SELECTED_LANGUAGES=en 235 | ORACLE_HOME="${ORACLE_HOME}" 236 | ORACLE_BASE="${ORACLE_BASE}" 237 | oracle.install.db.InstallEdition=EE 238 | oracle.install.db.DBA_GROUP=dba 239 | oracle.install.db.BACKUPDBA_GROUP=bckpdba 240 | oracle.install.db.DGDBA_GROUP=dgdba 241 | oracle.install.db.KMDBA_GROUP=kmdba 242 | SECURITY_UPDATES_VIA_MYORACLESUPPORT=false 243 | DECLINE_SECURITY_UPDATES=true 244 | oracle.installer.autoupdates.option=SKIP_UPDATES" > ${ORACLE_INSTALLFILES_LOCATION}/db_install.rsp 245 | 246 | echo "Now installing Database software. This may take a while..." 247 | su ${ORACLE_USER} -c "cd ${ORACLE_INSTALLFILES_LOCATION}/database; ./runInstaller -silent -waitForCompletion -responseFile ${ORACLE_INSTALLFILES_LOCATION}/db_install.rsp" 248 | 249 | # Configure DB software 250 | ${ORACLE_HOME}/root.sh 251 | 252 | # Update .bash_profile of oracle user 253 | su ${ORACLE_USER} -c "echo ' 254 | #Oracle config 255 | export ORACLE_HOME=${ORACLE_HOME} 256 | export PATH=$PATH:\$ORACLE_HOME/bin' >> ~/.bash_profile" 257 | 258 | # Create an Oracle listener in the GRID_HOME 259 | echo "Adding listener..." 260 | 261 | echo "[GENERAL] 262 | RESPONSEFILE_VERSION=\"12.1\" 263 | CREATE_TYPE=\"CUSTOM\" 264 | SHOW_GUI=false 265 | [oracle.net.ca] 266 | INSTALLED_COMPONENTS={\"server\",\"net8\",\"javavm\"} 267 | INSTALL_TYPE=\"\"typical\"\" 268 | LISTENER_NUMBER=1 269 | LISTENER_NAMES={\"LISTENER\"} 270 | LISTENER_PROTOCOLS={\"TCP;1521\"} 271 | LISTENER_START=\"\"LISTENER\"\" 272 | NAMING_METHODS={\"TNSNAMES\",\"ONAMES\",\"HOSTNAME\"} 273 | NSN_NUMBER=1 274 | NSN_NAMES={\"EXTPROC_CONNECTION_DATA\"} 275 | NSN_SERVICE={\"PLSExtProc\"} 276 | NSN_PROTOCOLS={\"TCP;HOSTNAME;1521\"}" > ${ORACLE_INSTALLFILES_LOCATION}/netca.rsp 277 | 278 | su ${ORACLE_USER} -c "${GRID_HOME}/bin/netca -silent -responseFile ${ORACLE_INSTALLFILES_LOCATION}/netca.rsp" 279 | echo "Listener configured, now adding to CRS..." 280 | su ${ORACLE_USER} -c "${GRID_HOME}/bin/srvctl add listener -endpoints TCP:1521 -oraclehome ${GRID_HOME}" 281 | su ${ORACLE_USER} -c "${GRID_HOME}/bin/srvctl start listener" 282 | 283 | # Cleanup 284 | cd 285 | rm -rf ${ORACLE_INSTALLFILES_LOCATION}/database 286 | 287 | echo "Installation finished. Check the logfiles for errors" 288 | 289 | --------------------------------------------------------------------------------