101 Series of Oracle in Google Cloud - Part I : Building ASM and Database

6 min read
Apr 8, 2020 7:18:00 AM

Introduction to Oracle on Google Cloud

About a year ago, I worked on a project with some amazing teammates (Simon Pane and Karun Dutt) to collaborate on a POC to move their Oracle environment into Google Cloud. This series reflects some of the things I learned while working on this project, and provides a guide for testing Oracle in Google Cloud.

Prerequisites and Environment Details

Note: that I am not a licensing expert, so before you do this, make sure you consult with your Google/Oracle Sales representative to be clear about what’s allowed and the costs involved.

Because this is a “101” series, let’s start by logging into Google Cloud. By now you should already have an account in cloud.google.com and installed the Google Cloud SDK. Because I use a Mac, I downloaded it from this location. Then, I logged into my Google Cloud account:

Renes-MacBook-Pro-2:~ rene$ gcloud auth login **********@*****.com

Because I’m using Google Free Tier, there are limitations on disk sizes, instance type, quotas, etc. These are the specifications I used:

  • Google Cloud instance name: rene-ace-test-inst1
  • n1-standard-8 VM: 8 vCPU and 30GB of memory
  • OS: Centos 7
  • ASM Disk: 1 150GB SSD disk, disk group name: DATA
  • Boot Disk: 1 100GB HD disk
  • Network: Default subnet
  • Software: Oracle 19.3 for OHAS and RDBMS
  • Oracle DB SID: DBTEST

Provisioning Google Cloud Resources

First, create the disk to use for ASM. In this case, I used a 150GB SSD disk:

