Greenplum 的dblink與tablefunc模塊安裝
阿新 • • 發佈:2017-07-08
greenplum
1、dblink模塊安裝
登錄主節點並切換到GP用戶下
[[email protected] ~]#su - gpadmin
下載源碼包並解壓,進入dblink目錄下
[[email protected] ~]$ wget https://ftp.postgresql.org/pub/source/v8.2.23/postgresql-8.2.23.tar.gz [[email protected] ~]$ tar xvf postgresql-8.2.23.tar.gz [[email protected] ~]$ cd postgresql-8.2.23/contrib/dblink/
修改Makefile文件,作用是去掉編譯中的警告信息
[[email protected] dblink]$ vi Makefile PG_CPPFLAGS = -I$(libpq_srcdir) -w
編譯dblink模塊
[[email protected] dblink]$ make USE_PGXS=1 install
查看hosts中的節點信息
[[email protected] dblink]$ cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.16.104.21 mdw 172.16.104.22 smdw 172.16.104.23 sdw1 172.16.104.24 sdw2 172.16.104.25 sdw3
把模塊復制到各個節點
[[email protected] dblink]$ gpscp -h smdw -h sdw1 -h sdw2 -h sdw3 dblink.so =:/usr/local/greenplum-db/lib/postgresql/dblink.so
初始化dblink模塊
[[email protected] dblink]$ psql -f dblink.sql gpdatabase CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION REVOKE REVOKE CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE TYPE CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION
測試
[[email protected] dblink]$ psql -d gpdatabase psql (8.2.15) Type "help" for help. gpdatabase=# select dblink_connect(‘myconn‘,‘dbname=gpdatabase‘); dblink_connect ---------------- OK (1 row)
OK,安裝成功。
2、安裝tablefunc模塊,步驟基本如上,
切換到tablefunc目錄下,編譯
[[email protected] ~]$ cd postgresql-8.2.23/contrib/tablefunc/ [[email protected] tablefunc]$ make USE_PGXS=1 install
把模塊傳到各節點
[[email protected] dblink]$ gpscp -h smdw -h sdw1 -h sdw2 -h sdw3 tablefunc.so =:/usr/local/greenplum-db/lib/postgresql/tablefunc.so
初始化模塊
[[email protected] tablefunc]$ psql -f tablefunc.sql gpdatabase SET CREATE FUNCTION CREATE FUNCTION CREATE TYPE CREATE TYPE CREATE TYPE CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION
測試
[[email protected] ~]$ psql -d gpdatabase psql (8.2.15) Type "help" for help. gpdatabase=# select * from normal_rand(10, 5, 3); normal_rand ------------------ 6.49804853868727 5.94780258015849 3.76292085922418 2.26097995785225 1.06472447639215 1.83973228257959 3.4955971041885 3.95784964260771 7.32294513598636 9.51874065685311 (10 rows)
OK,安裝成功。
本文出自 “運維筆記” 博客,請務必保留此出處http://quliren.blog.51cto.com/9849266/1945494
Greenplum 的dblink與tablefunc模塊安裝