Although you can use AWS RDS service which offers PaaS architectural model of running Oracle database on top of AWS Cloud, due to many limitations (installation type, options selected etc.), many enterprises still prefer using IaaS model, where such restrictions does not exist (e.g. you can install Enterprise Edition of Oracle database, RAC, Data Guard etc).

There is also security concerns as with PaaS model you have less control under your data when comparing it with IaaS or classical on-premises model.

For installing Oracle database on Amazon AWS you can use the following link as a starting point with a few comments/corrections you need to be aware of that I’ll explain later in the article:

https://oracle-base.com/articles/vm/aws-ec2-installation-of-oracle

From the Marketplace I’ve selected Oracle Linux 7 update 6 for x86_64 HVM – OL7.6-x86_64-HVM-2019-01-29 (ami-06e5c2a0f634abeb1) and t2.micro VM which comes with a free tier eligible option.

As t2.micro is equipped with limited resources (1Gb RAM, 1 vCPU) which is not enough to install Oracle Enterprise database, you need to create swap file:

#preallocate 1 Gb space for a swap file 
root@ip-address.ec2.internal:~> fallocate -l 1G /mnt/1GB.swap

#set correct permission
root@ip-address.ec2.internal:~> chmod 600 /mnt/1GB.swap

#set a file as Linux swap area
root@ip-address.ec2.internal:~> mkswap /mnt/1GB.swap

#Enable swap 
root@ip-address.ec2.internal:~> swapon /mnt/1GB.swap

#Verify the swap status
root@ip-address.ec2.internal:~>swapon --show
NAME          TYPE  SIZE USED PRIO
/mnt/1GB.swap file 1024M   0B   -2

To adjust swappines value from the default value of 60 to 10:

root@ip-address.ec2.internal:~> cat /proc/sys/vm/swappiness
60

you can execute the following command:

root@ip-address.ec2.internal:~> sysctl vm.swappiness=10

root@ip-address.ec2.internal:~> vim /etc/sysctl.conf 
vm.swappiness=10

This change is necessary if you want to avoid strange Oracle installation errors due to insufficient memory.

Next step is to download and install Oracle database preinstall rpm package to avoid manually installation of all required packages.

Here I’m providing correct link to the package for 19.3 version of Oracle database:

https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

#downloading Oracle preinstallation package 
ec2-user@ip-address.ec2.internal:~> 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

#local installation of Oracle package 
root@ip-address.ec2.internal:/home/ec2-user> yum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

On the following link you can find setup instructions to prepare your OS for the Oracle software installation:

https://oracle-base.com/articles/12c/oracle-db-12cr1-installation-on-oracle-linux-7

You also need to disable Transparent HugePages (RHEL 6/7, OEL6/7) as that feature is incompatible with Oracle memory management where only static HugePages is allowed.

#check if Transparent Huge Pages feature is enabled:
root@ip-address.ec2.internal:/>cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

#Check the name of default kernel 
root@ip-address.ec2.internal:/>grubby --default-kernel
/boot/vmlinuz-0-rescue-08bcca960bd3419992b8a5f33698258c

#disable using Transparent Huge Pages on the next boot
root@ip-address.ec2.internal:/>grubby --args="transparent_hugepage=never" --update-kernel /boot/vmlinuz-0-rescue-08bcca960bd3419992b8a5f33698258c

#check if  transparent_hugepage is set to never
root@ip-address.ec2.internal:/>grubby --info /boot/vmlinuz-0-rescue-08bcca960bd3419992b8a5f33698258c
index=5
kernel=/boot/vmlinuz-0-rescue-08bcca960bd3419992b8a5f33698258c
args="ro console=ttyS0,115200n8 console=tty0 net.ifnames=0 crashkernel=auto numa=off transparent_hugepage=never"
root=UUID=d5388b06-35e3-435e-8eaf-09a08de83883
initrd=/boot/initramfs-0-rescue-08bcca960bd3419992b8a5f33698258c.img
title=Oracle Linux Server (0-rescue-08bcca960bd3419992b8a5f33698258c with Linux) 7.7

The server must be rebooted for this to take effect, but before reboot, you should be aware that you might loose your data.

Data loss warning

To prevent data loss, before reboot you need to check if your instance is based on Instance store which is temporary block-level storage for an instance or EBS based permanent storage.

Check if instance is using EBS for a root volume

For more details of how to enable HugePages (and disabling Transparent Huge Pages), you can use the following link:

https://oracle-base.com/articles/linux/configuring-huge-pages-for-oracle-on-linux-64

You may also need to allocate more space to your Volume as Oracle installation files for staging and after extraction takes a quite a bit of space.

To do that you need to install the following utility:

#installing cloud-utils-growpart utility
root@ip-ip-address.ec2.internal:/ >yum install cloud-utils-growpart

root@ip-ip-address.ec2.internal:/u01/app/oracle/product/12.2.0.1/dbhome_1>lsblk 
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  40G  0 disk 
└─xvda1 202:1    0  15G  0 part /

