SQL Server 2019 – Linux


Este documento foi elaborado a partir de documento disponibilizado pelo desenvolvedor.
Fonte: Diretrizes de instalação para SQL Server em Linux

Plataformas compatíveis
O SQL Server é compatível com o Red Hat Enterprise Linux (RHEL), o SUSE Linux Enterprise Server (SLES) e o Ubuntu. Também tem suporte como uma imagem do Docker, que pode ser executada em um Mecanismo do Docker em Linux ou Docker for Windows/Mac.

PlataformaSistema de Arquivos
Red Hat Enterprise Linux 7.3 – 7.8 ou 8.0 – 8.2 ServerXFS ou EXT4
SUSE Enterprise Linux Server v12 SP2, SP3, SP4 ou SP5XFS ou EXT4
Ubuntu 16.04 LTS, 18.04 LTS*XFS ou EXT4
Docker Engine 1.8+ no Windows, Mac ou LinuxN/D

* procedimento efetuado no Ubuntu 20.04 LTS com sucesso

Para configurar o SQL Server no Ubuntu, execute os seguintes comandos em um terminal para instalar o pacote mssql-server.

1. Importe as chaves GPG do repositório público:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

2. Registre o repositório do Ubuntu do Microsoft SQL Server para o SQL Server 2019:

sudo add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list)"
Hit:1 http://br.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://br.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                       
Get:3 http://br.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                                     
Get:4 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1012 kB]                                             
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                        
Get:6 https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic InRelease [10.5 kB]                                     
Get:7 http://br.archive.ubuntu.com/ubuntu bionic-updates/main i386 Packages [714 kB]                                
Get:8 http://br.archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [341 kB]                               
Get:9 http://br.archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [77.0 kB]   
Get:10 http://br.archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [17.2 kB]                   
Get:11 https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic/main armhf Packages [1693 B]                
Get:12 https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic/main amd64 Packages [9271 B]
Get:13 https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic/main arm64 Packages [1693 B]
Fetched 2436 kB in 1s (2210 kB/s)                                                                 
Reading package lists... Done

3. Execute os comandos a seguir para instalar o SQL Server:

sudo apt-get update
sudo apt-get install -y mssql-server
SRV1:~$ sudo apt-get update
Hit:1 http://br.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://br.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]                                                       
Get:3 http://br.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]                                                     
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease                                                                  
Hit:5 https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic InRelease                    
Fetched 163 kB in 1s (211 kB/s)
Reading package lists... Done

SRV1:~$ sudo apt-get install -y mssql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libllvm9 linux-headers-4.15.0-76 linux-headers-4.15.0-76-generic linux-headers-4.15.0-96 linux-headers-4.15.0-96-generic
  linux-image-4.15.0-76-generic linux-image-4.15.0-96-generic linux-modules-4.15.0-76-generic linux-modules-4.15.0-96-generic
  linux-modules-extra-4.15.0-76-generic linux-modules-extra-4.15.0-96-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  gdb gdbserver libbabeltrace1 libc++1 libc++abi1 libc6-dbg libdw1 libsasl2-modules-gssapi-mit libsss-nss-idmap0
Suggested packages:
  gdb-doc clang
