Skip to content

Commit d49212c

Browse files
authored
Add OracleDatabase/21.3.0-XE project (#412)
Adds an OracleDatabase/21.3.0-XE project, based on the OracleDatabase/18.4.0-XE project. Notable changes from the 18.4.0-XE project: - Use Oracle Linux 8 instead of Oracle Linux 7 - Increase default VM memory to 2300 MB (approximately 2.25 GB) to avoid memory warning during installation - 21c Oracle homes are read-only by default, so the tnsnames.ora file is in ORACLE_BASE_HOME/network/admin, instead of ORACLE_HOME/network/admin - install.sh script: - Address all ShellCheck warnings - Remove unnecessary use of sudo (script runs as root) - Ensure that permissions on setPassword.sh are set correctly - Minor formatting fixes (trailing spaces, single vs. double quotes, etc.) Tested with both VirtualBox and libvirt/KVM. Closes #380. Signed-off-by: Paul Neumann <[email protected]>
1 parent 391e94e commit d49212c

File tree

10 files changed

+530
-0
lines changed

10 files changed

+530
-0
lines changed

OracleDatabase/21.3.0-XE/.env

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Oracle Database 21.3.0 Express Edition configuration file
2+
#
3+
# Requires vagrant-env plugin
4+
#
5+
# This file will be overwritten on updates, so it is recommended to make
6+
# a copy of this file called .env.local, then make changes in .env.local.
7+
#
8+
# To change a parameter, uncomment it and set it to the desired value.
9+
# All commented parameters will retain their default values.
10+
11+
# VM name
12+
# VM_NAME='oracle21c-xe-vagrant'
13+
14+
# Memory for the VM (in MB, 2300 MB is ~2.25 GB)
15+
# VM_MEMORY=2300
16+
17+
# VM time zone
18+
# If not specified, will be set to match host time zone (if possible)
19+
# Can use time zone name (e.g., 'America/Los_Angeles')
20+
# or an offset from GMT (e.g., 'Etc/GMT-2')
21+
# VM_SYSTEM_TIMEZONE=
22+
23+
# Save database installer RPM file for reuse when VM is rebuilt
24+
# VM_KEEP_DB_INSTALLER=false
25+
26+
# Database character set
27+
# VM_ORACLE_CHARACTERSET='AL32UTF8'
28+
29+
# Listener port
30+
# VM_LISTENER_PORT=1521
31+
32+
# EM Express port
33+
# VM_EM_EXPRESS_PORT=5500
34+
35+
# Oracle Database password for SYS, SYSTEM and PDBADMIN accounts
36+
# If left blank, the password will be generated automatically
37+
# VM_ORACLE_PWD=
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.sh text eol=lf
2+
*.tmpl text eol=lf

OracleDatabase/21.3.0-XE/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.rpm
2+
.env.local*

OracleDatabase/21.3.0-XE/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# oracle21c-xe-vagrant
2+
3+
This Vagrant project provisions Oracle Database automatically, using Vagrant, an Oracle Linux 8 box and a shell script.
4+
5+
## Prerequisites
6+
7+
1. Read the [prerequisites in the top level README](../../README.md#prerequisites) to set up Vagrant with either VirtualBox or KVM.
8+
2. The [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is optional but
9+
makes configuration much easier
10+
11+
## Getting started
12+
13+
1. Clone this repository `git clone https://github.com/oracle/vagrant-projects`
14+
2. Change into the `vagrant-projects/OracleDatabase/21.3.0-XE` directory
15+
3. Run `vagrant up`
16+
1. 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 `dnf`.
17+
2. The installation can be customized, if desired (see [Configuration](#configuration)).
18+
4. Connect to the database (see [Connecting to Oracle](#connecting-to-oracle))
19+
5. You can shut down the VM via the usual `vagrant halt` and then start it up again via `vagrant up`
20+
21+
## Connecting to Oracle
22+
23+
The default database connection parameters are:
24+
25+
* Hostname: `localhost`
26+
* Port: `1521`
27+
* SID: `XE`
28+
* PDB: `XEPDB1`
29+
* EM Express port: `5500`
30+
* Database passwords are auto-generated and printed on install
31+
32+
These parameters can be customized, if desired (see [Configuration](#configuration)).
33+
34+
## Resetting password
35+
36+
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>`.
37+
38+
## Running scripts after setup
39+
40+
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.
41+
42+
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 = XEPDB1` statement in the script.
43+
44+
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.
45+
46+
## Configuration
47+
48+
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.
49+
50+
### How to configure
51+
52+
There are three ways to set parameters:
53+
54+
1. Update the `Vagrantfile`. This is straightforward; the downside is that you will lose changes when you update this repository.
55+
2. Use environment variables. It might be difficult to remember the parameters used when the VM was instantiated.
56+
3. Use the `.env`/`.env.local` files (requires
57+
[vagrant-env](https://github.com/gosuri/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!).
58+
59+
Parameters are considered in the following order (first one wins):
60+
61+
1. Environment variables
62+
2. `.env.local` (if it exists and the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
63+
3. `.env` (if the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
64+
4. `Vagrantfile` definitions
65+
66+
### VM parameters
67+
68+
* `VM_NAME` (default: `oracle21c-xe-vagrant`): VM name.
69+
* `VM_MEMORY` (default: `2300`): memory for the VM (in MB, 2300 MB is ~2.25 GB).
70+
* `VM_SYSTEM_TIMEZONE` (default: host time zone (if possible)): VM time zone.
71+
* The system time zone is used by the database for SYSDATE/SYSTIMESTAMP.
72+
* The guest time zone will be set to the host time zone when the host time zone is a full hour offset from GMT.
73+
* 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.
74+
* 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](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
75+
76+
### Oracle Database parameters
77+
78+
* `VM_KEEP_DB_INSTALLER` (default: `false`): save database installer RPM file for reuse when VM is rebuilt.
79+
* `VM_ORACLE_CHARACTERSET` (default: `AL32UTF8`): database character set.
80+
* `VM_LISTENER_PORT` (default: `1521`): Listener port.
81+
* `VM_EM_EXPRESS_PORT` (default: `5500`): EM Express port.
82+
* `VM_ORACLE_PWD` (default: automatically generated): Oracle Database password for the SYS, SYSTEM and PDBADMIN accounts.
83+
84+
## Optional plugins
85+
86+
When installed, this Vagrant project will make use of the following third party Vagrant plugins:
87+
88+
* [vagrant-env](https://github.com/gosuri/vagrant-env): loads environment
89+
variables from .env files;
90+
* [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf): set
91+
proxies in the guest VM if you need to access the Internet through a proxy. See
92+
the plugin documentation for configuration.
93+
94+
To install Vagrant plugins run:
95+
96+
```shell
97+
vagrant plugin install <name>...
98+
```
99+
100+
## Other info
101+
102+
* If you need to, you can connect to the virtual machine via `vagrant ssh`.
103+
* You can `sudo su - oracle` to switch to the oracle user.
104+
* On the guest OS, the directory `/vagrant` is a shared folder and maps to wherever you have this file checked out.

OracleDatabase/21.3.0-XE/Vagrantfile

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
#
2+
# LICENSE UPL 1.0
3+
#
4+
# Copyright (c) 1982-2018 Oracle and/or its affiliates. All rights reserved.
5+
#
6+
# Since: July, 2018
7+
8+
# Description: Creates an Oracle database Vagrant virtual machine.
9+
# Optional plugins:
10+
# vagrant-env (use .env files for configuration)
11+
# vagrant-proxyconf (if you don't have direct access to the Internet)
12+
# see https://github.com/tmatilai/vagrant-proxyconf for configuration
13+
#
14+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
15+
#
16+
17+
# -*- mode: ruby -*-
18+
# vi: set ft=ruby :
19+
20+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
21+
VAGRANTFILE_API_VERSION = "2"
22+
23+
# Box metadata location and box name
24+
BOX_URL = "https://oracle.github.io/vagrant-projects/boxes"
25+
BOX_NAME = "oraclelinux/8"
26+
27+
# UI object for printing information
28+
ui = Vagrant::UI::Prefixed.new(Vagrant::UI::Colored.new, "vagrant")
29+
30+
# Define constants
31+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
32+
# Use vagrant-env plugin if available
33+
if Vagrant.has_plugin?("vagrant-env")
34+
config.env.load(".env.local", ".env") # enable the plugin
35+
end
36+
37+
# VM name
38+
VM_NAME = default_s('VM_NAME', 'oracle21c-xe-vagrant')
39+
40+
# Memory for the VM (in MB, 2300 MB is ~2.25 GB)
41+
VM_MEMORY = default_i('VM_MEMORY', 2300)
42+
43+
# VM time zone
44+
# If not specified, will be set to match host time zone (if possible)
45+
VM_SYSTEM_TIMEZONE = default_s('VM_SYSTEM_TIMEZONE', host_tz)
46+
47+
# Save database installer RPM file for reuse when VM is rebuilt
48+
VM_KEEP_DB_INSTALLER = default_b('VM_KEEP_DB_INSTALLER', false)
49+
50+
# Database character set
51+
VM_ORACLE_CHARACTERSET = default_s('VM_ORACLE_CHARACTERSET', 'AL32UTF8')
52+
53+
# Listener port
54+
VM_LISTENER_PORT = default_i('VM_LISTENER_PORT', 1521)
55+
56+
# EM Express port
57+
VM_EM_EXPRESS_PORT = default_i('VM_EM_EXPRESS_PORT', 5500)
58+
59+
# Oracle Database password for SYS, SYSTEM and PDBADMIN accounts
60+
# If left blank, the password will be generated automatically
61+
VM_ORACLE_PWD = default_s('VM_ORACLE_PWD', '')
62+
end
63+
64+
# Convenience methods
65+
def default_s(key, default)
66+
ENV[key] && ! ENV[key].empty? ? ENV[key] : default
67+
end
68+
69+
def default_i(key, default)
70+
default_s(key, default).to_i
71+
end
72+
73+
def default_b(key, default)
74+
default_s(key, default).to_s.downcase == "true"
75+
end
76+
77+
def host_tz
78+
# get host time zone for setting VM time zone
79+
# if host time zone isn't an integer hour offset from GMT, fall back to UTC
80+
offset_sec = Time.now.gmt_offset
81+
if (offset_sec % (60 * 60)) == 0
82+
offset_hr = ((offset_sec / 60) / 60)
83+
timezone_suffix = offset_hr >= 0 ? "-#{offset_hr.to_s}" : "+#{(-offset_hr).to_s}"
84+
'Etc/GMT' + timezone_suffix
85+
else
86+
'UTC'
87+
end
88+
end
89+
90+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
91+
config.vm.box = BOX_NAME
92+
config.vm.box_url = "#{BOX_URL}/#{BOX_NAME}.json"
93+
config.vm.define VM_NAME
94+
95+
# Provider-specific configuration
96+
config.vm.provider "virtualbox" do |v|
97+
v.memory = VM_MEMORY
98+
v.name = VM_NAME
99+
end
100+
config.vm.provider :libvirt do |v|
101+
v.memory = VM_MEMORY
102+
end
103+
104+
# add proxy configuration from host env - optional
105+
if Vagrant.has_plugin?("vagrant-proxyconf")
106+
ui.info "Getting Proxy Configuration from Host..."
107+
has_proxy = false
108+
["http_proxy", "HTTP_PROXY"].each do |proxy_var|
109+
if proxy = ENV[proxy_var]
110+
ui.info "HTTP proxy: " + proxy
111+
config.proxy.http = proxy
112+
has_proxy = true
113+
break
114+
end
115+
end
116+
117+
["https_proxy", "HTTPS_PROXY"].each do |proxy_var|
118+
if proxy = ENV[proxy_var]
119+
ui.info "HTTPS proxy: " + proxy
120+
config.proxy.https = proxy
121+
has_proxy = true
122+
break
123+
end
124+
end
125+
126+
if has_proxy
127+
# Only consider no_proxy if we have proxies defined.
128+
no_proxy = ""
129+
["no_proxy", "NO_PROXY"].each do |proxy_var|
130+
if ENV[proxy_var]
131+
no_proxy = ENV[proxy_var]
132+
ui.info "No proxy: " + no_proxy
133+
no_proxy += ","
134+
break
135+
end
136+
end
137+
config.proxy.no_proxy = no_proxy + "localhost,127.0.0.1"
138+
end
139+
else
140+
["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"].each do |proxy_var|
141+
if ENV[proxy_var]
142+
ui.warn 'To enable proxies in your VM, install the vagrant-proxyconf plugin'
143+
break
144+
end
145+
end
146+
end
147+
148+
# VM hostname
149+
# must be "localhost", or listener configuration will fail
150+
config.vm.hostname = "localhost"
151+
152+
# Oracle port forwarding
153+
config.vm.network "forwarded_port", guest: VM_LISTENER_PORT, host: VM_LISTENER_PORT
154+
config.vm.network "forwarded_port", guest: VM_EM_EXPRESS_PORT, host: VM_EM_EXPRESS_PORT
155+
156+
# Provision everything on the first run
157+
config.vm.provision "shell", path: "scripts/install.sh", env:
158+
{
159+
"SYSTEM_TIMEZONE" => VM_SYSTEM_TIMEZONE,
160+
"KEEP_DB_INSTALLER" => VM_KEEP_DB_INSTALLER,
161+
"ORACLE_CHARACTERSET" => VM_ORACLE_CHARACTERSET,
162+
"LISTENER_PORT" => VM_LISTENER_PORT,
163+
"EM_EXPRESS_PORT" => VM_EM_EXPRESS_PORT,
164+
"ORACLE_PWD" => VM_ORACLE_PWD
165+
}
166+
167+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#This is a configuration file to setup the Oracle Database.
2+
#It is used when running '/etc/init.d/oracle-xe-21c configure'.
3+
4+
# LISTENER PORT used Database listener, Leave empty for automatic port assignment
5+
LISTENER_PORT=###LISTENER_PORT###
6+
7+
# EM_EXPRESS_PORT Oracle EM Express URL port
8+
EM_EXPRESS_PORT=###EM_EXPRESS_PORT###
9+
10+
# Character set of the database
11+
CHARSET=###ORACLE_CHARACTERSET###
12+
13+
# Database file directory
14+
# If not specified, database files are stored under Oracle base/oradata
15+
DBFILE_DEST=
16+
17+
# DB Domain name
18+
DB_DOMAIN=
19+
20+
# SKIP Validations, memory, space
21+
SKIP_VALIDATIONS=false
22+
23+
# Password for SYS, SYSTEM and PDBADMIN accounts
24+
ORACLE_PASSWORD=###ORACLE_PWD###

0 commit comments

Comments
 (0)