Install Oracle Linux 9 and Oracle Database 19c on Windows WSL

Since a few days I’ve a Oracle Database 19c running on my laptop (4 year old i5 processor with 16GB memory) under the Windows Subsystem for Linux with the latest Oracle Linux 9.3. It is working great for testing functionalities. It survives without problem sleep and restart without first shutting down correctly the database.

While there are no snapshot possibility like with Virtualbox, it is possible to export the running image and re-import later.

Below I describe the main steps to quickly install the system.

  1. Download the Oracle Linux 9.3 from Microsoft Store

2. Activate the systemd system and service mananger

sudo su -

echo -e "[boot]\nsystemd=true" >> /etc/wsl.conf


Wait 30 seconds (Microsoft says 8 are enough) and connect again to the WSL

3. Install necessary packages

These will configure Oracle user and groups and and provide the required tools to install and run the database

sudo su -

dnf install -y oracle-database-preinstall-19c
dnf install -y gcc
dnf install -y gcc-c++
dnf install -y compat-openssl11
dnf install -y fontconfig
dnf install -y libasan
dnf install -y liblsan
dnf install -y librdmacm
dnf install -y libvirt-libs
dnf install -y libxcrypt-compat
dnf install -y oracle-epel-release-el9
dnf install -y rlwrap
dnf install -y hostname

4. Make necessary and useful preparations for the Oracle database installation

This includes giving sudo access to the Oracle user and creating the base directories.

# As root user
echo "oracle    ALL=(ALL)    NOPASSWD: ALL" > /etc/sudoers.d/oracle
mkdir /u01
mkdir /u02
chown oracle:oinstall /u01
chown oracle:oinstall /u02

# As Oracle user
su - oracle

# Add info to Bash profile
echo "export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\${ORACLE_BASE}/product/19.0.0/dbhome_1
export TNS_ADMIN=\${ORACLE_HOME}/network/admin
export PATH=\${PATH}:\${ORACLE_HOME}/bin
export ORACLE_SID=mycdb1" >> /home/oracle/.bash_profile

. .bash_profile

5. Download the Oracle Database software and patches

You need:

Unzip ONLY the patch file. This will generate several directories. From those, you need to keep the directories named 35943157 and 35967489. Move those two to the same level as the other zip files. You can delete the rest.

More information about the requirements to install Oracle 19c on Oracle Linux 9 on Oracle Support site.

6. Patch Oracle 19c image with latest patches

This step is required to be able to install correctly on Oracle Linux 9.3. In the commands below I expect the two zip files and two directories to be available under /mnt/c/Users/<user>/Downloads/ .

# As Oracle user


mkdir -p $ORACLE_HOME

# Unzip Base Oracle 19c image

# Update OPatch

# Patch Oracle Home with 19.22
./runInstaller -applyRU ${STAGING_AREA}/35943157 -applyOneOffs ${STAGING_AREA}/35967489

7. Install Oracle 19c (19.22)

# As Oracle user


./runInstaller -ignorePrereq -waitforcompletion -silent   \
    -responseFile ${ORACLE_HOME}/install/response/db_install.rsp  \
    oracle.install.option=INSTALL_DB_SWONLY                       \
    ORACLE_HOSTNAME=$(hostname -f)                                \
    UNIX_GROUP_NAME=oinstall                                      \
    INVENTORY_LOCATION=${ORA_INVENTORY}                           \
    SELECTED_LANGUAGES=en,en_GB                                   \
    ORACLE_HOME=${ORACLE_HOME}                                    \
    ORACLE_BASE=${ORACLE_BASE}                                    \
    oracle.install.db.InstallEdition=EE                           \
    oracle.install.db.OSDBA_GROUP=dba                             \
    oracle.install.db.OSBACKUPDBA_GROUP=backupdba                 \
    oracle.install.db.OSDGDBA_GROUP=dgdba                         \
    oracle.install.db.OSKMDBA_GROUP=kmdba                         \
    oracle.install.db.OSRACDBA_GROUP=racdba                       \
    SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                    \

