Database with Patching

Warning
This guide is a work in progress!

1. Example Beginners Guide with Patchingp

Important
The setup of Vagrant, VirtualBox and SSH is not part of this documentation.
Please follow the documentation.

1.1. Overview

1.1.1. Architecture overview

Architecturview

1.1.2. Defaults

Table 1. Used defaults in this guide
Value Description

~/git/ansible-oracle

git Repository on Host System

~/git/ansible-oracle

git Repository in VM

~/.ssh/id_rsa

private Key on Host System

vagrant

SSH-User for Login and Ansible

~/git/ansible-oracle/ansible-oracle/example/beginner

Vagrantfile location

1.2. Setup Host System

Important
All steps are executed on the Host System inside a git+bash.
clone git Repository
mkdir ~/git
cd ~/git

git clone https://github.com/oravirt/ansible-oracle.git

1.2.1. Build Oracle Software tree

Important
It is highly recommended to use the following structure.
Do not change this until you really know what you are doing.

All installation media are searched in oracle_stage_remote on the database server.

Warning
It is assumend that oracle_stage_remote is set to /sw
1.2.1.1. Installation media
Important
Only LINUX.X64_193000_db_home.zip is needed as base media for the Advanced Guide.
Example oracle_stage_remote: /sw
/sw/LINUX.X64_180000_db_home.zip
/sw/LINUX.X64_193000_grid_home.zip
/sw/LINUX.X64_213000_grid_home.zip
/sw/LINUX.X64_193000_db_home.zip
/sw/LINUX.X64_213000_db_home.zip
1.2.1.2. OPatch archive
Important
Only p6880880_190000_Linux-x86-64.zip is needed for patching in the Advanced Guide.
Example oracle_stage_remote: /sw for OPatch
/sw/oracle/linux64/p6880880_112000_Linux-x86-64.zip
/sw/oracle/linux64/p6880880_180000_Linux-x86-64.zip
/sw/oracle/linux64/p6880880_190000_Linux-x86-64.zip
/sw/oracle/linux64/p6880880_210000_Linux-x86-64.zip
1.2.1.3. Patch structure

<todo wip>

Directory Description

1.2.2. Configure SSH-Key

Important
Do not skip the preparation for Vagrant and SSH.
Please follow the documentation.
Copy Public key into Vagrantfile directory
cp ~/.ssh/id_rsa.pub ~/git/ansible-oracle/ansible-oracle/example/beginner
Start ssh-Agent
eval $(ssh-agent)
Import the generated key
ssh-add ~/.ssh/id_rsa

1.2.3. Start Vagrantbox

Important
The Deployment und provisioning of the VM takes some minutes.
It highly depends on the speed of the internet connection.
Important
The SSH public key is configured during the provisioning phase of the VM.
Do not forget to copy the file before starting the box with vagrant up.
vagrant up
cd ~/git/ansible-oracle/ansible-oracle/example/beginner
VAGRANT_EXPERIMENTAL=disks vagrant up
1.2.3.1. What happens when I start vagrant?
  1. Using the vagrantfile, an Oracle Linux VM is installed (2x CPU, 4096MB RAM, 150GB HDD). IP = 192.168.56.161

  2. A mount point /vagrant is available in the Oracle Linux VM. This is a shared folder from your Windows machine.

  3. Your ssh key is used to connect to the VM in a secure way

  4. docker is installed in the Oracle Linux VM

  5. docker-compose is installed in the Oracle Linux VM

  6. The ansible-oracle repository is cloned to the Oracle Linux VM

  7. A docker container "Ansible Container" is built with docker-compose. This runs in the Oracle Linux VM

  8. No Oracle database is yet installed. See below

1.3. Working inside the VM

1.3.1. Connect to VM

Important
The next steps are done inside the VM.
The SSH-Setup from the previous chapter must be completed before continuing!
Connect into VM with SSH from git+bash
ssh -A vagrant@192.168.56.161

1.3.2. Note about Installation media

The installation media is mounted with vboxsf from Vagrant into the Linux VM, mounted as /vagrant.
Use the following command to check this…​

check for Installation media
[vagrant@beginner-dbfs-151-192-168-56-161 ~]$ ls /vagrant/LINUX.X64_193000_db_home.zip

/vagrant/LINUX.X64_193000_db_home.zip

1.3.3. Start Ansible-Container inside VM

Important
Check the prompt shown in this documentation, as to whether you should start the commands in the shell or inside the Ansible-Container.
ansible@ansible-oracle is for working inside the container. .Start Ansible-Container
cd ~/git/ansible-oracle/docker
docker-compose run --rm -w /git/ansible-oracle/example/beginner/ansible ansible bash
Example
[vagrant@beginner-dbfs-151-192-168-56-161 docker]$ docker-compose run --rm -w /git/ansible-oracle/example/beginner/ansible ansible bash
[+] Running 2/0
 ⠿ Network docker_default          Created
 ⠿ Volume "docker_ansible_galaxy"  Created

