Solved

Install TDS on Centos

Posted on 2013-06-20
15
1,682 Views
Last Modified: 2013-06-24
I have setup a testing Centos and try to setup the TDS and ODBC on my Centos in order to connect to MS SQL Server.

1. yum install unixODBC.x86_64

2. wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz 
        ./configure --prefix=/usr/local  
        make
        make install

Configure the /usr/local/etc/freetds.conf and connect to MS SQL, it works fine.

Checking my production server, there is also ODBC setting.(odbc.ini) that refer a driver : /usr/local/lib/libtdsodbc.so.  However, I can't find this library in my testing Centos. Should it be installed with steps mentioned below.

What's the usage for this odbc.ini ? Seem like setting up the freetds.conf can connect to MS SQL ? Any idea ?

Thanks
0
Comment
Question by:AXISHK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 

Author Comment

by:AXISHK
ID: 39265356
Follow the link
http://www.unixodbc.org/doc/FreeTDS.html

I can install the libtdsodbc.so. However, run "odbcinst -i -s -f tds.datasource.template" but it can't generate any entry in odbc.ini. Any idea ?

In addition, how to odbc.so in Centos as mentioned in the article ?

Tks
0
 
LVL 78

Expert Comment

by:arnold
ID: 39267560
The file odbcinst is using is odbcinst.ini
You could try adding the -l /etc/odbc.ini

Reference http://csurs.csr.uky.edu/cgi-bin/man/man2html?1+odbcinst
0
 

Author Comment

by:AXISHK
ID: 39270201
odbcinst -i -s -f tds.datasource.template -l /etc/odbc.ini

It doesn't make any different. File odbc.ini does not created under /etc/

Tks
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 78

Expert Comment

by:arnold
ID: 39270233
I have not used it, but which of your applications/programs rely on odbc.ini and are not working because of that?

There was a commercial ODBC driver and everything relied on the /etc/odbc.ini file for the connection.

your system with freetds has odbcinst.ini which reflects the same set of information.
You could hard link odbcinst.ini to odbc.ini
rm /etc/odbc.ini ; ln /etc/odbcinst.ini /etc/odbc.ini
0
 

Author Comment

by:AXISHK
ID: 39270355
The production server has been setup for PHP to access the SQL Server and I believe we will just follow it.

http://www.get-the-solution.net/index-blog-1-14-118-freetds+odbc+Datas+%5BS1000%5D%5BunixODBC%5D%5BFreeTDS%5D%5BSQL+Server%5DUnable+to+connect+to+data+source.html

The FreeTDS connection works fine (with tsql), but I can't access through UnixODBC. It pops out "Unable to connect to data source".
0
 
LVL 78

Expert Comment

by:arnold
ID: 39270370
Hard link the odbcinst.ini to odbc.ini and see if that resolves you issue.

Do you have the template you used with odbcinst?
0
 

Author Comment

by:AXISHK
ID: 39270503
Doesn't help.

[root@myweb etc]# cat tds.datasource.template
[SMS_SRV]
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Server = 10.131.28.22
Port = 1433
TDS Version = 8.0

[root@myweb etc]# cat tds.driver.template
[FreeTDS]
Description=v0.63 with protocol v8.0
Driver = /usr/local/lib/libtdsodbc.so
[root@myweb etc]#
0
 
LVL 78

Expert Comment

by:arnold
ID: 39270900
Look at odbcinst.ini

Create an entry for the server you want to access there based on example present there.

You have an example how the server has to be defined within either file.
I think, are you working on he basis that running odbcinst will create the appropriate entry for you?
0
 

Author Comment

by:AXISHK
ID: 39271518
odbcinst.ini & odbc.ini have the entry inside. Can't find anything wrong on the entry.

TDS setup should be correct as I can use tsql command to login to the MS SQL. Only the UnixODBC shouldn't be setup but I have review odbc.ini & odbcinst.ini. Can't identify any problem..


