Introduction

TimesTen XE on WSL

This blog shows you how to install and use the free TimesTen XE on Windows via the Windows Subsystem for Linux [WSL].

 

What is WSL

Linux distributions on WSL

The Windows Subsystem for Linux [WSL] is part of Windows 10 and 11 that allows Linux ELF executables to run on Windows:

  • WSL 1 uses a compatability layer in the Windows Kernel and can be quite slow
  • WSL 2 uses a full Linux kernel and Linux programs run within a light-weight Hyper-V virtual machine with the personality of a linux distribution
  • Linux programs tend to run much faster on WSL 2 than WSL 1
  • Multiple WSL Linux sessions can run at the same time, for either the same or different Linux distributions

 

 

Why use TimesTen on WSL

Using Linux on Windows

Microsoft WSL makes it quick and easy to test different Linux distributions if you do all of your work on Windows 10 or 11.  WSL also has tight integration between Linux VMs and Windows for files, networking and graphics.

 

 

WSL or VirtualBox for Linux VMs on Windows

VirtualBox and WSL on Windows

At a high level, both Oracle VirtualBox and Microsoft WSL allow Linux to run in VMs on Windows.

Oracle VirtualBox is a type 2 host hypervisor which allows you to run virtual machines for guest operating systems like Windows, macOS, Linux and BSD from host operating systems like Windows, macOS, Linux and Solaris.  VirtualBox is a general purpose solution for using VMs on x8664 machines.

Microsoft WSL is also a type 2 hypervisor, but it only runs Linux guest virtual machines from Windows. However WSL is highly optimized for Windows which allows:

  • Very fast VM startup
  • Simple VM install
  • Simple file and network sharing within a Windows machine

On Windows, TimesTen XE can run on either VirtualBox or WSL as both are great for development and test environments.

 

 

 

 

Install WSL on Windows

It is quite simple to install WSL on Windows 11 or Windows 10 (21H1, 19043.1526+).  Although it is possible to run WSL on Windows 10 version 2004 (Build 19041+), or Windows Server 2019 (version 1709+), they are much harder to install and the functionality is not as good.

I strongly advise upgrading Windows 11 [or Windows 10] with the latest feature and quality upgrades before attempting to install WSL.  This takes time, but it is worth the effort.  Also make sure that your windows machine has sufficient RAM and disk space.   WSL with lots of RAM is as fast as native Linux.  WSL with insufficient RAM and swapping is painfully slow.

For Windows 11, open PowerShell running in administrator mode, just type wsl –install and it will install WSL 2 + download and install Ubuntu 20.04 LTS.  Once Ubuntu 20.04 is working you can use the normal Ubuntu upgrade process to ugrade it to 22.04.

Install WSL on Windows 11

 

The WSL install process for Windows 10 is the same.

Install WSL on Windows 10

Other Linux distributions for WLS are available from the Microsoft Store.

 

 

Install Linux Distributions on WSL

WSL distros

I have tested TimesTen XE with the following Linux distributions on WSL 1 and 2:

  • Ubuntu 16.04, 18.04, 20.04 and 22.04
  • Debian 9, 10 and 11
  • OpenSUSE Leap 42.2 and 15.3
  • OpenSUSE Tumbleweed
  • SUSE Enterprise Linux Server 12 SP5 and 15 SP3
  • Oracle Linux 7.9 and 8.5
  • AOSC OS
  • Arch Linux
  • Kali Linux 2019.2

WSL distros

It is possible to deploy almost any Linux distribution on WLS.  The above were easily available and free.  Linux distributions which are not on Microsoft Store require some extra steps to install. 

Arch Linux on WSL

Arch Linux needed to be installed from GitHub.  The unzip method for Arch was the easiest.

The following shows you how to to install Debian on WSL 2 from Windows 11.

Install Debian from Windows 11

 

The following shows you how to install OpenSUSE Leap on WSL from Windows Server 2019.

Install OpenSUSE Lean on Windows Server 2019

The Windows 11 wsl.exe –install process is simpler than using Add-AppxPackage on Windows Server 2019.

 

 

 

TimesTen XE C runtime library

glibc and libc

TimesTen depends on GNU glibc and will not work on Musl libc.  As Alpine Linux uses libc rarther than glibc, TimesTen XE will not work on Alpine Linux.

 

 

 

TimesTen XE Install

Given a working WSL Linux distribution console, installing TimesTen XE is just the same as installing TimesTen 22.1 on any Linux x8664 machine.

Depending on the Linux distribution, you may first need to install packages such as:

  • unzip
  • libnsl
  • ncurses-compat-libs
  • libxcrypt-compat

 

The following show how to install and use TimesTen XE on Ubuntu Linux.

Copy XE to home directory

The simplest way to prepare to install TimesTen XE on WSL is: 

  • Copy the TimesTen XE ZIP file from the Windows Desktop to the Linux home directory
  • cp /mnt/c/Users/Doug/Desktop/timesten221120.xe.server.linux8664.zip .

 

 

Unzip TimesTen XE

  • Unzip timesten221120.xe.server.linux8664.zip to create the TimesTen XE Installation

 

 

ttInstallCheck

  • Once the unzip has completed, run the ttInstallationCheck script to verify that all of the required files are present with the correct permissions
  • If ttInstallationCheck fails, download TimesTen XE again

 

 

Then create an instance via ttInstanceCreate.

