Skip to content

Commit a4b1533

Browse files
authored
Add OracleDatabase/23.2.0-Free project (#479)
Adds an OracleDatabase/23.2.0-Free project, based on the OracleDatabase/21.3.0-XE project. Notable changes from the 21.3.0-XE project: - This release doesn't use a read-only Oracle home, so the tnsnames.ora file is under /opt/oracle/product..., rather than /opt/oracle/homes... - This release doesn't include EM Express, so related code has been removed Tested with both VirtualBox and libvirt/KVM. Closes #478. Signed-off-by: Paul Neumann <[email protected]>
1 parent 42206a4 commit a4b1533

File tree

10 files changed

+506
-0
lines changed

10 files changed

+506
-0
lines changed

OracleDatabase/23.2.0-Free/.env

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Oracle Database 23.2.0 Free 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='oracle23c-free-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+
# Oracle Database password for SYS, SYSTEM and PDBADMIN accounts
33+
# If left blank, the password will be generated automatically
34+
# VM_ORACLE_PWD=
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.sh text eol=lf
2+
*.tmpl text eol=lf

OracleDatabase/23.2.0-Free/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.rpm
2+
.env.local*

OracleDatabase/23.2.0-Free/README.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# oracle23c-free-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/23.2.0-Free` 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: `FREE`
28+
* PDB: `FREEPDB1`
29+
* Database passwords are auto-generated and printed on install
30+
31+
These parameters can be customized, if desired (see [Configuration](#configuration)).
32+
33+
## Resetting password
34+
35+
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>`.
36+
37+
## Running scripts after setup
38+
39+
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.
40+
41+
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 = FREEPDB1` statement in the script.
42+
43+
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.
44+
45+
## Configuration
46+
47+
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.
48+
49+
### How to configure
50+
51+
There are three ways to set parameters:
52+
53+
1. Update the `Vagrantfile`. This is straightforward; the downside is that you will lose changes when you update this repository.
54+
2. Use environment variables. It might be difficult to remember the parameters used when the VM was instantiated.
55+
3. Use the `.env`/`.env.local` files (requires
56+
[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!).
57+
58+
Parameters are considered in the following order (first one wins):
59+
60+
1. Environment variables
61+
2. `.env.local` (if it exists and the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
62+
3. `.env` (if the [vagrant-env](https://github.com/gosuri/vagrant-env) plugin is installed)
63+
4. `Vagrantfile` definitions
64+
65+
### VM parameters
66+
67+
* `VM_NAME` (default: `oracle23c-free-vagrant`): VM name.
68+
* `VM_MEMORY` (default: `2300`): memory for the VM (in MB, 2300 MB is ~2.25 GB).
69+
* `VM_SYSTEM_TIMEZONE` (default: host time zone (if possible)): VM time zone.
70+
* The system time zone is used by the database for SYSDATE/SYSTIMESTAMP.
71+
* The guest time zone will be set to the host time zone when the host time zone is a full hour offset from GMT.
72+
* 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.
73+
* 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).
74+
75+
### Oracle Database parameters
76+
77+
* `VM_KEEP_DB_INSTALLER` (default: `false`): save database installer RPM file for reuse when VM is rebuilt.
78+
* `VM_ORACLE_CHARACTERSET` (default: `AL32UTF8`): database character set.
79+
* `VM_LISTENER_PORT` (default: `1521`): Listener port.
80+
* `VM_ORACLE_PWD` (default: automatically generated): Oracle Database password for the SYS, SYSTEM and PDBADMIN accounts.
81+
82+
## Optional plugins
83+
84+
When installed, this Vagrant project will make use of the following third party Vagrant plugins:
85+
86+
* [vagrant-env](https://github.com/gosuri/vagrant-env): loads environment
87+
variables from .env files;
88+
* [vagrant-proxyconf](https://github.com/tmatilai/vagrant-proxyconf): set
89+
proxies in the guest VM if you need to access the Internet through a proxy. See
90+
the plugin documentation for configuration.
91+
92+
To install Vagrant plugins run:
93+
94+
```shell
95+
vagrant plugin install <name>...
96+
```
97+
98+
## Other info
99+
100+
* If you need to, you can connect to the virtual machine via `vagrant ssh`.
101+
* You can `sudo su - oracle` to switch to the oracle user.
102+
* On the guest OS, the directory `/vagrant` is a shared folder and maps to wherever you have this file checked out.
+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#
2+
# Copyright (c) 2023 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at
4+
# https://oss.oracle.com/licenses/upl.
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', 'oracle23c-free-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+
# Oracle Database password for SYS, SYSTEM and PDBADMIN accounts
57+
# If left blank, the password will be generated automatically
58+
VM_ORACLE_PWD = default_s('VM_ORACLE_PWD', '')
59+
end
60+
61+
# Convenience methods
62+
def default_s(key, default)
63+
ENV[key] && ! ENV[key].empty? ? ENV[key] : default
64+
end
65+
66+
def default_i(key, default)
67+
default_s(key, default).to_i
68+
end
69+
70+
def default_b(key, default)
71+
default_s(key, default).to_s.downcase == "true"
72+
end
73+
74+
def host_tz
75+
# get host time zone for setting VM time zone
76+
# if host time zone isn't an integer hour offset from GMT, fall back to UTC
77+
offset_sec = Time.now.gmt_offset
78+
if (offset_sec % (60 * 60)) == 0
79+
offset_hr = ((offset_sec / 60) / 60)
80+
timezone_suffix = offset_hr >= 0 ? "-#{offset_hr.to_s}" : "+#{(-offset_hr).to_s}"
81+
'Etc/GMT' + timezone_suffix
82+
else
83+
'UTC'
84+
end
85+
end
86+
87+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
88+
config.vm.box = BOX_NAME
89+
config.vm.box_url = "#{BOX_URL}/#{BOX_NAME}.json"
90+
config.vm.define VM_NAME
91+
92+
# Provider-specific configuration
93+
config.vm.provider "virtualbox" do |v|
94+
v.memory = VM_MEMORY
95+
v.name = VM_NAME
96+
end
97+
config.vm.provider :libvirt do |v|
98+
v.memory = VM_MEMORY
99+
end
100+
101+
# add proxy configuration from host env - optional
102+
if Vagrant.has_plugin?("vagrant-proxyconf")
103+
ui.info "Getting Proxy Configuration from Host..."
104+
has_proxy = false
105+
["http_proxy", "HTTP_PROXY"].each do |proxy_var|
106+
if proxy = ENV[proxy_var]
107+
ui.info "HTTP proxy: " + proxy
108+
config.proxy.http = proxy
109+
has_proxy = true
110+
break
111+
end
112+
end
113+
114+
["https_proxy", "HTTPS_PROXY"].each do |proxy_var|
115+
if proxy = ENV[proxy_var]
116+
ui.info "HTTPS proxy: " + proxy
117+
config.proxy.https = proxy
118+
has_proxy = true
119+
break
120+
end
121+
end
122+
123+
if has_proxy
124+
# Only consider no_proxy if we have proxies defined.
125+
no_proxy = ""
126+
["no_proxy", "NO_PROXY"].each do |proxy_var|
127+
if ENV[proxy_var]
128+
no_proxy = ENV[proxy_var]
129+
ui.info "No proxy: " + no_proxy
130+
no_proxy += ","
131+
break
132+
end
133+
end
134+
config.proxy.no_proxy = no_proxy + "localhost,127.0.0.1"
135+
end
136+
else
137+
["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"].each do |proxy_var|
138+
if ENV[proxy_var]
139+
ui.warn 'To enable proxies in your VM, install the vagrant-proxyconf plugin'
140+
break
141+
end
142+
end
143+
end
144+
145+
# VM hostname
146+
# must be "localhost", or listener configuration will fail
147+
config.vm.hostname = "localhost"
148+
149+
# Oracle port forwarding
150+
config.vm.network "forwarded_port", guest: VM_LISTENER_PORT, host: VM_LISTENER_PORT
151+
152+
# Provision everything on the first run
153+
config.vm.provision "shell", path: "scripts/install.sh", env:
154+
{
155+
"SYSTEM_TIMEZONE" => VM_SYSTEM_TIMEZONE,
156+
"KEEP_DB_INSTALLER" => VM_KEEP_DB_INSTALLER,
157+
"ORACLE_CHARACTERSET" => VM_ORACLE_CHARACTERSET,
158+
"LISTENER_PORT" => VM_LISTENER_PORT,
159+
"ORACLE_PWD" => VM_ORACLE_PWD
160+
}
161+
162+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#This is a configuration file to setup the Oracle Database.
2+
#It is used when running '/etc/init.d/oracle-free-23c configure'.
3+
4+
# LISTENER PORT used Database listener, Leave empty for automatic port assignment
5+
LISTENER_PORT=###LISTENER_PORT###
6+
7+
# Character set of the database
8+
CHARSET=###ORACLE_CHARACTERSET###
9+
10+
# Database file directory
11+
# If not specified, database files are stored under Oracle base/oradata
12+
DBFILE_DEST=
13+
14+
# DB Domain name
15+
DB_DOMAIN=
16+
17+
# SKIP Validations, memory, space
18+
SKIP_VALIDATIONS=false
19+
20+
# Password for SYS, SYSTEM and PDBADMIN accounts
21+
ORACLE_PASSWORD=###ORACLE_PWD###

0 commit comments

Comments
 (0)