|
| 1 | +--- |
| 2 | +title: SQL Server Unattended Install on SUSE Linux Enterprise Server | Microsoft Docs |
| 3 | +description: SQL Server Script Sample - Unattended Install on SUSE Linux Enterprise Server |
| 4 | +services: sql-database |
| 5 | +documentationcenter: sql-database |
| 6 | +author: edmacauley |
| 7 | +manager: |
| 8 | +editor: |
| 9 | +tags: azure-service-management |
| 10 | + |
| 11 | +ms.assetid: |
| 12 | +ms.service: sql-database |
| 13 | +ms.custom: mvc |
| 14 | +ms.devlang: azurecli |
| 15 | +ms.topic: sample |
| 16 | +ms.tgt_pltfrm: sql-database |
| 17 | +ms.workload: database |
| 18 | +ms.date: 6/19/2017 |
| 19 | +ms.author: edmacauley |
| 20 | +--- |
| 21 | + |
| 22 | +# Install SQL Server on SUSE Linux Enterprise Server |
| 23 | + |
| 24 | +This sample Bash script installs SQL Server 2017 CTP 2.1 on SUSE Linux Enterprise Server (SLES) v12 SP2 without interactive input. |
| 25 | + |
| 26 | +> [!NOTE] |
| 27 | +> SQL Server 2017 CTP 2.1 requires libsss_nss_idmap0, which is not provided by the default SLES repositories. You can install it from the SLES v12 SP2 SDK. |
| 28 | +
|
| 29 | +> You need at least 3.25 GB of memory to run SQL Server on Linux. Also, the file system must be **XFS** or **EXT4**. Other file systems, such as **BTRFS**, are unsupported. For other system requirements, see [System requirements for SQL Server on Linux](sql-server-linux-setup.md#system). |
| 30 | +
|
| 31 | +## Sample script |
| 32 | + |
| 33 | +```bash |
| 34 | +#!/bin/bash |
| 35 | + |
| 36 | +# Use the following variables to control your install: |
| 37 | + |
| 38 | +# Password for the SA user (required) |
| 39 | +SA_PASSWORD='<YourStrong!Passw0rd>' |
| 40 | + |
| 41 | +# Install SQL Server Agent (recommended) |
| 42 | +SQL_INSTALL_AGENT='y' |
| 43 | + |
| 44 | +# Install SQL Server Full Text Search (optional) |
| 45 | +# SQL_INSTALL_FULLTEXT='y' |
| 46 | + |
| 47 | +# Create an additional user with sysadmin privileges (optional) |
| 48 | +# SQL_INSTALL_USER='<Username>' |
| 49 | +# SQL_INSTALL_USER_PASSWORD='<YourStrong!Passw0rd>' |
| 50 | + |
| 51 | +if [ -z $SA_PASSWORD ] |
| 52 | +then |
| 53 | + echo Environment variable SA_PASSWORD must be set for unattended install |
| 54 | + exit 1 |
| 55 | +fi |
| 56 | + |
| 57 | +echo Adding Microsoft repositories... |
| 58 | +sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server.repo |
| 59 | +sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/prod.repo |
| 60 | +sudo zypper --gpg-auto-import-keys refresh |
| 61 | + |
| 62 | +echo Installing SQL Server... |
| 63 | +sudo zypper install -y mssql-server |
| 64 | + |
| 65 | +echo Running mssql-conf setup... |
| 66 | +sudo SA_PASSWORD=$SA_PASSWORD \ |
| 67 | + /opt/mssql/bin/mssql-conf -n setup accept-eula |
| 68 | + |
| 69 | +echo Installing mssql-tools and unixODBC developer... |
| 70 | +sudo ACCEPT_EULA=Y zypper install -y mssql-tools unixODBC-devel |
| 71 | + |
| 72 | +# Add SQL Server tools to the path by default: |
| 73 | +echo Adding SQL Server tools to your path... |
| 74 | +echo PATH="$PATH:/opt/mssql-tools/bin" >> ~/.bash_profile |
| 75 | +echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc |
| 76 | + |
| 77 | +# Optional SQL Server Agent installation: |
| 78 | +if [ ! -z $SQL_INSTALL_AGENT ] |
| 79 | +then |
| 80 | + echo Installing SQL Server Agent... |
| 81 | + sudo zypper install -y mssql-server-agent |
| 82 | +fi |
| 83 | + |
| 84 | +# Optional SQL Server Full Text Search installation: |
| 85 | +if [ ! -z $SQL_INSTALL_FULLTEXT ] |
| 86 | +then |
| 87 | + echo Installing SQL Server Full-Text Search... |
| 88 | + sudo zypper install -y mssql-server-fts |
| 89 | +fi |
| 90 | + |
| 91 | +# Configure firewall to allow TCP port 1433: |
| 92 | +echo Configuring SuSEfirewall2 to allow traffic on port 1433... |
| 93 | +sudo SuSEfirewall2 open INT TCP 1433 |
| 94 | +sudo SuSEfirewall2 stop |
| 95 | +sudo SuSEfirewall2 start |
| 96 | + |
| 97 | +# Example of setting post-installation configuration options |
| 98 | +# Set trace flags 1204 and 1222 for deadlock tracing: |
| 99 | +echo Setting trace flags... |
| 100 | +sudo /opt/mssql/bin/mssql-conf traceflag 1204 1222 on |
| 101 | + |
| 102 | +# Restart SQL Server after making configuration changes: |
| 103 | +echo Restarting SQL Server... |
| 104 | +sudo systemctl restart mssql-server |
| 105 | + |
| 106 | +# Connect to server and get the version: |
| 107 | +counter=1 |
| 108 | +errstatus=1 |
| 109 | +while [ $counter -le 5 ] && [ $errstatus = 1 ] |
| 110 | +do |
| 111 | + echo Waiting for SQL Server to start... |
| 112 | + sleep 5s |
| 113 | + /opt/mssql-tools/bin/sqlcmd \ |
| 114 | + -S localhost \ |
| 115 | + -U SA \ |
| 116 | + -P $SA_PASSWORD \ |
| 117 | + -Q "SELECT @@VERSION" 2>/dev/null |
| 118 | + errstatus=$? |
| 119 | + ((counter++)) |
| 120 | +done |
| 121 | + |
| 122 | +# Display error if connection failed: |
| 123 | +if [ $errstatus = 1 ] |
| 124 | +then |
| 125 | + echo Cannot connect to SQL Server, installation aborted |
| 126 | + exit $errstatus |
| 127 | +fi |
| 128 | + |
| 129 | +# Optional new user creation: |
| 130 | +if [ ! -z $SQL_INSTALL_USER ] && [ ! -z $SQL_INSTALL_USER_PASSWORD ] |
| 131 | +then |
| 132 | + echo Creating user $SQL_INSTALL_USER |
| 133 | + /opt/mssql-tools/bin/sqlcmd \ |
| 134 | + -S localhost \ |
| 135 | + -U SA \ |
| 136 | + -P $SA_PASSWORD \ |
| 137 | + -Q "CREATE LOGIN [$SQL_INSTALL_USER] WITH PASSWORD=N'$SQL_INSTALL_USER_PASSWORD', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=ON, CHECK_POLICY=ON; ALTER SERVER ROLE [sysadmin] ADD MEMBER [$SQL_INSTALL_USER]" |
| 138 | +fi |
| 139 | + |
| 140 | +echo Done! |
| 141 | +``` |
| 142 | + |
| 143 | +## Next steps |
| 144 | + |
| 145 | +Simplify your unattended installs by creating a Bash script that sets the proper environment variables, instead of doing it inline. |
| 146 | + |
| 147 | +```bash |
| 148 | +#!/bin/bash |
| 149 | +export SA_PASSWORD='<YourStrong!Passw0rd>' |
| 150 | +export SQL_INSTALL_AGENT='y' |
| 151 | +export SQL_INSTALL_USER='<Username>' |
| 152 | +export SQL_INSTALL_USER_PASSWORD='<YourStrong!Passw0rd>' |
| 153 | +``` |
| 154 | + |
| 155 | +For more information about SQL Server on Linux, see [SQL Server on Linux overview](sql-server-linux-overview.md). |
0 commit comments