You probably already know about the Oracle cloud free tier which include Autonomous Database and 2 VMs for free forever.
Something Id dint know, is that you can actually set a second (or third) database using it thanks to Oracle XE Database and couple of memory tricks.
If you don't know about Oracle XE, please have a look to Tim's blog about it and how to install it in Red-Hat or Oracle Linux:
Oracle Database 18c Express Edition (XE) RPM Installation On Oracle Linux 6 (OL6) and 7 (OL7)
Let's spin up a VM with Oracle-Linux and try
[root@P42 ~]# head -1 /etc/*rel*
==> /etc/oracle-release <==
Oracle Linux Server release 7.8
If you use the VMs coming your free account, you are aware that their limited to 1GB of RAM, which is just the low limit for Oracle XE database installation. Unfortunately, the VMs are actually limited to 970MB, which is bellow the memory limits
[root@P42 ~]# cat /proc/meminfo
MemTotal: 994500 kB
If we just try the installation, we will face the following error:
[root@P42 ~]# yum install oracle-database-xe-18c
---> Package libSM.x86_64 0:1.2.2-2.el7 will be installed
--> Finished Dependency Resolution
Installing:
oracle-database-xe-18c x86_64 1.0-1
[......]
Total download size: 2.4 G
Installed size: 5.2 G
Is this ok [y/d/N]: y
Downloading packages:
(1/32): compat-libcap1-1.10-7.el7.x86_64.rpm | 17 kB 00:00:00
(2/32): compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm | 190 kB 00:00:00]...
[......]
Installing : libstdc++-devel-4.8.5-39.0.3.el7.x86_64 30/32
Installing : oracle-database-preinstall-18c-1.0-1.el7.x86_64 31/32
[SEVERE] Oracle Database 18c Express Edition requires a minimum of 1GB of physical
memory (RAM). This system has 971 MB of RAM and does not meet minimum
requirements.
error: %pre(oracle-database-xe-18c-1.0-1.x86_64) scriptlet failed, exit status 1
[......]
Failed:
oracle-database-xe-18c.x86_64 0:1.0-1
Complete!
[root@P42 ~]#
As you can see, we hit the predicted issue about lack of RAM in the system, however, there is a trick to continue the installation as Kamil showed us on this blog:
How to install Oracle XE 18c in Oracle Cloud Free Tier
The good news is that we got all prerequisites installed, so we only have to focus in the Oracle XE main package.
Let's download the RPM instead of do the installation:
[root@P42 ~]# yum install --downloadonly --downloaddir=/root/ oracle-database-xe-18c
[....]
oracle-database-xe-18c-1.0-1.x86_64.rpm | 2.4 GB 00:02:27
exiting because "Download Only" specified
[root@P42 ~]#
As Kamil mentioned, install rpmrebuild so we can edit the RPM file
[root@P42 ~]# yum install rpmrebuild -y
[......]
Complete!
[root@P42 ~]#
Edit the RPM and change the following Memory restrictions option:
This will take long time to execute, so try to use screen or just make sure you leave your session open
Change the 1024 from that calculation
# Check and disallow install, if RAM is less than 1 GB
space=`cat /proc/meminfo | grep '^MemTotal' | awk '{print $2}'`
PhyMem=`expr $space / 1024`
swapspace=`free -m | grep Swap | awk '{print $4}'`
for a number 100 (for example)
# Check and disallow install, if RAM is less than 1 GB
space=`cat /proc/meminfo | grep '^MemTotal' | awk '{print $2}'`
PhyMem=`expr $space / 100`
swapspace=`free -m | grep Swap | awk '{print $4}'`
This is how I did it and the time it took to complete:
[root@P42 ~]# time rpmrebuild -e -p oracle-database-xe-18c-1.0-1.x86_64.rpm
# Check and disallow install, if RAM is less than 1 GB
space=`cat /proc/meminfo | grep '^MemTotal' | awk '{print $2}'`
PhyMem=`expr $space / 100`
swapspace=`free -m | grep Swap | awk '{print $4}'`
[.....]
Do you want to continue ? (y/N) y
warning: Explicit %attr() mode not applicaple to symlink: /root/.tmp/rpmrebuild.3468/work/root/opt/oracle/product/18c/dbhomeXE/bin/lbuilder
warning: Explicit %attr() mode not applicaple to symlink: /root/.tmp/rpmrebuild.3468/work/root/opt/oracle/product/18c/dbhomeXE/javavm/admin/cbp.jar
[.....]
rk/root/opt/oracle/product/18c/dbhomeXE/precomp/public/SQLCA.COB
warning: Explicit %attr() mode not applicaple to symlink: /root/.tmp/rpmrebuild.3468/work/root/opt/oracle/product/18c/dbhomeXE/precomp/public/SQLCA.H
warning: Explicit %attr() mode not applicaple to symlink: /root/.tmp/rpmrebuild.3468/work/root/opt/oracle/product/18c/dbhomeXE/precomp/public/SQLDA.H
result: /root/rpmbuild/RPMS/x86_64/oracle-database-xe-18c-1.0-1.x86_64.rpm
real 74m0.087s
user 25m58.256s
sys 1m6.120s
[root@P42 ~]#
Now we can install the Software part of the Oracle Database XE using the modified RPM file without issues:
[root@P42 ~]# yum install /root/rpmbuild/RPMS/x86_64/oracle-database-xe-18c-1.0-1.x86_64.rpm
Loaded plugins: langpacks, ulninfo
[......]
To configure Oracle Database XE, optionally modify the parameters in '/etc/sysconfig/oracle-xe-18c.conf' and then execute '/etc/init.d/oracle-xe-18c configure' as root.
Verifying : oracle-database-xe-18c-1.0-1.x86_64 1/1
Installed:
oracle-database-xe-18c.x86_64 0:1.0-1
Complete!
[root@P42 ~]#
Trying to create a new Database will still fail, since we don't have enough memory, but this also have a fix:
[root@P42 ~]# /etc/init.d/oracle-xe-18c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
[WARNING] [DBT-11205] Specified shared pool size does not meet the recommended minimum size requirement. This might cause database creation to fail.
ACTION: Specify at least (383 MB) for shared pool size.
Enter SYS user password:
********
Enter SYSTEM user password:
*********
Enter PDBADMIN User Password:
********
Prepare for db operation
7% complete
Copying database files
8% complete
[WARNING] ORA-00821: Specified value of sga_target 292M is too small, needs to be at least 400M
ORA-01078: failure in processing system parameters
[.....]
Database configuration failed. Check logs under '/opt/oracle/cfgtoollogs/dbca'.
[root@P42 ~]#
Delete the Configuration attempt before you continue:
[root@P42 ~]# /etc/init.d/oracle-xe-18c delete
Deleting Oracle Listener.
Deleting Oracle Database XE.
[.....]
100% complete
Database deletion completed.
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE0.log" for further details.
[root@P42 ~]#
Now we have to edit the installation file /etc/init.d/oracle-xe-18c
Inside this file, we need to change the MEMORY_CONSTRUCT parameter to use the sizes we want to, instead of allow the script to divide the current system memory.
I have set 500M and 400M, but you just need to make sure is at least 400M as we saw in the previous attempt
[root@P42 ~]# diff /etc/init.d/oracle-xe-18c /etc/init.d/oracle-xe-18c.bk
242c242
< MEMORY_CONSTRUCT="-initParams sga_target=500M,pga_aggregate_target=400M"
---
> MEMORY_CONSTRUCT="-initParams sga_target=${sga}M,pga_aggregate_target=${pga}M"
[root@P42 ~]#
We can now create the Database using the normal process just ignore the first warning:
[root@P42 XE]# /etc/init.d/oracle-xe-18c configure
Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:
Confirm the password:
Configuring Oracle Listener.
Listener configuration succeeded.
Configuring Oracle Database XE.
[WARNING] [DBT-11209] Current available memory is less than the required available memory (900MB) for creating the database.
CAUSE: Following nodes do not have required available memory :
Node:P42 Available memory:706.0117MB (722956.0KB)
Enter SYS user password:
*********
Enter SYSTEM user password:
*******
Enter PDBADMIN User Password:
*******
Prepare for db operation
7% complete
Copying database files
[.....]
Creating Pluggable Databases
54% complete
71% complete
Executing Post Configuration Actions
93% complete
Running Custom Scripts
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE26.log" for further details.
Connect to Oracle Database using one of the connect strings:
Pluggable database: P42/XEPDB1
Multitenant container database: P42
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE
[root@P42 ~]#
and voila! you got your Oracle XE Database running
[root@P42 ~]# su oracle
bash-4.2$ . oraenv
ORACLE_SID = [oracle] ? XE
The Oracle base has been set to /opt/oracle
bash-4.2$ sqlplus / as sysdba
SQL*Plus: Release 18.0.0.0.0 - Production on Fri Jun 12 23:12:05 2020
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- -------------- --------------- ------------
2 PDB$SEED READ ONLY NO
3 XEPDB1 READ WRITE NO
SQL>
You can also enable the service to start as soon as the VM is started, like Tim showed us in his blog post.
[root@P42 ~]# systemctl enable oracle-xe-18c
oracle-xe-18c.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig oracle-xe-18c on
[root@P42 ~]# systemctl stop oracle-xe-18c
[root@P42 ~]# ps -ef |grep pmon
root 18465 16407 0 23:08 pts/1 00:00:00 grep --color=auto pmon
[root@P42 ~]#
[root@P42 ~]# systemctl start oracle-xe-18c
[root@P42 ~]# ps -ef |grep pmon
oracle 18137 1 0 23:08 ? 00:00:00 xe_pmon_XE
root 18466 16410 0 23:09 pts/1 00:00:00 grep --color=auto pmon
[root@P42 ~]#
Some you can also do, if you dont want to have the default Oracel XE configuration, you can just use dbca and do a silent installation with whatever options you prefer:
bash-4.2$ /opt/oracle/product/18c/dbhomeXE/bin/dbca -silent -createDatabase -templateName XE_Database.dbc -SysPassword Welcome1 -SystemPassword Welcome1 -gdbName XE -sid XE -ignorePreReqs
[WARNING] [DBT-11209] Current available memory is less than the required available memory (1,312MB) for creating the database.
CAUSE: Following nodes do not have required available memory :
Node:P42 Available memory:636.2578MB (651528.0KB)
[.....]
70% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/opt/oracle/cfgtoollogs/dbca/XE.
Database Information:
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE18.log" for further details.
bash-4.2$
bash-4.2$ /opt/oracle/product/18c/dbhomeXE/bin/dbca -silent -createDatabase
-templateName XE_Database.dbc \
-SysPassword Welcome1 \
-SystemPassword Welcome1 \
-emConfiguration NONE \
-characterSet AL32UTF8 \
-nationalCharacterSet AL16UTF16 \
-automaticMemoryManagement true \
-memoryPercentage 20 \
-databaseType MULTIPURPOSE \
-gdbName XE \
-sid XE \
-ignorePreReqs \
-initParams memory_max_target='453M',memory_target='453M',sga_max_size='453M',sga_target='0M',pga_aggregate_target='0M',pga_aggregate_limit='0M'
Prepare for db operation
10% complete
Copying database files
40% complete
[.....]
Global Database Name:XE
System Identifier(SID):XE
Look at the log file "/opt/oracle/cfgtoollogs/dbca/XE/XE16.log" for further details.
bash-4.2$
The system won't be the fastest, but will allow you to have yet another Database to do tests for free :)
Top comments (0)