ttInstanceCreate

  • The ttInstanceCreate script creates a read/write directory tree called an instance
  • For simplicity, this instance was made a subdirectory of the user home directory
  • The default TimesTen TCP ports [6624 & 6625] were used for the TimesTen main daemon and client listener [TTC_SERVER]
  • The TNS_ADMIN value was not detected in the shell.  It can be set later via ttInstanceModify
  • The TimesTen main daemon is now running

The whole unzip and instance creation process should take only a few minutes depending on how fast your machine’s disks are.

 

 

Create a TimesTen XE database

To create a TimesTen XE database, first define the critical attributes in the sys.odbc.ini file.

  • cd ~/xe/conf
  • vi sys.odbc.ini
  • uncomment the relevant lines in the sys.odbc.ini config file
  • Make sure that a directory exists for the database files for the DataStore attribute

sys.odbc.ini

  • This creates a deliberately tiny database which is able to store 512 MB of data
  • You can modify the PermSize attribute in the sys.odbc.ini file and re-load the database to enable more data to be stored
    • TimesTen XE has a PermSize limit of 16 GB
    • TimesTen 22.1 is only limited by physical RAM. eg multi TB TimesTen 22.1 databases are possible
  • As TimesTen XE is an in-memory database, all of the data needs to be able to fit within the RAM
    • If there is insufficient RAM then Linux will swap and TimesTen XE will have terrible performance
    • With sufficient RAM [and perferably with huge pages configured], TimesTen can have amazing performance

 

Next, you need to set the TimesTen XE environment within WSL via ttenv.sh.

ttEnv

  • cd ~/xe/bin
  • The ttenv.sh [or ttenv.csh] script sets the TimesTen environment:
    • TIMESTEN_HOME
    • PATH
    • LD_LIBRARY_PATH
    • CLASSPATH
    • TNS_ADMIN

 

 

Then use ttIsql to create the database.

ttIsql on wsl

  • There is no create database statement for TimesTen
  • Connecting to a database which does not yet exist will create the database as a side effect
  • By default, connecting to the database will load the database into RAM and after the last disconnection it will unload the database from RAM
  • For large databases this loading/unloading from RAM can be time consuming, so the database can be made to reside in RAM independent of database connections via the ttAdmin ramPolicy

 

 

TimesTen XE SQL APIs

TimesTen XE SQL APIs

  • TimesTen XE supports the same SQL APIs as TimesTen 22.1
  • TimesTen SQL APIs that are OCI or ODPI-C based use the same drivers as Oracle Database 19c

 

 

TimesTen Direct Linked Connections

Direct Linked nad Client/Server connections

TimesTen XE supports two types of database connections for all of its SQL APIs:

  • Direct Linked Connections
  • Client Server connections

 

Direct Linked connections are really fast:

  • TimesTen XE uses shared memory to store data in tables and indexes
  • Linux shared memory allows multiple different Linux processes to access the same memory address space
  • The various different TimesTen multi-threaded daemons all use the same [shared] memory address space
  • When an application is on the same machine as the TimesTen database, it can also access the TimesTen XE shared memory
  • The TimesTen XE direct linked SQL APIs are the mechanism to access the TimesTen XE shared memory
  • Direct Linked SQL connections do not require any context switches in the Linux kernel
  • TimesTen XE direct Linked SQL APIs enable SQL round trip times of a few microseconds

 

Client Server connections are a lot slower:

  • Most databases only support TCP/IP connections
  • TimesTen XE SQL APIs can also use TCP/IP sockets to communicate with the TimesTen database
  • TCP/IP sockets are significantly slower than using shared memory
    • The Linuk kernel needs to do context switches when it sends and receives messages
    • When the TimesTen XE client is on a different machine that the TimesTen XE database, the TCP network round trip time [RTT] will tend to dominate the SQL access time
  • Client Server connections are more flexible than direct linked connections
    • Direct Linked connections only work on the same machine as the TimesTen XE database
    • Client Server connections can be on the same machine as the TimesTen XE database, or on a set of remote machines

 

TimesTen XE supports both Direct Linked and Client Server connections for all of its SQL APIs. eg:

  • The ttIsql utility is direct linked
  • The ttIsqlCS utility is client server

The TimesTen XE database connect string determines whether a direct linked or client server API is used.

The SQL and PLSQL statements work un-changed with both direct linked and client server connections.

 

 

Use the Linux TimesTen XE client within WSL

You can use the TimesTen XE ttIsqlCS client to communicate with the local TimesTen XE on Windows via TCP/IP.

Use ttIsqlCS for client/server connection over TCP/IP

  • When using WSL 1 the Linux session will use the same IP address as the Windows host as it uses bridged networking
  • When using WSL 2 the Linux VM will use a different IP address than the Windows host as it uses NAT

 

 

Use the Linux client to a remote TimesTen XE server

TimesTen XE can act as a TimesTen client to remote TimesTen servers from within WSL.

remote client server

 

 

Use the TimesTen Windows client to TimesTen XE on WSL

You can use the TimesTen 22.1 Windows client to communicate with TimesTen XE on Windows via TCP/IP.

TimesTen XE Windows client

 

 

 

Learn more about TimesTen XE:

 

More TimesTen XE Blogs

 

 

Summary

  • The Microsoft Windows Subsystem for Linux [WSL] makes it easy to test many different Linux distributions from within Windows 11 or Windows 10
  • A Linux distribution on WSL acts just like Linux on a [fast] VM
  • Using TimesTen XE on WSL is just like using TimesTen XE on any Linux x8664 distribution
  • WSL makes it easy to use TimesTen XE on a Windows 11 or Windows 10 machine

 

 

Disclaimer: These are my personal thoughts and do not represent Oracle’s official viewpoint in any way, shape, or form.