[root@myweb ~]# isql -v HPSMS_SRV sa xxxxx
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect
[root@myweb ~]#
Tks
0
 
LVL 78

Expert Comment

by:arnold
ID: 39271756
odbcinst -i -d -f tds.datasource.template

is this what you have in the odbcinst.ini
[PostgreSQL]
Description             = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64                = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage               = 1

[MySQL]
Description             = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64                = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage               = 1

[Registrar]
Driver          = FreeTDS
Description             = UCLA Registrar (SRDB)
Trace           = No
Server          = srdb.registrar.ucla.edu
Port            = 1433
Create file tds.datasource.template:            =
UsageCount              = 1

[FreeTDS]
Description             = v0.63 with protocol v8.0
Driver          = /usr/lib/libtdsodbc.so
UsageCount              = 1


Is this what you have in freeTDS.conf


#   $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".

# Global settings are overridden by those in a database
# server specific section
[global]
        # TDS protocol version
;       tds version = 4.2

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.
        # Try setting 'text size' to a more reasonable limit
        text size = 64512

# A typical Sybase server
[egServer50]
        host = symachine.domain.com
        port = 5000
        tds version = 5.0

# A typical Microsoft server
[egServer70]
        host = ntmachine.domain.com
        port = 1433
        tds version = 7.0

The entries that are added to odbcinst.ini  provide an example on creating note the last two entries in /etc/odbcinst.ini
0
 

Author Comment

by:AXISHK
ID: 39273497
Those settings the the files are correct. Again, TDS works fine but not for UNIXODBC setting. Do I miss anything beside the files mentioned ? Do I miss any system file ?

Tks


/etc/odbcinst.ini
-----------------
[FreeTDS]
Description=v0.63 with protocol v8.0
Driver=/usr/local/lib/libtdsodbc.so
UsageCount=4

/etc/freetds.conf
-----------------
[HPSMS_SRV]
        host = 10.131.28.22
        port = 1433
        tds version = 8.0


/etc/odbc.ini
-------------
[HPSMS_SRV]
Driver=/usr/local/lib/libtdsodbc.so
Description=ODBC connection via FreeTDS
Servername=HPSMS_SRV
TDS_Version=8.0
Database=SMS


tsql result
-----------
[root@myweb etc]# tsql -S HPSMS_SRV -U sa -P xxxxxx
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit



isql result
----------------
[root@myweb etc]# isql -v HPSMS_SRV sa xxxxxx
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect
0
 
LVL 78

Accepted Solution

by:
arnold earned 500 total points
ID: 39273529
The error you get is between the interaction of unixodbc and freetds.

http://mailman.unixodbc.org/pipermail/unixodbc-support/2008-November/001842.html

suggests including server connection information within odbc.ini
versus bouncing odbc.ini and assuming it will jump to odbcinst.ini to determine the server IP/PORT

odbc.ini following above link example, change yours to:
[HPSMS_SRV]

Description     = HPSMS_SRV

Driver          = TDS

Trace           = Yes

TraceFile       = /tmp/odbc.trace

Database        = SMS

Server          = 10.131.28.22

Port            = 1433

TDS_Version = 8.0

Open in new window

0
 

Author Comment

by:AXISHK
ID: 39273624
Get the same result.

However, accidentically find out that "TDSVER=8.0 isql HPSMS_SRV root xxxx –v" works fine for my old configuration.

But still looking around how to ingore "TDSVER=8.0" as I don't need that on my production server....
0
 
LVL 78

Expert Comment

by:arnold
ID: 39273708
The tds version control the interaction with sql server. Different "Versions" had issued referenced freetds references.
0
 

Author Closing Comment

by:AXISHK
ID: 39273759
Finally, fix the problem by removing a file the odbc.ini under root/.odbc.ini.

Afterwards, it could connect to the SQL server. Thanks for the information anyway.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question