Showing posts with label step by step SQL Server Database Installation and Configuration On RHEL 8. Show all posts
Showing posts with label step by step SQL Server Database Installation and Configuration On RHEL 8. Show all posts

Wednesday 2 August 2023

step by step SQL Server Database Installation and Configuration On RHEL 8

 

Connecting to 10.88.13.90:22...
Connection established.
Escape character is '^@]'.

Activate the web console with: systemctl enable --now cockpit.socket

Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last login: Sun May  7 16:41:03 2023 from 10.11.208.198
/usr/bin/xauth:  file /root/.Xauthority does not exist
[root@binimoy-db ~]# df -h
Filesystem                Size  Used Avail Use% Mounted on
devtmpfs                  7.8G     0  7.8G   0% /dev
tmpfs                     7.8G     0  7.8G   0% /dev/shm
tmpfs                     7.8G  210M  7.6G   3% /run
tmpfs                     7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/banik02-root   80G   57G   24G  71% /
/dev/mapper/banik02-u01   337G  2.4G  335G   1% /u01
/dev/sda2                 495M  325M  171M  66% /boot
/dev/sda1                 500M  5.8M  494M   2% /boot/efi
tmpfs                     1.6G     0  1.6G   0% /run/user/971
tmpfs                     1.6G   40K  1.6G   1% /run/user/0
/dev/sr0                   11G   11G     0 100% /run/media/root/RHEL-8-5-0-BaseOS-x86_64

[root@binimoy-db ~]# subscription-manager register
This system is already registered. Use --force to override
[root@binimoy-db ~]#

[root@binimoy-db ~]# subscription-manager register
Registering to: subscription.rhsm.redhat.com:443/subscription
Username: bankasia
Password:
The system has been registered with ID: a4c9598d-476a-474f-8306-604c963efffe
The registered system name is: binimoy-db
[root@binimoy-db ~]#

[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]# tar cvf - . | (cd /var/ftp/pub/server/; tar xvf -)

[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]# ls -lrt /var/ftp/pub/server/
total 56
-r--r--r--. 1 root root   103 Oct 13  2021 media.repo
-r--r--r--. 1 root root  5135 Oct 13  2021 RPM-GPG-KEY-redhat-release
-r--r--r--. 1 root root  1669 Oct 13  2021 RPM-GPG-KEY-redhat-beta
-r--r--r--. 1 root root 18092 Oct 13  2021 GPL
-r--r--r--. 1 root root  1455 Oct 13  2021 extra_files.json
-r--r--r--. 1 root root  8154 Oct 13  2021 EULA
-r--r--r--. 1 root root  1796 Oct 13  2021 TRANS.TBL
dr-xr-xr-x. 2 root root  4096 Oct 13  2021 isolinux
dr-xr-xr-x. 3 root root    76 Oct 13  2021 images
dr-xr-xr-x. 3 root root    18 Oct 13  2021 EFI
dr-xr-xr-x. 4 root root    38 Oct 13  2021 BaseOS
dr-xr-xr-x. 4 root root    38 Oct 13  2021 AppStream
[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]#

[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]# find / -name media.repo
/run/media/root/RHEL-8-5-0-BaseOS-x86_64/media.repo
/var/ftp/pub/server/media.repo
[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]#



[root@binimoy-db ~]# vim /etc/yum.repos.d/redhat.repo
[InstallMedia-BaseOS]
name=Red Hat Enterprise Linux 8 - BaseOS
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///var/ftp/pub/package/RHEL-8-5-0-BaseOS-x86_64/BaseOS/
gpgkey=file:///var/ftp/pub/package/RHEL-8-5-0-BaseOS-x86_64/rpm-gpg/RPM-GPG-KEY-redhat-release

[InstallMedia-AppStream]
name=Red Hat Enterprise Linux 8 - AppStream
metadata_expire=-1
gpgcheck=1
enabled=1
baseurl=file:///var/ftp/pub/package/RHEL-8-5-0-BaseOS-x86_64/AppStream/
gpgkey=file:///var/ftp/pub/package/RHEL-8-5-0-BaseOS-x86_64/rpm-gpg/RPM-GPG-KEY-redhat-release


Steps to install SQL Server on Linux on RedHat

You can use the following steps to install SQL Server on Linux on Redhat Linux:

Step 1: Choose the Python interpreter


[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]# alternatives --config python

There are 3 programs which provide 'python'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/libexec/no-python
   2           /usr/bin/python3
   3           /usr/bin/python3.9

Enter to keep the current selection[+], or type selection number: 3
[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]#


