top of page

Installing, Administering, and Configuring Microsoft SQL in a Linux Environment

Feb 4

7 min read

0

5

0

Installing, Administering, and Configuring Microsoft SQL in a Linux Environment

SQL Server is a powerful relational database management system developed by Microsoft. While traditionally associated with Windows environments, Microsoft has extended its reach to the Linux world, offering new possibilities for developers and administrators. This move allows for greater flexibility in choosing the best platform for your needs and potentially achieving performance advantages1. This article provides a comprehensive guide to installing, administering, and configuring Microsoft SQL Server in a Linux environment.

Installation

Before installing SQL Server on your Linux system, ensure it meets the following requirements:

  • Supported Distributions: Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise Server (SLES), and Ubuntu2.

  • Memory: 2 GB minimum3.

  • Disk Space: 6 GB minimum3.

  • Processor Speed: 2 GHz minimum3.

  • Processor Cores: 2 cores minimum3.

  • Processor Type: x64-compatible only3.

  • File System: XFS or EXT4 (other file systems, such as BTRFS, are not supported)3.

Network File System (NFS) Support

If you plan to use NFS remote shares in your production environment, ensure that:

  • You are using NFS version 4.2 or higher. Older versions lack essential features like fallocate and sparse file creation3.

  • Only the /var/opt/mssql directories are located on the NFS mount. Storing other files, such as SQL Server system binaries, on NFS shares is not supported3.

Installation Steps

The installation process generally involves the following steps:

  1. Add the Microsoft SQL Server repository to your system's package manager.

  2. Update the package list.

  3. Install the mssql-server package4.

For example, on Ubuntu, you can use the following commands:


Bash



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

Unattended Installation

You can perform an unattended installation by setting environment variables and using the -n (no prompt) option with the mssql-conf setup command3.

Offline Installation

For offline installations, follow these steps:

  1. Download the database engine package for your platform.

  2. Move the package to your Linux machine.

  3. Install the package using the appropriate command for your distribution (e.g., sudo yum localinstall for RHEL, sudo zypper install for SLES, sudo dpkg -i for Ubuntu)3.

  4. Resolve any missing dependencies.

  5. Complete the SQL Server setup using mssql-conf3.

Verifying Installation

To verify the installed SQL Server version and edition, use the sqlcmd command-line tool:


Bash



sqlcmd -S localhost -U sa -Q 'select @@VERSION'

This command requires the sqlcmd tool to be installed. If it's not already installed, you can install it separately.

Firewall Configuration

If you plan to connect to your SQL Server instance remotely, you might need to open the SQL Server TCP port (default 1433) on your firewall4.

Optional Features

After installation, you can install or enable optional SQL Server features, such as:

  • SQL Server Agent 3

  • Full-Text Search 3

  • Machine Learning Services (Python and R) 3

  • Integration Services (SSIS) 3

SQL Server Editions

Microsoft offers different editions of SQL Server on Linux, each tailored to specific needs and budgets. Here's a comparison of the key features:





Edition

Maximum Compute Capacity

Maximum Memory

Maximum Database Size

High Availability Features

Security Features

Enterprise

Operating system maximum

Operating system maximum

524 PB

Always On Availability Groups (up to 8 replicas), Failover Cluster Instances (up to 16 nodes), Log shipping, Online page and file restore, Online indexing

Row-Level Security, Dynamic Data Masking, Always Encrypted, Transparent Data Encryption (TDE), Extensible Key Management (EKM)

Standard

4 sockets or 24 cores

128 GB

524 PB

Failover Cluster Instances (up to 2 nodes), Log shipping, Basic Availability Groups (2 replicas, 1 database)

Row-Level Security, Dynamic Data Masking, Always Encrypted, Transparent Data Encryption (TDE)

Web

4 sockets or 16 cores

64 GB

524 PB

Log shipping

Row-Level Security, Dynamic Data Masking, Always Encrypted

Express

1 socket or 4 cores

1410 MB

10 GB

None

Row-Level Security, Always Encrypted

Developer

Operating system maximum

Operating system maximum

524 PB

All Enterprise edition features

All Enterprise edition features

