我按照here的说明在PostgreSQL服务器上安装Oracle外部数据包装器oracle_fdw。
Oracle版本:Oracle Database 12c企业版12.1.0.2.0版 - 64位生产版,在Red Hat Linux 7.2上运行
PostgreSQL版本: x86_64-unknown-linux-gnu上的PostgreSQL 9.4.4,由gcc编译(Debian 4.7.2-5)4.7.2,64位,在Debian 7上运行(喘鸣)。
我能够成功安装sqlplus并使用sqlplus从PostgreSQL服务器连接到Oracle服务器,因此连接不是问题。
但是当我尝试创建扩展时,我收到以下错误:
postgres=# create extension oracle_fdw;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
然后我从https://github.com/dalibo/pg_qualstats/issues/1获取线索并将oracle_fdw添加到postgresql.conf中的shared_preload_libraries,如下所示:
shared_preload_libraries = 'oracle_fdw'
但现在我无法重启Postgres:
# service postgresql restart
[....] Restarting PostgreSQL 9.4 database server: main[....] The PostgreSQL server failed to start. Please check the log output: t=2016-09-15 11:05:42 PDT d= h= p=23300 a=FATAL: XX000: invalid cache ID[FAILt=2016-09-15 11:05:42 PDT d= h= p=23300 a=LOCATION: SearchSysCacheList, syscache.c:1219 ... failed!
failed!
查看/var/log/postgresql/postgresql-9.4-main.log我只看到这两行:
t=2016-09-15 11:05:42 PDT d= h= p=23300 a=FATAL: XX000: invalid cache ID: 41
t=2016-09-15 11:05:42 PDT d= h= p=23300 a=LOCATION: SearchSysCacheList, syscache.c:1219
从shared_preload_libraries中删除oracle_fdw允许重新启动postgres,因此这会导致重启失败。所以我从shared_preload_libraries中删除了oracle_fdw,并在postgresql.conf中保存它:
shared_preload_libraries = ''
然后我就能重启Postgres。
以下是完成的确切步骤:
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
root@app-4:/# cat /etc/debian_version
7.8
root@app-4:/# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 7.8 (wheezy)
Release: 7.8
Codename: wheezy
使用此处给出的说明安装: https://help.ubuntu.com/community/Oracle%20Instant%20Client
我从http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html下载了以下rpm文件:
使用以下命令将它们安装在PostgreSQL服务器上:
# apt-get install alien
# alien -i oracle-instantclient-basic-10.2.0.3-1.x86_64.rpm
# alien -i oracle-instantclient-devel-10.2.0.3-1.x86_64.rpm
# alien -i oracle-instantclient-sqlplus-10.2.0.3-1.x86_64.rpm
确认安装:
# dpkg --list | grep -i oracle
ii oracle-instantclient-basic 10.2.0.3-2 amd64 Instant Client for Oracle Database 11g
ii oracle-instantclient-devel 10.2.0.3-2 amd64 Development headers for Instant Client.
ii oracle-instantclient-sqlplus 10.2.0.3-2 amd64 SQL*Plus for Instant Client.
# su - postgres
postgres@app-4:~$ sqlplus <ORACLE_USER>/<ORACLE_PASS>@//<ORACLE_HOST>:<ORACLE_PORT>/<SID>
SQL*Plus: Release 10.2.0.3.0 - Production on Fri Sep 16 09:55:02 2016
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select count(*) from <TEST_TABLE>;
COUNT(*)
----------
937530
SQL>
所以这很好。
下载oracle_fdw 1.4.0版,即文件oracle_fdw-1.4.0.zip http://pgxn.org/dist/oracle_fdw/
然后解压缩并安装如下:
root@app-4:/home/arun/oracle_fdw-1.4.0# ls
CHANGELOG LICENSE META.json oracle_fdw--1.1.sql oracle_fdw.control oracle_fdw.o oracle_gis.c oracle_utils.c README.oracle_fdw TODO
expected Makefile oracle_fdw--1.0--1.1.sql oracle_fdw.c oracle_fdw.h oracle_fdw.so oracle_gis.o oracle_utils.o sql
root@app-4:/home/arun/oracle_fdw-1.4.0# make
...
root@app-4:/home/arun/oracle_fdw-1.4.0# make install
/bin/mkdir -p '/usr/lib/postgresql/9.4/lib'
/bin/mkdir -p '/usr/share/postgresql/9.4/extension'
/bin/mkdir -p '/usr/share/postgresql/9.4/extension'
/bin/mkdir -p '/usr/share/doc/postgresql-doc-9.4/extension'
/usr/bin/install -c -m 755 oracle_fdw.so '/usr/lib/postgresql/9.4/lib/oracle_fdw.so'
/usr/bin/install -c -m 644 oracle_fdw.control '/usr/share/postgresql/9.4/extension/'
/usr/bin/install -c -m 644 oracle_fdw--1.1.sql oracle_fdw--1.0--1.1.sql '/usr/share/postgresql/9.4/extension/'
/usr/bin/install -c -m 644 README.oracle_fdw '/usr/share/doc/postgresql-doc-9.4/extension/'
root@app-4:/# su - postgres
postgres@app-4:~$ psql
psql (9.4.4)
Type "help" for help.
postgres=# create extension oracle_fdw;
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> \q
我按照Laurenz Albe的建议安装了GNU调试器(gdb)并获得了以下堆栈跟踪(暂时没有调试符号):
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
#0 0x0000000000000000 in ?? ()
#1 0x00007ff657dfcc99 in DirectFunctionCall1Coll ()
#2 0x00007ff657de19a9 in ?? ()
#3 0x00007ff657de3037 in SearchCatCacheList ()
#4 0x00007ff4c5fcce7d in _PG_init () at oracle_fdw.c:648
#5 0x00007ff657dfb717 in ?? ()
#6 0x00007ff657dfc051 in load_external_function ()
#7 0x00007ff657b6b486 in fmgr_c_validator ()
#8 0x00007ff657dfdeba in OidFunctionCall1Coll ()
#9 0x00007ff657b6aedc in ProcedureCreate ()
#10 0x00007ff657bcf645 in CreateFunction ()
#11 0x00007ff657d14e73 in ?? ()
#12 0x00007ff657d140c7 in standard_ProcessUtility ()
#13 0x00007ff657bc89ed in ?? ()
#14 0x00007ff657bc98de in CreateExtension ()
#15 0x00007ff657d154c1 in ?? ()
#16 0x00007ff657d140c7 in standard_ProcessUtility ()
#17 0x00007ff657d11243 in ?? ()
#18 0x00007ff657d11e96 in ?? ()
#19 0x00007ff657d12b3d in PortalRun ()
#20 0x00007ff657d0fb1a in PostgresMain ()
#21 0x00007ff657acbdad in ?? ()
#22 0x00007ff657caf351 in PostmasterMain ()
#23 0x00007ff657acccba in main ()
Continuing.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
UPDATE :我能够在debian 8(8.6,jessie)上运行的Postgres 9.4.9上安装扩展程序。我使用的是Oracle即时客户端版本12.1.0.2.0-1和oracle_fdw版本1.5。
答案 0 :(得分:1)
你应该真的打开一个Github问题,这是报告错误的正确位置。
以下问题的答案将有所帮助:
您使用的是哪个版本的oracle_fdw
?
您用于构建它的具体步骤是什么?你是在运行它的系统上构建的吗?
崩溃的stack trace看起来如何(带有调试符号)?
两个一般性评论:
您应该使用README来构建oracle_fdw
而不是其他网站。
将其添加到shared_preload_libraries
是完全错误的。
答案 1 :(得分:1)
为什么对Oracle 12.1.0.2数据库使用oracle 10.2.0.3即时?我建议使用最新版本的即时客户端。
“SQL * Plus:版本10.2.0.3.0 - 生产于2016年9月16日星期五09:55:02”
当您使用基于debian的系统时,请不要使用即时客户端rpms并将其转换为deb软件包,请使用zip版本并相应地设置您的环境。
我会看看是否有时间来测试您的设置
干杯, 丹尼尔