簡體   English   中英

將 postgis 擴展安裝到 postgresql 數據庫時出錯

[英]Error when installing postgis extension to postgresql database

我在將 postgis 安裝到現有數據庫時遇到問題。 但得到這樣的錯誤:

ERROR:  could not load library "/usr/local/pgsql/lib/postgis-2.0.so": libgeos_c.so.1: cannot open shared object file: No such file or directory

postgis-2.0.so 在/usr/local/pgsql/lib/postgis-2.0.so沒問題。 libgeos_c.so.1安裝在/usr/local/lib

那么,這里有什么問題呢?

任何幫助,將不勝感激。

謝謝。

順便說一句,我安裝了所有這些,然后是本教程:

http://www.codingsteps.com/installing-and-configuring-postgresql-in-amazon-linux-ami/

更新

$ ldd /usr/local/lib/libgeos_c.so.1
linux-vdso.so.1 =>  (0x00007fff6f55b000)
libgeos-3.3.7.so => /usr/local/lib/libgeos-3.3.7.so (0x00007f53700d9000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f536fdd0000)
libm.so.6 => /lib64/libm.so.6 (0x00007f536fb4c000)
libc.so.6 => /lib64/libc.so.6 (0x00007f536f7c0000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f536f5ab000)
/lib64/ld-linux-x86-64.so.2 (0x00007f537068d000)

它的方式更容易,只需使用一個明智的Linux發行版如Ubuntu,Debian的,Fedora的,紅帽等,您可以就用http://apt.postgresql.org/http://yum.postgresql.org/酌情預先構建所有這些東西並且易於安裝。 亞馬遜的 PostgreSQL 包裝不安全,近乎無能,應該避免。

我懷疑當前的問題是/usr/local/lib不在LD_LIBRARY_PATH和/或/etc/ld.so.conf ,所以當 PostgreSQL dlopen(...)postgis-2.0.so它試圖解決libgeos_c.so.1並沒有找到它。

另一種可能性是/usr/local/lib/libgeos_c.so.1是指向不存在文件的符號鏈接。

如果您通過源代碼安裝了 postgis,則可能您忘記運行sudo ldconfig 運行這個對我有用!

謝謝Yunwei.W,我在你分享的wiki看到了這個!

我似乎偶然遇到了類似的問題。 在 Cent OS 6 上,我從 PostgreSQL YUM 存儲庫安裝了二進制 PostgreSQL 9.3。 從官方穩定 tar 編譯 GDAL 庫版本 1.11.0。 然后從原始 PostGIS 存儲庫編譯 PostGIS 2.1.4dev。 單元測試表明,未加載libgdal ,因為未找到它。 錯誤消息看起來與原始問題中的類似。 @Craig 給出了使用strace想法。 關鍵在於將strace專門附加到在客戶端連接到 DBMS 之后創建的進程。 strace附加到 DBMS 后,讓客戶端要求服務器在當前數據庫上CREATE EXTENSION postgis並查看strace的輸出。 在我的情況下,它給出了這個:

open("/lib64/tls/x86_64/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/tls/x86_64", 0x7fffefb20290) = -1 ENOENT (No such file or directory)
open("/lib64/tls/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/tls", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
open("/lib64/x86_64/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/lib64/x86_64", 0x7fffefb20290)   = -1 ENOENT (No such file or directory)
open("/lib64/libgdal.so.1", O_RDONLY)   = -1 ENOENT (No such file or directory)
stat("/lib64", {st_mode=S_IFDIR|0555, st_size=12288, ...}) = 0
open("/usr/lib64/tls/x86_64/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/tls/x86_64", 0x7fffefb20290) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/tls", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
open("/usr/lib64/x86_64/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib64/x86_64", 0x7fffefb20290) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libgdal.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/lib64", {st_mode=S_IFDIR|0555, st_size=12288, ...}) = 0

它顯示了 DBMS 嘗試在哪些特定路徑中查找庫。在我的情況下,庫位於/usr/local/lib/libgdal.so.1.18.0帶有符號鏈接,以便在同一文件夾中使用更廣泛的版本。 我的解決方案是將這些文件的符號鏈接放入/usr/lib64文件夾中。

我已經有一段時間沒有解決這個問題了,幾乎忘記了我之前問過的這個問題。 我發現仍然從可能有這個問題的人那里得到贊成票。

所以基本上,我發現這個問題可能是因為我通過sudo apt-get install postgis安裝的postgis插件沒有正確安裝到PostgreSQl數據庫首選的位置。 我真的不是一個 linux 人來確保這一點。 但似乎每次我嘗試postgis這種方式安裝postgis ,都會出現此錯誤。

因此,解決此問題的方法是從源代碼下載、構建和安裝postgis

我關注了這個維基 希望它對某人有幫助。

/etc/ld.so.conf.d/應該包含 postgresql 庫目錄和地理庫的路徑。

Amazon linux 上的 postgresql 9.6.6 示例:

-create postgresql-pgdg-libs.conf with "/usr/lib64/pgsql96/" path
-create libgeos.conf with "/usr/local/lib/" path 
-check the geos library present in 
 ldconfig -v | grep geos
- if yes compile the extension
sudo -u postgres -- psql -c "CREATE EXTENSION postgis;"

這個命令對我有用

sudo ln -s /usr/lib/x86_64-linux-gnu/libgeos_c.so.1 /usr/lib/

這基本上是到 django 想要的位置的符號鏈接。 默認情況下, libgeos_c.so.1安裝在/usr/lib/x86_64-linux-gnu文件夾中

如果將來對任何人有幫助,我遇到了類似的問題(現在使用 postgis 3.0.1),結果問題的根源在於在 AWS Linux 2 上,我必須手動安裝 postgres 的pgxs部分(以管理擴展),以及那安裝部分期間./configure命令硬編碼為擴展的路徑的庫/usr/lib64/perl5/CORE/ (其中libperl.so生活)。 這是配置命令:

(見最后一個參數)

/usr/lib64/pgsql/pgxs/src/Makefile.global:configure_args =  '--build=x86_64-koji-linux-gnu' '--host=x86_64-koji-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--disable-rpath' '--with-perl' '--with-tcl' '--with-tclconfig=/usr/lib64' '--with-ldap' '--with-openssl' '--with-pam' '--with-gssapi' '--with-ossp-uuid' '--with-libxml' '--with-libxslt' '--enable-nls' '--enable-dtrace' '--with-selinux' '--with-system-tzdata=/usr/share/zoneinfo' '--datadir=/usr/share/pgsql' '--with-systemd' '--with-icu' '--with-python' 'build_alias=x86_64-koji-linux-gnu' 'host_alias=x86_64-koji-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-rpath=/usr/lib64/perl5/CORE/ -L/usr/lib64/perl5/CORE/' 'LDFLAGS=-Wl,-z,relro ' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic' 'PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

/usr/lib64/pgsql/pgxs/src/Makefile.global:CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-rpath=/usr/lib64/perl5/CORE/ -L/usr/lib64/perl5/CORE/

無論如何,我最終通過 @progalgo 提到的strace發現 postgis 試圖使用的庫(在創建擴展時)位於/usr/local/lib但沒有多少配置LD_LIBRARY_PATH變量可以使它看那里。 因此,我將文件從 perl 文件夾移至 /usr/local/lib,刪除該 /CORE 目錄,並將“CORE”符號鏈接至 /usr/local/lib 本身。 有點hack-y,但它有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM