Skip to content

Commit 9dd14ed

Browse files
authored
Add OracleDatabase/23.4.0-Free project (#506)
Adds an Oracle Database 23ai Free project, based on the OracleDatabase/23.3.0-Free project. Since the 23.3.0-Free rpm is still available for download, this is a new project, rather than an update to the 23.3.0-Free project. Notable changes from the 23.3.0-Free project: - Use Oracle Linux 9 instead of Oracle Linux 8 - Add notes to .env, README.md and Vagrantfile stating that database creation will fail if the password includes special characters - Modify install.sh to prevent auto-generated passwords from containing equals signs Tested with both VirtualBox and libvirt/KVM. Closes #505. Signed-off-by: Paul Neumann <[email protected]>
1 parent 33d39d3 commit 9dd14ed

File tree

10 files changed

+511
-0
lines changed

10 files changed

+511
-0
lines changed

OracleDatabase/23.4.0-Free/.env

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Oracle Database 23.4.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='oracle23ai-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+
# Database creation will fail if the password contains spaces or special characters
35+
# 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/23.4.0-Free/.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/23.4.0-Free/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# oracle23ai-free-vagrant
2+
3+
This Vagrant project provisions Oracle Database automatically, using Vagrant, an Oracle Linux 9 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.4.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: `oracle23ai-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. **Important: Database creation will fail if the password contains spaces or special characters.**
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.
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
#
2+
# Copyright (c) 2024 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/9"
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', 'oracle23ai-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+
# Database creation will fail if the password contains spaces or special characters
59+
VM_ORACLE_PWD = default_s('VM_ORACLE_PWD', '')
60+
end
61+
62+
# Convenience methods
63+
def default_s(key, default)
64+
ENV[key] && ! ENV[key].empty? ? ENV[key] : default
65+
end
66+
67+
def default_i(key, default)
68+
default_s(key, default).to_i
69+
end
70+
71+
def default_b(key, default)
72+
default_s(key, default).to_s.downcase == "true"
73+
end
74+
75+
def host_tz
76+
# get host time zone for setting VM time zone
77+
# if host time zone isn't an integer hour offset from GMT, fall back to UTC
78+
offset_sec = Time.now.gmt_offset
79+
if (offset_sec % (60 * 60)) == 0
80+
offset_hr = ((offset_sec / 60) / 60)
81+
timezone_suffix = offset_hr >= 0 ? "-#{offset_hr.to_s}" : "+#{(-offset_hr).to_s}"
82+
'Etc/GMT' + timezone_suffix
83+
else
84+
'UTC'
85+
end
86+
end
87+
88+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
89+
config.vm.box = BOX_NAME
90+
config.vm.box_url = "#{BOX_URL}/#{BOX_NAME}.json"
91+
config.vm.define VM_NAME
92+
93+
# Provider-specific configuration
94+
config.vm.provider "virtualbox" do |v|
95+
v.memory = VM_MEMORY
96+
v.name = VM_NAME
97+
end
98+
config.vm.provider :libvirt do |v|
99+
v.memory = VM_MEMORY
100+
end
101+
102+
# add proxy configuration from host env - optional
103+
if Vagrant.has_plugin?("vagrant-proxyconf")
104+
ui.info "Getting Proxy Configuration from Host..."
105+
has_proxy = false
106+
["http_proxy", "HTTP_PROXY"].each do |proxy_var|
107+
if proxy = ENV[proxy_var]
108+
ui.info "HTTP proxy: " + proxy
109+
config.proxy.http = proxy
110+
has_proxy = true
111+
break
112+
end
113+
end
114+
115+
["https_proxy", "HTTPS_PROXY"].each do |proxy_var|
116+
if proxy = ENV[proxy_var]
117+
ui.info "HTTPS proxy: " + proxy
118+
config.proxy.https = proxy
119+
has_proxy = true
120+
break
121+
end
122+
end
123+
124+
if has_proxy
125+
# Only consider no_proxy if we have proxies defined.
126+
no_proxy = ""
127+
["no_proxy", "NO_PROXY"].each do |proxy_var|
128+
if ENV[proxy_var]
129+
no_proxy = ENV[proxy_var]
130+
ui.info "No proxy: " + no_proxy
131+
no_proxy += ","
132+
break
133+
end
134+
end
135+
config.proxy.no_proxy = no_proxy + "localhost,127.0.0.1"
136+
end
137+
else
138+
["http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY"].each do |proxy_var|
139+
if ENV[proxy_var]
140+
ui.warn 'To enable proxies in your VM, install the vagrant-proxyconf plugin'
141+
break
142+
end
143+
end
144+
end
145+
146+
# VM hostname
147+
# must be "localhost", or listener configuration will fail
148+
config.vm.hostname = "localhost"
149+
150+
# Oracle port forwarding
151+
config.vm.network "forwarded_port", guest: VM_LISTENER_PORT, host: VM_LISTENER_PORT
152+
153+
# Provision everything on the first run
154+
config.vm.provision "shell", path: "scripts/install.sh", env:
155+
{
156+
"SYSTEM_TIMEZONE" => VM_SYSTEM_TIMEZONE,
157+
"KEEP_DB_INSTALLER" => VM_KEEP_DB_INSTALLER,
158+
"ORACLE_CHARACTERSET" => VM_ORACLE_CHARACTERSET,
159+
"LISTENER_PORT" => VM_LISTENER_PORT,
160+
"ORACLE_PWD" => VM_ORACLE_PWD
161+
}
162+
163+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#This is a configuration file to setup the Oracle Database.
2+
#It is used when running '/etc/init.d/oracle-free-23ai 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+
# Configure TDE
18+
CONFIGURE_TDE=false
19+
20+
# Encrypt Tablespaces list, Leave empty for user tablespace alone or provide ALL for encrypting all tablespaces
21+
# For specific tablespaces use SYSTEM:true,SYSAUX:false
22+
ENCRYPT_TABLESPACES=
23+
24+
# SKIP Validations, memory, space
25+
SKIP_VALIDATIONS=false

0 commit comments

Comments
 (0)