Wednesday 10 January 2024

Step by step how to relocate an ACFS filesystem to another Diskgroup in Exadata

 Step 1) Backup all the files and directories contains on ACFS

Step 2) Obtain the information about the current ACFS filesystem and ADVM volume:

opc@said-dbvm01 ~]$ sudo su -
Last login: Thu Jan 11 08:31:39 +06 2024 on pts/1
Last login: Thu Jan 11 08:46:30 +06 2024 on pts/0
[root@said-dbvm01 ~]# su - grid
Last login: Thu Jan 11 08:43:44 +06 2024
Last login: Thu Jan 11 08:46:33 +06 2024 on pts/0
[grid@said-dbvm01 ~]$ asmcmd
ASMCMD> volinfo --all
Diskgroup Name: DATAC1

         Volume Name: ACFSVOL01
         Volume Device: /dev/asm/acfsvol01-390
         State: ENABLED
         Size (MB): 1150976
         Resize Unit (MB): 64
         Redundancy: HIGH
         Stripe Columns: 8
         Stripe Width (K): 1024
         Usage: ACFS
         Mountpath: /acfs01

ASMCMD>


[grid@said-dbvm01 ~]$ df -m /acfs01/
Filesystem             1M-blocks  Used Available Use% Mounted on
/dev/asm/acfsvol01-390   1150976  8427   1142550   1% /acfs01
[grid@said-dbvm01 ~]$


3) Stop and dismount the associated filesystem clusterwide as follows (as root user):

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATAC1.ACFSVOL01.advm
               ONLINE  ONLINE       dr01v-dbvm01             STABLE
               ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.LISTENER.lsnr
               ONLINE  ONLINE       dr01v-dbvm01             STABLE
               ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.chad
               ONLINE  ONLINE       dr01v-dbvm01             STABLE
               ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.datac1.acfsvol01.acfs
               ONLINE  ONLINE       dr01v-dbvm01             mounted on /acfs01,S
                                                             TABLE
               ONLINE  ONLINE       dr01v-dbvm02             mounted on /acfs01,S
                                                             TABLE
ora.net1.network
               ONLINE  ONLINE       dr01v-dbvm01             STABLE
               ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.ons
               ONLINE  ONLINE       dr01v-dbvm01             STABLE
               ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.proxy_advm
               ONLINE  ONLINE       dr01v-dbvm01             STABLE
               ONLINE  ONLINE       dr01v-dbvm02             STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
      2        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.DATAC1.dg(ora.asmgroup)
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
      2        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
ora.LISTENER_SCAN2.lsnr
      1        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.LISTENER_SCAN3.lsnr
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
ora.RECOC1.dg(ora.asmgroup)
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
      2        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.asm(ora.asmgroup)
      1        ONLINE  ONLINE       dr01v-dbvm01             Started,STABLE
      2        ONLINE  ONLINE       dr01v-dbvm02             Started,STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
      2        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.badgcc.bacoredb_pdb1.paas.oracle.com.svc
      1        OFFLINE OFFLINE                               STABLE
      2        OFFLINE OFFLINE                               STABLE
ora.badgcc.db
      1        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
      2        OFFLINE OFFLINE                               Instance Shutdown,ST
                                                             ABLE
ora.cvu
      1        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.dr01v-dbvm01.vip
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
ora.dr01v-dbvm02.vip
      1        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.qosmserver
      1        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.scan1.vip
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
ora.scan2.vip
      1        ONLINE  ONLINE       dr01v-dbvm02             STABLE
ora.scan3.vip
      1        ONLINE  ONLINE       dr01v-dbvm01             STABLE
--------------------------------------------------------------------------------
[root@dr01v-dbvm01 ~]#

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/srvctl status filesystem -d /dev/asm/acfsvol01-390
ACFS file system /acfs01 is mounted on nodes dr01v-dbvm01,dr01v-dbvm02
[root@said-dbvm01 ~]#

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/srvctl stop filesystem -d /dev/asm/acfsvol01-390

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/srvctl status filesystem -d /dev/asm/acfsvol01-390
ACFS file system /acfs01 is not mounted
[root@said-dbvm01 ~]#


Step 4) Then disable the associated volume in every node:

[grid@said-dbvm01 ~]$ asmcmd voldisable -G DATAC1 ACFSVOL01
[grid@said-dbvm01 ~]$

[opc@said-dbvm02 ~]$ sudo su -
Last login: Thu Jan 11 08:49:21 +06 2024
Last login: Thu Jan 11 08:56:44 +06 2024 on pts/0
[root@said-dbvm02 ~]# su - grid
Last login: Thu Jan 11 08:49:21 +06 2024
Last login: Thu Jan 11 08:56:48 +06 2024 on pts/0
[grid@said-dbvm02 ~]$ asmcmd voldisable -G DATAC1 ACFSVOL01
[grid@said-dbvm02 ~]$

Step 5) After the volume is disabled in every node, it can be deleted from node #1 as follows:

[grid@said-dbvm01 ~]$ asmcmd voldelete -G DATAC1 ACFSVOL01
[grid@said-dbvm01 ~]$

[grid@said-dbvm02 ~]$ asmcmd voldelete -G DATAC1 ACFSVOL01
ORA-15032: not all alterations performed
ORA-15466: volume 'ACFSVOL01' in disk group 'DATAC1' does not exist (DBD ERROR: OCIStmtExecute)
[grid@said-dbvm02 ~]$

