Your local development environment: Oracle Database 23ai Free on WSL2

Recently I posted a few tweets about my experience developing on windows. That’s something new to me, typically I’d use either Linux or MacOS. Some of you wanted to know how that went, so … here’s the story.

In preparation for my talk about Continuous Integration/Delivery (CI/CD) and the pending update of my “DevOps with Oracle Database” tech brief I wanted to explore options, and one of them is using a “local development environment on windows”. To this extend I fired up my windows 11/x86-64 system and started this journey.

Installing Windows Subsystem for Linux (WSL2)

I always keep my base operation system as minimalist as possible, things I need are either installed in virtual machines (based on Vagrant), or containers. That way things are less likely to break when I apply security updates. WSL seems to be a nice way to achieve the same goal on windows, so let’s go! By the way, when you read WSL, it’s actually WSL2:

PS> wsl --version
WSL version: 2.3.26.0
Kernel version: 5.15.167.4-1
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4460

WSL is surprisingly well documented, I used the official installation instructions without problems. The first step is to open a powershell (ps) with elevated, admin privileges. Installation of WSL is literally as simple as

wsl --install

A little while later after the mandatory reboot, you’re good to go! The next step is to pick a Linux distribution. As a long time Oracle Linux user, and given that I want to develop an application based on Oracle Database 23ai Free, there really is only one choice. I went with Oracle Linux 9:

wsl --list --online
wsl --install -d OracleLinux_9_1

You are then prompted for a (Linux) username, which I set to oracle. Assign a suitable password and update all the packages:

sudo dnf update -y

That’s it! Next it’s time to prepare the Oracle Linux environment for the database.

Preparing Oracle Database 23ai Free

With the start of your Oracle Linux distribution complete, and all updates applied, it’s time to get serious: install podman, the default container runtime for Oracle Linux 9.

sudo dnf install -y podman

Time to create a database! The following command pulls Oracle Database 23.5 Free from Oracle’s container registry and starts a database. After the initial pull is complete, it takes literally less than 1 minute to have a working database:

export PODMAN_IGNORE_CGROUPSV1_WARNING=true

echo -n "mysupersecretpasword" | podman secret create oracle-secret -
podman network create oracle-net
podman volume create oradata-vol

podman run --detach --volume oradata-vol:/opt/oracle/oradata \
--secret oracle-secret,type=env,target=ORACLE_PWD \
--publish 1521:1521 \
--name some-oracle \
container-registry.oracle.com/database/free:23.5.0.0

Congratulations, you now have a working database in WSL2! Over time, as this post ages, you may want to check for a more recent database release.

Additional Software

I was almost done. Now that Oracle Linux 9 serves an Oracle Database 23ai Free instance what do you do with it? Well, code cool applications of course. The following software worked really well for me, but there are of course many alternatives so feel free to explore! Or give the tools in the following section a go, as long as your choice is compliant with your workplace, works for you, and is fun, you should be good.

Rather than using the somewhat antiquated windows command line prompt cmd.exe there’s a new guy around: windows terminal offers a much enhanced experience. It even supports ohmyzsh themes. Speaking of ohmyzsh: you may want to install zsh and make it your default shell. Note that if you’re using windows server there isn’t a ms store to pull the terminal from. I found the executable in the “release” page on microsoft’s github, downloaded it and used it without problems.

Visual Studio Code seems to be a great choice for developers to interact with WSL. There’s a dedicated WSL extension you to work with WSL as if it were a local file system. Once that is installed, simply type code /path/to/wsl/dir to open the IDE. You can add additional extensions depending on your needs to the local installation. The first one I always install is Oracle’s SQLDeveloper extension for VSCode.

Summary

Installing Oracle Linux 9 on windows finally turns this operating system into a platform worth my while. Here’s a screenshot of my development environment:

A screenshot of VSCode running from my Oracle_Linux_9_1 WSL instance. Podman serves an Oracle Database 23ai Free instance. Life is good

Working with the new configuration has been fun, and the WSL integration into VSCode worked nicely. Whenever I run into problems with the database that appear unrecoverable I have a safe state I can get back to. APEX is also really simple to integrate, I wrote about that topic earlier this year.

Have fun!