Renes-MacBook-Pro-2:~ rene$ gcloud compute disks create rene-ace-disk-asm1 \ >    --project=oracle-migration \ >    --type=pd-ssd \ >    --size=150GB \ >    --labels=item=rene-ace \ >    --zone=us-central1-c Created [https://www.googleapis.com/compute/v1/projects/oracle-migration/zones/us-central1-c/disks/rene-ace-disk-asm1]. NAME                ZONE           SIZE_GB  TYPE    STATUS rene-ace-disk-asm1  us-central1-c  150      pd-ssd  READY 

Creating the Boot Disk and VM Instance

Create a 100GB HD disk for the boot disk with Centos 7:

Renes-MacBook-Pro-2:~ rene$ gcloud compute disks create rene-ace-inst1-boot-disk \ > --project=oracle-migration \ > --type=pd-standard \ > --size=100GB \ > --zone=us-central1-c \ > --image=centos-7-v20200309 \ > --image-project=centos-cloud  

After creating the ASM disk, create the VM with the boot disk that you just created:

Renes-MacBook-Pro-2:~ rene$ gcloud compute instances create rene-ace-test-inst1 \ >    --project=oracle-migration \ >    --zone=us-central1-c \ >    --machine-type=n1-standard-8 \ >    --subnet=default \ >    --network-tier=PREMIUM \ >    --no-restart-on-failure \ >    --maintenance-policy=TERMINATE \ >    --no-service-account \ >    --no-scopes \ >    --disk=name=rene-ace-inst1-boot-disk,device-name=rene-ace-inst1-boot-disk,mode=rw,boot=yes,auto-delete=yes \ >    --tags=allow-ssh,egress-nat-gce \ >    --labels=item=rene-ace 

Attaching Storage and Accessing the VM

Attach the disk to use for ASM:

Renes-MacBook-Pro-2:~ rene$ gcloud compute instances attach-disk rene-ace-test-inst1 \ >    --disk=rene-ace-disk-asm1 \ >    --device-name=rene-ace-disk-asm1 \ >    --mode=rw \ >    --zone=us-central1-c  Renes-MacBook-Pro-2:~ rene$ gcloud compute ssh rene-ace-test-inst1 --zone=us-central1-c 

Preparing the Operating System

Unless otherwise mentioned, perform all steps as the root user. Now, install the 19c pre-install RPM:

[rene@rene-ace-test-inst1 ~]$ sudo su - [root@rene-ace-test-inst1 ~]# curl -o ./oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm \ >    https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm  [root@rene-ace-test-inst1 ~]# yum -y localinstall ./oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm 

Additional Package Installation and System Updates

You must install some additional packages and update what you have already installed:

[root@rene-ace-test-inst1 ~]# yum -y install wget java-11-openjdk gcc gcc-c++ [root@rene-ace-test-inst1 ~]# yum -y update [root@rene-ace-test-inst1 ~]# yum clean all 

Configuring Swap, HugePages, and Security

Make sure that there is at least 16GB of swap space:

[root@rene-ace-test-inst1 ~]# dd if=/dev/zero of=/swapfile bs=1M count=16384 [root@rene-ace-test-inst1 ~]# mkswap /swapfile [root@rene-ace-test-inst1 ~]# chmod 0600 /swapfile [root@rene-ace-test-inst1 ~]# swapon /swapfile [root@rene-ace-test-inst1 ~]# echo "/swapfile          swap            swap    defaults        0 0" >> /etc/fstab  [root@rene-ace-test-inst1 ~]# echo "transparent_hugepage=never" >> /etc/default/grub [root@rene-ace-test-inst1 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg 

Disable the firewall and change SELINUX to permissive:

[root@rene-ace-test-inst1 ~]# systemctl stop firewalld [root@rene-ace-test-inst1 ~]# systemctl disable firewalld [root@rene-ace-test-inst1 ~]# sed -i.bak '/^SELINUX=/ s/SELINUX=.*/SELINUX=permissive/' /etc/selinux/config 

Next, enable hugepages by changing the value in /etc/sysctl.conf and restarting the VM:

[root@rene-ace-test-inst1 ~]# echo "vm.nr_hugepages=4096" >> /etc/sysctl.conf [root@rene-ace-test-inst1 ~]# shutdown -r now 

Software Installation and Directory Structure

Create the directories for the binaries, the additional OS groups, and update the bash profile:

[root@rene-ace-test-inst1 ~]# mkdir -p /u01/app/19.0.0.0/grid [root@rene-ace-test-inst1 ~]# mkdir -p /u01/app/oracle/product/19.0.0.0/dbhome_1 [root@rene-ace-test-inst1 ~]# usermod -u 54321 -g oinstall -G dba,asmadmin,asmdba,asmoper oracle 

Downloading Binaries and OPatch

Log in as the oracle use and download the latest OPatch using Maris Elsins getMOSpatch:

[oracle@rene-ace-test-inst1 oracle_software]$ java -jar getMOSPatch.jar patch=6880880 platform=226P regexp=.*190.* download=all 

Download Oracle base software using wget from edelivery.oracle.com. Download files V982063-01.zip (ORACLE RDBMS) and V982068-01.zip (ORACLE GI). Unzip the files to the corresponding location and update the OPatch:

[oracle@rene-ace-test-inst1 oracle_software]$ unzip -q ${SWLIB}/V982063-01.zip -d ${ORACLE_HOME} [oracle@rene-ace-test-inst1 oracle_software]$ unzip -q ${SWLIB}/V982068-01.zip -d ${GRID_HOME}

Deploying Oracle Grid Infrastructure

As the root user, install the cvuqdisk:

[root@rene-ace-test-inst1 rpm]# CVUQDISK_GRP=oinstall; export CVUQDISK_GRP [root@rene-ace-test-inst1 rpm]# rpm -iv cvuqdisk-*.rpm 

As the oracle user, run cluvfy pre crsinst to make sure there is nothing missing so that you can successfully install OHAS and ASM. Because this is not a RAC environment, you only need to use ASM.

[oracle@rene-ace-test-inst1 grid]$ ./runcluvfy.sh stage -pre crsinst -n `hostname -s` 

Customizing the Grid Response File and Installation

Modify the response file so that you can use the GI software as a CRS_SWONLY installation:

[oracle@rene-ace-test-inst1 grid]$ sed -i '/^oracle.install.option/ s~oracle.install.option=$~oracle.install.option=CRS_SWONLY~' ${SWLIB}/grid_install.rsp [oracle@rene-ace-test-inst1 grid]$ ${GRID_HOME}/gridSetup.sh -silent -responseFile ${SWLIB}/grid_install.rsp 

When the software installation is complete, run orainstRoot.sh and root.sh as root user. Also, run roothas.pl to setup the HAS stack:

[root@rene-ace-test-inst1 ~]# ${GRID_HOME}/crs/install/roothas.pl [root@rene-ace-test-inst1 ~]# ${GRID_HOME}/bin/crsctl stat res -t 

Configuring ASM and Shared Storage

As the root user, prepare the disks for ASM using UDEV rules:

[root@rene-ace-test-inst1 ~]# ASM_DISK1=`/usr/lib/udev/scsi_id -g -u -d /dev/sdb` [root@rene-ace-test-inst1 ~]# cat > /etc/udev/rules.d/99-oracle-asmdevices.rules <<EOF > KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/\$parent", RESULT=="${ASM_DISK1}", SYMLINK+="oracleasm/asm-disk1", OWNER="oracle", GROUP="dba", MODE="0660" > EOF 

Initializing the ASM Instance and Diskgroup

Create and start the ASM Instance:

[oracle@rene-ace-test-inst1 ~]$ srvctl add asm -d '/dev/oracleasm/*' [oracle@rene-ace-test-inst1 ~]$ srvctl start asm 

Create the ASM diskgroup (DATA):

CREATE DISKGROUP DATA EXTERNAL REDUNDANCY    DISK '/dev/oracleasm/asm-disk1'    ATTRIBUTE       'compatible.asm'   = '19.0.0.0.0',       'compatible.rdbms' = '19.0.0.0.0'; 

Creating the Oracle Database (DBTEST)

As the oracle user, prepare the RDBMS install software response file and install the RDBMS software:

[oracle@rene-ace-test-inst1 ~]$ ${ORACLE_HOME}/runInstaller -silent -waitforcompletion -responseFile ${SWLIB}/db_install.rsp 

Running DBCA and Post-Installation Tuning

Create the database (DBTEST):

[oracle@rene-ace-test-inst1 ~]$ dbca -silent \ >    -createDatabase \ >    -templateName General_Purpose.dbc \ >    -sid ${ORACLE_SID} \ >    -datafileDestination '+DATA' \ >    -storageType ASM \ >    -diskGroupName DATA  

Adjust redo log settings to 128MB and adjust the database to use large pages only, minimize SGA allocations, and adjust file system IO options:

SQL> alter system set USE_LARGE_PAGES=ONLY scope=spfile; SQL> alter system set FILESYSTEMIO_OPTIONS=SETALL scope=spfile; 

Verification and Summary

Stop and restart the database so that the new parameters take effect. Use crs_status.sh to verify the status of the OHAS environment:

[oracle@rene-ace-test-inst1 working]$ ${HOME}/working/crs_status.sh Name                                          Target     State           Server --------------------------------------------------------------------------------------- ora.DATA.dg                                   ONLINE     ONLINE          rene-ace-test-inst1 ora.LISTENER.lsnr                             ONLINE     ONLINE          rene-ace-test-inst1 ora.asm                                       ONLINE     ONLINE          rene-ace-test-inst1 ora.dbtest.db                                 ONLINE     ONLINE          rene-ace-test-inst1 

Now that you have created the Google VM, installed OHAS, and created the Oracle DB, we're set to perform several tasks that I'll be describing in future series posts. I hope this helps expand your understanding of Google Cloud and how to install a database in it.

Note: This was originally published at rene-ace.

Google Cloud Consulting Services

Ready to optimize your use of Google Cloud's AI tools?

On this page

Ready to unlock value from your data?

With Pythian, you can accomplish your data transformation goals and more.