Microsoft SQL Server 2019 on Ubuntu 18.04.x

Officially Microsoft SQL Server 2019 is only available for Ubuntu 16.04 (Xenial) if you read the documentation: https://docs.microsoft.com/nl-nl/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-ver15

Some blogs are saying that the preview can be run on Ubuntu 18.04 as you see here: https://bornsql.ca/blog/does-sql-server-2019-run-on-ubuntu-18-04-lts/

We’re a bit further in time now and SQL Server 2019 is GA and CU3 is all ready released. I’m still wondering that it is still not supported since I did find repositories for older and newer Ubuntu distributions there. Probably I was a bit ahead in time with this post because I found a new article saying that 18.04 is really supported since CU3 and in the meantime CU4 is released!

After installing a new Ubuntu 18.04 through the netboot.iso with the OpenSSH server enabled and the only thing you need to do is:

apt-get install open-vm-tools gnupg software-properties-common
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
apt-get update
apt-get install -y mssql-server
/opt/mssql/bin/mssql-conf setup
systemctl status mssql-server --no-pager

The detailed output of the setup command:

root@sql03:~# /opt/mssql/bin/mssql-conf setup
usermod: no changes
Choose an edition of SQL Server:
  1) Evaluation (free, no production use rights, 180-day limit)
  2) Developer (free, no production use rights)
  3) Express (free)
  4) Web (PAID)
  5) Standard (PAID)
  6) Enterprise (PAID) - CPU Core utilization restricted to 20 physical/40 hyperthreaded
  7) Enterprise Core (PAID) - CPU Core utilization up to Operating System Maximum
  8) I bought a license through a retail sales channel and have a product key to enter.

Details about editions can be found at
https://go.microsoft.com/fwlink/?LinkId=2109348&clcid=0x409

Use of PAID editions of this software requires separate licensing through a
Microsoft Volume Licensing program.
By choosing a PAID edition, you are verifying that you have the appropriate
number of licenses in place to install and run this software.

Enter your edition(1-8): 5
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=2104294&clcid=0x409

The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409

Do you accept the license terms? [Yes/No]:Yes

Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server...

The licensing PID was successfully processed. The new edition is [Standard Edition].
ForceFlush is enabled for this instance.
ForceFlush feature is enabled for log durability.
Created symlink /etc/systemd/system/multi-user.target.wants/mssql-server.service → /lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.
root@sql03:~# systemctl status mssql-server --no-pager
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-03-12 23:03:09 CET; 9s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 3935 (sqlservr)
    Tasks: 139
   CGroup: /system.slice/mssql-server.service
           ├─3935 /opt/mssql/bin/sqlservr
           └─3959 /opt/mssql/bin/sqlservr

