Practical guide to Oracle Virtual environments ODC Tour Latin America – August 2018 Nelson Calero
Today’s topics • Virtual environments review – Docker – Oracle VirtualBox – Oracle VM – Oracle Cloud • Automation – Vagrant – Ansible – Terraform • Examples – VirtualBox VMs using Vagrant/Ansible – Docker on Windows – RAC using VirtualBox and Docker – Terraform for Oracle Cloud instances 2 © 2018 Pythian Motivation Explore alternatives to create database environments Intended audience DBAs and Developers
• Database Consultant at Pythian since 2014 • Working with Oracle tools and Linux environments since 1996 • DBA Oracle (2001) & MySQL (2005) • Co-founder and President of the Oracle user Group of Uruguay (2009) • LAOUC Director of events (2013) • Computer Engineer (1998) • Oracle ACE (2014), Oracle ACE Director (2017) • Oracle Certified Professional 10g/11g/12c, OCE, Cloud DB & Infra • Amazon Solutions Architect – Associate (2016) • Google Cloud Architect (2017), Google Cloud Data Engineer (2017) • Oracle University Instructor (2011) • Blogger and speaker: Oracle Open World, Collaborate, OTN Tour, Regional conferences About me 3 © 2018 Pythian http://www.linkedin.com/in/ncalero @ncalerouy
Pythian overview © 2015 Pythian Confidential4 • 22 Years of data infrastructure management consulting • 250+ Top brands • 11800+ Systems under management • 400+ employees in 35 countries • 10 Oracle ACEs, 4 ACED, 3 OakTable members, 2 OCM, 6 Microsoft MVPs, 1 Cloudera Champion of Big Data, AWS Certified Solutions Architect – 2 Professional, 12 Associate • Oracle, Microsoft, MySQL, Hadoop, Cassandra, MongoDB, and more • Infrastructure, Cloud, DevOps, and application expertise
5 © 2018 Pythian
Introduction to Virtual environments 6 KVM, Oracle VM, VirtualBox, … LXC, WPAR, Docker, … Sharing server resources isolating processes https://docs.docker.com/get-started/
Introduction to Virtual environments • Hypervisors (Server virtualization) – Type 1: run directly in host’s hardware • Xen, Oracle VM, Hyper-V, Vmware ESX, KVM, … – Type 2: run on a OS (host) • VMware Workstation, VirtualBox, QEMU, … • Containers (OS virtualization) – Share OS kernel and libraries – LXC, Docker – MOS 2216342.1 Oracle Support for Database Running on Docker  Supported SI on Oracle Linux 7 with UEK4 (and later) or RHEL7 7 © 2018 Pythian
Not only server virtualization • Data virtualization – Delphix, … • Storage snapshots (vendor based) – SMO, NetAPP, Oracle ACFS, .. – gDBClone – clone databases based on ACFS snapshots http://www.oracle.com/technetwork/indexes/samplecode/gdbclone-download-2295388.html • Cloud provisioning – Compute instances – managed hypervisor – Bare Metal – bring your own hypervisor (only on new OCI, not classic) – Containers – as managed services or DIY in BM 8 © 2018 Pythian
Today’s focus: VMs and containers 9 © 2018 Pythian
Containers with Docker 10 • Creates process with access to same OS binaries and resources from the host, executing programs in isolation as if they were inside a VM • Runs on any OS - Download latest binary from https://www.docker.com - On Windows it creates a VirtualBox VM to execute containers inside it  VM needs CPU, disk and RAM adjustments to be useful • Commands: - docker-machine: manage machines running Docker (Windows/Mac before v1.12) - docker o build: Build an image from a Dockerfile o run: Run a command in a new container o exec: Run a command in a running container © 2018 Pythian
Docker – command line Windows – control VM status 11 D:>docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v18.01.0-ce Management Commands: checkpoint Manage checkpoints config Manage Docker configs container Manage containers image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker volume Manage volumes D:>docker Commands: attach Attach local standard input, output, and error streams to a running contain build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container deploy Deploy a new stack or update an existing stack diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers ...
Docker – configuration 12 Dockerfile – instructions to execute when a container starts FROM oraclelinux:7-Slim # Pull base image … USER Oracle RUN $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE EE … CMD exec $ORACLE_BASE/$RUN_FILE Base image usually are OS images, not including Oracle binaries (license restriction) Exception: Oracle provided images: - Docker Store: https://store.docker.com/images/oracle-database-enterprise-edition - Oracle Container Registry: https://container-registry.oracle.com Useful github repositories: – https://github.com/oracle/docker-images/OracleDatabase - RAC and Single instance – https://github.com/Seth-Miller/12c-rac-docker - pioneer RAC configuration © 2018 Pythian
Docker – creating a container 13 Install github repository D:GitHub>git clone https://github.com/oracle/docker-images.git Cloning into 'docker-images'... remote: Counting objects: 7740, done. remote: Compressing objects: 100% (36/36), done. rRemote: Total 7740 (delta 18), reused 45 (delta 16), pack-reused 7688 Receiving objects: 100% (7740/7740), 9.70 MiB | 870.00 KiB/s, done. Resolving deltas: 100% (4286/4286), done. Checking connectivity... done. Checking out files: 100% (968/968), done. Create the container (11.2.0.2 XE, 12.1.0.2 or 12.2.0.1 EE or SE as of March 2018): D:GitHub12.1.0.2/…>docker build -t oracle/database:12.1.0.2-ee -f Dockerfile.ee . Download Oracle installation files from OTN: • http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html • Copy to directory D:GitHubdocker-imagesOracleDatabasedockerfiles12.1.0.2 © 2018 Pythian
Docker – creating a container 14 Start the container (Windows example): D:>docker run --name ora121 -p 1521:1521 -p 5500:5500 -e ORACLE_SID=orcl -e ORACLE_PDB=pdb1 -e ORACLE_PWD=Oracle_123 -e ORACLE_CHARACTERSET=AL32UTF8 -v //c/users/calero/.docker/persistentdisk/ora121://opt/oracle/oradata oracle/database:12.1.0.2-ee Status of running containers D:>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2c1afcad6a50 oracle/database:12.1.0.2-ee "/bin/sh -c 'exec $O…" 11 hours ago Up 11 hours (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp ora121 Status D:>docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 12.1.0.2-ee c175ddb41772 4 minutes ago 10.6GB oraclelinux 7-slim 9870bebfb1d5 2 months ago 118MB © 2018 Pythian
Docker – connecting to Oracle 15 Using sqlplus binary from container Connect to database running in container – using host Oracle client D:>docker-machine ip 192.168.99.100 C:Userscalero>sqlplus system/Oracle_123@"192.168.99.100:1521/orcl" SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 4 01:51:50 2018 ... Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options D:>docker exec -ti 2c1afcad6a50 sqlplus pdbadmin/Oracle_123@pdb1 SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 4 16:23:47 2018 ... Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options © 2018 Pythian
Docker - images from container-registry Register in container-registry.oracle.com Start session Download image Step by step guide: 16 D:>docker login container-registry.oracle.com Username: nelson.calero@gmail.com Password: xxx Login Succeeded D:>docker pull container-registry.oracle.com/database/enterprise:12.2.0.1 12.2.0.1: Pulling from database/enterprise 9bd4d110366e: Downloading [> ] 2.668MB/143MB af8b29651e27: Download complete http://databaseindex.blogspot.com/2018/04/oracle-12c-docker-windows-ocr.html © 2018 Pythian
Example – Oracle DB using Docker Image Check local images 17 D:>docker images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/database/enterprise 12.2.0.1 12a359cd0528 5 months ago 3.44GB Define image settings D:>echo DB_MEMORY=1Gb >ora.conf Start the container D:>docker run -d -it --name ora122 -P --env-file ora.conf container-registry.oracle.com/database/enterprise:12.2.0.1 5896d37c1cae083c9ab82ec52cf9900a3b22a012b5257c1cb065a6093d7d55c5 Check running containers D:>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5896d37c1cae container-registry.oracle.com/database/enterprise:12.2.0.1 "/bin/sh -c '/bin/ba…" 24 minutes ago Up 24 minutes (healthy) 0.0.0.0:32769->1521/tcp, 0.0.0.0:32768->5500/tcp ora122
Summary – Oracle DB using Docker Using images with preinstalled Oracle binaries - Docker Store - Container registry Step-by-step: http://databaseindex.blogspot.com/2018/04/oracle-12c-docker-windows-ocr.html Using Oracle github repository, must download binaries from OTN - Step-by-step example on Windows 10: http://www.oracle.com/technetwork/es/articles/datawarehouse/oracle12c-docker-win10-4485487-esa.html More examples: - Standby: https://github.com/jamesattard/oracle-xe-docker - RAC: https://github.com/Seth-Miller/12c-rac-docker https://github.com/oracle/docker-images/tree/master/OracleDatabase/RAC 18 © 2018 Pythian
Docker - creating a container 19 Demo © 2018 Pythian
Hypervisors – Oracle VM (type 1) • Xen Kernel – UEK R4 as of July 2018 with OVM 3.4.4 • Server needs to boot with it (reinstall needed if other OS was used) • Minimal resources used by OVM server (1 CPU 2Gg RAM) • VMs uses free available server’s resources – can be created from OVS using CLI (xm) or using OVM manager web client – RAM/CPUs can be allocated dynamically without restarting VMs (up to max config) – Only supported method to reduce license costs (hard partitioning) – HA configuration allowed with clustered repositories (using SAN, not with local HDs) – Windows, Linux and Solaris guests • OVM Manager – Needs to be installed in a different server – Uses MySQL as metadata repository 20 © 2018 Pythian
Oracle VM - examples 21 © 2018 Pythian [root@ovs ~]# xm list Name ID Mem VCPUs State Time(s) 0004fb00000600001000d7829bf5a105 4 30723 4 -b---- 2415636.4 0004fb0000060000cf08a173c50efdc1 2 13063 4 r----- 784876.4 Domain-0 0 1958 20 r----- 1211462.2 [root@ovs /OVS/Repositories]# ls -l */VirtualMachines/*/vm.cfg -rw------- 1 root root 1950 Apr 19 02:37 0004fb00000300005b800c75ea8932be/VirtualMachines/0004fb00000600001000d7829bf5a105/vm.cfg -rw-r--r-- 1 root root 1946 Apr 19 02:36 0004fb00000300005b800c75ea8932be/VirtualMachines/0004fb0000060000cf08a173c50efdc1/vm.cfg [root@ovs ~]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 20 Hypervisor vendor: Xen Virtualization type: none [root@ovs ~]# cd /OVS/Repositories/*/VirtualMachines [root@ovs VirtualMachines]# grep cpus 0004fb0000060000cf08a173c50efdc1/vm.cfg maxvcpus = 4 vcpus = 4 cpus = '0-3‘ # '2,3'
Oracle VM Manager console 22 © 2018 Pythian
VirtualBox VMs (type 2) • Run on any OS (Linux, Windows, Mac) • Download binaries for your platform • How to create your Oracle VM? – a) Download OS ISO+ Oracle binaries Create VM, boot from ISO, install OS + DB, create DB – b) Download VM template - all pre(installed/configured) http://www.oracle.com/technetwork/community/developer-vm/index.html – c) use tools to automate a) • Several github repos available (details later) • Allows to customize your VM and create your own template 23 © 2018 Pythian
Example – Oracle DB using Vbox © 2015 Pythian Confidential24
25
CLI tools • VBox: VBoxManage post creation steps? • Docker: dockerfile – ENTRYPOINT – commands to execute when container is run – CMD – provide default parameters for ENTRYPOINTS or executing an ad-hoc command 26 C:Program FilesOracleVirtualBox> ./VBoxManage list vms "Oracle DB Developer VM" {6f3d3706-a84d-4163-9bf7-14da26393179} "oracle-OEL69" {2b835d64-f868-44d8-88e9-9f214dd2fb7d} "oel68-asm2" {e4d7eb54-2159-4398-a49a-3c2ccfe3cc86} "oel68-asm1" {bc5e8bc7-3e15-47a1-b81c-2d7bca77b7dd} "ora12c-si-asm-oel682" {a7318e8a-5b6d-496f-992c-46f84108d345} "ora12c-si-asm-oel681" {19e74473-bb07-423d-914c-354dc94d6b61} "default" {fbe05e1e-3c50-4f8f-ba29-6a795a56bdc8} © 2018 Pythian
Automation tools Vagrant (from HashiCorp) - Manage VMs with a standard workflow - Out of the box with support for VirtualBox, Hyper-V, and Docker - Uses CLI (Vbox, Vmware, Docker) to manage lifecycle - Handles CLI parameters accordingly with their different versions - Automatic ssh setup, etc - Configuration files, providers, plugins - Use case: few local VMs - Runs on any OS – Linux, Windows, Mac 27 Ansible (from RedHat) • Automation tool using a simple configuration language • Agentless, uses OpenSSH and WinRM • Provisioning, configuration management and workload orchestration • Available on Linux and Mac Terraform (from HashiCorp) • Build infrastructure, complex sets, local and remote using simple language • Runs on any OS © 2018 Pythian
Vagrant 28 $ vagrant init hashicorp/precise64 $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'hashicorp/precise64'... ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Waiting for machine to boot... $ vagrant ssh vagrant@precise64:~$ _ Install latest binaries: https://www.vagrantup.com/downloads.html OS Images - Called box: used to create your VM. - Public catalog: https://app.vagrantup.com/boxes/search - or create your own, or use from any URL Vagrantfile - Configuration and provisioning steps - Ruby syntax - Created with defaults using init Simple example: creating a VM based on precise64 image (Ubuntu 12.04 64- bit) from their public catalog © 2018 Pythian
Vagrant Provisioning: execute steps after it is running - part of initial up process, or called manually - Built-in types: Shell, Ansible, Chef, Docker, Puppet, Salt, … Sample Vagrantfile using a shell provisioner Providers: virtual machine to manage - Out of the box for: VirtualBox (default), Docker, Hyper-V - More can be installed as plugins: Vmware, Custom 29 © 2018 Pythian Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello, World" end
Vagrant - commands 30 D:GitHub>vagrant box list bento/oracle-6.9 (virtualbox, 201801.02.0) kikitux/oracle6-racattack (virtualbox, 16.01.01) oravirt/ol67 (virtualbox, 20170424) oravirt/ol68 (virtualbox, 20170418) oravirt/ol72 (virtualbox, 20170425) D:GitHub>vagrant Usage: vagrant [options] <command> [<args>] box manages boxes: installation, removal, etc. init initializes a new Vagrant environment by creating a Vagrantfile validate validates the Vagrantfile up starts and provisions the vagrant environment provision provisions the vagrant machine push deploys code in this environment to a configured destination port displays information about guest port mappings status outputs status of the vagrant machine connect connect to a remotely shared Vagrant environment suspend suspends the machine resume resume a suspended vagrant machine halt stops the vagrant machine destroy stops and deletes all traces of the vagrant machine reload restarts vagrant machine, loads new Vagrantfile configuration snapshot manages snapshots: saving, restoring, etc. ssh connects to machine via SSH powershell connects to machine via powershell remoting rdp connects to machine via RDP
Ansible • Install binaries in a control machine (Windows not supported) • No agent – uses ssh to connect to remote machines • Inventory to define machines to use - /etc/ansible/hosts • Playbook: language used for configuration, deployment, and orchestration – YAML format – tags and actions to execute – conditional control: when, loop, until – this is the main code to keep under source control • Modules describing resources and desired state – Created by us or built-in modules: http://docs.ansible.com/modules_by_category.html – Can be executed directly or inside playbooks 31 © 2018 Pythian
Ansible playbooks Sample playbook – playbook.yml To execute it: 32 - hosts: webservers remote_user: root tasks: - name: ensure apache is at the latest version yum: name: httpd state: latest - name: write the apache config file template: src: /srv/httpd.j2 dest: /etc/httpd.conf $ ansible-playbook playbook.yml © 2018 Pythian
Oracle VBox VMs using Vagrant/Ansible (1) Repository with several configurations: https://github.com/oravirt/ Example for single instance: vagrant-vbox-si-asm  Customization explained: ${INST_DIR}/README.md  Code to change: o vagrant-vbox-si-asmhosts.yml: o vagrant-vbox-si-asmextra-provisionansible-oraclegroup_vars  Copy binary files from OTN - ${INST_DIR}vagrant-vbox-si-asmswrepo 33 basename_vm: ora12c-si-asm-oel68 num_vm: 2 base_priv_ip: 172.16.56.30 # (your chosen IP) oracle_install_version_gi: 12.1.0.2 oracle_version_db: 12.1.0.2 © 2018 Pythian
Oracle VBox VMs using Vagrant/Ansible (2) To create the VM without installing Oracle: To install Oracle after the VM is created: All together: 34 D:GitHubvboxsi2vagrant-vbox-si-asm>vagrant provision ==> oel68-asm1: Running provisioner: ansible_local... Vagrant has automatically selected the compatibility mode '2.0' according to the Ansible version installed (2.2.1.0). … PLAY [all] ********************************************************************* TASK [setup] ******************************************************************* ok: [oel68-asm1] TASK [init : Install packages] ************************************************* ok: [oel68-asm1] => (item=[u'ntp', u'dnsmasq']) … $ vagrant up $ setup=true ; vagrant up © 2018 Pythian
Oracle VBox VMs using Vagrant/Ansible DEMO time More step-by-step examples: - Oracle Standby 12c using vagrant-vbox-si-asm: http://databaseindex.blogspot.com/2018/02/crear-oracle-standby-12c-usando.html - Oracle 12c VM on Windows 10 using ubuntu shell (WLS) and ansible: http://databaseindex.blogspot.com/2018/03/oracle-12c-vagrant-windows-wls-ubuntu.html 35 © 2018 Pythian
Oracle RAC VBox VMs • Similar approach: https://github.com/racattack/racattack-ansible-oracle • Implements configuration described in RAC Attack handbook: https://en.wikibooks.org/wiki/RAC_Attack_-_Oracle_Cluster_Database_at_Home/RAC_Attack_12c • Customization explained in project readme (README.md) on Vagrantfile: step-by-step example on Windows: http://databaseindex.blogspot.com/2017/04/automatizar-instalacion-de-oracle-rac.html 36 © 2018 Pythian ############################# ##### BEGIN CUSTOMIZATION ##### ############################# #define number of nodes num_APPLICATION = 0 num_LEAF_INSTANCES = 0 num_DB_INSTANCES = 1 #define number of cores for guest num_CORE = 1 #define memory for each type of node in MBytes memory_APPLICATION = 1500 memory_LEAF_INSTANCES = 2300 memory_DB_INSTANCES = 3072
Oracle RAC with Docker As pointed earlier: https://github.com/oracle/docker-images/tree/master/OracleDatabase/RAC Several containers needs to be created: - OracleConnectionManager: bind single port to host and serve containers on different ports - OracleRACStorageServer: Oracle ASM on NFS Server for RAC testing - OracleRealApplicationClusters: RAC instance, minimum two Several steps for each container. 37 © 2018 Pythian
VMs in Oracle Cloud • Infrastructure services – Database Cloud Service (DBCS): all managed, pre-built configurations – Compute (OCI or OCI-C): install DB manually as in VirtualBox – Bare Metal and BYOH (OCI): entire server, can install OVM or use as Compute • Container services • Automation – Terraform for OCI and OCI-C – Orchestration for OCI-C – REST API Upcoming example – already in my other session about that topic 38 © 2018 Pythian
Example: OCI Instance using Terraform • Download Terraform binary (my example uses v0.11.3) – https://www.terraform.io/downloads.html • Download Terraform OCI-provider (using v2.1.0) – https://github.com/oracle/terraform-provider-oci/releases • Create .tf HCL Project (based on examples): – https://github.com/oracle/terraform-provider-oci/tree/master/docs/examples • Configure your account Access (env-vars.ps1) – Tenancy and user OCIDs, fingerprint, private key, region • Terraform Plan • Terraform Apply • Step by step guide: https://community.oracle.com/docs/DOC-1019936 39 © 2018 Pythian
ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI/$ ls block.tf compute.tf env-vars.ps1 outputs.tf userdata datasources.tf network.tf provider.tf remote-exec.tf variables.tf ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI$ cat /mnt/c/users/calero/AppData/Roaming/terraform.rc providers { oci = "d:softterraform-provider-oci_v2.1.0.exe" } 40 © 2018 Pythian PS D:GitHubterraform-OCI> cat ./env-vars.ps1 $env:TF_VAR_tenancy_ocid="ocid1.tenancy.oc1..aaaaaaaaw5hodl4pajmymyo62bwkj4kokziowmjkvj7fvmgt4lqia3yg7km" $env:TF_VAR_user_ocid="ocid1.user.oc1..aaaaaaaaiyhrscq7rhfiyhrscql4tb3ojto2ysw72l656yknkyqau2lxotqf" $env:TF_VAR_compartment_ocid="ocid1.compartment.oc1.. aaaaaaaakdevdha7q7yjdheridcy63sgv2syefv7x46u67jk4hj" $env:TF_VAR_region="us-ashburn-1“ $env:TF_VAR_fingerprint="db:a3:b8:59:ce:05:ff:78:c0:fb:aa:ca:d7:09:77:ad" $env:TF_VAR_private_key_path="C:Userscalero.ocioci_api_key.pem" ### Public/private keys used on the instances $env:TF_VAR_ssh_public_key = Get-Content C:Userscalero.sshid_rsa.pub -Raw $env:TF_VAR_ssh_private_key = Get-Content C:Userscalero.sshid_rsa -Raw PS D:GitHubterraform-OCI> ./env-vars.ps1
ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI$ cat compute.tf resource "oci_core_instance" "DemoInstance" { availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[0],"name")}" compartment_id = "${var.compartment_ocid}" display_name = "Demo-Instance" image = "${lookup(data.oci_core_images.OLImageOCID.images[0], "id")}" shape = "${var.InstanceShape}" subnet_id = "${oci_core_subnet.SN-DemoSubnetAD1.id}" metadata { ssh_authorized_keys = "${var.ssh_public_key}" user_data = "${base64encode(file(var.InstanceBootStrap))}" } } ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI/demo$ cat provider.tf provider "oci" { tenancy_ocid = "${var.tenancy_ocid}" user_ocid = "${var.user_ocid}" fingerprint = "${var.fingerprint}" private_key_path = "${var.private_key_path}“ region = "${var.region}" } 41 © 2018 Pythian
42 © 2018 Pythian
43 © 2018 Pythian
© 2015 Pythian Confidential44 PS D:GitHubterraform-OCI> d:softterraform graph | dot -Tpng -o demo-graph.png
Terraform apply © 2015 Pythian Confidential45
Summary Comparing options to create an Oracle instance using dataguard (2 VMs) Notes: * host CPU can be shared among VMs but performance will be impacted. Use 1 CPU per VM for prod ** only as described in MOS 2216342.1 - SI on OEL7 with UEK4 or RHEL7 as of July 2018 *** once familiar with the tool and concepts 46 Solution Host OS Disk space CPU min. License Creation effort Production support OVM OVM 2xVM+ 1 (*) VM CPUs Medium yes VirtualBox any 2xVM 1 (*) Entire host Easy (***) no Docker any 1xVM+ 1 (*) Entire host Easy (***) yes (**) Cloud any 2xVM 1 (*) VM shape Easiest yes © 2018 Pythian
References - documentation • Virtualization concepts: https://en.wikipedia.org/wiki/X86_virtualization • Docker documentation: https://docs.docker.com/ • Oracle database on Docker – github project: https://github.com/oracle/docker-images • VirtualBox user guide: https://www.virtualbox.org/manual/ch01.html • Oracle VM documentation: https://www.oracle.com/technetwork/documentation/vm-096300.html • Vagrant documentation: https://www.vagrantup.com/intro/index.html • Ansible user guide: https://docs.ansible.com/ansible/latest/user_guide/index.html • Terraform documentation: https://www.terraform.io/intro/index.html 47 © 2018 Pythian
THANK YOU Questions? 48 calero@pythian.com @ncalerouy http://www.linkedin.com/in/ncalero © 2017 Pythian