The following NEW packages will be installed:
  gdb gdbserver libbabeltrace1 libc++1 libc++abi1 libc6-dbg libdw1 libsasl2-modules-gssapi-mit libsss-nss-idmap0 mssql-server
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 235 MB of archives.
After this operation, 1122 MB of additional disk space will be used.
Get:1 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libdw1 amd64 0.170-0.4ubuntu0.1 [203 kB]
Get:2 http://br.archive.ubuntu.com/ubuntu bionic/main amd64 libbabeltrace1 amd64 1.5.5-1 [154 kB]
Get:3 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gdb amd64 8.1-0ubuntu3.2 [2938 kB]
Get:4 https://packages.microsoft.com/ubuntu/18.04/mssql-server-2019 bionic/main amd64 mssql-server amd64 15.0.4043.16-4 [226 MB]
Get:5 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gdbserver amd64 8.1-0ubuntu3.2 [282 kB]
Get:6 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsasl2-modules-gssapi-mit amd64 2.1.27~101-g0780600+dfsg-3ubuntu2.1 [35.5 kB]
Get:7 http://br.archive.ubuntu.com/ubuntu bionic/universe amd64 libc++abi1 amd64 6.0-2 [56.7 kB]
Get:8 http://br.archive.ubuntu.com/ubuntu bionic/universe amd64 libc++1 amd64 6.0-2 [183 kB]
Get:9 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6-dbg amd64 2.27-3ubuntu1.2 [5163 kB]
Get:10 http://br.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsss-nss-idmap0 amd64 1.16.1-1ubuntu1.6 [20.1 kB]           
Fetched 235 MB in 55s (4281 kB/s)                                                                                                  
Preconfiguring packages ...
Selecting previously unselected package libdw1:amd64.
(Reading database ... 196756 files and directories currently installed.)
Preparing to unpack .../0-libdw1_0.170-0.4ubuntu0.1_amd64.deb ...
Unpacking libdw1:amd64 (0.170-0.4ubuntu0.1) ...
Selecting previously unselected package libbabeltrace1:amd64.
Preparing to unpack .../1-libbabeltrace1_1.5.5-1_amd64.deb ...
Unpacking libbabeltrace1:amd64 (1.5.5-1) ...
Selecting previously unselected package gdb.
Preparing to unpack .../2-gdb_8.1-0ubuntu3.2_amd64.deb ...
Unpacking gdb (8.1-0ubuntu3.2) ...
Selecting previously unselected package gdbserver.
Preparing to unpack .../3-gdbserver_8.1-0ubuntu3.2_amd64.deb ...
Unpacking gdbserver (8.1-0ubuntu3.2) ...
Selecting previously unselected package libsasl2-modules-gssapi-mit:amd64.
Preparing to unpack .../4-libsasl2-modules-gssapi-mit_2.1.27~101-g0780600+dfsg-3ubuntu2.1_amd64.deb ...
Unpacking libsasl2-modules-gssapi-mit:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2.1) ...
Selecting previously unselected package libc++abi1:amd64.
Preparing to unpack .../5-libc++abi1_6.0-2_amd64.deb ...
Unpacking libc++abi1:amd64 (6.0-2) ...
Selecting previously unselected package libc++1:amd64.
Preparing to unpack .../6-libc++1_6.0-2_amd64.deb ...
Unpacking libc++1:amd64 (6.0-2) ...
Selecting previously unselected package libc6-dbg:amd64.
Preparing to unpack .../7-libc6-dbg_2.27-3ubuntu1.2_amd64.deb ...
Unpacking libc6-dbg:amd64 (2.27-3ubuntu1.2) ...
Selecting previously unselected package libsss-nss-idmap0.
Preparing to unpack .../8-libsss-nss-idmap0_1.16.1-1ubuntu1.6_amd64.deb ...
Unpacking libsss-nss-idmap0 (1.16.1-1ubuntu1.6) ...
Selecting previously unselected package mssql-server.
Preparing to unpack .../9-mssql-server_15.0.4043.16-4_amd64.deb ...
Unpacking mssql-server (15.0.4043.16-4) ...
Setting up libc++abi1:amd64 (6.0-2) ...
Setting up libc6-dbg:amd64 (2.27-3ubuntu1.2) ...
Setting up libsss-nss-idmap0 (1.16.1-1ubuntu1.6) ...
Setting up libdw1:amd64 (0.170-0.4ubuntu0.1) ...
Setting up gdbserver (8.1-0ubuntu3.2) ...
Setting up libsasl2-modules-gssapi-mit:amd64 (2.1.27~101-g0780600+dfsg-3ubuntu2.1) ...
Setting up libbabeltrace1:amd64 (1.5.5-1) ...
Setting up libc++1:amd64 (6.0-2) ...
Setting up gdb (8.1-0ubuntu3.2) ...
Setting up mssql-server (15.0.4043.16-4) ...

+--------------------------------------------------------------+
Please run 'sudo /opt/mssql/bin/mssql-conf setup'
to complete the setup of Microsoft SQL Server
+--------------------------------------------------------------+

Processing triggers for libc-bin (2.27-3ubuntu1.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

4. Após a conclusão da instalação do pacote, execute a instalação de mssql-conf e siga os prompts para definir a senha SA e escolher sua edição.

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

Observação:
Especifique uma senha forte para a conta SA (comprimento mínimo de 8 caracteres, incluindo letras maiúsculas e minúsculas, 10 dígitos básicos e/ou símbolos não alfanuméricos).

SRV1:~$ sudo /opt/mssql/bin/mssql-conf setup
usermod: no changes
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
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

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 /etc/systemd/system/multi-user.target.wants/mssql-server.service → /lib/systemd/system/mssql-server.service.
Setup has completed successfully. SQL Server is now starting.

5. Após concluir a configuração, verifique se o serviço está em execução:

systemctl status mssql-server --no-pager
SRV1:~$ systemctl status mssql-server --no-pager
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-07-20 16:50:09 -03; 16min ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 8312 (sqlservr)
    Tasks: 171
   CGroup: /system.slice/mssql-server.service
           ├─8312 /opt/mssql/bin/sqlservr
           └─8380 /opt/mssql/bin/sqlservr

6. Se planeja se conectar remotamente, talvez seja preciso abrir a porta TCP do SQL Server (padrão 1433) em seu firewall.