Microsoft SQL Server Server (MS SQL) is a relational database management system (RDBMS) developed by Microsoft. It was created initially to run on Windows Servers but later ported to Linux. The MS SQL Server 2019 is build on the previous releases to grow SQL Server as a platform that gives you choices of development languages, data types, on-premises or cloud environments, and operating systems.
In this short article we will perform an installation of Microsoft SQL Server (MS SQL) 2019 on Amazon Linux 2. This release of MS SQL Server introduces Big Data Clusters for SQL Server and provides additional capability and improvements for the database engine, Analysis Services, Machine Learning Services, Master Data Services among many others.
Step 1: Update Amazon Linux Server
Before we begin the installation process let us update the operating system
sudo yum -y update
Since there could be kernel updates it is recommended to reboot the system after a successful upgrade:
Step 2: Add Microsoft YUM Repositories
Run the commands below to add required repository to the system.
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo
Confirm the repository is now available:
$ sudo yum repolist Loaded plugins: langpacks, priorities, update-motd amzn2-core | 3.7 kB 00:00:00 packages-microsoft-com-mssql-server-2019 | 3.0 kB 00:00:00 packages-microsoft-com-mssql-server-2019/primary_db | 209 kB 00:00:00 repo id repo name status amzn2-core/2/x86_64 Amazon Linux 2 core repository 24,398 amzn2extra-docker/2/x86_64 Amazon Extras repo for docker 41 packages-microsoft-com-mssql-server-2019 packages-microsoft-com-mssql-server-2019 122 repolist: 24,561
Step 3: Install MS SQL Server 2019 on Amazon Linux 2
The SQL Server installation on Amazon Linux and any other Linux distribution has the the following system requirements:
|File System||XFS or EXT4 (other file systems, such as BTRFS, are unsupported)|
|Disk space||6 GB|
|Processor speed||2 GHz|
|Processor cores||2 cores|
|Processor type||x64-compatible only|
Ensure your system meets the following requirements for the installation to be successful.
Then run the following commands to install SQL Server:
sudo yum install mssql-server
Accept installation prompt to proceed.
Dependencies Resolved ================================================================================================================================================================== Package Arch Version Repository Size ================================================================================================================================================================== Installing: mssql-server x86_64 15.0.4123.1-5 packages-microsoft-com-mssql-server-2019 232 M Installing for dependencies: cyrus-sasl x86_64 2.1.26-23.amzn2 amzn2-core 87 k cyrus-sasl-gssapi x86_64 2.1.26-23.amzn2 amzn2-core 42 k gdb x86_64 8.0.1-30.amzn2.0.3 amzn2-core 3.2 M python3 x86_64 3.7.9-1.amzn2.0.2 amzn2-core 72 k python3-libs x86_64 3.7.9-1.amzn2.0.2 amzn2-core 9.2 M python3-pip noarch 9.0.3-1.amzn2.0.2 amzn2-core 1.9 M python3-setuptools noarch 38.4.0-3.amzn2.0.6 amzn2-core 617 k Transaction Summary ================================================================================================================================================================== Install 1 Package (+7 Dependent packages) Total download size: 247 M Installed size: 1.1 G Is this ok [y/d/N]: y
Also import GPG key
Retrieving key from https://packages.microsoft.com/keys/microsoft.asc Importing GPG key 0xBE1229CF: Userid : "Microsoft (Release signing) <[email protected]>" Fingerprint: bc52 8686 b50d 79e3 39d3 721c eb3e 94ad be12 29cf From : https://packages.microsoft.com/keys/microsoft.asc Is this ok [y/N]: y
Step 4: Configure MS SQL Server 2019 on Amazon Linux 2
After the installation you’ll need to run mssql-conf setup and follow the prompts to set the SA password and choose your edition.
sudo /opt/mssql/bin/mssql-conf setup
Chosse MS SQL Server edition:
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): 2
Then accept the license agreement
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
Next set SQL Server system administrator password:
Enter the SQL Server system administrator password: Confirm the SQL Server system administrator password:
Setup should be completed in a short while.
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.
Verify that the service is running after the configurations are done.
$ systemctl status mssql-server ● mssql-server.service - Microsoft SQL Server Database Engine Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2021-04-29 12:41:29 UTC; 1min 26s ago Docs: https://docs.microsoft.com/en-us/sql/linux Main PID: 3445 (sqlservr) CGroup: /system.slice/mssql-server.service ├─3445 /opt/mssql/bin/sqlservr └─3468 /opt/mssql/bin/sqlservr
Step 5: Install the MS SQL Server Client tools on Amazon Linux 2
You need SQL Server command-line tools to connect to the database server and perform operations such as database creation.
Start by downloading the Microsoft Red Hat repository configuration file:
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo
Run the following commands to install mssql-tools with the unixODBC developer package.
sudo yum -y install mssql-tools unixODBC-devel
For convenience, add /opt/mssql-tools/bin/ to your PATH environment variable. This enables you to run the tools without specifying the full path
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
You should now be able to connect locally to the Database Server:
sqlcmd -S localhost -U SA -P '<YourPassword>'
You can omit the password on the command line to be prompted to enter it.
$ sqlcmd -S localhost -U SA Password: 1>
Type QUIT to exit SQL Server terminal session.
After a successful installation of MS SQL Server 2019 on Amazon Linux 2, review the best practices for configuring Linux and SQL Server to improve performance for production scenarios. Read through the Performance best practices and configuration guidelines for SQL Server on Linux guide.