Check odbc connection linux

Configuring ODBC on Linux

ODBC driver managers use configuration files to define and configure ODBC data sources and drivers. To configure an ODBC connection for Linux, complete the following steps:

Sample Configuration Files

Before you connect to Drill through an ODBC client tool on Linux, copy the following configuration files in /opt/mapr/drill/Setup to your home directory unless the files already exist in your home directory:

In your home directory, rename the files as hidden files. Use sudo if necessary:

Step 1: Set Environment Variables

Set the ODBCINI environment variable to point to the .odbc.ini in your home directory.

Example:
export ODBCINI=

Set the MAPRDRILLINI environment variable to point to .mapr.drillodbc.ini in your home directory.

Example:
export MAPRDRILLINI=

Set the LD_LIBRARY_PATH environment variable to point to your ODBC driver manager libraries.

Example:
export LD_LIBRARY_PATH=/usr/local/lib

You can have both 32- and 64-bit versions of the driver installed at the same time on the same computer.

Do not include the paths to both 32- and 64-bit shared libraries in `LD_LIBRARY_PATH` at the same time.

Only include the path to the shared libraries corresponding to the driver matching the bitness of the client application you use to access Drill.

Step 2: Define the ODBC Data Sources in .odbc.ini

Define the ODBC data sources in the

/.odbc.ini configuration file for your environment. To use Drill in embedded mode, set the following properties:

To use Drill in distributed mode, set the following properties. (These properties are described in detail in the Direct and ZooKeeper Quorum Properties section.)

The following Linux sample shows a possible configuration for using Drill in distributed mode.

Authentication Properties

If the Drillbit requires authentication, uncomment the AuthenticationType, add an AuthenticationType, and configure properties. If the Drillbit does not require authentication (or to configure no password protection), you can use the No Authentication option. You do not need to configure additional settings.

  • Kerberos
    • See the MIT Kerberos documentation for installing and configuring a Kerberos environment, which is beyond the scope of the information provided here.
    • To specify the Kerberos mechanism:
      • Set the AuthenticationType to Kerberos.
      • Set the KrbServiceHost property to the FQDN of the Drill server host.
      • Set the KrbServiceName property to the Kerberos service principal name of the Drill server.
  • Plain (or Basic Authentication)
    • Configure the UID to an appropriate name for accessing the Drill server.
    • Set the PWD property to the password corresponding to the UID.

Direct and ZooKeeper Quorum Properties

To use Drill in distributed mode, set ConnectionType to Zookeeper, get the ZKQuorum and ZKClusterID values from the drill-override.conf file, and define the ZKQuorum and ZKClusterID properties. The drill-override.conf is in the /drill/drill- /conf directory. Format ZKQuorum as a comma separated list of ZooKeeper nodes in the following format:

To use Drill in embedded mode, do not define the ZKQuorum and ZKClusterID properties. Start Drill using the drill-localhost command, set ConnectionType to Direct, and define HOST and PORT properties. For example:

Driver Configuration Options describes configuration options available for controlling the behavior of DSNs using the Drill ODBC Driver.

Читайте также:  Загрузочный файл windows 10 pro

Step 3: (Optional) Define the ODBC Driver in .odbcinst.ini

The .odbcinst.ini is an optional configuration file that defines the ODBC Drivers. This configuration file is optional because you can specify drivers directly in the .odbc.ini configuration file. The .odbinst.ini file contains the following sample configurations.

Example

Step 4: Configure the Drill ODBC Driver

Configure the Drill ODBC Driver for your environment by modifying the .mapr.drillodbc.ini configuration file. This configures the driver to work with your ODBC driver manager. The following sample shows a possible configuration, which you can use as is if you installed the default iODBC driver manager.

Example

Configuring .mapr.drillodbc.ini

To configure the Drill ODBC Driver in the .mapr.drillodbc.ini configuration file, complete the following steps:

Open the .mapr.drillodbc.ini configuration file in a text editor.

Edit the DisableAsync setting if you want to enable a synchronous ODBC connection for performance reasons. Change the default 0 to 1 to disable the asynchronous and enable the synchronous connection. A change in state occurs during driver initialization and is propagated to all driver DSNs.

