新问题:
我正在尝试运行check_sql命令并遇到此问题
./odbcinst -j
unixODBC 2.3.0
DRIVERS............: /usr/local/unixODBC/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixODBC/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixODBC/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
[root@]# /usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:Driver={SQL Server};Server=10.125.243.4;dbname=test" -U TEST -P PASS
Trying to connect. Connect string: 'DBI:ODBC:Driver={SQL Server};Server=10.125.243.4;dbname=test'
DBI connect('Driver={SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at /usr/lib64/nagios/plugins/check_sql.pl line 212
CHECK_SQL.PL CRITICAL - [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)
[root@]# /usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test" -U TEST -P PASS
Trying to connect. Connect string: 'DBI:ODBC:Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test'
DBI connect('Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at /usr/lib64/nagios/plugins/check_sql.pl line 212
CHECK_SQL.PL CRITICAL - [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)
----------已修复---------已下载并已安装1.48且无错误
------使用1.1X ODBC的旧问题----------
我目前在DBD-ODBC-1.13目录
export LD_LIBRARY_PATH=/usr/lib:/usr/local/unixODBC
export ODBCHOME=/usr
export DBI_DSN=dbi:ODBC:JDBC
export DBI_USER=guest
export DBI_PASS=sybase
perl Makefile.PL
perl Makefile.PL
Useless use of private variable in void context at Makefile.PL line 431.
Argument "6.55_02" isn't numeric in numeric ge (>=) at Makefile.PL line 33.
Configuring DBD::ODBC ...
>>> Remember to actually *READ* the README file!
And re-read it if you have any problems.
Using DBI 1.609 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/
Using ODBC in /usr/local/unixODBC
Umm, this looks like a unixodbc type of driver manager.
We expect to find the sql.h, sqlext.h and (which were
supplied with unixODBC) in $ODBCHOME/include directory alongside
the /usr/local/unixODBC/lib/libodbc.so library. in $ODBCHOME/lib
Use of uninitialized value in pattern match (m//) at Makefile.PL line 272.
Warning: LD_LIBRARY_PATH doesn't include /usr/local/unixODBC
Injecting selected odbc driver into cc command
Injecting selected odbc driver into cc command
Using DBI 1.609 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/
Writing Makefile for DBD::ODBC
The DBD::ODBC tests will use these values for the database connection:
DBI_DSN=dbi:ODBC:JDBC e.g. dbi:ODBC:demo
DBI_USER=guest
DBI_PASS=sybase
提前致谢!
答案 0 :(得分:1)
我必须正确设置我的系统,让unixODBC与FreeTDS交谈:
我通过以下方式配置FreeTDS来完成此操作:取自http://www.unixodbc.org/doc/FreeTDS.html
./configure --with-tdsver=8.0 --prefix=/usr/local/freetds --with-unixodbc=/usr/local/unixODBC
make && make install
cd /usr/local/unixODBC/
mkdir templates && cd templates
vim tds.driver.template
[FreeTDS]
Description = v0.91 with protocol v8.0
Driver = /usr/local/freetds/lib/libtdsodbc.so
# Register ODBC Driver
../bin/odbcinst -i -d -f tds.driver.template
# Setup default DB - easily add or remove DSNs
vim tds.datasource.template
[ODBCTestServer]
Driver = FreeTDS
Description = Test
Trace = No
Server = 5.5.5.5
Port = 1433
Database = Test
# Create ODBC data source
../bin/odbcinst -i -d -f tds.datasource.template
/usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:DRIVER={FreeTDS};Server=5.5.5.5;dbname=test" -U TEST -P PASS
这最终允许连接发生。