Step 6) Remove the associated ACFS and ADVM CRS resources as follows (as root user from node #1):

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/srvctl remove filesystem -d /dev/asm/acfsvol01-390 -force
PRCT-1011 : Failed to run "advmutil". Detailed error: advmutil: ADVM-03168: Internal error: clscrs_res_get_attr(). attrName=CANONICAL_VOLUME_DEVICE 4,advmutil: ADVM-03180: Unable to obtain ASM volume device information for '/dev/asm/acfsvol01-390'


Step 7) Recreate the ADVM volume in the new diskgroup (e.g. ACFSDG):

SQL> ALTER DISKGROUP ACFSDG ADD VOLUME ACFSVOL SIZE 600G;

[grid@said-dbvm01 ~]$ sqlplus

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jan 11 09:03:25 2024
Version 19.20.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

Enter user-name: /as sysasm

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0

SQL> ALTER DISKGROUP RECOC1 ADD VOLUME ACFSVOL01 SIZE 600G;

Diskgroup altered.

SQL>

[grid@said-dbvm01 ~]$ asmcmd volinfo --all
Diskgroup Name: RECOC1

         Volume Name: ACFSVOL01
         Volume Device: /dev/asm/acfsvol01-178
         State: ENABLED
         Size (MB): 614400
         Resize Unit (MB): 64
         Redundancy: HIGH
         Stripe Columns: 8
         Stripe Width (K): 1024
         Usage:
         Mountpath:

[grid@said-dbvm01 ~]$


Step 9) Create an ACFS filesystem in the new volume:

$> /sbin/mkfs -t acfs /dev/asm/acfsvol01-178


[root@dr01v-dbvm01 ~]# /sbin/mkfs -t acfs /dev/asm/acfsvol01-178
mkfs.acfs: version                   = 19.0.0.0.0
mkfs.acfs: on-disk version           = 46.0
mkfs.acfs: volume                    = /dev/asm/acfsvol01-178
mkfs.acfs: volume size               = 644245094400  ( 600.00 GB )
mkfs.acfs: Format complete.
[root@dr01v-dbvm01 ~]#


Step 10) Create the CRS resource associated to the new ACFS filesystem as follows (as root user from node #1):


# srvctl add filesystem -d /dev/asm/acfsvol-286 -g 'ACFSDG' -v ACFSVOL -m /goldengate -u grid

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/srvctl add filesystem -d /dev/asm/acfsvol01-178 -g 'RECOC1' -v ACFSVOL01 -m /acfs01 -u grid
[root@dr01v-dbvm01 ~]#


Step 11) Finally, start and mount the filesystem as follows (as root user from node #1):

# srvctl start filesystem -d /dev/asm/acfsvol-286

[root@said-dbvm01 ~]# /u01/app/19.0.0.0/grid/bin/srvctl start filesystem -d /dev/asm/acfsvol01-178
[root@said-dbvm01 ~]#


Step 12) Verify the new ACFS filesystem is mounted on all the nodes:

[root@said-dbvm01 ~]# df -m /acfs01/
Filesystem             1M-blocks  Used Available Use% Mounted on
/dev/asm/acfsvol01-178    614400  1832    612569   1% /acfs01
[root@said-dbvm01 ~]#

[grid@said-dbvm02 ~]$ df -m /acfs01/
Filesystem             1M-blocks  Used Available Use% Mounted on
/dev/asm/acfsvol01-178    614400  1832    612569   1% /acfs01
[grid@said-dbvm02 ~]$ df -h
Filesystem                                                Size  Used Avail Use% Mounted on
devtmpfs                                                  252G     0  252G   0% /dev
tmpfs                                                     504G  209M  504G   1% /dev/shm
tmpfs                                                     252G   11M  252G   1% /run
tmpfs                                                     252G     0  252G   0% /sys/fs/cgroup
/dev/mapper/VGExaDb-LVDbSys1                               15G  7.7G  7.4G  51% /
/dev/sda1                                                 509M  118M  391M  24% /boot
/dev/mapper/VGExaDb-LVDbKdump                              20G   33M   20G   1% /crashfiles
/dev/mapper/VGExaDbDisk.u01.20.img-LVDBDisk                20G  1.9G   19G  10% /u01
/dev/mapper/VGExaDbDisk.grid19.0.0.0.230718.img-LVDBDisk   50G   12G   39G  23% /u01/app/19.0.0.0/grid
/dev/mapper/VGExaDb-LVDbVar1                              5.0G  1.8G  3.3G  36% /var
/dev/mapper/VGExaDbDisk.u02_extra.img-LVDBDisk             57G   15G   40G  27% /u02
/dev/mapper/VGExaDb-LVDbHome                              4.0G   45M  4.0G   2% /home
/dev/mapper/VGExaDb-LVDbTmp                               3.0G   33M  3.0G   2% /tmp
/dev/mapper/VGExaDb-LVDbVarLog                             18G  466M   18G   3% /var/log
/dev/mapper/VGExaDb-LVDbVarLogAudit                       3.0G  161M  2.9G   6% /var/log/audit
tmpfs                                                      51G     0   51G   0% /run/user/1001
tmpfs                                                      51G     0   51G   0% /run/user/1000
tmpfs                                                      51G     0   51G   0% /run/user/0
tmpfs                                                      51G     0   51G   0% /run/user/2000
/dev/asm/acfsvol01-178                                    600G  1.8G  599G   1% /acfs01
[grid@said-dbvm02 ~]$

13) Copy back the files and directories from your backup (transient filesystem) to your new ACFS filesystem (“/acfs01”).


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 ~]#