Note: As of version 1.3.8 of the driver, the DriverManagerEncoding setting is automatically detected and set if necessary. The value depends on the driver manager used; it’s typically UTF-16 or UTF-32. iODBC uses UTF-32 and unixODBC uses UTF-16.

Save the .mapr.drillodbc.ini configuration file.

Next Step

Copyright В© 2012-2020 The Apache Software Foundation, licensed under the Apache License, Version 2.0.
Apache and the Apache feather logo are trademarks of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.

Источник

Installing and Configuring an ODBC Driver on Linux (DEB / RPM)

This article explains how to install, configure, and test Devart ODBC drivers on Debian-based or RPM-based Linux distributions.

What is an ODBC Driver?

Open Database Connectivity (ODBC) is an industry-standard application programming interface for database access. It is based on call-level specifications for database APIs and uses SQL as its database access language.

An ODBC driver uses the ODBC interface to access data in database management systems. It allows an ODBC-compliant application to gain access to one or more data sources.

ODBC drivers work under the control of an ODBC driver manager, which is a library that manages communication between the ODBC-aware application and ODBC drivers. The driver manager carries out a number of tasks, such as resolving data source names, loading and unloading of the driver, processing and passing ODBC function calls to the driver, mapping function calls and data types between different versions of the ODBC standard, e.g. between version 3.x and 2.x.

On Linux systems, you can choose between the unixODBC and iODBC driver manager. We recommend using the unixODBC driver manager as it is more popular among Linux users and our drivers are fully compatible with it. If you would like to use iODBC with our drivers on Linux, you would have to manually modify the configuration files of the driver manager; note though that full compatibility with iODBC and stable operation of the drivers is not guaranteed in this event.

You can choose to install the ODBC driver using the DEB or RPM package, depending on your Linux distribution. Both DEB and RPM packages of Devart ODBC drivers require unixODBC as the driver manager.

Prerequisites

1. Prior to installing an ODBC driver on Linux, you need to install the unixODBC driver manager and its dependencies. To verify whether unixODBC is installed in the system, you can run the commands which odbcinst and which isql, which should return the path to the corresponding tools, or just run isql, which should print the syntax and available options for the isql utility.

Читайте также:  Есть файлы установки windows

2. Verify that the bitness of the driver that you are going to install matches the bitness of your Linux system and the unixODBC driver manager. The bitness of the driver is indicated on the download page of our website; also can you find out the bitness of the driver by looking at the .deb filename — a 32-bit driver contains i386 in its filename, whereas a 64-bit driver contains amd64.

To learn about the bitness of your Linux system, run the command uname -m, which should print x86_64 on a 64-bit system and anything else like i386 / i486 / i586 / i686 on a 32-bit system.

Which ODBC Driver Manager to Choose on Linux?

Sometimes, our users ask, which ODBC driver manager they should choose on a Linux system, unixODBC or iODBC. Both of them are open-source implementations of the ODBC standard, which enable non-Windows systems to communicate with databases via ODBC. We recommend using the unixODBC driver manager with our ODBC drivers on Linux, mainly because it is more stable than iODBC.

Advantages of unixODBC include support by many ODBC applications by default, availability of a cursor library, thread safety (including flags to protect handles at different levels), support for the latest ODBC 3.8 standard, and others. Historically, iODBC has been used mostly on macOS.

Debian-Specific Prerequisites

For a Debian derivative, such as Ubuntu, the following packages are required:

    odbcinst1debian2 – this package contains the libodbcinst library from unixODBC, a library used by ODBC drivers for reading their configuration settings from /etc/odbc.ini and

