Beginners Guide
This guide installs an Oracle AI Database 26ai with a container database DB1 and the PDB ORCLPDB
on an Oracle Linux 9 VM with ansible-oracle.
1. Overview
1.1. Architecture overview
1.2. What are we going to do?
-
Prepare the Ansible controller: Ansible in Ubuntu on WSL2 on Windows.
-
Configure the inventory with the IP address and login user of the Oracle Linux 9 VM.
-
Start the playbook
playbooks/do_all.yml. It executes all needed playbooks:-
opitzconsulting.ansible_oracle.os: prepare the VM for AutoUpgrade -
playbooks/autoupgrade.yml: install AutoUpgrade on the VM and download a gold image from My Oracle Support. The gold image is a complete ORACLE_HOME including the Release Update. -
opitzconsulting.ansible_oracle.single_instance_fs: configure the OS, install the ORACLE_HOME from the gold image and create the database.
-
1.3. Defaults
| Value | Description |
|---|---|
|
git repository on the Ansible controller |
|
Working directory for all Ansible commands |
|
Name of the VM in the inventory |
|
IP address of the VM ( |
|
Login user on the VM ( |
|
Installation media on the VM, target of the download ( |
|
Staging directory on the VM ( |
2. Requirements
2.1. Oracle Linux 9 VM
Any Oracle Linux 9 VM matching the requirements below can be used. See Create the VM with Hyper-V and Packer for an example with Hyper-V on Windows.
| Item | Requirement |
|---|---|
Operating system |
Oracle Linux 9 x86_64 |
CPU |
2 vCPUs (recommended) |
Memory |
8 GB RAM (recommended) |
Disk |
|
Network |
Fixed IP address, reachable from the Ansible controller with SSH |
Internet |
Access to the Oracle Linux yum repositories and to My Oracle Support for AutoUpgrade
( |
Login user |
User with SSH login and |
2.2. Create the VM with Hyper-V and Packer
The repository packer-hyperv builds an Oracle Linux 9 template with Packer
and creates the VM for this guide on Hyper-V.
See the README of the repository for the installation of packer and task.
|
Important
|
All steps in this chapter are executed in PowerShell on Windows, not in WSL. |
The template uses
-
the login user
olwithsudoprivileges and SSH key login, -
the volume group
olon/dev/sda3, as expected byhost_fs_layoutin this guide, and -
the SSH public key
%USERPROFILE%\.ssh\id_ed25519.pub.
git clone https://github.com/Rendanic/packer-hyperv.git cd packer-hyperv
task hyperv:hyperv-add-admin-user
task hyperv:packer-ol9
task hyperv:packer-ol9 SSH_KEY_FILE=C:\path\to\key.pub
cd OL9 .\create-vm.ps1 -NewVMName beginner-dbfs -Hostname beginner-dbfs -ExternalSwitch intern_66 -FixedIP 192.168.66.161 -CPUs 2 -MemoryGB 8
create-vm.ps1 creates the VM with two network adapters:
-
Default Switchwith DHCP for the internet access -
the switch from
-ExternalSwitchwith the fixed IP address from-FixedIP. Use this address foransible_hostininventory/hosts.yml.
|
Important
|
The template has a disk with 80 GB.
The volume group ol has approx. 60 GB free space then, but the guide needs 81 GB.Increase the disk of the VM, e.g. to 130 GB, before you start the installation. |
|
Note
|
The SSH public key of the template must belong to the private key of the Ansible controller.
Copy the key pair from Windows into WSL or use the public key from WSL for SSH_KEY_FILE.
|
2.3. Ansible controller
This guide uses Ubuntu on WSL2 on Windows as Ansible controller.
|
Note
|
Optionally, the database VM can be used as Ansible controller as well.
Install the packages with dnf instead of apt in this case,
e.g. sudo dnf install -y git python3.
ansible_host and ansible_user in the inventory are used the same way,
the VM connects to itself with SSH.
|
| Item | Requirement |
|---|---|
Python |
Python 3 with |
Ansible |
|
Internet |
Access to GitHub and Ansible Galaxy |
AutoUpgrade is executed on the VM, not on the Ansible controller. Java and the gold image are not needed on the Ansible controller.
2.4. My Oracle Support
A My Oracle Support account is needed for the download of the gold image.
3. Setup Ansible controller
|
Important
|
All steps are executed on the Ansible controller. |
sudo apt update sudo apt install -y git python3-venv
mkdir -p ~/git cd ~/git git clone https://github.com/oravirt/ansible-oracle.git
python3 -m venv ~/venv/ansible-oracle source ~/venv/ansible-oracle/bin/activate cd ~/git/ansible-oracle pip install -r tools/dev/requirements_dev_2.16.txt
|
Tip
|
tools/dev/requirements_dev_2.19.txt installs ansible-core 2.19 instead of 2.16.
|
|
Important
|
Activate the virtual environment in each new shell with source ~/venv/ansible-oracle/bin/activate.
|
cd ~/git/ansible-oracle/example/beginner/ansible ansible-galaxy collection install -r requirements.yml
4. Configure inventory
4.1. IP address and login user
The VM is configured in inventory/hosts.yml.
Change ansible_host and ansible_user for your VM.
---
all:
children:
dbfs:
hosts:
beginner-dbfs:
# IP address or DNS name of the Oracle Linux 9 VM
ansible_host: 192.168.66.161
# Login user on the VM with sudo privileges (SSH key login)
ansible_user: ol
|
Note
|
beginner-dbfs is only the name of the host in the inventory.
The host specific variables are in inventory/host_vars/beginner-dbfs/.
Rename the directory as well, when you change the name.
|
4.2. SSH key
Ansible connects with an SSH key to the VM.
ssh-keygen -t ed25519
ssh-copy-id ol@192.168.66.161
4.3. Check the connection
cd ~/git/ansible-oracle/example/beginner/ansible ansible all -m ansible.builtin.ping
ansible all -b -m ansible.builtin.command -a id
|
Tip
|
Add --ask-become-pass (-K) to all ansible and ansible-playbook commands,
when sudo requires a password for the login user.
|
4.4. My Oracle Support credentials
The My Oracle Support credentials are read from the environment variables MOS_USERNAME and MOS_PASSWORD.
export MOS_USERNAME=<your My Oracle Support login> read -s MOS_PASSWORD && export MOS_PASSWORD
Alternatively, store the credentials in the file .env in the working directory
and load it into the shell before starting ansible-playbook.
MOS_USERNAME=<your My Oracle Support login> MOS_PASSWORD=<your My Oracle Support password>
cd ~/git/ansible-oracle/example/beginner/ansible set -a; . ./.env; set +a
|
Important
|
.env contains your password. Restrict the permissions with chmod 600 .env.The file is ignored by git ( .gitignore).
|
|
Note
|
The lookups are defined in inventory/group_vars/all/mos_login.yml. Optionally, set mos_username and mos_password there statically
instead of the environment variables. Encrypt the password with ansible-vault in this case.
|
4.5. Database passwords
The password for all database users is default_dbpass in inventory/group_vars/all/password.yml.
|
Warning
|
The default Oracle_123 is for test environments only. Change it and use ansible-vault for other environments.
|
5. AutoUpgrade on the VM
AutoUpgrade is executed on the VM (autoupgrade_run_local: false in inventory/group_vars/all/autoupgrade.yml).
It downloads the gold image directly into /u01/sw on the VM.
No installation media are copied from the Ansible controller (oracle_sw_copy: false).
The execution of AutoUpgrade on the VM requires:
-
the Python module
pexpectfor the keystore with the My Oracle Support credentials, -
a JDK for
autoupgrade.jarand -
the download directory
/u01/swon the filesystem/u01.
The playbook os creates the filesystem /u01 (host_fs_layout in the inventory).
playbooks/autoupgrade.yml installs the packages for the JDK and pexpect before the installation of AutoUpgrade.
Therefore do_all.yml executes the playbook os before AutoUpgrade.
The playbook os is executed a second time, because it is a fixed part of
opitzconsulting.ansible_oracle.single_instance_fs.
The second execution changes nothing.
| Variable | Value | Description |
|---|---|---|
|
|
Download the latest |
|
|
Gold image for 26ai with all recommended patches |
|
|
Rename the gold image to |
|
|
Symlink |
See Oracle AutoUpgrade for details.
|
Important
|
The gold image is built by Oracle on request. When no suitable image is cached, the download can take a few hours. |
The release update of the gold image is known only after the download.
Therefore the inventory uses the symlink db_home_26_latest.zip as imagename instead of the real filename.
The symlink points to the gold image with the highest release update in /u01/sw.
It is changed only, when a newer gold image is downloaded - the download of an older release update keeps it unchanged.
ls -l /u01/sw/db_home_*.zip
db_home_26.04.zip db_home_26_latest.zip -> db_home_26.04.zip
db26_si_ee: &db26_si_ee
version: 26.1.0.0
oracle_home: /u01/app/oracle/product/db26_si_ee
edition: EE
imagename: db_home_26_latest.zip
|
Tip
|
Use the real filename, e.g. imagename: db_home_26.04.zip, when an ORACLE_HOME must be installed with a fixed release update.
|
6. Install database with Ansible
cd ~/git/ansible-oracle/example/beginner/ansible ansible-playbook playbooks/do_all.yml
|
Note
|
The execution takes approx. 60 minutes plus the download of the gold image. |
| Parameter | Value |
|---|---|
ORACLE_BASE |
|
ORACLE_HOME |
|
ORACLE_SID |
|
PDB |
|
db_create_file_dest |
|
db_recovery_file_dest |
|
Listener |
|
7. How to work with the installed database
ssh ol@192.168.66.161
sudo -iu oracle
ocenv
ocenv shows the ORACLE_HOMEs, databases and listeners on the host.
envhelp shows an overview of the commands.
DB1
sql