root@ip-ip-address.ec2.internal:/u01/app/oracle/product/12.2.0.1/dbhome_1>growpart /dev/xvda 1
CHANGED: partition=1 start=2048 old: size=31455232 end=31457280 new: size=83883999 end=83886047

root@ip-ip-address.ec2.internal:/u01/app/oracle/product/12.2.0.1/dbhome_1>mount | grep xvda
/dev/xvda1 on / type ext4 (rw,relatime,seclabel,data=ordered)

root@ip-ip-address.ec2.internal:/u01/app/oracle/product/12.2.0.1/dbhome_1>resize2fs /dev/xvda1 
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 5
The filesystem on /dev/xvda1 is now 10485499 blocks long.

Instead of using Dropbox, I uploaded Oracle installation binaries directly on the file system in AWS EC2 instance by using scp after which directories for Oracle installations should be created.

#upload Oracle database installation 
user@hostname.com:-> scp -r -i "oracle-test.pem" linuxx64_12201_database.zip ec2-user@ec2-54-166-145-114.compute-1.amazonaws.com:/home/ec2-user

#create required directories
root@ip-address.ec2.internal:/>chown -R oracle:oinstall u01/

oracle@ip-address.ec2.internal:~>mkdir -p /u01/app/oracle/product/12.2.0.1/dbhome_1
oracle@ip-address.ec2.internal:~>mkdir -p /u01/oradata
oracle@ip-address.ec2.internal:~>mkdir -p /u01/software

Additionally, for installing Oracle database I’m not using response file, but GUI (X11 forwarding) instead (easier to debug), as Oracle installation is not something you want to perform every day.

#exporting a display after you setup X11 forwarding and authentifications
export DISPLAY=localhost:10

#starting Oracle installation
oracle@ip-address.ec2.internal:/u01/app/oracle/product/12.2.0.1/dbhome_1>./runInstaller 

Finally you can start the installation (here I’m not going to show every step  like unpacking files, changing permissions etc., just those that differ from the regular installation).

#exporting a display after you setup X11 forwarding and authentifications
export DISPLAY=localhost:10

#starting Oracle installation
oracle@ip-address.ec2.internal:/u01/app/oracle/product/12.2.0.1/dbhome_1>./runInstaller 

After the installation is completed, to start Oracle database, you need to use ssh to connect to AWS cloud.

Assuming you have already downloaded private key file from EC2, and you switch from ec2-user to oracle, you should execute the following steps:

oracle@ip-172-31-33-192.ec2.internal:~>. oraset 
1) orcl
SID? 1
orcl

where “oraset” is my script that setup the following environment variables:

export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1
export TNS_ADMIN=/u01/app/oracle/product/12.2.0.1/dbhome_1/network/admin

plus PATH and LD_LIBRARY_PATH.

oracle@ip-address.ec2.internal:~>lsnrctl start
oracle@ip-address .ec2.internal:~>sqlp
SQL*Plus: Release 12.2.0.1.0 Production on Mon Oct 7 09:47:36 2019
Copyright (c) 1982, 2016, Oracle.  All rights reserved.
Connected to an idle instance.

SYS@orcl> startup
ORACLE instance started.

Total System Global Area  536870912 bytes
Fixed Size		    8622776 bytes
Variable Size		  293604680 bytes
Database Buffers	  230686720 bytes
Redo Buffers		    3956736 bytes
Database mounted.
Database opened.

SYS@orcl> alter system register;	

To connect to your first AWS Cloud Oracle instance, you need to create ssh tunnel.

Normally, you should setup ssh connection type and local port forward in SQL Developer.

How to do that you can find on the following link:

https://www.thatjeffsmith.com/archive/2014/09/30-sql-developer-tips-in-30-days-day-17-using-ssh-tunnels/

On my Linux laptop, SQL Developer ssh connection doesn’t work properly (probably bug in SQL Developer), which is a reason why I need to manually create ssh tunnel and to setup port forwarding in one shot by executing the following command:

user@hostname.com:/Path_to_private_key > ssh -i oracle-private_key.pem -L 1521:ip-address.compute-1.amazonaws.com:1521 ec2-user@ip-address.compute-1.amazonaws.com

Last login: Mon Oct  7 09:47:15 2019 from 46.188.135.62
ec2-user@ip-172-31-33-192.ec2.internal:~>

After that I need to setup connection in SQL Developer that might look like one in the following figure:

SQL Developer connection setup for AWS

Last step is to connect and test if everything is working as expected.

Check if connection is working as expected

Summary:

Having your Oracle database in a AWS Cloud might be beneficial for you to understand Cloud computing and Oracle behavior in the Cloud.

AWS is selected only because it is the most popular widely used Cloud vendor at the moment, but you can use similar steps with other major Cloud vendors.



Get notified when a new post is published!

Loading

Comments

There are no comments yet. Why not start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.