/.odbc.ini;

  • odbcinst – a unixODBC tool for manipulating configuration files: odbc.ini and odbcinst.ini;
  • libodbc1 – this package provides the unixODBC shared library, libodbc;
  • unixodbc – this package is an open source implementation of the Open Database Connectivity standard, a database abstraction layer that allows ODBC-compliant applications to access various databases; the package also contains isql, a command-line interactive SQL tool that allows you to test the configured DSN for connectivity to the database server and execute SQL statements interactively.
  • These packages depend on each other, so if you try to install them separately, you will most likely get an error saying that one package depends on another package from the list, and you will keep going round in circles. The solution is to install the packages with a single command: sudo apt-get install odbcinst1debian2 libodbc1 odbcinst unixodbc

    RPM-Specific Prerequisites

    To retrieve a list of available RPM packages of the unixODBC driver manager, run sudo yum search unixODBC.

    To install the 64-bit version of the unixODBC driver manager and all of its dependencies on a RHEL-derivative such as CentOS, run the command: sudo yum install -y unixODBC.x86_64 in the terminal.

    The above command installs all programs and libraries in the unixODBC package, such as isql, odbcinst, libodbcinst, libodbc.

    Installing and Configuring an ODBC Driver on Ubuntu

    Let’s see how to install an ODBC driver on Ubuntu, which is a popular open-source Linux distribution based on Debian. For the sake of this tutorial, we will install Devart ODBC Driver for PostgreSQL, but the following steps are true for other Devart ODBC drivers as well.

    There are two ways to install the driver on Ubuntu: using the Ubuntu Software Center (a discontinued high-level graphical front end for the APT/dpkg package management system) or using the dpkg manager for Debian packages.

    1. To install the driver with Software Center, navigate to the directory with the .deb package of the ODBC driver and double click on the file. This will launch Software Center, where you only need to click on the Install button.

    Читайте также:  Как убрать экран ввода пароля windows 10

    2. To install the driver using the command line, open a terminal window and navigate to the directory with the .deb package using the cd command, e.g. cd

    /Downloads. Run the command sudo dpkg -i devartodbcpostgresql_amd64.deb in the terminal.

    Note that the devartodbcpostgresql part of the filename is driver-specific, it will be different for other drivers. Once the installation has been successfully completed, we can configure a DSN to test connection to our database server.

    During installation, a sample system DSN is created by the driver in odbc.ini, which is a registry and configuration file for ODBC Data Source Names. To configure the connection parameters, open the file in any text editor – for example, nano, and specify connection information.

    You can either navigate to the folder /etc and double click on the odbc.ini file or run the command sudo nano /etc/odbc.ini in the terminal to open the file and start editing it. After entering the connection information, save the changes.

    If you prefer to configure a user DSN, run sudo nano

    /.odbc.ini in the terminal.

    Now it is time to test our DSN for its connectivity to the database server and execute a few SQL statements using the interactive command-line tool isql. In the terminal, run the isql command followed by the name of the data source, e.g. isql Devart_PostgreSQL. If an ODBC connection has been successfully established, you should see the appropriate message printed.

    Let’s try and execute an SQL statement to retrieve all fields from the table ‘cars’. Note that in order to remove extra white space from the isql output, we had to reconnect to the database system to add the -mNUM option, which limits the column display width to NUM characters.

    Installing and Configuring an ODBC Driver on CentOS

    Among the RPM-based distributions, we have chosen CentOS to install the RPM file of the ODBC driver.

    Navigate to the directory with the RPM file and run the command sudo rpm -ivh devart-odbc-postgresql.x86_64.rpm to install the ODBC driver for Linux (64-bit version). Once the installation has been successfully completed, you can configure the DSN that is created during installation, or you can create a new one.

    Navigate to the folder /etc and double click on the odbc.ini file or simply run the command sudo nano /etc/odbc.ini in the terminal to open the file for editing. After configuring the DSN parameters, save the changes to the odbc.ini file.

    Now you can connect to the data source by issuing the command isql Devart_PostgreSQL, and then execute a query against the database to fetch data.

    Step-by-Step ODBC Data Source Setup on Linux

    1. Run isql to verify whether unixODBC is installed.
    2. If not, install unixODBC: run sudo apt-get install odbcinst1debian2 libodbc1 odbcinst unixodbc for DEB or sudo yum install -y unixODBC.x86_64 for RPM.
    3. Run uname -m to verify that the installer matches the bitness of your system and unixODBC.
    4. To install the driver, run sudo dpkg -i drivername_amd64.deb for the .deb package or sudo rpm -ivh drivername.x86_64.rpm for the .rpm package.
    5. Run sudo nano /etc/odbc.ini to add entries to the odbc.ini file. Configure a DSN and save the changes.
    6. Run isql dsn_name to connect to the data source.

    By following the instructions in this article, you can easily install and configure an ODBC driver on Linux and execute SQL statements to access or modify data in the database.

    Источник

    Оцените статью