Step 2: Download Microsoft SQL Server 2019 Red Hat repository configuration

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

[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]# curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   231  100   231    0     0    174      0  0:00:01  0:00:01 --:--:--   174
[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]#

Step 3: Install SQL Server on Linux

[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]# yum install -y mssql-server
Updating Subscription Management repositories.

This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions.

packages-microsoft-com-mssql-server-2019                                                                                                                       1.3 MB/s | 5.5 MB     00:04    
BaseOS                                                                                                                                                          49 MB/s | 2.4 MB     00:00    
AppStream                                                                                                                                                       69 MB/s | 7.2 MB     00:00    
Dependencies resolved.
===============================================================================================================================================================================================
 Package                                 Architecture                      Version                                   Repository                                                           Size
===============================================================================================================================================================================================
Installing:
 mssql-server                            x86_64                            15.0.4316.3-2                             packages-microsoft-com-mssql-server-2019                            229 M

Transaction Summary
===============================================================================================================================================================================================
Install  1 Package

Total download size: 229 M
Installed size: 1.1 G
Downloading Packages:
mssql-server-15.0.4316.3-2.x86_64.rpm                                                                                                                          1.9 MB/s | 229 MB     02:03    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                          1.9 MB/s | 229 MB     02:03     
packages-microsoft-com-mssql-server-2019                                                                                                                       1.1 kB/s | 983  B     00:00    
Importing GPG key 0xBE1229CF:
 Userid     : "Microsoft (Release signing) <gpgsecurity@microsoft.com>"
 Fingerprint: BC52 8686 B50D 79E3 39D3 721C EB3E 94AD BE12 29CF
 From       : https://packages.microsoft.com/keys/microsoft.asc
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                       1/1
  Running scriptlet: mssql-server-15.0.4316.3-2.x86_64                                                                                                                                     1/1
  Installing       : mssql-server-15.0.4316.3-2.x86_64                                                                                                                                     1/1
  Running scriptlet: mssql-server-15.0.4316.3-2.x86_64                                                                                                                                     1/1

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


  Verifying        : mssql-server-15.0.4316.3-2.x86_64                                                                                                                                     1/1
Installed products updated.

Installed:
  mssql-server-15.0.4316.3-2.x86_64                                                                                                                                                            

Complete!
[root@binimoy-db RHEL-8-5-0-BaseOS-x86_64]#

Step 4: Launch SQL Server Configuration Manager utility for SQL Server on Linux



[root@binimoy-db ~]# /opt/mssql/bin/mssql-conf setup
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): 5
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]:y

Enter the SQL Server system administrator password:   ----> Bankasia#2020
Confirm the SQL Server system administrator password:
Configuring SQL Server...

The licensing PID was successfully processed. The new edition is [Standard Edition].
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.
[root@binimoy-db ~]#

Step 5: Verify SQL Server services status