# Call required scripts as root
sudo /u01/app/oraInventory/
sudo /u01/app/oracle/product/19.0.0/dbhome_1/

# Activate Unified auditing mode
cd $ORACLE_HOME/rdbms/lib
make -f uniaud_on ioracle

8. Configure Listener

# As Oracle user

echo "# listener.ora 
  )" > $ORACLE_HOME/network/admin/listener.ora

echo "# sqlnet.ora

# Network encryption required

cd $ORACLE_HOME/network/admin
sed -i "s/VM_NAME/$(hostname)/g" listener.ora

$ORACLE_HOME/bin/lsnrctl start
$ORACLE_HOME/bin/lsnrctl status

9. Create Database Container and Pluggable database

# as Oracle user


dbca -silent -createDatabase                            \
     -templateName General_Purpose.dbc                  \
     -gdbname ${ORACLE_SID} -sid  ${ORACLE_SID}         \
	 -dbOptions JSERVER:false,DV:false,ORACLE_TEXT:false,IMEDIA:false,CWMLITE:false,SPATIAL:false,OMS:false,APEX:false \
     -sysPassword Welcome_1                             \
     -systemPassword Welcome_1                          \
     -createAsContainerDatabase true                    \
     -numberOfPDBs 1                                    \
     -pdbName orapdb1                                   \
     -pdbAdminPassword Welcome_1                        \
     -totalMemory 2048                                  \
     -memoryMgmtType AUTO_SGA	                        \
     -storageType FS                                    \
     -datafileDestination /u02/app/oracle/oradata       \
	 -recoveryAreaDestination /u02/app/oracle/fast_recovery_area \
	 -recoveryAreaSize 4096                             \
     -emConfiguration NONE                              \
     -ignorePreReqs -sampleSchema true

You can follow the creation on another window under the directory (took about 40 minutes on my laptop):

ls -l /u01/app/oracle/cfgtoollogs/dbca/mycdb1

The output is the following

[WARNING] [DBT-06801] Specified Fast Recovery Area size (4,096 MB) is less than the recommended value.
   CAUSE: Fast Recovery Area size should at least be three times the database size (3,603 MB).
   ACTION: Specify Fast Recovery Area Size to be at least three times the database size.
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
Database Information:
Global Database Name:mycdb1
System Identifier(SID):mycdb1
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/mycdb1/mycdb1.log" for further details.

At the end is the CDB created and running:

export ORACLE_SID=mycdb1

$ sqlplus / as sysdba

SQL*Plus: Release - Production on Sun Mar 10 15:42:07 2024

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release - Production

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ORAPDB1                        READ WRITE NO

10. (optional) Create systemd service to automatic start database

# As root

echo "[Unit]
Description=Oracle Database Service 

#set any limits here

ExecStart=/bin/bash -c '${ORACLE_HOME}/bin/dbstart $ORACLE_HOME'
ExecStop=/bin/bash -c '${ORACLE_HOME}/bin/dbshut $ORACLE_HOME'

[Install]" > /usr/lib/systemd/system/oracle-db.service

systemctl daemon-reload
systemctl enable oracle-db.service

11. Export and save a backup of the WSL image

From a Powershell window (it will stop/kill the WSL instance):

mkdir C:\Users\<user>\Backup\WSL\

wsl --list
wsl --export OracleLinux_9_3 C:\Users\<user>\Backup\WSL\OracleLinux_OracleDB1922.tar
wsl gzip OracleLinux_OracleDB1922.tar

The Zip file is about 6GB in my case.

12. Import backup of WSL image

After unzipping the image from backup, open a Powershell window and run:

 wsl --import OracleLinux9_Oracle1922 C:\Users\<user>\WSL\ C:\Users\<user>\Backup\WSL\OracleLinux_OracleDB1922.tar

Leave a comment

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