Pages

Wednesday, February 25, 2015

How to Install Configure FreeTDS on centos 6.5

FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases.

Technically speaking, FreeTDS is an open source implementation of the TDS (Tabular Data Stream) protocol used by these databases for their own clients. It supports many different flavors of the protocol and three APIs to access it.
Additionally FreeTDS works with other software such as Perl and PHP, providing access from those languages as well.


Well i will use this to connect my Perl Scripts to SQL Server Databases in CentOS.
Currently in 6.5 using yum, version installed is not working correct with Perl DBD Module. By this reason i need to do this task manually from scratch.

Requirement

RHE EPEL Repository
You must have make and gcc commands installed on your system
1.Install UnixODBC Package

[root@localhost ~]# yum install unixODBC unixODBC-devel

2. Install freeTDS Package

[root@localhost tmp]# wget ftp://ftp.astron.com/pub/freetds/stable/freetds-stable.tgz
[root@localhost tmp]# tar xfvz freetds-stable.tgz
[root@localhost freetds-stable]# cd [your freetds folder]
[root@localhost freetds-stable]# ./configure --prefix=/usr/local/freetds
[root@localhost freetds-stable]# make
[root@localhost freetds-stable]# make install
[root@localhost freetds-stable]# ln -s /usr/local/freetds/etc/freetds.conf /etc/freetds.conf




3. Configure freeTDS and unixODBC

[root@localhost ~]# nano /etc/odbcinst.ini

and add an entry for FreeTDS like this

[FreeTDS]
Description=ODBC for SQL Server
Driver=/usr/lib/libtdsodbc.so
Setup=/usr/lib/libtdsS.so
FileUsage=1

Now edit /etc/freetds.conf file and modify line
; tds version = 4.2
by
tds version = 8

4. EXPORT Variables needed Configuration

[root@localhost ~]# vim /etc/profile.d/freeTDS.sh

and add the following content

# Desc: Variable necesaria para las conexiones desde Perl a SQL SERVER uasndo Freetds y DBD:Sybase
export SYBASE=/usr/local/freetds

save the data.

Now you need to logout and login into the system

5. Test
Now you can test your SQL Server connectivity by issuing command on shell prompt.

[root@localhost ~]# tsql -S serverIP -U sql-username -P password

After issuing this command you will be in sql shell and can query sql server instance.

sql> use jincommon; select * from tableName; go;


To exit from sql shell type exit and enter.

sql> exit;

and then restart your server.

No comments:

Post a Comment