[root@binimoy-db ~]# systemctl status mssql-server.service
● mssql-server.service - Microsoft SQL Server Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-08-02 15:15:17 +06; 56s ago
     Docs: https://docs.microsoft.com/en-us/sql/linux
 Main PID: 2758308 (sqlservr)
    Tasks: 141
   Memory: 655.7M
   CGroup: /system.slice/mssql-server.service
           ├─2758308 /opt/mssql/bin/sqlservr
           └─2758335 /opt/mssql/bin/sqlservr

Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [65B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [155B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [61B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [96B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [66B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [75B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [96B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [100B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [124B blob data]
Aug 02 15:15:21 binimoy-db sqlservr[2758335]: [71B blob data]
[root@binimoy-db ~]#


Install the SQL Server command-line tools

installs SQL Server command-line utility, i.e., SQLCMD, for database connections.  
The first step is to download the RedHat repository configuration file.

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

[root@binimoy-db ~]# curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   192  100   192    0     0    127      0  0:00:01  0:00:01 --:--:--   127
[root@binimoy-db ~]# yum install -y mssql-tools unixODBC-devel
Updating Subscription Management repositories.

This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions.

packages-microsoft-com-prod                                                                                                                                    3.2 MB/s | 7.9 MB     00:02    
Last metadata expiration check: 0:00:03 ago on Wed 02 Aug 2023 03:22:23 PM +06.
Dependencies resolved.
===============================================================================================================================================================================================
 Package                                      Architecture                         Version                                     Repository                                                 Size
===============================================================================================================================================================================================
Installing:
 mssql-tools                                  x86_64                               17.10.1.1-1                                 packages-microsoft-com-prod                               291 k
 unixODBC-devel                               x86_64                               2.3.11-1.rh                                 packages-microsoft-com-prod                                53 k
Upgrading:
 unixODBC                                     x86_64                               2.3.11-1.rh                                 packages-microsoft-com-prod                               274 k
Installing dependencies:
 msodbcsql17                                  x86_64                               17.10.4.1-1                                 packages-microsoft-com-prod                               908 k

Transaction Summary
===============================================================================================================================================================================================
Install  3 Packages
Upgrade  1 Package

Total download size: 1.5 M
Downloading Packages:
(1/4): unixODBC-devel-2.3.11-1.rh.x86_64.rpm                                                                                                                    76 kB/s |  53 kB     00:00    
(2/4): msodbcsql17-17.10.4.1-1.x86_64.rpm                                                                                                                      869 kB/s | 908 kB     00:01    
(3/4): mssql-tools-17.10.1.1-1.x86_64.rpm                                                                                                                      277 kB/s | 291 kB     00:01    
(4/4): unixODBC-2.3.11-1.rh.x86_64.rpm                                                                                                                         779 kB/s | 274 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                          1.4 MB/s | 1.5 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                       1/1
  Upgrading        : unixODBC-2.3.11-1.rh.x86_64                                                                                                                                           1/5
  Running scriptlet: unixODBC-2.3.11-1.rh.x86_64                                                                                                                                           1/5
  Running scriptlet: msodbcsql17-17.10.4.1-1.x86_64                                                                                                                                        2/5
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)
YES
  Installing       : msodbcsql17-17.10.4.1-1.x86_64                                                                                                                                        2/5
  Running scriptlet: msodbcsql17-17.10.4.1-1.x86_64                                                                                                                                        2/5
odbcinst: Driver installed. Usage count increased to 1.
    Target directory is /etc

  Running scriptlet: mssql-tools-17.10.1.1-1.x86_64                                                                                                                                        3/5
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)
YES
  Installing       : mssql-tools-17.10.1.1-1.x86_64                                                                                                                                        3/5
  Installing       : unixODBC-devel-2.3.11-1.rh.x86_64                                                                                                                                     4/5
  Cleanup          : unixODBC-2.3.7-1.el8.x86_64                                                                                                                                           5/5
  Running scriptlet: unixODBC-2.3.7-1.el8.x86_64                                                                                                                                           5/5
  Running scriptlet: msodbcsql17-17.10.4.1-1.x86_64                                                                                                                                        5/5
  Running scriptlet: unixODBC-2.3.7-1.el8.x86_64                                                                                                                                           5/5
  Verifying        : msodbcsql17-17.10.4.1-1.x86_64                                                                                                                                        1/5
  Verifying        : mssql-tools-17.10.1.1-1.x86_64                                                                                                                                        2/5
  Verifying        : unixODBC-devel-2.3.11-1.rh.x86_64                                                                                                                                     3/5
  Verifying        : unixODBC-2.3.11-1.rh.x86_64                                                                                                                                           4/5
  Verifying        : unixODBC-2.3.7-1.el8.x86_64                                                                                                                                           5/5
Installed products updated.

Upgraded:
  unixODBC-2.3.11-1.rh.x86_64                                                                                                                                                                  
Installed:
  msodbcsql17-17.10.4.1-1.x86_64                                mssql-tools-17.10.1.1-1.x86_64                                unixODBC-devel-2.3.11-1.rh.x86_64                               

Complete!
[root@binimoy-db ~]#



We can add /opt/mssql-tools/bin/ to the PATH environment variable to run the tool without specifying the full path.

The following scripts modifies the PATH for both login sessions and interactive/non-login sessions:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc

source ~/.bashrc

[root@binimoy-db ~]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
[root@binimoy-db ~]# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
[root@binimoy-db ~]# source ~/.bashrc
[root@binimoy-db ~]# sqlcmd -s localhost -U sa
Password:
1> select @@version
2> go

                                                                                                                                                                                                                                                                                                            
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2019 (RTM-CU21) (KB5025808) - 15.0.4316.3 (X64)
    Jun  1 2023 16:32:31
    Copyright (C) 2019 Microsoft Corporation
    Standard Edition (64-bit) on Linux (Red Hat Enterprise Linux 8.7 (Ootpa)) <X64>                                                                                    

(1 rows affected)
1>


[root@binimoy-db ~]# firewall-cmd --zone=public --add-port=1433/tcp --permanent
success
[root@binimoy-db ~]#
[root@binimoy-db ~]# firewall-cmd --reload
success
[root@binimoy-db ~]#