1. 程式人生 > >PostgreSQL+REDIS_FDW詳細記錄踩坑過程(二)

PostgreSQL+REDIS_FDW詳細記錄踩坑過程(二)

為Pg安裝redis_fdw外掛

安裝PG https://blog.csdn.net/qq_36934544/article/details/82854762

1.為redis_fdw建立資料夾contrib :mkdir /monchickey/pgsql/contrib


[[email protected] /]# mkdir /monchickey/pgsql/contrib

2.解壓redis_fdw-REL_10_STABLE.zip : unzip  redis_fdw-REL_10_STABLE.zip

[[email protected] admin]# unzip redis_fdw-REL_10_STABLE.zip 
Archive:  redis_fdw-REL_10_STABLE.zip
8839b65ffff2d3f3f1b72297f32299d8d17fa534
   creating: redis_fdw-REL_10_STABLE/
  inflating: redis_fdw-REL_10_STABLE/.dir-locals.el  
  inflating: redis_fdw-REL_10_STABLE/.gitattributes  
  inflating: redis_fdw-REL_10_STABLE/.gitignore  
  inflating: redis_fdw-REL_10_STABLE/META.json  
  inflating: redis_fdw-REL_10_STABLE/Makefile  
  inflating: redis_fdw-REL_10_STABLE/README.md  
  inflating: redis_fdw-REL_10_STABLE/redis_fdw--1.0.sql  
  inflating: redis_fdw-REL_10_STABLE/redis_fdw.c  
  inflating: redis_fdw-REL_10_STABLE/redis_fdw.control  
   creating: redis_fdw-REL_10_STABLE/test/
 extracting: redis_fdw-REL_10_STABLE/test/.gitignore  
   creating: redis_fdw-REL_10_STABLE/test/expected/
  inflating: redis_fdw-REL_10_STABLE/test/expected/redis_fdw.out  
   creating: redis_fdw-REL_10_STABLE/test/sql/
 extracting: redis_fdw-REL_10_STABLE/test/sql/redis_clean  
  inflating: redis_fdw-REL_10_STABLE/test/sql/redis_fdw.sql  
  inflating: redis_fdw-R

3.將解壓後的檔案移動到contrib : mv /home/admin/redis_fdw-REL_10_STABLE /monchickey/pgsql/contrib/

[[email protected] /]# mv /home/admin/redis_fdw-REL_10_STABLE /monchickey/pgsql/contrib/
[[email protected] /]# 

4.把redis下面的 deps/hiredis 目錄拷貝到  deps/hiredis 目錄拷貝到redis_fdw-REL_10_STABLE目錄下

[[email protected]
/]# mv /home/admin/hiredis/ /monchickey/pgsql/contrib/redis_fdw-REL_10_STABLE/ [[email protected] /]#

5.進入hiredis :cd hiredis   編譯 make   進行指定安裝

[[email protected] /]# cd /monchickey/pgsql/contrib/redis_fdw-REL_10_STABLE/hiredis/
[[email protected] hiredis]# make
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  net.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  async.c
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  read.c
cc -shared -Wl,-soname,libhiredis.so.0.13 -o libhiredis.so  net.o hiredis.o sds.o async.o read.o
ar rcs libhiredis.a net.o hiredis.o sds.o async.o read.o
cc -std=c99 -pedantic -c -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  test.c
cc -O3 -fPIC  -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb  -o hiredis-test   test.o libhiredis.a
Generating hiredis.pc for pkgconfig...
[
[email protected]
hiredis]# make prefix=/monchickey/pgsql/contrib/redis_fdw-REL_10_STABLE/hiredis/ install mkdir -p /usr/local/include/hiredis /usr/local/lib cp -a hiredis.h async.h read.h sds.h adapters /usr/local/include/hiredis cp -a libhiredis.so /usr/local/lib/libhiredis.so.0.13 cd /usr/local/lib && ln -sf libhiredis.so.0.13 libhiredis.so cp -a libhiredis.a /usr/local/lib mkdir -p /usr/local/lib/pkgconfig cp -a hiredis.pc /usr/local/lib/pkgconfig [[email protected] hiredis]#

6.這裡要進行對hiredis進行操作,不然之後會報錯,以下是報錯資訊。