Key Insight: Choosing the right edition can significantly impact your costs. For instance, SQL Server Standard edition provides substantial cost savings compared to the Enterprise edition, with a price difference of around 74%6. This makes it a viable option for smaller organizations or those with less demanding workloads.

Configuration

After installing SQL Server, you can configure various settings using the mssql-conf utility7. Here are some examples:

  • Enabling SQL Server Agent:


Bash



sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled truesudo systemctl restart mssql-server

  • Configuring Memory Limits:


Bash



sudo /opt/mssql/bin/mssql-conf set memory.memorylimitmb 16000  # Set max memory to 16 GBsudo systemctl restart mssql-server

  • Adjusting Worker Threads:


Bash



sudo /opt/mssql/bin/mssql-conf set hadr.num_worker_threads 300sudo systemctl restart mssql-server

  • Changing Collation:


Bash



sudo /opt/mssql/bin/mssql-conf set-collation  # Follow the prompts

Remember to restart the SQL Server service after making any configuration changes.

Administration

Administering SQL Server on Linux involves managing users, databases, security, performance, and backups, as well as troubleshooting issues.

User and Database Management

  • Creating Logins: Use the CREATE LOGIN statement to create logins in the master database. Ensure passwords meet SQL Server's complexity requirements8.

  • Creating Users: Create database users and assign them to logins. Grant appropriate permissions using roles and granular permissions9.

Security

SQL Server on Linux provides a range of security features:

  • Authentication: Choose between SQL Server authentication and Active Directory authentication. Active Directory authentication requires configuring the Linux host within the domain, including DNS settings and potentially Kerberos configuration10.

  • Authorization: Use roles and permissions to grant users the necessary access to database objects. Adhere to the principle of least privilege8.

  • Row-Level Security: Control data access at the row level based on user attributes or roles8.

  • Dynamic Data Masking: Protect sensitive data by masking it in query results8.

  • Transparent Data Encryption (TDE): Encrypt data at rest to safeguard it from unauthorized access8.

Connecting with sqlcmd

You can connect to SQL Server and execute queries using the sqlcmd command-line tool:


Bash



sqlcmd -S localhost -U <username> -P <password>

Once connected, you can run SQL queries like:


SQL



SELECT * FROM your_table;

To exit sqlcmd, type QUIT12.

Connecting Remotely

To connect to your SQL Server instance remotely, you need to:

  1. Enable remote access in SQL Server.

  2. Configure your firewall to allow connections to the SQL Server port (default 1433).

  3. Use a SQL Server client tool like dbForge Studio to connect to the server5.

Performance Monitoring

Monitor your SQL Server instance using tools like:

  • Query Store: Analyze query performance data to identify and address bottlenecks13.

  • System Dynamic Management Views (DMVs): Gain real-time insights into server performance metrics13.

  • Performance Dashboard: Visualize key performance indicators in SQL Server Management Studio13.

Backups and Recovery

Regularly back up your databases using full, differential, and transaction log backups14. You can manage backups using SQL Server Management Studio or the sqlcmd utility.

Troubleshooting

Common issues you might encounter include:

  • Connection problems: Verify network connectivity, firewall settings, and authentication credentials13.

  • Password resets: If you forget the SA password, you can reset it using the mssql-conf setup command13.

  • Hostname limitations: SQL Server on Linux has a limitation where the hostname cannot exceed 15 characters13.

  • Special characters in passwords: Some special characters might need to be escaped with a backslash when used in passwords on the Linux command line13.

For assistance, refer to the Microsoft troubleshooting guide for SQL Server on Linux and explore community forums and online resources like Reddit communities (r/SQLServer), Microsoft forums, and SQL Server Central13.

Best Practices

Follow these best practices for optimal performance and security:

  • Storage: Use a storage system with sufficient IOPS and throughput. Implement RAID configurations for redundancy and performance17.

  • Filesystem: Utilize the XFS filesystem for SQL Server data and log files17.

  • CPU: Configure CPU affinity to optimize processor core usage18.

  • Memory: Allocate an appropriate amount of memory to SQL Server using the max_server_memory setting, leaving enough for the operating system18.

  • Networking: Optimize network settings, such as jumbo frames and receive side scaling18.

  • Security: Implement strong passwords, least privilege access control, and encryption to protect your data.

