添加postgis報cannot open shared object file: No such file or directory
安裝完瀚高數(shù)據(jù)庫后,客戶要求添加postgis,語句執(zhí)行情況如下
highgo=# create extension postgis; |
1、問題原因
檢查該文件的庫文件:
[highgo@dbtest lib]$ ldd /opt/HighGo6.0.4-cluster/lib/postgresql/postgis-3.so |
部分庫文件沒有加載
2、解決方案
一般有兩種方法加載庫文件:
建議使用第一種方法:
(1)默認的環(huán)境變量中未設(shè)置LD_LIBRARY_PATH
vi .bash_profile |
檢查ldd /opt/HighGo6.0.4-cluster/lib/postgresql/postgis-3.so
ldd /opt/HighGo6.0.4-cluster/lib/postgresql/postgis-3.so
linux-vdso.so.1 => (0x00007fff128f8000)
libm.so.6 => /usr/lib64/libm.so.6 (0x00007f9bba42b000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f9bba124000)
libgeos_c.so.1 => /opt/HighGo6.0.4-cluster/lib/libgeos_c.so.1 (0x00007f9bb9ee7000)
libproj.so.12 => /opt/HighGo6.0.4-cluster/lib/libproj.so.12 (0x00007f9bb9c7e000)
libjson-c.so.5 => /opt/HighGo6.0.4-cluster/lib/libjson-c.so.5 (0x00007f9bb9a6a000)
libprotobuf-c.so.1 => /opt/HighGo6.0.4-cluster/lib/libprotobuf-c.so.1 (0x00007f9bb9861000)
libxml2.so.2 => /opt/HighGo6.0.4-cluster/lib/libxml2.so.2 (0x00007f9bb94f7000)
libz.so.1 => /usr/lib64/libz.so.1 (0x00007f9bb92e1000)
libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f9bb90dd000)
libSFCGAL.so.1 => /opt/HighGo6.0.4-cluster/lib/libSFCGAL.so.1 (0x00007f9bb859f000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f9bb8389000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007f9bb7fbc000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9bbaa99000)
libgeos-3.8.0.so => /opt/HighGo6.0.4-cluster/lib/libgeos-3.8.0.so (0x00007f9bb7bf4000)
libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f9bb79d8000)
liblzma.so.5 => /usr/lib64/liblzma.so.5 (0x00007f9bb77b2000)
libCGAL_Core.so.13 => /opt/HighGo6.0.4-cluster/lib/libCGAL_Core.so.13 (0x00007f9bb7508000)
libboost_thread.so.1.72.0 => /opt/HighGo6.0.4-cluster/lib/libboost_thread.so.1.72.0 (0x00007f9bb72e8000)
libboost_system.so.1.72.0 => /opt/HighGo6.0.4-cluster/lib/libboost_system.so.1.72.0 (0x00007f9bb70e6000)
libboost_serialization.so.1.72.0 => /opt/HighGo6.0.4-cluster/lib/libboost_serialization.so.1.72.0 (0x00007f9bb6ea3000)
libCGAL.so.13 => /opt/HighGo6.0.4-cluster/lib/libCGAL.so.13 (0x00007f9bb6c6e000)
libgmp.so.10 => /usr/lib64/libgmp.so.10 (0x00007f9bb69f6000)
libmpfr.so.6 => /opt/HighGo6.0.4-cluster/lib/libmpfr.so.6 (0x00007f9bb6780000)
librt.so.1 => /usr/lib64/librt.so.1 (0x00007f9bb6578000)
pg_ctl reload執(zhí)行后報錯不變,需要重啟數(shù)據(jù)庫
pg_ctl restart |
添加postgis成功。
(2)在/etc/ld.so.conf添加庫文件位置
vi /etc/ld.so.conf |
添加postgis成功
這種方法不需要重啟數(shù)據(jù)庫,但ldconfig后有可能導(dǎo)致操作系統(tǒng)崩潰,可嘗試切換用戶su - highgo,如果報段錯誤,不要重啟服務(wù)器,刪除在ld.so.conf添加的內(nèi)容,重新執(zhí)行l(wèi)dconfig,在報段錯誤時重啟服務(wù)器,操作系統(tǒng)將無法啟動。