Running HANA on a developer machine

So I needed to run SAP HANA for a certain project locally. Actually I wanted to. Because.
Since SAP is doing a great job opening up over the last years, I was not surprised finding a
HANA docker image on dockerhub. However I was unable to instantiate a container with HANA,
since the boot script complained about a non matching kernel version, only kernels 3.x and 4.x would be supported.
Since I am on an LTS release of Ubuntu (20.04), I was somewhat surprised, since I usually go with LTS only to avoid
these kind of situations.

However, now¬† I need to find a solution. I was unable to find a way to “cloak” my kernel version and I felt uncomfortable
manually building an older kernel for my distro. So I decided to go with VirtualBox, which feels like wasting CPU-cycles,
since another kernel needs to be run, but that’s the price.

I decided to start with 16GB of RAM and 4 CPU cores, so I would still have enough resources left on the host system:

I decided to go for Ubuntu Server 18.04 LTS, since the installer comes with a 4.x kernel, we will need to pin that version later.


You can actually launch a second terminal by pressing ALT+F2 to escape the installer and run commands.
Since the installation itself is pretty straight forward, I will not document it here. Just make sure not to enable the docker feature in the
features list. We will install docker-ce later on manually. And, if you like, enable the openSSH server when asked for.

Pinning the kernel

To avoid friendly updates installing a 5.x kernel, I pinned the currently installed kernel with:

$ sudo apt-mark hold $(uname -r)

It should print a list of now pinned packages, look for

linux-headers-4.15.0-128-generic set on hold.
linux-image-4.15.0-128-generic set on hold.
linux-modules-4.15.0-128-generic set on hold.
linux-image-unsigned-4.15.0-128-generic set on hold.
linux-modules-extra-4.15.0-128-generic set on hold.
linux-tools-4.15.0-128-generic set on hold.

Now it should be safe to do updates:

$ sudo apt update && sudo apt upgrade -y

Only a few packages should be updated, keep an eye on kernel updates (which are not supposed to happen).

Installing docker

Now we need to install docker-ce on our new, shiny server:

$ sudo apt-get remove docker docker-engine docker.io containerd runc 
$ sudo apt-get install \ 
apt-transport-https \ 
ca-certificates \ 
curl \ 
gnupg-agent \ 
software-properties-common 
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 
$ sudo add-apt-repository \ 
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ 
$(lsb_release -cs) \ 
stable" 
$ sudo apt-get update && sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose

In a nutshell, this installs the prerequisites, downloads and install the gpg signing key and installs docker-ce along with docker-compose.
Now you will need to login to dockerhub:

$ sudo docker login

If you also run into a SIGSEGV situation, you would need to remove the golang-docker-credential-helpers package as suggested in: https://github.com/docker/cli/issues/2890
To see if your installation of docker was successful, you can run

$ sudo docker run hello-world

It should print you a rough overview of docker. In case that fails, you need to fix it before you continue (and please comment on this post)

Installing HANA

Now it’s time to have a brief look on the installation notes on dockerhub. Summarized what we need to do:
– configure the host operating system
– create folder for host volume
– create initial configuration
– create launcher script (to make it easier to start over)

As said earlier, life is easier if you have enabled the openSSH-server for your new virtual machine, since I feel copy & pasting is easier that way.
After logging in, I was informed 12 packages can be updated, well, let’s do it.
First off, make sure we are not updating to a 5.x kernel by accident, you can check with
$ apt list --upgradable | grep linux
and in my case only another 4.15 kernel is in the update list.
Do not do ‘do-release-upgrade‘ as suggested by the login-banner, but instead just go for sudo apt upgrade.

Host system settings
Now lets edit the /etc/sysctl.conf file and append or edit these values:

fs.file-max=20000000
fs.aio-max-nr=262144
vm.memory_failure_early_kill=1
vm.max_map_count=135217728
net.ipv4.ip_local_port_range=40000 60999

You can apply these settings without reboot by issuing sysctl --system which should also print the values of the variables.

Volume
For the volume I will use a host mounted volume, so it will be easier to integrate it with my existing backup strategy, but of course you could use a different volume strategy. So lets create it with
mkdir ./volumes/hana
and assign the permissions according to the uid and gid used in the container:
chown 12000:79 ./volumes/hana

Initial credentials
In order to create initial credentials in the new system, you need to provide it with a file where the creds can be read from.
So create the file with vim ./volumes/hana/password.json and modify this template according to your needs:

{
"system_user_password" : "HXEHana1",
"master_password" : "HXEHana1",
"default_tenant_system_user_password" : "HXEHana1"
}

Do not forget to chmod 0600 ./volumes/hana/password.json to make sure the file is considered safe by the database and chown 12000:79 ./volumes/hana/passwords.json to set the ownership to the database user.

Leave a Reply

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