我正在尝试使用以下(工作)脚本通过代理测试Oracle数据库访问:
#!/usr/bin/perl
use DBI;
use strict;
use warnings qw(all);
print "Start ->\n";
my $driver = "Proxy";
my $host = "*******";
my $port = "2001";
my $database = "********";
my $driver2 = "Oracle";
my $userid = "******";
my $password = "*****";
my $dsn = "dbi:$driver:hostname=$host;port=$port;dsn=dbi:$driver2:$database";
print "Connect to database ->\n";
my $dbh = DBI->connect($dsn, $userid, $password) or die $DBI::errstr;
print "Read data ->\n";
my $sth = $dbh->prepare("SELECT SYSDATE FROM DUAL");
$sth->execute() or die $DBI::errstr;
print "Number of rows found :". $sth->rows;
while (my @row = $sth->fetchrow_array()) {
my ($sysdate) = @row;
print " System Time = $sysdate\n";
}
$sth->finish();
print "Disconnect ->\n";
$dbh = $dbh->disconnect or warn $dbh->errstr;
当我运行它时,唯一的输出是
Start ->
Connect to database ->
[blank line]
然后没有其他事情发生(等待超过一分钟)我必须用CTRL + C打破这个过程。
我确实通过连接到另一台主机/代理来验证脚本是否正常工作。所以我假设我正在测试的代理必须有一些特殊的东西。
我的问题是:脚本在没有提供任何错误的情况下暂停的原因是什么?有没有办法获得有关连接尝试的更多信息(如果访问尝试已经在目标系统上记录了点)?
修改
根据评论的建议,我通过“DBI_TRACE = 15 perl scriptname.pl”运行脚本并得到以下输出:
Connect to database ->
-> DBI->connect(dbi:Proxy:hostname=*****;port=2001;dsn=dbi:Oracle:******, *****, ****)
-> DBI->install_driver(Proxy) for linux perl=5.008005 pid=31261 ruid=27003 euid=27003
install_driver: DBD::Proxy version 0.2004 loaded from /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBD/Proxy.pm
New DBI::dr (for DBD::Proxy::dr, parent=, id=)
dbih_setup_handle(DBI::dr=HASH(0x9fdcf88)=>DBI::dr=HASH(0x9f96edc), DBD::Proxy::dr, 0, Null!)
dbih_make_com(Null!, 0, DBD::Proxy::dr, 112, 0) thr#0
dbih_setup_attrib(DBI::dr=HASH(0x9f96edc), Err, Null!) SCALAR(0x9fdf9d0) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x9f96edc), State, Null!) SCALAR(0x9fdf9b8) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x9f96edc), Errstr, Null!) SCALAR(0x9fdf9e8) (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x9f96edc), TraceLevel, Null!) 0 (already defined)
dbih_setup_attrib(DBI::dr=HASH(0x9f96edc), FetchHashKeyName, Null!) 'NAME' (already defined)
>> STORE DISPATCH (DBI::dr=HASH(0x9fdcf88) rc1/1 @3 g0 ima41c pid#31261) at /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBD/Proxy.pm line 76
-> STORE in DBD::_::common for DBD::Proxy::dr (DBI::dr=HASH(0x9fdcf88)~0x9f96edc 'CompatMode' 1)
STORE DBI::dr=HASH(0x9f96edc) 'CompatMode' => 1
warn: 0 '' (err#0)
<- STORE= 1 at /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBD/Proxy.pm line 76
<- install_driver= DBI::dr=HASH(0x9fdcf88)
>> connect DISPATCH (DBI::dr=HASH(0x9fdcf88) rc2/3 @5 g0 ima1 pid#31261) at /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBI.pm line 625
!! warn: 0 CLEARED by call to connect method
-> connect for DBD::Proxy::dr (DBI::dr=HASH(0x9fdcf88)~0x9f96edc 'hostname=****;port=2001;dsn=dbi:Oracle:*****' '*****' **** HASH(0x9f0f834))
将试图找出实际意味着什么。 :)
EDIT2
根据Why is there a "0 CLEARED by call to connect method" warning in DBI_TRACE?,“警告”线不是罪魁祸首。所以我跟踪之前一样聪明吗?
EDIT3
相当冒险。我确实让脚本在后台闲置,并且在4分钟之后它实际上已停止并提供了更多的跟踪神度:
>> set_err DISPATCH (DBI::dr=HASH(0x8d1fedc) rc1/3 @4 g0 ima11 pid#32187) at /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBD/Proxy.pm line 89
1 -> set_err in DBD::_::common for DBD::Proxy::dr (DBI::dr=HASH(0x8d1fedc)~INNER 1 'Cannot log in to DBI::ProxyServer: Cannot connect: Connection timed out at /opt/perl585/lib/site_perl/5.8.5/RPC/PlClient.pm line 70. at /opt/perl585/lib/site_perl/5.8.5/Net/Daemon/Log.pm line 136.
' ' ')
!! ERROR: 1 'Cannot log in to DBI::ProxyServer: Cannot connect: Connection timed out at /opt/perl585/lib/site_perl/5.8.5/RPC/PlClient.pm line 70. at /opt/perl585/lib/site_perl/5.8.5/Net/Daemon/Log.pm line 136.
' (err#1)
1 <- set_err= undef at /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBD/Proxy.pm line 89
!! ERROR: 1 'Cannot log in to DBI::ProxyServer: Cannot connect: Connection timed out at /opt/perl585/lib/site_perl/5.8.5/RPC/PlClient.pm line 70. at /opt/perl585/lib/site_perl/5.8.5/Net/Daemon/Log.pm line 136.
' (err#1)
<- connect= undef at /opt/perl585/lib/site_perl/5.8.5/i686-linux/DBI.pm line 625
-> $DBI::errstr (&) FETCH from lasth=HASH
>> DBD::Proxy::dr::errstr
<- $DBI::errstr= 'Cannot log in to DBI::ProxyServer: Cannot connect: Connection timed out at /opt/perl585/lib/site_perl/5.8.5/RPC/PlClient.pm line 70. at /opt/perl585/lib/site_perl/5.8.5/Net/Daemon/Log.pm line 136.
'
DBI connect('hostname=*****;port=2001;dsn=dbi:Oracle:****','*****',...) failed: Cannot log in to DBI::ProxyServer: Cannot connect: Connection timed out at /opt/perl585/lib/site_perl/5.8.5/RPC/PlClient.pm line 70. at /opt/perl585/lib/site_perl/5.8.5/Net/Daemon/Log.pm line 136.
[... more of the same and the final DESTROY ...]
所以目标代理/主机似乎只是脱机或在防火墙后面(在后一种情况下我会得到相同的响应)吗?