Practical guide to Oracle Virtual environments

  • 1.
    Practical guide toOracle Virtual environments ODC Tour Latin America – August 2018 Nelson Calero
  • 2.
    Today’s topics •Virtual environments review – Docker – Oracle VirtualBox – Oracle VM – Oracle Cloud • Automation – Vagrant – Ansible – Terraform • Examples – VirtualBox VMs using Vagrant/Ansible – Docker on Windows – RAC using VirtualBox and Docker – Terraform for Oracle Cloud instances 2 © 2018 Pythian Motivation Explore alternatives to create database environments Intended audience DBAs and Developers
  • 3.
    • Database Consultantat Pythian since 2014 • Working with Oracle tools and Linux environments since 1996 • DBA Oracle (2001) & MySQL (2005) • Co-founder and President of the Oracle user Group of Uruguay (2009) • LAOUC Director of events (2013) • Computer Engineer (1998) • Oracle ACE (2014), Oracle ACE Director (2017) • Oracle Certified Professional 10g/11g/12c, OCE, Cloud DB & Infra • Amazon Solutions Architect – Associate (2016) • Google Cloud Architect (2017), Google Cloud Data Engineer (2017) • Oracle University Instructor (2011) • Blogger and speaker: Oracle Open World, Collaborate, OTN Tour, Regional conferences About me 3 © 2018 Pythian http://www.linkedin.com/in/ncalero @ncalerouy
  • 4.
    Pythian overview © 2015Pythian Confidential4 • 22 Years of data infrastructure management consulting • 250+ Top brands • 11800+ Systems under management • 400+ employees in 35 countries • 10 Oracle ACEs, 4 ACED, 3 OakTable members, 2 OCM, 6 Microsoft MVPs, 1 Cloudera Champion of Big Data, AWS Certified Solutions Architect – 2 Professional, 12 Associate • Oracle, Microsoft, MySQL, Hadoop, Cassandra, MongoDB, and more • Infrastructure, Cloud, DevOps, and application expertise
  • 5.
    5 © 2018Pythian
  • 6.
    Introduction to Virtualenvironments 6 KVM, Oracle VM, VirtualBox, … LXC, WPAR, Docker, … Sharing server resources isolating processes https://docs.docker.com/get-started/
  • 7.
    Introduction to Virtualenvironments • Hypervisors (Server virtualization) – Type 1: run directly in host’s hardware • Xen, Oracle VM, Hyper-V, Vmware ESX, KVM, … – Type 2: run on a OS (host) • VMware Workstation, VirtualBox, QEMU, … • Containers (OS virtualization) – Share OS kernel and libraries – LXC, Docker – MOS 2216342.1 Oracle Support for Database Running on Docker  Supported SI on Oracle Linux 7 with UEK4 (and later) or RHEL7 7 © 2018 Pythian
  • 8.
    Not only servervirtualization • Data virtualization – Delphix, … • Storage snapshots (vendor based) – SMO, NetAPP, Oracle ACFS, .. – gDBClone – clone databases based on ACFS snapshots http://www.oracle.com/technetwork/indexes/samplecode/gdbclone-download-2295388.html • Cloud provisioning – Compute instances – managed hypervisor – Bare Metal – bring your own hypervisor (only on new OCI, not classic) – Containers – as managed services or DIY in BM 8 © 2018 Pythian
  • 9.
    Today’s focus: VMsand containers 9 © 2018 Pythian
  • 10.
    Containers with Docker 10 •Creates process with access to same OS binaries and resources from the host, executing programs in isolation as if they were inside a VM • Runs on any OS - Download latest binary from https://www.docker.com - On Windows it creates a VirtualBox VM to execute containers inside it  VM needs CPU, disk and RAM adjustments to be useful • Commands: - docker-machine: manage machines running Docker (Windows/Mac before v1.12) - docker o build: Build an image from a Dockerfile o run: Run a command in a new container o exec: Run a command in a running container © 2018 Pythian
  • 11.
    Docker – commandline Windows – control VM status 11 D:>docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v18.01.0-ce Management Commands: checkpoint Manage checkpoints config Manage Docker configs container Manage containers image Manage images network Manage networks node Manage Swarm nodes plugin Manage plugins secret Manage Docker secrets service Manage services stack Manage Docker stacks swarm Manage Swarm system Manage Docker volume Manage volumes D:>docker Commands: attach Attach local standard input, output, and error streams to a running contain build Build an image from a Dockerfile commit Create a new image from a container's changes cp Copy files/folders between a container and the local filesystem create Create a new container deploy Deploy a new stack or update an existing stack diff Inspect changes to files or directories on a container's filesystem events Get real time events from the server exec Run a command in a running container export Export a container's filesystem as a tar archive history Show the history of an image images List images import Import the contents from a tarball to create a filesystem image info Display system-wide information inspect Return low-level information on Docker objects kill Kill one or more running containers load Load an image from a tar archive or STDIN login Log in to a Docker registry logout Log out from a Docker registry logs Fetch the logs of a container pause Pause all processes within one or more containers port List port mappings or a specific mapping for the container ps List containers ...
  • 12.
    Docker – configuration 12 Dockerfile– instructions to execute when a container starts FROM oraclelinux:7-Slim # Pull base image … USER Oracle RUN $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE EE … CMD exec $ORACLE_BASE/$RUN_FILE Base image usually are OS images, not including Oracle binaries (license restriction) Exception: Oracle provided images: - Docker Store: https://store.docker.com/images/oracle-database-enterprise-edition - Oracle Container Registry: https://container-registry.oracle.com Useful github repositories: – https://github.com/oracle/docker-images/OracleDatabase - RAC and Single instance – https://github.com/Seth-Miller/12c-rac-docker - pioneer RAC configuration © 2018 Pythian
  • 13.
    Docker – creatinga container 13 Install github repository D:GitHub>git clone https://github.com/oracle/docker-images.git Cloning into 'docker-images'... remote: Counting objects: 7740, done. remote: Compressing objects: 100% (36/36), done. rRemote: Total 7740 (delta 18), reused 45 (delta 16), pack-reused 7688 Receiving objects: 100% (7740/7740), 9.70 MiB | 870.00 KiB/s, done. Resolving deltas: 100% (4286/4286), done. Checking connectivity... done. Checking out files: 100% (968/968), done. Create the container (11.2.0.2 XE, 12.1.0.2 or 12.2.0.1 EE or SE as of March 2018): D:GitHub12.1.0.2/…>docker build -t oracle/database:12.1.0.2-ee -f Dockerfile.ee . Download Oracle installation files from OTN: • http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html • Copy to directory D:GitHubdocker-imagesOracleDatabasedockerfiles12.1.0.2 © 2018 Pythian
  • 14.
    Docker – creatinga container 14 Start the container (Windows example): D:>docker run --name ora121 -p 1521:1521 -p 5500:5500 -e ORACLE_SID=orcl -e ORACLE_PDB=pdb1 -e ORACLE_PWD=Oracle_123 -e ORACLE_CHARACTERSET=AL32UTF8 -v //c/users/calero/.docker/persistentdisk/ora121://opt/oracle/oradata oracle/database:12.1.0.2-ee Status of running containers D:>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2c1afcad6a50 oracle/database:12.1.0.2-ee "/bin/sh -c 'exec $O…" 11 hours ago Up 11 hours (healthy) 0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp ora121 Status D:>docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 12.1.0.2-ee c175ddb41772 4 minutes ago 10.6GB oraclelinux 7-slim 9870bebfb1d5 2 months ago 118MB © 2018 Pythian
  • 15.
    Docker – connectingto Oracle 15 Using sqlplus binary from container Connect to database running in container – using host Oracle client D:>docker-machine ip 192.168.99.100 C:Userscalero>sqlplus system/Oracle_123@"192.168.99.100:1521/orcl" SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 4 01:51:50 2018 ... Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options D:>docker exec -ti 2c1afcad6a50 sqlplus pdbadmin/Oracle_123@pdb1 SQL*Plus: Release 12.1.0.2.0 Production on Sun Feb 4 16:23:47 2018 ... Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options © 2018 Pythian
  • 16.
    Docker - imagesfrom container-registry Register in container-registry.oracle.com Start session Download image Step by step guide: 16 D:>docker login container-registry.oracle.com Username: nelson.calero@gmail.com Password: xxx Login Succeeded D:>docker pull container-registry.oracle.com/database/enterprise:12.2.0.1 12.2.0.1: Pulling from database/enterprise 9bd4d110366e: Downloading [> ] 2.668MB/143MB af8b29651e27: Download complete http://databaseindex.blogspot.com/2018/04/oracle-12c-docker-windows-ocr.html © 2018 Pythian
  • 17.
    Example – OracleDB using Docker Image Check local images 17 D:>docker images REPOSITORY TAG IMAGE ID CREATED SIZE container-registry.oracle.com/database/enterprise 12.2.0.1 12a359cd0528 5 months ago 3.44GB Define image settings D:>echo DB_MEMORY=1Gb >ora.conf Start the container D:>docker run -d -it --name ora122 -P --env-file ora.conf container-registry.oracle.com/database/enterprise:12.2.0.1 5896d37c1cae083c9ab82ec52cf9900a3b22a012b5257c1cb065a6093d7d55c5 Check running containers D:>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 5896d37c1cae container-registry.oracle.com/database/enterprise:12.2.0.1 "/bin/sh -c '/bin/ba…" 24 minutes ago Up 24 minutes (healthy) 0.0.0.0:32769->1521/tcp, 0.0.0.0:32768->5500/tcp ora122
  • 18.
    Summary – OracleDB using Docker Using images with preinstalled Oracle binaries - Docker Store - Container registry Step-by-step: http://databaseindex.blogspot.com/2018/04/oracle-12c-docker-windows-ocr.html Using Oracle github repository, must download binaries from OTN - Step-by-step example on Windows 10: http://www.oracle.com/technetwork/es/articles/datawarehouse/oracle12c-docker-win10-4485487-esa.html More examples: - Standby: https://github.com/jamesattard/oracle-xe-docker - RAC: https://github.com/Seth-Miller/12c-rac-docker https://github.com/oracle/docker-images/tree/master/OracleDatabase/RAC 18 © 2018 Pythian
  • 19.
    Docker - creatinga container 19 Demo © 2018 Pythian
  • 20.
    Hypervisors – OracleVM (type 1) • Xen Kernel – UEK R4 as of July 2018 with OVM 3.4.4 • Server needs to boot with it (reinstall needed if other OS was used) • Minimal resources used by OVM server (1 CPU 2Gg RAM) • VMs uses free available server’s resources – can be created from OVS using CLI (xm) or using OVM manager web client – RAM/CPUs can be allocated dynamically without restarting VMs (up to max config) – Only supported method to reduce license costs (hard partitioning) – HA configuration allowed with clustered repositories (using SAN, not with local HDs) – Windows, Linux and Solaris guests • OVM Manager – Needs to be installed in a different server – Uses MySQL as metadata repository 20 © 2018 Pythian
  • 21.
    Oracle VM -examples 21 © 2018 Pythian [root@ovs ~]# xm list Name ID Mem VCPUs State Time(s) 0004fb00000600001000d7829bf5a105 4 30723 4 -b---- 2415636.4 0004fb0000060000cf08a173c50efdc1 2 13063 4 r----- 784876.4 Domain-0 0 1958 20 r----- 1211462.2 [root@ovs /OVS/Repositories]# ls -l */VirtualMachines/*/vm.cfg -rw------- 1 root root 1950 Apr 19 02:37 0004fb00000300005b800c75ea8932be/VirtualMachines/0004fb00000600001000d7829bf5a105/vm.cfg -rw-r--r-- 1 root root 1946 Apr 19 02:36 0004fb00000300005b800c75ea8932be/VirtualMachines/0004fb0000060000cf08a173c50efdc1/vm.cfg [root@ovs ~]# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 20 Hypervisor vendor: Xen Virtualization type: none [root@ovs ~]# cd /OVS/Repositories/*/VirtualMachines [root@ovs VirtualMachines]# grep cpus 0004fb0000060000cf08a173c50efdc1/vm.cfg maxvcpus = 4 vcpus = 4 cpus = '0-3‘ # '2,3'
  • 22.
    Oracle VM Managerconsole 22 © 2018 Pythian
  • 23.
    VirtualBox VMs (type2) • Run on any OS (Linux, Windows, Mac) • Download binaries for your platform • How to create your Oracle VM? – a) Download OS ISO+ Oracle binaries Create VM, boot from ISO, install OS + DB, create DB – b) Download VM template - all pre(installed/configured) http://www.oracle.com/technetwork/community/developer-vm/index.html – c) use tools to automate a) • Several github repos available (details later) • Allows to customize your VM and create your own template 23 © 2018 Pythian
  • 24.
    Example – OracleDB using Vbox © 2015 Pythian Confidential24
  • 25.
  • 26.
    CLI tools • VBox:VBoxManage post creation steps? • Docker: dockerfile – ENTRYPOINT – commands to execute when container is run – CMD – provide default parameters for ENTRYPOINTS or executing an ad-hoc command 26 C:Program FilesOracleVirtualBox> ./VBoxManage list vms "Oracle DB Developer VM" {6f3d3706-a84d-4163-9bf7-14da26393179} "oracle-OEL69" {2b835d64-f868-44d8-88e9-9f214dd2fb7d} "oel68-asm2" {e4d7eb54-2159-4398-a49a-3c2ccfe3cc86} "oel68-asm1" {bc5e8bc7-3e15-47a1-b81c-2d7bca77b7dd} "ora12c-si-asm-oel682" {a7318e8a-5b6d-496f-992c-46f84108d345} "ora12c-si-asm-oel681" {19e74473-bb07-423d-914c-354dc94d6b61} "default" {fbe05e1e-3c50-4f8f-ba29-6a795a56bdc8} © 2018 Pythian
  • 27.
    Automation tools Vagrant (fromHashiCorp) - Manage VMs with a standard workflow - Out of the box with support for VirtualBox, Hyper-V, and Docker - Uses CLI (Vbox, Vmware, Docker) to manage lifecycle - Handles CLI parameters accordingly with their different versions - Automatic ssh setup, etc - Configuration files, providers, plugins - Use case: few local VMs - Runs on any OS – Linux, Windows, Mac 27 Ansible (from RedHat) • Automation tool using a simple configuration language • Agentless, uses OpenSSH and WinRM • Provisioning, configuration management and workload orchestration • Available on Linux and Mac Terraform (from HashiCorp) • Build infrastructure, complex sets, local and remote using simple language • Runs on any OS © 2018 Pythian
  • 28.
    Vagrant 28 $ vagrant inithashicorp/precise64 $ vagrant up Bringing machine 'default' up with 'virtualbox' provider... ==> default: Importing base box 'hashicorp/precise64'... ==> default: Forwarding ports... default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Waiting for machine to boot... $ vagrant ssh vagrant@precise64:~$ _ Install latest binaries: https://www.vagrantup.com/downloads.html OS Images - Called box: used to create your VM. - Public catalog: https://app.vagrantup.com/boxes/search - or create your own, or use from any URL Vagrantfile - Configuration and provisioning steps - Ruby syntax - Created with defaults using init Simple example: creating a VM based on precise64 image (Ubuntu 12.04 64- bit) from their public catalog © 2018 Pythian
  • 29.
    Vagrant Provisioning: execute stepsafter it is running - part of initial up process, or called manually - Built-in types: Shell, Ansible, Chef, Docker, Puppet, Salt, … Sample Vagrantfile using a shell provisioner Providers: virtual machine to manage - Out of the box for: VirtualBox (default), Docker, Hyper-V - More can be installed as plugins: Vmware, Custom 29 © 2018 Pythian Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello, World" end
  • 30.
    Vagrant - commands 30 D:GitHub>vagrantbox list bento/oracle-6.9 (virtualbox, 201801.02.0) kikitux/oracle6-racattack (virtualbox, 16.01.01) oravirt/ol67 (virtualbox, 20170424) oravirt/ol68 (virtualbox, 20170418) oravirt/ol72 (virtualbox, 20170425) D:GitHub>vagrant Usage: vagrant [options] <command> [<args>] box manages boxes: installation, removal, etc. init initializes a new Vagrant environment by creating a Vagrantfile validate validates the Vagrantfile up starts and provisions the vagrant environment provision provisions the vagrant machine push deploys code in this environment to a configured destination port displays information about guest port mappings status outputs status of the vagrant machine connect connect to a remotely shared Vagrant environment suspend suspends the machine resume resume a suspended vagrant machine halt stops the vagrant machine destroy stops and deletes all traces of the vagrant machine reload restarts vagrant machine, loads new Vagrantfile configuration snapshot manages snapshots: saving, restoring, etc. ssh connects to machine via SSH powershell connects to machine via powershell remoting rdp connects to machine via RDP
  • 31.
    Ansible • Install binariesin a control machine (Windows not supported) • No agent – uses ssh to connect to remote machines • Inventory to define machines to use - /etc/ansible/hosts • Playbook: language used for configuration, deployment, and orchestration – YAML format – tags and actions to execute – conditional control: when, loop, until – this is the main code to keep under source control • Modules describing resources and desired state – Created by us or built-in modules: http://docs.ansible.com/modules_by_category.html – Can be executed directly or inside playbooks 31 © 2018 Pythian
  • 32.
    Ansible playbooks Sample playbook– playbook.yml To execute it: 32 - hosts: webservers remote_user: root tasks: - name: ensure apache is at the latest version yum: name: httpd state: latest - name: write the apache config file template: src: /srv/httpd.j2 dest: /etc/httpd.conf $ ansible-playbook playbook.yml © 2018 Pythian
  • 33.
    Oracle VBox VMsusing Vagrant/Ansible (1) Repository with several configurations: https://github.com/oravirt/ Example for single instance: vagrant-vbox-si-asm  Customization explained: ${INST_DIR}/README.md  Code to change: o vagrant-vbox-si-asmhosts.yml: o vagrant-vbox-si-asmextra-provisionansible-oraclegroup_vars  Copy binary files from OTN - ${INST_DIR}vagrant-vbox-si-asmswrepo 33 basename_vm: ora12c-si-asm-oel68 num_vm: 2 base_priv_ip: 172.16.56.30 # (your chosen IP) oracle_install_version_gi: 12.1.0.2 oracle_version_db: 12.1.0.2 © 2018 Pythian
  • 34.
    Oracle VBox VMsusing Vagrant/Ansible (2) To create the VM without installing Oracle: To install Oracle after the VM is created: All together: 34 D:GitHubvboxsi2vagrant-vbox-si-asm>vagrant provision ==> oel68-asm1: Running provisioner: ansible_local... Vagrant has automatically selected the compatibility mode '2.0' according to the Ansible version installed (2.2.1.0). … PLAY [all] ********************************************************************* TASK [setup] ******************************************************************* ok: [oel68-asm1] TASK [init : Install packages] ************************************************* ok: [oel68-asm1] => (item=[u'ntp', u'dnsmasq']) … $ vagrant up $ setup=true ; vagrant up © 2018 Pythian
  • 35.
    Oracle VBox VMsusing Vagrant/Ansible DEMO time More step-by-step examples: - Oracle Standby 12c using vagrant-vbox-si-asm: http://databaseindex.blogspot.com/2018/02/crear-oracle-standby-12c-usando.html - Oracle 12c VM on Windows 10 using ubuntu shell (WLS) and ansible: http://databaseindex.blogspot.com/2018/03/oracle-12c-vagrant-windows-wls-ubuntu.html 35 © 2018 Pythian
  • 36.
    Oracle RAC VBoxVMs • Similar approach: https://github.com/racattack/racattack-ansible-oracle • Implements configuration described in RAC Attack handbook: https://en.wikibooks.org/wiki/RAC_Attack_-_Oracle_Cluster_Database_at_Home/RAC_Attack_12c • Customization explained in project readme (README.md) on Vagrantfile: step-by-step example on Windows: http://databaseindex.blogspot.com/2017/04/automatizar-instalacion-de-oracle-rac.html 36 © 2018 Pythian ############################# ##### BEGIN CUSTOMIZATION ##### ############################# #define number of nodes num_APPLICATION = 0 num_LEAF_INSTANCES = 0 num_DB_INSTANCES = 1 #define number of cores for guest num_CORE = 1 #define memory for each type of node in MBytes memory_APPLICATION = 1500 memory_LEAF_INSTANCES = 2300 memory_DB_INSTANCES = 3072
  • 37.
    Oracle RAC withDocker As pointed earlier: https://github.com/oracle/docker-images/tree/master/OracleDatabase/RAC Several containers needs to be created: - OracleConnectionManager: bind single port to host and serve containers on different ports - OracleRACStorageServer: Oracle ASM on NFS Server for RAC testing - OracleRealApplicationClusters: RAC instance, minimum two Several steps for each container. 37 © 2018 Pythian
  • 38.
    VMs in OracleCloud • Infrastructure services – Database Cloud Service (DBCS): all managed, pre-built configurations – Compute (OCI or OCI-C): install DB manually as in VirtualBox – Bare Metal and BYOH (OCI): entire server, can install OVM or use as Compute • Container services • Automation – Terraform for OCI and OCI-C – Orchestration for OCI-C – REST API Upcoming example – already in my other session about that topic 38 © 2018 Pythian
  • 39.
    Example: OCI Instanceusing Terraform • Download Terraform binary (my example uses v0.11.3) – https://www.terraform.io/downloads.html • Download Terraform OCI-provider (using v2.1.0) – https://github.com/oracle/terraform-provider-oci/releases • Create .tf HCL Project (based on examples): – https://github.com/oracle/terraform-provider-oci/tree/master/docs/examples • Configure your account Access (env-vars.ps1) – Tenancy and user OCIDs, fingerprint, private key, region • Terraform Plan • Terraform Apply • Step by step guide: https://community.oracle.com/docs/DOC-1019936 39 © 2018 Pythian
  • 40.
    ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI/$ ls block.tf compute.tfenv-vars.ps1 outputs.tf userdata datasources.tf network.tf provider.tf remote-exec.tf variables.tf ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI$ cat /mnt/c/users/calero/AppData/Roaming/terraform.rc providers { oci = "d:softterraform-provider-oci_v2.1.0.exe" } 40 © 2018 Pythian PS D:GitHubterraform-OCI> cat ./env-vars.ps1 $env:TF_VAR_tenancy_ocid="ocid1.tenancy.oc1..aaaaaaaaw5hodl4pajmymyo62bwkj4kokziowmjkvj7fvmgt4lqia3yg7km" $env:TF_VAR_user_ocid="ocid1.user.oc1..aaaaaaaaiyhrscq7rhfiyhrscql4tb3ojto2ysw72l656yknkyqau2lxotqf" $env:TF_VAR_compartment_ocid="ocid1.compartment.oc1.. aaaaaaaakdevdha7q7yjdheridcy63sgv2syefv7x46u67jk4hj" $env:TF_VAR_region="us-ashburn-1“ $env:TF_VAR_fingerprint="db:a3:b8:59:ce:05:ff:78:c0:fb:aa:ca:d7:09:77:ad" $env:TF_VAR_private_key_path="C:Userscalero.ocioci_api_key.pem" ### Public/private keys used on the instances $env:TF_VAR_ssh_public_key = Get-Content C:Userscalero.sshid_rsa.pub -Raw $env:TF_VAR_ssh_private_key = Get-Content C:Userscalero.sshid_rsa -Raw PS D:GitHubterraform-OCI> ./env-vars.ps1
  • 41.
    ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI$ cat compute.tf resource"oci_core_instance" "DemoInstance" { availability_domain = "${lookup(data.oci_identity_availability_domains.ADs.availability_domains[0],"name")}" compartment_id = "${var.compartment_ocid}" display_name = "Demo-Instance" image = "${lookup(data.oci_core_images.OLImageOCID.images[0], "id")}" shape = "${var.InstanceShape}" subnet_id = "${oci_core_subnet.SN-DemoSubnetAD1.id}" metadata { ssh_authorized_keys = "${var.ssh_public_key}" user_data = "${base64encode(file(var.InstanceBootStrap))}" } } ncalero@H6RMYZ1:/mnt/d/GitHub/terraform-OCI/demo$ cat provider.tf provider "oci" { tenancy_ocid = "${var.tenancy_ocid}" user_ocid = "${var.user_ocid}" fingerprint = "${var.fingerprint}" private_key_path = "${var.private_key_path}“ region = "${var.region}" } 41 © 2018 Pythian
  • 42.
    42 © 2018Pythian
  • 43.
    43 © 2018Pythian
  • 44.
    © 2015 PythianConfidential44 PS D:GitHubterraform-OCI> d:softterraform graph | dot -Tpng -o demo-graph.png
  • 45.
    Terraform apply © 2015Pythian Confidential45
  • 46.
    Summary Comparing options tocreate an Oracle instance using dataguard (2 VMs) Notes: * host CPU can be shared among VMs but performance will be impacted. Use 1 CPU per VM for prod ** only as described in MOS 2216342.1 - SI on OEL7 with UEK4 or RHEL7 as of July 2018 *** once familiar with the tool and concepts 46 Solution Host OS Disk space CPU min. License Creation effort Production support OVM OVM 2xVM+ 1 (*) VM CPUs Medium yes VirtualBox any 2xVM 1 (*) Entire host Easy (***) no Docker any 1xVM+ 1 (*) Entire host Easy (***) yes (**) Cloud any 2xVM 1 (*) VM shape Easiest yes © 2018 Pythian
  • 47.
    References - documentation •Virtualization concepts: https://en.wikipedia.org/wiki/X86_virtualization • Docker documentation: https://docs.docker.com/ • Oracle database on Docker – github project: https://github.com/oracle/docker-images • VirtualBox user guide: https://www.virtualbox.org/manual/ch01.html • Oracle VM documentation: https://www.oracle.com/technetwork/documentation/vm-096300.html • Vagrant documentation: https://www.vagrantup.com/intro/index.html • Ansible user guide: https://docs.ansible.com/ansible/latest/user_guide/index.html • Terraform documentation: https://www.terraform.io/intro/index.html 47 © 2018 Pythian
  • 48.