Skip to content

Instantly share code, notes, and snippets.

@cbj4074
Last active October 3, 2019 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbj4074/d8fee249e5a959d9aced6e6bd5e46959 to your computer and use it in GitHub Desktop.
Save cbj4074/d8fee249e5a959d9aced6e6bd5e46959 to your computer and use it in GitHub Desktop.
Automated Installation and configuration for Oracle Database XE 18
#!/bin/sh
echo 'Installing Oracle Database XE...'
# See: https://www.oracle.com/database/technologies/appdev/xe/quickstart.html
# /vagrant_data is a directory that is mounted from the host filesystem and
# contains the installation binary, "oracle-database-xe-18c-1.0-1.x86_64.rpm".
cd /vagrant_data
yum -y localinstall oracle-database*18c*
# Modify /etc/hosts so that the one line includes the non-FQDN, e.g.: "oracle7";
# absent this measure, Oracle complains, very oddly: [FATAL] [DBT-06103] The port (5,500) is already in use.
sudo sed -i "s/oracle7\.localdomain/oracle7 oracle7.localdomain/" /etc/hosts
# Create oracle user's home directory.
mkdir /home/oracle
chown oracle:dba /home/oracle
chmod 770 /home/oracle
# Create a Bash profile that includes the necessary environment variables.
cat << EOF > /home/oracle/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
export ORACLE_HOME
ORACLE_SID=xe
export ORACLE_SID
PATH=$PATH:/home/oracle/.local/bin:/home/oracle/bin:/opt/oracle/product/18c/dbhomeXE/bin
export PATH
EOF
chown oracle:oinstall /home/oracle/.bash_profile
# Configure XE with silent installation; see: https://docs.oracle.com/en/database/oracle/oracle-database/18/xeinl/performing-silent-installation.html
(echo "secret"; echo "secret";) | /etc/init.d/oracle-xe-18c configure # >> /tmp/xe_logs/XEsilentinstall.log 2>&1
# Configure default users and settings.
echo @/vagrant/scripts-custom/resources/provision | sudo ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE PATH=$PATH:/home/oracle/.local/bin:/home/oracle/bin:/opt/oracle/product/18c/dbhomeXE/bin -H -u oracle /bin/sh -c "/opt/oracle/product/18c/dbhomeXE/bin/sqlplus system/secret@//localhost:1521/XEPDB1"
# Disable and stop the firewall, which will prevent incoming connection if not done:
systemctl stop firewalld
systemctl disable firewalld
systemctl mask --now firewalld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment