Monday, 12 June 2017

SQL Server on Ubuntu - Installation Overview

As I have gotten into the habit of writing follow up articles lately this one is no different and is an overview of my last post where I installed Microsoft SQL Server onto the Ubuntu Operating System.

The article is a bit link heavy and that's because I wanted to provide links to the web pages that I have been using to construct this article. One of the great things that I have found about the Linux platform is its documentation, there is a wealth of information out there, both official and via blogs and forums. You certainly get the community sense from these pages, as you would do SQL Server I hasten to add!

I started out using the guide available from Microsoft: which is a pretty standard instruction document for getting SQL Server installed on to Linux. Although it is a pretty straightforward process I did have to deviate from the document from time to time, that's mainly because I have very little Linux experience so it's a good way to get used to using the CLI (Command Line Interface).

Here's the first command:

curl | sudo apt-key add -

This is actually where I got my first problem and I kind of skipped over it in the first article and went straight to the solution. Essentially the problem is that if you're following the guide without having installed curl you will get an error like I did:
The program 'curl' is currently not installed.  You can install it by typing:
sudo apt-get install curl
Curl is a tool that enables us to transfer data to or from a server and specifically in this command we're attempting to import the public repository GPG keys from which will enable us to install the SQL Server Ubuntu repository.

So, this didn't work but the message rather handily gives us a solution!

sudo apt install curl

Let's break it down a little bit. First sudo, which is giving root permissions to a particular command this is as opposed to sudo su which I had to do later on in the install to switch to superuser mode for the session.

Next is apt. Apt is a command line tool which works with the Advanced Packaging Tool and enables to perform installs, updates and removals of software packages. In this case we're installing curl so we use the install command. 

At this point our command is saying, as a superuser use the Advanced Packaging Tool to install; and finally curl. That went off fine and now I tried to run the command once more:

curl | sudo apt-key add -

This failed again with a connection refused error and my initial thought was that perhaps there was some network configuration that I need to do in the VM or indeed Ubuntu but a quick search brought me to the sudo su command.

Now I have to admit, I'm still reading into the differences between sudo, sudo su etc and I encourage anyone to pick the brains of any Linux friends they have on the security layers because whilst at a high level I can see that sudo is a one time prompt for root permission whereas sudo su actually switches user and because no parameter is specified it switches to the superuser account by default.

This enabled me to install the GPG key; the apt-key command is used to manage the keys within the Advanced Packaging Tool, add is going to add a new key to the list of keys. My assumption is that because we have specified the microsoft.asc file that the - specifies that the key is retrieved from there:

 add filename
           Add a new key to the list of trusted keys. The key is read from
           filename, or standard input if filename is -.

So now we're ready to register the SQL Server Ubuntu repository:

| sudo tee /etc/apt/sources.list.d/mssql-server.list

A repository is essentially a collection of software for Linux. We use tools to get information about the repository then download and install the software from the designated servers. Microsoft uses two repositories for software that it builds for Linux, prod which is used for commercially supported software and mssql-server which contains the packages for SQL Server. 

Once registered we can install SQL Server. The apt-get command is another command for APT, this time we are using apt-get update which download the latest package lists and latest information for all the repositories. We then use apt-get install to tell APT we're installing a package, -y to automatically answer yes to all prompts and then finally mssql-server which is our package.

sudo apt-get update sudo apt-get install -y mssql-server

That is it as far as the actual install is concerned but we now need to configure our SQL Server. To do this we use mssql-conf tool. mssql-conf  allows us to make several changes that are very familiar for those who are used to administering SQL Server such as modifying file locations or enabling/disabling trace flags. 

sudo /opt/mssql/bin/mssql-conf setup

In this case we are using the tool to perform setup which allows us to specify the administrator password and once set we are informed that SQL Server has started. The final command systemctl is a central management tool that  enables us to perform various service management tasks.

systemctl status mssql-server

Here's the final screenshot again that shows the Microsoft SQL Server service up and running on Linux. The whole process was extremely straightforward and I'm looking forward to getting some of the other tools installed and start putting the server through it's paces. It's worth adding that the VM is running on my laptop quite happily so as long as you have 3.5Gb RAM available for a Linux box then a fully working test instance is something that is very simple (and free) to create.

No comments:

Post a Comment