Troubeshooting SQL Server ODBC Connection Issues
Related to Copied
Can’t open lib ‘ODBC Driver 17 for SQL Server’, [unixODBC][Driver Manager]
Problem Copied
Unable to establish connection to an MSSQL server using ODBC driver Copied
This is apparent in the Active Console, where the database connectionStatus will show as Not Connected, and the below error will be seen in the gateway log file.
There was a problem connecting => db error msg: 01000 [unixODBC][Driver Manager]
Can't open lib 'ODBC Driver 17 for SQL Server' : file not found, db error code: 0 (type: DBMSAPI) [0] 01000 [unixODBC][Driver Manager]
Can't open lib 'ODBC Driver 17 for SQL Server' : file not found DBMSAPI
Possible Cause(s) Copied
- Microsoft OBDC driver library not installed
- Gateway unable to find ODBC library
- OBDC Library dependencies not satisfied
- Incompatible Gateway/OS installation
Possible Solution(s) Copied
Install the Microsoft ODBC library Copied
This will involve installing the correct Microsoft repository configuration, the library and any dependencies. You can find detailed installation instructions on the Microsoft website for various Linux distributions. Microsoft ODBC Linux installation instructions
Gateway unable to find ODBC library Copied
The following environment variables need to be initialised, as in the example below, in order for the ODBC library to be found. This would be best done in the gateway startup script, or can be set in the user’s shell environment.
SQLSERVER_LIB=/opt/microsoft/msodbcsql17/lib64 LD_LIBRARY_PATH=${SQLSERVER_LIB}:.:${LD_LIBRARY_PATH} ODBCHOME=${SQLSERVER_LIB} ODBCSYSINI=${SQLSERVER_LIB} ODBCINSTINI=odbcinst.ini GENEOS_MSSQL_DRIVER=‘ODBC Driver 17 for SQL Server’
Verify ODBC Library dependencies Copied
If a library that is a dependency of libmsodbcsql is not present, it may appear that libmsodbcsql is missing, as the same error message will appear in the log.
You can check library dependencies with the ldd command as shown below.
The example below shows a missing dependency, (libpcre2-8), that would lead to the ‘Can’t open lib ODBC Driver 17 for SQL Server’ error.
## ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.10.so.4.1
linux-vdso.so.1 (0x00007ffff687c000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f05566ca000)
librt.so.1 => /lib64/librt.so.1 (0x00007f05564c2000)
libodbcinst.so.2 => /lib64/libodbcinst.so.2 (0x00007f05562ae000)
libkrb5.so.3 => /lib64/libkrb5.so.3 (0x00007f0555fc3000)
libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x00007f0555d6e000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f05559d9000)
libm.so.6 => /lib64/libm.so.6 (0x00007f0555657000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f055543f000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f055521f000)
libc.so.6 => /lib64/libc.so.6 (0x00007f0554e5a000)
/lib64/ld-linux-x86-64.so.2 (0x00007f0556cd9000)
libltdl.so.7 => /lib64/libltdl.so.7 (0x00007f0554c50000)
libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x00007f0554a39000)
libcom_err.so.2 => /lib64/libcom_err.so.2 (0x00007f0554835000)
libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x00007f0554624000)
libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x00007f0554420000)
libcrypto.so.1.1 => /lib64/libcrypto.so.1.1 (0x00007f0553f36000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f0553d1e000)
libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f0553af3000)
libz.so.1 => /lib64/libz.so.1 (0x00007f05538db000)
libpcre2-8.so.0 => not found
Incompatible Gateway/OS installation Copied
There are different versions of Geneos software built for EL7, EL8, EL9, with specific library dependencies, in particular openssl and libcurl.
It is vital that the software matches the intended installation platform. e.g.
- geneos-gateway-6.4.0-el8-linux-x64.tar.gz - suitable for Enterprise Linux 8
- geneos-gateway-6.4.0-el9-linux-x64.tar.gz - suitable for Enterprise Linux 9