Conclusion

Microsoft SQL Server on Linux provides a robust and flexible database solution for those seeking cross-platform compatibility. This allows developers to build and deploy applications across different environments, expanding their reach and providing businesses with cost-effective solutions and greater infrastructure choices1. By understanding the installation, administration, and configuration aspects, you can harness the power of SQL Server in a Linux environment. Following best practices and leveraging available resources will contribute to a successful and optimized SQL Server on Linux experience.

Looking ahead, we can anticipate increased adoption of SQL Server on Linux, with a growing emphasis on containerized deployments and deeper integration with cloud platforms like Azure. This trend will further enhance the versatility and scalability of SQL Server, making it an even more compelling choice for diverse database needs.

Works cited

1. Why run Microsoft SQL Server on Linux? - Red Hat, accessed on February 4, 2025, https://www.redhat.com/en/topics/linux/why-run-sql-server-on-linux

2. Overview of SQL Server Requirements on Linux and Comparison with Windows SQL Server, accessed on February 4, 2025, https://severalnines.com/blog/overview-sql-server-requirements-linux-and-comparison-windows-sql-server/

3. Installation Guidance for SQL Server on Linux - Microsoft Learn, accessed on February 4, 2025, https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-setup?view=sql-server-ver16

4. Quickstart: Install SQL Server and create a database on Ubuntu - Microsoft Learn, accessed on February 4, 2025, https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver16

5. How to Install SQL Server on Linux (Ubuntu) - Devart Blog, accessed on February 4, 2025, https://blog.devart.com/how-to-install-sql-server-on-linux-ubuntu.html

6. Compare SQL Server editions - AWS Prescriptive Guidance, accessed on February 4, 2025, https://docs.aws.amazon.com/prescriptive-guidance/latest/optimize-costs-microsoft-workloads/sql-server-editions.html

7. Configure SQL Server on Linux with the mssql-conf tool - Microsoft Learn, accessed on February 4, 2025, https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-configure-mssql-conf?view=sql-server-ver16

8. Walkthrough for the Security Features of SQL Server on Linux - Microsoft Learn, accessed on February 4, 2025, https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-security-get-started?view=sql-server-ver16

9. Configuring User Access in SQL Server on Linux - Pluralsight, accessed on February 4, 2025, https://www.pluralsight.com/cloud-guru/labs/azure/configuring-user-access-in-sql-server-on-linux

10. Installing SQL Server on Linux - YouTube, accessed on February 4, 2025, https://www.youtube.com/watch?v=GBboALYvvuE

11. Configure SQL Server on Linux for Active Directory Authentication, accessed on February 4, 2025, https://www.nocentino.com/posts/2021-12-1-sql-server-linux-active-directory/

12. Installing and Configuring SQL Server 2022 on Red Hat 9 - SQL Table Talk, accessed on February 4, 2025, https://www.sqltabletalk.com/?p=569

13. Troubleshoot SQL Server on Linux - Microsoft Learn, accessed on February 4, 2025, https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-troubleshooting-guide?view=sql-server-ver16

14. Administering a SQL Database Infrastructure | Robusta Technology and Training Center, accessed on February 4, 2025, https://robusta.vn/en/courses/microsoft/database/administering-microsoft-sql-server-databases

15. What are the best resources for asking questions when it comes to SQL Server and other applications like Visual Studio and Viso? : r/SQLServer - Reddit, accessed on February 4, 2025, https://www.reddit.com/r/SQLServer/comments/n6l3i7/what_are_the_best_resources_for_asking_questions/

16. SQL Server on Linux - Forums - SQLServerCentral, accessed on February 4, 2025, https://www.sqlservercentral.com/forums/topic/sql-server-on-linux/page/2

17. Performance best practices and configuration guidelines for SQL Server on Linux, accessed on February 4, 2025, https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-performance-best-practices?view=sql-server-ver16

18. Configuring and Troubleshooting SQL Server on Linux - YouTube, accessed on February 4, 2025, https://www.youtube.com/watch?v=CznMCouSsM4


Feb 4

7 min read

0

5

0

Comments

Share Your ThoughtsBe the first to write a comment.
bottom of page