ansible@ansible-oracle:/git/ansible-oracle/example/beginner/ansible$
Important
The collection is installed once and stored on the docker volume.
Install Collections
ansible@ansible-oracle:/git/ansible-oracle/example/beginner/ansible$ ansible-galaxy collection install -r requirements.yml
Example
ansible@ansible-oracle:/git/ansible-oracle/example/beginner/ansible$ ansible-galaxy collection install -r requirements.yml
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://galaxy.ansible.com/download/devsec-hardening-8.2.0.tar.gz to /home/ansible/.ansible/tmp/ansible-local-25z8isd809/tmp25w_hn4o/devsec-hardening-8.2.0-0j9481f1
Installing 'devsec.hardening:8.2.0' to '/ansible/galaxy/ansible_collections/devsec/hardening'
Downloading https://galaxy.ansible.com/download/opitzconsulting-ansible_oracle-3.2.0.tar.gz to /home/ansible/.ansible/tmp/ansible-local-25z8isd809/tmp25w_hn4o/opitzconsulting-ansible_oracle-3.2.0-x3wo4c3b
devsec.hardening:8.2.0 was installed successfully
Installing 'opitzconsulting.ansible_oracle:3.2.0' to '/ansible/galaxy/ansible_collections/opitzconsulting/ansible_oracle'
Downloading https://galaxy.ansible.com/download/ansible-posix-1.4.0.tar.gz to /home/ansible/.ansible/tmp/ansible-local-25z8isd809/tmp25w_hn4o/ansible-posix-1.4.0-1jub71c6
opitzconsulting.ansible_oracle:3.2.0 was installed successfully
Installing 'ansible.posix:1.4.0' to '/ansible/galaxy/ansible_collections/ansible/posix'
Downloading https://galaxy.ansible.com/download/community-mysql-3.5.1.tar.gz to /home/ansible/.ansible/tmp/ansible-local-25z8isd809/tmp25w_hn4o/community-mysql-3.5.1-lkcnbkd5
ansible.posix:1.4.0 was installed successfully
Installing 'community.mysql:3.5.1' to '/ansible/galaxy/ansible_collections/community/mysql'
Downloading https://galaxy.ansible.com/download/community-crypto-2.8.0.tar.gz to /home/ansible/.ansible/tmp/ansible-local-25z8isd809/tmp25w_hn4o/community-crypto-2.8.0-6sco_75m
community.mysql:3.5.1 was installed successfully
Installing 'community.crypto:2.8.0' to '/ansible/galaxy/ansible_collections/community/crypto'
Downloading https://galaxy.ansible.com/download/community-general-5.8.0.tar.gz to /home/ansible/.ansible/tmp/ansible-local-25z8isd809/tmp25w_hn4o/community-general-5.8.0-up2j_3iq
community.crypto:2.8.0 was installed successfully
Installing 'community.general:5.8.0' to '/ansible/galaxy/ansible_collections/community/general'
community.general:5.8.0 was installed successfully

1.3.4. Start Installation with Ansible

Important
Make sure to start the installation inside the Ansible Container.
The prompt shows the correct location.
The execution takes ~60 minutes.
Start installation with Ansible
cd /git/ansible-oracle/example/beginner/ansible
ansible-playbook -i inventory/ -e hostgroup=dbfs playbooks/single-instance-fs.yml

The Database creation is now complete.
See the following chapter for details about how to work with the VM. === How to work with installed database

1.3.5. Login as vagrant

Login with SSH from git+bash
ssh -A vagrant@192.168.56.161

1.3.6. Sudo oracle

sudo oracle
[vagrant@beginner-dbfs-151-192-168-56-161 ~]$ sudo su - oracle
Example
[vagrant@beginner-dbfs-151-192-168-56-161 ~]$ sudo su - oracle
Last login: Sun Nov  6 11:16:54 UTC 2022 on pts/2
execute ocenv to source Oracle Environment

1.3.7. Start ocenv

Initialize ocenv to set the environment variables
[oracle@beginner-dbfs-151-192-168-56-161 ~]$ ocenv
Example
[oracle@beginner-dbfs-151-192-168-56-161 ~]$ ocenv
#####################################################################################
## Version: 2022-08-10
## get command overview by typing envhelp
#####################################################################################
home   oracle       OraHome_OraDB19Home1                       /u01/app/oracle/product/19/db1
db     oracle       DB1              (up)                      /u01/app/oracle/product/19/db1
lsnr   oracle       LISTENER                                   /u01/app/oracle/product/19/db1
[oracle@beginner-dbfs-151-192-168-56-161] [] [~]

1.3.8. Switch to DB1

Set ORACLE_SID
[oracle@beginner-dbfs-151-192-168-56-161] [] [~]
$ DB1
Example
[oracle@beginner-dbfs-151-192-168-56-161] [] [~]
$ DB1
=================================
INSTANCE NAME       : DB1
INSTANCE STATUS     : OPEN (READ WRITE)
INSTANCE START TIME : 2022-11-06 11:34:06
DB NAME             : DB1
DB UNIQUE NAME      : DB1
DB ID               : 1713907024
DB LOGGING MODE     : NOARCHIVELOG
DB ROLE             : PRIMARY
DB FORCE LOGGING    : YES
DB FLASHBACK ON     : NO
DB is CDB           : YES
PDBs
   PDB NAME        STATUS     RESTRICTED OPEN TIME           LOCAL UNDO
   --------------- ---------- ---------- ------------------- ----------
   ORCLPDB         READ WRITE NO         2022-11-06 11:34:28 YES
=================================
[oracle@beginner-dbfs-151-192-168-56-161] [DB1] [~]

1.3.9. Database Login

Start SQLPlus
[oracle@beginner-dbfs-151-192-168-56-161] [DB1] [~]
$ sql
Example
[oracle@beginner-dbfs-151-192-168-56-161] [DB1] [~]
$ sql

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Nov 6 11:41:40 2022
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

11:41:40 SYS@DB1
SQL>
Last modified September 25, 2024: hugo-docsy (f1963ade)