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.

VBoxHeadless, the Remote Desktop Server


Site do VirtualBox
https://www.virtualbox.org/


Instalando o VirtualBox

Efetue o download do pacote apropriado para a sua distribuição linux e proceda com a instalação.

Ubuntu (20.04):

Para baixar o pacote (.deb):

wget https://download.virtualbox.org/virtualbox/6.1.18/virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

Para instalar:

sudo apt install ./virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

Instalação do “Oracle VM VirtualBox Extension Pack”

Listando os extension pack instalados

VBoxManage list extpacks
Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      6.1.18
Revision:     142142
Edition:      
Description:  Oracle Cloud Infrastructure integration, USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe.
VRDE Module:  VBoxVRDP
Usable:       true 
Why unusable: 

Baixando o extension pack

wget https://download.virtualbox.org/virtualbox/6.1.18/Oracle_VM_VirtualBox_Extension_Pack-6.1.18.vbox-extpack

Instalando o extension pack

sudo VBoxManage extpack install /home/pub/Oracle_VM_VirtualBox_Extension_Pack-6.1.18.vbox-extpack

Leitura adicional:
https://www.virtualbox.org/manual/ch01.html#intro-installing

Manutenção das VMs no ambiente server (headless)

Fonte principal:
https://www.virtualbox.org/manual/ch07.html

Executando uma VM no modo headless:

VBoxManage startvm "win_10_20h2" --type headless

Habilitando o servidor VRDP para a VM:

VBoxManage modifyvm "win_10_20h2" --vrde on

Trocando a porta de acesso VRDP para a VM:

VBoxManage modifyvm "winxp_sp3" --vrdeport 5000

VBoxManage

Fonte:
https://www.virtualbox.org/manual/ch08.html#vboxmanage-intro

Para exibir informações da máquina host:

# VBoxManage list hostinfo
Host Information:

Host time: 2021-02-08T18:59:19.757000000Z
Processor online count: 4
Processor count: 4
Processor online core count: 4
Processor core count: 4
Processor supports HW virtualization: yes
Processor supports PAE: yes
Processor supports long mode: yes
Processor supports nested paging: yes
Processor supports unrestricted guest: yes
Processor supports nested HW virtualization: yes
Processor#0 speed: 3000 MHz
Processor#0 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Processor#1 speed: 3000 MHz
Processor#1 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Processor#2 speed: 3000 MHz
Processor#2 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Processor#3 speed: 3000 MHz
Processor#3 description: AMD A8-3870 APU with Radeon(tm) HD Graphics
Memory size: 31610 MByte
Memory available: 31383 MByte
Operating system: Linux
Operating system version: 5.4.0-65-generic

Para exibir informações globais sobre o ambiente do VirtualBox:

