InstallIng Microsoft SQL Server on RHEL 7.5 Part 1

As I play around with RHEL and Learn New things I wanted to put this Simple Post out about installing Microsoft SQL Server on Red Hat Enterprise Linux 7.5 . The first Method that i will describe is the one based on the Microsoft Docs https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-red-hat?view=sql-server-linux-2017

After setting a new RHEL 7.5 Install you can download the SQL server Yum Repo

root@localhost ~]# sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 232 100 232 0 0 629 0 — : — : — — : — : — — : — : — 630

THE Microsoft SQL Server Package is pretty small about 169M Plus dependencies

root@localhost ~]# sudo yum install -y mssql-server
Loaded plugins: product-id, search-disabled-repos, subscription-manager
packages-microsoft-com-mssql-server-2017 | 2.9 kB 00:00
packages-microsoft-com-mssql-server-2017/primary_db | 13 kB 00:00
Resolving Dependencies
 → Running transaction check
 — -> Package mssql-server.x86_64 0:14.0.3030.27–1 will be installed
 → Processing Dependency: libsss_nss_idmap for package: mssql-server-14.0.3030.27–1.x86_64
 → Processing Dependency: gdb for package: mssql-server-14.0.3030.27–1.x86_64
 → Running transaction check
 — -> Package gdb.x86_64 0:7.6.1–110.el7 will be installed
 — -> Package libsss_nss_idmap.x86_64 0:1.16.0–19.el7_5.5 will be installed
 → Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package Arch Version Repository Size
================================================================================
Installing:
 mssql-server x86_64 14.0.3030.27–1 packages-microsoft-com-mssql-server-2017
 169 M
Installing for dependencies:
 gdb x86_64 7.6.1–110.el7 rhel-7-server-rpms 2.4 M
 libsss_nss_idmap x86_64 1.16.0–19.el7_5.5 rhel-7-server-rpms 148 k
Transaction Summary
================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 171 M
Installed size: 176 M
Downloading packages:
(1/3): libsss_nss_idmap-1.16.0–19.el7_5.5.x86_64.rpm | 148 kB 00:00
(2/3): gdb-7.6.1–110.el7.x86_64.rpm | 2.4 MB 00:00
warning: /var/cache/yum/x86_64/7Server/packages-microsoft-com-mssql-server-2017/packages/mssql-server-14.0.3030.27–1.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID be1229cf: NOKEY
Public key for mssql-server-14.0.3030.27–1.x86_64.rpm is not installed
(3/3): mssql-server-14.0.3030.27–1.x86_64.rpm | 169 MB 00:02:06
 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
Total 1.3 MB/s | 171 MB 00:02:06
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc
Importing GPG key 0xBE1229CF:
 Userid : “Microsoft (Release signing) <gpgsecurity@microsoft.com>”
 Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf
 From : https://packages.microsoft.com/keys/microsoft.asc
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : libsss_nss_idmap-1.16.0–19.el7_5.5.x86_64 1/3
 Installing : gdb-7.6.1–110.el7.x86_64 2/3
 Installing : mssql-server-14.0.3030.27–1.x86_64 3/3
+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — +
Please run ‘sudo /opt/mssql/bin/mssql-conf setup’
to complete the setup of Microsoft SQL Server
+ — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — +
SQL Server needs to be restarted in order to apply this setting. Please run
‘systemctl restart mssql-server.service’.
 Verifying : mssql-server-14.0.3030.27–1.x86_64 1/3
 Verifying : gdb-7.6.1–110.el7.x86_64 2/3
 Verifying : libsss_nss_idmap-1.16.0–19.el7_5.5.x86_64 3/3
Installed:
 mssql-server.x86_64 0:14.0.3030.27–1
Dependency Installed:
 gdb.x86_64 0:7.6.1–110.el7 libsss_nss_idmap.x86_64 0:1.16.0–19.el7_5.5

The Install is Pretty quick and the you can run the configuration. Sql Server Requires 200M of Free Memory and you will get an error like below if you dont have it

sqlservr: This program requires a machine with at least 2000 megabytes of memory.
Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG
in /var/opt/mssql/log for more information.

The Configuration of a basic instance is pretty quick if every thing is good.

[root@localhost ~]# sudo /opt/mssql/bin/mssql-conf setup
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)
 7) Enterprise Core (PAID)
 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=852748&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): 2
The license terms for this product can be found in
/usr/share/doc/mssql-server or downloaded from:
https://go.microsoft.com/fwlink/?LinkId=855862&clcid=0x409
The privacy statement can be viewed at:
https://go.microsoft.com/fwlink/?LinkId=853010&clcid=0x409
Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:
Configuring SQL Server…
ForceFlush is enabled for this instance.
ForceFlush feature is enabled for log durability.
Created symlink from /etc/systemd/system/multi-user.target.wants/mssql-server.service to /usr/lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.

At this Point we have SQL Server Installed and running. To Start Using it though you do need the SQL Command tools installed . So Lets Install the command tools.
[root@localhost ~]# sudo curl -o /etc/yum.repos.d/msprod.repo

% Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 193 100 193 0 0 701 0 — : — : — — : — : — — : — : — 704
[root@localhost ~]# sudo yum install -y mssql-tools unixODBC-devel
Loaded plugins: product-id, search-disabled-repos, subscription-manager
packages-microsoft-com-prod | 2.9 kB 00:00:00
packages-microsoft-com-prod/primary_db | 137 kB 00:00:00
Package unixODBC-devel-2.3.1–11.el7.x86_64 already installed and latest version
Resolving Dependencies
 → Running transaction check
 — -> Package mssql-tools.x86_64 0:17.2.0.1–1 will be installed
 → Processing Dependency: msodbcsql17 < 17.3.0.0 for package: mssql-tools-17.2.0.1–1.x86_64
 → Processing Dependency: msodbcsql17 >= 17.2.0.0 for package: mssql-tools-17.2.0.1–1.x86_64
 → Running transaction check
 — -> Package msodbcsql17.x86_64 0:17.2.0.1–1 will be installed
 → Finished Dependency Resolution
..
Total download size: 4.6 M
Installed size: 4.6 M
Downloading packages:
(1/2): mssql-tools-17.2.0.1–1.x86_64.rpm | 253 kB 00:00:00
(2/2): msodbcsql17–17.2.0.1–1.x86_64.rpm | 4.3 MB 00:00:00
 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
Total 6.1 MB/s | 4.6 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
The license terms for this product can be downloaded from
https://aka.ms/odbc172eula and found in
/usr/share/doc/msodbcsql17/LICENSE.txt . By entering ‘YES’,
you indicate that you accept the license terms.
Do you accept the license terms? (Enter YES or NO)
YES
 Installing : msodbcsql17–17.2.0.1–1.x86_64 1/2
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering ‘YES’,
you indicate that you accept the license terms.
Do you accept the license terms? (Enter YES or NO)
YES
 Installing : mssql-tools-17.2.0.1–1.x86_64 2/2
 Verifying : mssql-tools-17.2.0.1–1.x86_64 1/2
 Verifying : msodbcsql17–17.2.0.1–1.x86_64 2/2
Installed:
 mssql-tools.x86_64 0:17.2.0.1–1
Dependency Installed:
 msodbcsql17.x86_64 0:17.2.0.1–1
Complete!

The Command Line Tools are now Installed. Now if you have been using SQL Server on Windows for a while you will want to Install Powershell.

root@localhost ~]# # Register the Microsoft RedHat repository
[root@localhost ~]# curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 193 100 193 0 0 728 0 — : — : — — : — : — — : — : — 728
[packages-microsoft-com-prod]
name=packages-microsoft-com-prod
baseurl=https://packages.microsoft.com/rhel/7/prod/
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
[root@localhost ~]#
[root@localhost ~]# # Install PowerShell
[root@localhost ~]# sudo yum install -y powershell
Loaded plugins: product-id, search-disabled-repos, subscription-manager
Repository packages-microsoft-com-prod is listed more than once in the configuration
packages-microsoft-com-prod | 2.9 kB 00:00:00
Resolving Dependencies
 → Running transaction check
 — -> Package powershell.x86_64 0:6.1.0~preview.2–1.rhel.7 will be installed
 → Processing Dependency: libicu for package: powershell-6.1.0~preview.2–1.rhel.7.x86_64
 → Processing Dependency: libunwind for package: powershell-6.1.0~preview.2–1.rhel.7.x86_64
 → Running transaction check
 — -> Package libicu.x86_64 0:50.1.2–15.el7 will be installed
 — -> Package libunwind.x86_64 2:1.2–2.el7 will be installed
 → Finished Dependency Resolution
Dependencies Resolved

..
Total download size: 56 M
Installed size: 74 M
Downloading packages:
(1/3): libicu-50.1.2–15.el7.x86_64.rpm | 6.9 MB 00:00:00
(2/3): libunwind-1.2–2.el7.x86_64.rpm | 57 kB 00:00:00
(3/3): powershell-6.1.0~preview.2–1.rhel.7.x86_64.rpm | 50 MB 00:00:01
 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
Total 36 MB/s | 56 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : 2:libunwind-1.2–2.el7.x86_64 1/3
 Installing : libicu-50.1.2–15.el7.x86_64 2/3
 Installing : powershell-6.1.0~preview.2–1.rhel.7.x86_64 3/3
 Verifying : libicu-50.1.2–15.el7.x86_64 1/3
 Verifying : 2:libunwind-1.2–2.el7.x86_64 2/3
 Verifying : powershell-6.1.0~preview.2–1.rhel.7.x86_64 3/3
Installed:
 powershell.x86_64 0:6.1.0~preview.2–1.rhel.7
Dependency Installed:
 libicu.x86_64 0:50.1.2–15.el7 libunwind.x86_64 2:1.2–2.el7
Complete!

I now have SQL Server Installed with the Command Line Tools and Powershell on my RHEL 7.5 VM. 
Lets Do Some testing to see if it works

[root@localhost ~]# /opt/mssql-tools/bin/sqlcmd -S localhost -U SA
Password:
1> create database fuad
2> go
1> select name from sys.databases;
2> go
name
 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — 
master
tempdb
model
msdb
fuad

For using go after every set of instructions was a behaviour i was not accustomed to but seeing how seamless it was to install SQL Server on a vanille RHEL 7.5 Install was encouraging.

I’m my Next post i’m going to try to automate this for a quicker build using some of the things like ansible playbooks already available.