Mar 12 23:03:13 sql03 sqlservr[3935]: [158B blob data]
Mar 12 23:03:13 sql03 sqlservr[3935]: [155B blob data]
Mar 12 23:03:13 sql03 sqlservr[3935]: [61B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [96B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [66B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [75B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [96B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [100B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [71B blob data]
Mar 12 23:03:14 sql03 sqlservr[3935]: [124B blob data]

Within minutes you’ve your Microsoft SQL Server 2019 server running with the latest update and when you connect to it with the SQL Server Management Studio and built-in SQL user:

Install sqlcmd

On https://docs.microsoft.com/nl-nl/sql/linux/sql-server-linux-setup-tools?view=sql-server-linux- you can see that the sqlcmd for 18.04 is officially there… Odd! You can install it like:

apt install curl
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
apt-get update
apt-get install mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

After re-login you can execute a query through sqlcmd:

root@sql03:~# sqlcmd -S localhost -U SA -Q 'select @@VERSION'
Password:
                                                                                                                                                                                          
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU3) (KB4538853) - 15.0.4023.6 (X64)
        Mar  4 2020 00:59:26
        Copyright (C) 2019 Microsoft Corporation
        Standard Edition (64-bit) on Linux (Ubuntu 18.04.4 LTS) <X64>

(1 rows affected)

Running Home-Assistant with Docker containers on VIC

We’ve just deployed the Virtual Container Host (VCH) in the previous post. It’s time to run your first real world containers. In this post some containers for home automation will be deployed like Home-Assistant, Mosquitto, Node-RED.

First we deploy a container where you’ll get a GUI to have a view over your container deployment.

docker --tls run -d -p 8282:8282 --name admiral vmware/admiral
Unable to find image 'vmware/admiral:latest' locally
latest: Pulling from vmware/admiral
1c0b69d98c5b: Pull complete
a3ed95caeb02: Pull complete
f1bf54e3bee2: Pull complete
a636bec27aa0: Pull complete
9cf592e78ba2: Pull complete
827165f1c6de: Pull complete
3addb704a0c6: Pull complete
2ca7dc8e087d: Pull complete
e14e9eff31ca: Pull complete
2626a5abb3b1: Pull complete
f2c95f6064e6: Pull complete
Digest: sha256:82474001628fb5043caceb1c3c5a1c4a9b8246a84eddbf95756d46c125c51966
Status: Downloaded newer image for vmware/admiral:latest
390c91691cf551452a4aec72cadc9a420b7e5294a54624167b9ed298e067c043

You can browse now to http://#ip#:8282

Now we’re going to deploy containers with a persitent data volume so you easily update containers without loosing data. Keep in mind that you can’t extend data volumes but they are thin provisioned anyway. So create the persitent  volumes large enough by the beginning.

docker --tls volume create --name home_assistant_user_data --opt capacity=10GB
home_assistant_user_data
 
docker --tls run -d -p 8123:8123 -v home_assistant_user_data:/config -e "TZ=Europe/Amsterdam" --name home-assistant homeassistant/home-assistant
Unable to find image 'homeassistant/home-assistant:latest' locally
latest: Pulling from homeassistant/home-assistant
f49cf87b52c1: Pull complete
a3ed95caeb02: Pull complete
7b491c575b06: Pull complete
b313b08bab3b: Pull complete
51d6678c3f0e: Pull complete
09f35bd58db2: Pull complete
1bda3d37eead: Pull complete
9f47966d4de2: Pull complete
9fd775bfe531: Pull complete
075f8814af41: Pull complete
673b996ea6ee: Pull complete
13b5c6fd54a2: Pull complete
5627f8ac983a: Pull complete
9f49e962349f: Pull complete
69f64c4f5990: Pull complete
Digest: sha256:7e5acf3aba08350a62d2d531a4686bf15404cf29b0a3a68183c2f9c16be46c6d
Status: Downloaded newer image for homeassistant/home-assistant:latest
ca5b04071b24ea42afd51ed75f085520aff008095dcb4b225bd8aeb8b1fac405
 
docker --tls volume create --name node_red_user_data
node_red_user_data
 
docker --tls run -p 1880:1880 -v node_red_user_data:/data --name node-red nodered/node-red-docker
Unable to find image 'nodered/node-red-docker:latest' locally
latest: Pulling from nodered/node-red-docker
85b1f47fba49: Pull complete
a3ed95caeb02: Pull complete
ba6bd283713a: Pull complete
817c8cd48a09: Pull complete
47cc0ed96dc3: Pull complete
8888adcbd08b: Pull complete
6f2de60646b9: Pull complete
1dab1bd0d0d9: Pull complete
44ad4cf8b442: Pull complete
12fcc1c70dac: Pull complete
685330fe9c23: Pull complete
7d10c54dee0f: Pull complete
1fb8963ebd30: Pull complete
c451eb45c214: Pull complete
Digest: sha256:890f93b7f74398c3e77d21603342fc4d0d426e357914f2f10c38884c6d653a91
Status: Downloaded newer image for nodered/node-red-docker:latest
 
docker --tls volume create --name mosquitto_user_data
mosquitto_user_data
 
docker --tls run -d -p 1883:1883 -p 9001:9001 -v mosquitto_user_data:/mosquitto/data --name mosquitto eclipse-mosquitto
Unable to find image 'eclipse-mosquitto:latest' locally
latest: Pulling from library/eclipse-mosquitto
1160f4abea84: Pull complete
a3ed95caeb02: Pull complete
f1482e5005cd: Pull complete
670369387727: Pull complete
Digest: sha256:98a147e5b169dfbaf30ed7327c3677f63601892b1750860fd40fd01b52cee1ce
Status: Downloaded newer image for library/eclipse-mosquitto:latest
da0af95954d89d3e7c2b93c56709ee2f1651fe21cafa312c0757203811f7c064
 
docker --tls volume ls
DRIVER              VOLUME NAME
vsphere             home_assistant_user_data
vsphere             mosquitto_user_data
vsphere             node_red_user_data
 
docker --tls ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
632d654098ff        homeassistant/home-assistant   "python -m homeassis…"   5 days ago          Up 26 hours         192.168.1.18:8123-&gt;8123/tcp                                home-assistant
47b1a5ac0b7c        eclipse-mosquitto              "/docker-entrypoint.…"   3 weeks ago         Up 5 days           192.168.1.18:1883-&gt;1883/tcp, 192.168.1.18:9001-&gt;9001/tcp   mosquitto
490640cc5497        nodered/node-red-docker        "npm start -- --user…"   3 weeks ago         Up 5 days           192.168.1.18:1880-&gt;1880/tcp                                node-red
ddbc8657188d        vmware/admiral                 "/entrypoint.sh"         3 weeks ago         Up 5 days           192.168.1.18:8282-&gt;8282/tcp                                admiral

Some basic commands to manage your containers and volumes and how to update a container:

docker --tls exec -i -t home-assistant /bin/bash
docker --tls start home-assistant
docker --tls restart home-assistant
docker --tls image ls
docker --tls volume ls
docler --tls ps
Update Home-Assistant:
docker --tls stop home-assistant
docker --tls rename home-assistant home-assistant_0.6
docker --tls pull homeassistant/home-assistant
docker --tls run -d -p 8123:8123 -v home_assistant_user_data:/config -e "TZ=Europe/Amsterdam" --name home-assistant homeassistant/home-assistant
 
Delete container or volume:
docker --tls rm home-assistant_0.6
docker --tls volume rm home_assistant_user_data
 
Copy files between container and localhost:
docker --tls cp home-assistant:/config/configuration.yaml configuration.yaml
docker --tls cp home-assistant:/config/customize.yaml customize.yaml
docker --tls cp home-assistant:/config/automations.yaml automations.yaml
docker --tls cp configuration.yaml home-assistant:/config/configuration.yaml
docker --tls cp customize.yaml home-assistant:/config/customize.yaml
docker --tls cp automations.yaml home-assistant:/config/automations.yaml

Welcome to my (tech) blog!

It’s never too late to start blogging! So hereby I’ll start my blog with mostly technical challenges I’m facing during my work or hobby. Hopefully this blog will be helpful and time saving while you’re troubleshooting.