Skip to content

Latest commit

 

History

History
315 lines (241 loc) · 10.1 KB

beginner.adoc

File metadata and controls

315 lines (241 loc) · 10.1 KB

1. Beginners Guide

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. What are we going to do?

With one command, the following will happen…​

  • An Oracle Linux VM will be created.

  • A docker container is setup in this Linux VM.

  • Why do we need a docker container? Ansible runs in the docker container to configure the Oracle Linux VM and install the Oracle database. See Details of Ansible as a Docker Container for more information

  • The Oracle database installation is started from the docker container. See details below.

1.1.3. Defaults

Table 1. Defaults used 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/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. Download Oracle Installation media

Download the installation media for Oracle RDBMS 19c for Linux x86_64.

Place the ZIP archive into the directory of Vagrantfile.

copy archive
cd <Downloadlocation>

cp LINUX.X64_193000_db_home.zip ~/git/ansible-oracle/example/beginner/vagrant

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/example/beginner/vagrant
Start ssh-Agent (not needed when running from SSH-Setup)
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/example/beginner/vagrant
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.

1.4. How to work with the installed database

1.4.1. Login as vagrant

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

1.4.2. 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.4.3. 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.4.4. 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.4.5. 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>