This Vagrant project provisions Oracle Database automatically, using Vagrant, an Oracle Linux 7 box and a shell script.
- Read the prerequisites in the top level README to set up Vagrant with either VirtualBox or KVM.
- The vagrant-env plugin is optional but makes configuration much easier
-
Clone this repository
git clone https://github.com/oracle/vagrant-projects
-
Change into the
vagrant-projects/OracleDatabase/12.1.0.2
directory -
Download the installation zip files from OTN into this directory - first time only: http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
The zip files for Enterprise Edition (EE) are
linuxamd64_12102_database_1of2.zip
andlinuxamd64_12102_database_2of2.zip
. The zip files for Standard Edition 2 (SE2) arelinuxamd64_12102_database_se2_1of2.zip
andlinuxamd64_12102_database_se2_2of2.zip
. Make sure to download the correct files for the edition you want to use. -
Run
vagrant up
- The first time you run this it will provision everything and may take a while. Ensure you have a good internet connection as the scripts will update the VM to the latest via
yum
. - The installation can be customized, if desired (see Configuration).
- The first time you run this it will provision everything and may take a while. Ensure you have a good internet connection as the scripts will update the VM to the latest via
-
Connect to the database (see Connecting to Oracle)
-
You can shut down the VM via the usual
vagrant halt
and then start it up again viavagrant up
The default database connection parameters are:
- Hostname:
localhost
- Port:
1521
- SID:
ORCLCDB
- PDB:
ORCLPDB1
- EM Express port:
5500
- Database passwords are auto-generated and printed on install
These parameters can be customized, if desired (see Configuration).
You can reset the password of the Oracle database accounts (SYS, SYSTEM and PDBADMIN only) by switching to the oracle user (sudo su - oracle
), then executing /home/oracle/setPassword.sh <Your new password>
.
You can have the installer run scripts after setup by putting them in the userscripts
directory below the directory where you have this file checked out. Any shell (.sh
) or SQL (.sql
) scripts you put in the userscripts
directory will be executed by the installer after the database is set up and started. Only shell and SQL scripts will be executed; all other files will be ignored. These scripts are completely optional.
Shell scripts will be executed as root. SQL scripts will be executed as SYS. SQL scripts will run against the CDB, not the PDB, unless you include an ALTER SESSION SET CONTAINER = <pdbname>
statement in the script.
To run scripts in a specific order, prefix the file names with a number, e.g., 01_shellscript.sh
, 02_tablespaces.sql
, 03_shellscript2.sh
, etc.
The Vagrantfile
can be used as-is, without any additional configuration. However, there are several parameters you can set to tailor the installation to your needs.
There are three ways to set parameters:
- Update the
Vagrantfile
. This is straightforward; the downside is that you will lose changes when you update this repository. - Use environment variables. It might be difficult to remember the parameters used when the VM was instantiated.
- Use the
.env
/.env.local
files (requires vagrant-env plugin). You can configure your installation by editing the.env
file, but.env
will be overwritten on updates, so it's better to make a copy of.env
called.env.local
, then make changes in.env.local
. The.env.local
file won't be overwritten when you update this repository and it won't mark your Git tree as changed (you won't accidentally commit your local configuration!).
Parameters are considered in the following order (first one wins):
- Environment variables
.env.local
(if it exists and the vagrant-env plugin is installed).env
(if the vagrant-env plugin is installed)Vagrantfile
definitions
VM_NAME
(default:oracle-12102-vagrant
): VM name.VM_MEMORY
(default:2048
): memory for the VM (in MB, 2048 MB = 2 GB).VM_SYSTEM_TIMEZONE
(default: host time zone (if possible)): VM time zone.- The system time zone is used by the database for SYSDATE/SYSTIMESTAMP.
- The guest time zone will be set to the host time zone when the host time zone is a full hour offset from GMT.
- When the host time zone isn't a full hour offset from GMT (e.g., in India and parts of Australia), the guest time zone will be set to UTC.
- You can specify a different time zone using a time zone name (e.g., "America/Los_Angeles") or an offset from GMT (e.g., "Etc/GMT-2"). For more information on specifying time zones, see List of tz database time zones.
VM_ORACLE_BASE
(default:/opt/oracle/
): Oracle base directory.VM_ORACLE_HOME
(default:/opt/oracle/product/12.1.0.2/dbhome_1
): Oracle home directory.VM_ORACLE_SID
(default:ORCLCDB
): Oracle SID.VM_ORACLE_PDB
(default:ORCLPDB1
): PDB name.VM_ORACLE_CHARACTERSET
(default:AL32UTF8
): database character set.VM_ORACLE_EDITION
(default:EE
): Oracle Database edition. EitherEE
for Enterprise Edition orSE2
for Standard Edition 2.VM_LISTENER_PORT
(default:1521
): Listener port.VM_EM_EXPRESS_PORT
(default:5500
): EM Express port.VM_ORACLE_PWD
(default: automatically generated): Oracle Database password for the SYS, SYSTEM and PDBADMIN accounts.
When installed, this Vagrant project will make use of the following third party Vagrant plugins:
- vagrant-env: loads environment variables from .env files;
- vagrant-proxyconf: set proxies in the guest VM if you need to access the Internet through a proxy. See the plugin documentation for configuration.
To install Vagrant plugins run:
vagrant plugin install <name>...
- If you need to, you can connect to the virtual machine via
vagrant ssh
. - You can
sudo su - oracle
to switch to the oracle user. - On the guest OS, the directory
/vagrant
is a shared folder and maps to wherever you have this file checked out.