我试图在SLES12机器上使用Perl5.26.1连接到PostgreSQL12.1 DB实例,但是遇到了错误。我的测试脚本很简单。
#!/usr/pkgs/perl/5.26.1/bin/perl
use DBI;
my $dbname = "XXX";
my $host = "XXX";
my $port = XXX;
my $username = "XXX";
my $password = "XXX";
my $dbh = DBI -> connect("dbi:Pg:dbname=$dbname;sslmode=require;host=$host;port=$port",
$username,
$password,
{AutoCommit => 0, RaiseError => 1}
) or die $DBI::errstr;
当我运行这个脚本时,我得到以下错误:sslmode value "require" invalid when SSL support is not compiled in at...
我已经将LD_LIBRARY_PATH
设置为指向libpq库的本地版本(构建于PostgreSQL13.3源)。我使用--open-ssl
支持构建了这个库。我向pg_config --configure
证实了这一点。
$ ./bin/pg_config --configure
'--prefix' '/myworkarea/tmp/local' '--with-perl' '--with-python' '--with-tcl' '--with-openssl' '--with-ldap' '--with-pam' '--with-libxml' '--with-libxslt'
我可以使用pgAdmin连接到DB,而不会出现任何问题。我确认它支持通过DBD:Pg连接Postgres。
$ perl -MDBI -e 'DBI->installed_versions'
Perl : 5.026001 (x86_64-linux)
OS : linux (4.4.49-92.14-default)
DBI : 1.639
DBD::mysql : 4.043
DBD::Sybase : 1.16
DBD::Sponge : 12.010003
DBD::SQLite : 1.54
DBD::Proxy : 0.2004
DBD::Pg : 3.7.4
DBD::Oracle : 1.80
DBD::ODBC : 1.56
DBD::Multiplex : 2.11
DBD::Mock : 1.45
DBD::Mem : 0.001
DBD::LDAP : 0.22
DBD::Gofer : 0.015327
DBD::File : 0.44
DBD::ExampleP : 12.014311
DBD::DBM : 0.08
DBD::CSV : 0.49
但是我查看Pg.so来查找依赖项,但它似乎仍然指向已安装的系统文件,而不是我的版本。我该怎么解决这个问题?
$ ldd /usr/pkgs/perl/5.26.1/lib64/site_perl/x86_64-linux/auto/DBD/Pg/Pg.so
linux-vdso.so.1 (0x00007ffff7ffa000)
libpq.so.5 => /usr/pkgs/postgresql/9.5.0/lib/libpq.so.5 (0x00007ffff797b000) <-- Not picking up my setting from LD_LIBRARY_PATH
libm.so.6 => /lib64/libm.so.6 (0x00007ffff767e000)
libc.so.6 => /lib64/libc.so.6 (0x00007ffff72d9000)
libpthread.so.0 => /lib64/noelision/libpthread.so.0 (0x00007ffff70bc000)
/lib64/ld-linux-x86-64.so.2 (0x00007ffff7ddb000)
发布于 2021-06-28 22:03:49
与DBD::Pg链接的PostgreSQL客户端共享库(libpq)是在没有SSL支持的情况下构建的。那不管用。您必须使用带有SSL支持的libpq。
这需要做两件事:
--with-openssl
交换机配置PostgreSQL,POSTGRES_LIB
、POSTGRES_HOME
环境变量来构建DBD:Pg模块,以便与1中的库链接。请参阅安装方面的自述部分.https://stackoverflow.com/questions/68172118
复制相似问题