VBoxManage list systemproperties
API version:                     6_1
Minimum guest RAM size:          4 Megabytes
Maximum guest RAM size:          2097152 Megabytes
Minimum video RAM size:          0 Megabytes
Maximum video RAM size:          256 Megabytes
Maximum guest monitor count:     64
Minimum guest CPU count:         1
Maximum guest CPU count:         32
Virtual disk limit (info):       2199022206976 Bytes
Maximum Serial Port count:       4
Maximum Parallel Port count:     2
Maximum Boot Position:           4
Maximum PIIX3 Network Adapter count:   8
Maximum ICH9 Network Adapter count:   36
Maximum PIIX3 IDE Controllers:   1
Maximum ICH9 IDE Controllers:    1
Maximum IDE Port count:          2
Maximum Devices per IDE Port:    2
Maximum PIIX3 SATA Controllers:  1
Maximum ICH9 SATA Controllers:   8
Maximum SATA Port count:         30
Maximum Devices per SATA Port:   1
Maximum PIIX3 SCSI Controllers:  1
Maximum ICH9 SCSI Controllers:   8
Maximum SCSI Port count:         16
Maximum Devices per SCSI Port:   1
Maximum SAS PIIX3 Controllers:   1
Maximum SAS ICH9 Controllers:    8
Maximum SAS Port count:          255
Maximum Devices per SAS Port:    1
Maximum NVMe PIIX3 Controllers:  1
Maximum NVMe ICH9 Controllers:   8
Maximum NVMe Port count:         255
Maximum Devices per NVMe Port:   1
Maximum virtio-scsi PIIX3 Controllers:  1
Maximum virtio-scsi ICH9 Controllers:   8
Maximum virtio-scsi Port count:         256
Maximum Devices per virtio-scsi Port:   1
Maximum PIIX3 Floppy Controllers:1
Maximum ICH9 Floppy Controllers: 1
Maximum Floppy Port count:       1
Maximum Devices per Floppy Port: 2
Default machine folder:          /home/pub/VirtualBox_VMs
Raw-mode Supported:              no
Exclusive HW virtualization use: on
Default hard disk format:        VDI
VRDE auth library:               VBoxAuth
Webservice auth. library:        VBoxAuth
Remote desktop ExtPack:          
Log history count:               3
Default frontend:                
Default audio driver:            ALSA
Autostart database path:         
Default Guest Additions ISO:     /usr/share/virtualbox/VBoxGuestAdditions.iso
Logging Level:                   all
Proxy Mode:                      System
Proxy URL:                       

Para definir o diretório default de criação das VMs:

VBoxManage setproperty machinefolder /home/pub/VirtualBox_VMs

Para verificar os “tipos de OS” disponíveis para uso:

VBoxManage list ostypes
...
ID: Windows7_64
Description: Windows 7 (64-bit)
Family ID: Windows
Family Desc: Microsoft Windows
64 bit: true
...

Para listar as VMs registradas:

VBoxManage list vms

Para exibir informações sobre uma VM:

VBoxManage showvminfo "win_10_20h2"
Name:                        win_10_20h2
Groups:                      /
Guest OS:                    Windows 10 (64-bit)
UUID:                        33f7356c-3fd0-477b-948e-dfd6525cf19d
Config file:                 /home/pub/VirtualBox_VMs/win_10_20h2/win_10_20h2.vbox
Snapshot folder:             /home/pub/VirtualBox_VMs/win_10_20h2/Snapshots
Log folder:                  /home/pub/VirtualBox_VMs/win_10_20h2/Logs
Hardware UUID:               33f7356c-3fd0-477b-948e-dfd6525cf19d
Memory size                  8192MB
Page Fusion:                 disabled
VRAM size:                   128MB
CPU exec cap:                100%
HPET:                        disabled
CPUProfile:                  host
Chipset:                     piix3
Firmware:                    BIOS
Number of CPUs:              1
PAE:                         disabled
Long Mode:                   enabled
Triple Fault Reset:          disabled
...

Para criar uma VM:

VBoxManage createvm --name "Windows XP" --ostype WindowsXP --register

Para registrar uma VM existente:

VBoxManage registervm /home/pub/VirtualBox_VMs/win_10_20h2/win_10_20h2.vbox

Network (Bridge)

Fonte:
https://devminz.github.io/posts/devops/virtualbox-cli-vm-bridged-networking/
https://www.virtualbox.org/manual/ch06.html#nichardware

Criando uma interface bridge na máquina host:

VBoxManage modifyvm "winxp_sp3" --nic1 bridged --nictype1 82545EM --bridgeadapter1 enp2s0
--nictype<1-N> Am79C970A|Am79C973|Am79C960|82540EM|82543GC|82545EM|virtio

Controle de snapshots

Fonte:
https://www.virtualbox.org/manual/ch08.html#vboxmanage-snapshot

Listando as snapshots de uma VM:

VBoxManage snapshot "win_10_20h2" list

Criando uma snapshot para uma VM:

VBoxManage snapshot "win_10_20h2" take "zerada"
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Snapshot taken. UUID: 7bdcae1e-d875-457d-bddf-921a617987ec