libhiredis.so.0.13: cannot open shared object file: No such file or director

解決方式:

mkdir /usr/lib/hiredis
cp libhiredis.so /usr/lib/hiredis #將動態連線庫libhiredis.so至/usr/lib/hiredis
mkdir /usr/include/hiredis
cp hiredis.h /usr/include/hiredis
echo '/usr/local/lib' >>/etc/ld.so.conf 
ldconfig

---------------------

本文來自 SakuraLJ 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/sakurallj/article/details/79452435?utm_source=copy 


[[email protected] hiredis]# mkdir /usr/lib/hiredis
[[email protected] hiredis]# cp libhiredis.so /usr/lib/hiredis
[[email protected] hiredis]# mkdir /usr/include/hiredis
[[email protected] hiredis]# cp hiredis.h /usr/include/hiredis
[[email protected] hiredis]# echo '/usr/local/lib' >>/etc/ld.so.conf 
[[email protected] hiredis]# ldconfig

7.確認安裝之後,進入 redis_fdw-REL_10_STABLE目錄

修改MakeFile檔案:vi Makefile

[[email protected] redis_fdw-REL_10_STABLE]# vi Makefile 
# 末尾追加

include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

# we put all the tests in a test subdir, but pgxs expects us not to, darn it
override pg_regress_clean_files = test/results/ test/regression.diffs test/regression.out tmp_check/ log/
LDFLAGS += -L/monchickey/pgsql/contrib/redis_fdw-REL_10_STABLE/hiredis/bin

8.安裝redis_fdw

[[email protected] redis_fdw-REL_10_STABLE]# export PATH=/monchickey/pgsql/bin:$PATH
[[email protected] redis_fdw-REL_10_STABLE]# make USE_PGXS=clean
Makefile:42: ../../src/Makefile.global: No such file or directory
Makefile:43: /contrib/contrib-global.mk: No such file or directory
make: *** No rule to make target `/contrib/contrib-global.mk'.  Stop.
[[email protected] redis_fdw-REL_10_STABLE]# make USE_PGXS=1
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -DMAP_HUGETLB=0x40000 -fPIC -I. -I./ -I/monchickey/pgsql/include/postgresql/server -I/monchickey/pgsql/include/postgresql/internal -I/opt/local/Current/include -D_GNU_SOURCE  -I/opt/local/Current/include/libxml2 -I/opt/local/Current/include  -c -o redis_fdw.o redis_fdw.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -DMAP_HUGETLB=0x40000 -fPIC -shared -o redis_fdw.so redis_fdw.o -L/monchickey/pgsql/lib    -L/opt/local/Current/lib -Wl,--as-needed -Wl,-rpath,'/monchickey/pgsql/lib',--enable-new-dtags -L/monchickey/pgsql/contrib/redis_fdw-REL_10_STABLE/hiredis/bin  -lhiredis 
[[email protected] redis_fdw-REL_10_STABLE]# make USE_PGXS=1 install
/bin/mkdir -p '/monchickey/pgsql/lib/postgresql'
/bin/mkdir -p '/monchickey/pgsql/share/postgresql/extension'
/bin/mkdir -p '/monchickey/pgsql/share/postgresql/extension'
/usr/bin/install -c -m 755  redis_fdw.so '/monchickey/pgsql/lib/postgresql/redis_fdw.so'
/usr/bin/install -c -m 644 .//redis_fdw.control '/monchickey/pgsql/share/postgresql/extension/'
/usr/bin/install -c -m 644 .//redis_fdw--1.0.sql  '/monchickey/pgsql/share/postgresql/extension/'
[[email protected] redis_fdw-REL_10_STABLE]# 

假如報錯,就用yum list postgres* 檢視是否少了安裝包,如果少了 這裡是9.2的版本,那麼就直接執行yum install postgres-devel

如果是9.2及以上版本  就應該先下載對應的包 再進行安裝。

以上 就安裝完成了。

後面的使用 等我這邊完全熟練之後就開始更新。踩了不知道多少坑 才明白原來這麼簡單。

參考:https://yq.aliyun.com/articles/9035

          https://blog.csdn.net/sakurallj/article/details/79452435?utm_source=copy

          以及德哥的文章https://yq.aliyun.com/articles/14609