Instal·lació de MS SQL Server 2019 a Red Hat 8.3

Introducció

Tot i que l’entorn natural de SQL Server és un sistema Windows, des de la versió 2017 tenim l’opció d’instal·lar aquest gestor de bases de dades sobre vàries distribucions Linux.  Aquí veurem com és la seva instal·lació a Red Hat 8

Instal·lació de SQL Server

Abans de començar la instal·lació de SQL Server 2019, necessitem instal·la python2 i OpenSSL 1.0; les versions d’ambdós programaris que venen per defecte amb Red Hat 8 encara no son compatibles amb SQL Server.

sudo yum install python2
sudo yum install compat-openssl10

Configurem python2 perquè sigui l’intèrpret per defecte:

sudo alternatives --config python

seleccionem l’opció /usr/bin/python2 per crear un enllaç simbòlic a /usr/bin/python

 There are 3 programs which provide 'python'.
   Selection    Command
 -----------------------------------------------
 *  1           /usr/libexec/no-python
    2           /usr/bin/python3
  + 3           /usr/bin/python2
 Enter to keep the current selection[+], or type selection number: 

Configurem el sistema per accedir al repositori de Microsoft SQL Server

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo

Instal·lem SQL Server des del repositori que hem configurat:

sudo yum install -y mssql-server

Configuració de SQL Server

La configuració de SQL Server a Linux es duu a terme amb la utilitat mssql-conf

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

Introduïm primer l’edició que volem instal·lar:

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): 

Acceptem els termes de la llicència:

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]: 

I introduïm i confirmem la contrasenya de l’administrador de SQL Server

Enter the SQL Server system administrator password:
Confirm the SQL Server system administrator password:

Amb això s’acaba la configuració:

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

Comprovem que el servei està funcionant:

sudo systemctl status mssql-server

I obtenim aquest resultat:

● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendo>
   Active: active (running) since Thu 2021-04-08 20:40:14 CEST; 4min 23s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 34586 (sqlservr)
    Tasks: 137
   Memory: 663.3M
   CGroup: /system.slice/mssql-server.service
           ├─34586 /opt/mssql/bin/sqlservr
           └─34616 /opt/mssql/bin/sqlservr
  
Apr 08 20:40:19 localhost.localdomain sqlservr[34586]: [158B blob data]
Apr 08 20:40:19 localhost.localdomain sqlservr[34586]: [155B blob data]
Apr 08 20:40:19 localhost.localdomain sqlservr[34586]: [61B blob data]
Apr 08 20:40:19 localhost.localdomain sqlservr[34586]: [96B blob data]
Apr 08 20:40:19 localhost.localdomain sqlservr[34586]: [66B blob data]
Apr 08 20:40:20 localhost.localdomain sqlservr[34586]: [75B blob data]
Apr 08 20:40:20 localhost.localdomain sqlservr[34586]: [96B blob data]
Apr 08 20:40:20 localhost.localdomain sqlservr[34586]: [100B blob data]
Apr 08 20:40:20 localhost.localdomain sqlservr[34586]: [124B blob data]
Apr 08 20:40:20 localhost.localdomain sqlservr[34586]: [71B blob data]
lines 1-21/21 (END) 

Instal·lació de les eines de línia de comandes de SQL Server

Per instal·lar el client SQLCMD, descarreguem primer el repositori de les eines client de SQL Server:

sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo

Instal·lem les mssql-tools i el paquet unixODBC developer:

sudo yum install -y mssql-tools unixODBC-devel

Acceptem els termes de la llicència de les mssql-tools:

packages-microsoft-com-prod                     2.0 MB/s | 7.2 MB     00:03
Last metadata expiration check: 0:00:17 ago on Thu 08 Apr 2021 08:58:16 PM CEST.
Dependencies resolved.
================================================================================
 Package           Arch      Version       Repository                      Size
================================================================================
Installing:
 mssql-tools       x86_64    17.7.1.1-1    packages-microsoft-com-prod    288 k
 unixODBC-devel    x86_64    2.3.7-1.rh    packages-microsoft-com-prod     42 k
Installing dependencies:
 msodbcsql17       x86_64    17.7.2.1-1    packages-microsoft-com-prod    906 k
 unixODBC          x86_64    2.3.7-1.rh    packages-microsoft-com-prod    213 k
 
Transaction Summary
================================================================================
Install  4 Packages
 
Total download size: 1.4 M
Installed size: 3.2 M
Downloading Packages:
(1/4): unixODBC-2.3.7-1.rh.x86_64.rpm           333 kB/s | 213 kB     00:00
(2/4): unixODBC-devel-2.3.7-1.rh.x86_64.rpm     570 kB/s |  42 kB     00:00
(3/4): mssql-tools-17.7.1.1-1.x86_64.rpm        369 kB/s | 288 kB     00:00
(4/4): msodbcsql17-17.7.2.1-1.x86_64.rpm        722 kB/s | 906 kB     00:01
--------------------------------------------------------------------------------
Total                                           1.1 MB/s | 1.4 MB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : unixODBC-2.3.7-1.rh.x86_64                             1/4
  Running scriptlet: unixODBC-2.3.7-1.rh.x86_64                             1/4
  Running scriptlet: msodbcsql17-17.7.2.1-1.x86_64                          2/4
The license terms for this product can be downloaded from
https://aka.ms/odbc17eula and found in
/usr/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.
 
Do you accept the license terms? (Enter YES or NO) 

I els de l’ unixODBC developer:

 Installing       : msodbcsql17-17.7.2.1-1.x86_64                          2/4
 Running scriptlet: msodbcsql17-17.7.2.1-1.x86_64                          2/4
 Running scriptlet: mssql-tools-17.7.1.1-1.x86_64                          3/4
The license terms for this product can be downloaded from
http://go.microsoft.com/fwlink/?LinkId=746949 and found in
/usr/share/doc/mssql-tools/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.
 
Do you accept the license terms? (Enter YES or NO) 

Per últim, un cop instal·lades les eines, les afegim a la variable d’entorn PATH

echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile
echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
source ~/.bashrc 

I provem d’accedir:

sqlcmd -s localhost -U SA

Deixa un comentari

L'adreça electrònica no es publicarà. Els camps necessaris estan marcats amb *