greenplum安装mysql_fdw插件

参考文档之一
https://blog.csdn.net/xfg0218/article/details/107130345

多方整理,网上坑多可以看我这个:
首先原因:mysql_fdw 有两个版本有一个是Gitlab下载版
有一个是专门的 mysql_fdw_greenplum-master 版
我安装成功运行的是 mysql_fdw_greenplum-master 这个版本
主要原因是标准的mysql_fdw依赖是PostgreSQL9.5以上,所以在安装的时候会报如下错误!
Makefile:55: *** PostgreSQL 9.5, 9.6 10 11 12 is required to compile this extension. Stop.
而修改后的mysql_fdw_greenplum-master 在没有依赖的情况下会报如下错误
Makefile:55: *** PostgreSQL 9.3, 9.4, 9.5, 9.6 10 11 12 is required to compile this extension. Stop.

也就是说这个版本是修改过的用于9.3 9.4的PostgreSQL!!!!

安装过程:

下载mysql的源码

https://downloads.mysql.com/archives/community/

wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
选择linux-Generic版本

sudo yum -y install libmysqlclient-dev
下载mysql_fdw_greenplum-master
https://github.com/adam8157/mysql_fdw_greenplum
https://codeload.github.com/adam8157/mysql_fdw_greenplum/zip/master

开始安装

每服务器均进行以下操作

切换至gpadmin账户

export PATH=/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/bin:$PATH

检查export $PATH是否有greenplum bin目录,好像没有gp集群也无法正常运行。

进入mysql_fdw_greenplum-master目录
运行
make USE_PGXS=1
make USE_PGXS=1 install

[gpadmin@bogon mysql_fdw_greenplum-master]$ export PATH=/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/bin:$PATH
[gpadmin@bogon mysql_fdw_greenplum-master]$ make USE_PGXS=1
gcc -m64 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fno-aggressive-loop-optimizations -Wno-unused-but-set-variable -Wno-address -m64 -O3 -fargument-noalias-global -fno-omit-frame-pointer -g -std=gnu99   -Werror=uninitialized -Werror=implicit-function-declaration -fPIC -I/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/include -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/local/greenplum-db-6.7.1/include/postgresql/server -I/usr/local/greenplum-db-6.7.1/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2  -I/tmp/build/f8c7ee08/gpdb_src/gpAux/ext/rhel7_x86_64/include  -c -o connection.o connection.c
gcc -m64 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fno-aggressive-loop-optimizations -Wno-unused-but-set-variable -Wno-address -m64 -O3 -fargument-noalias-global -fno-omit-frame-pointer -g -std=gnu99   -Werror=uninitialized -Werror=implicit-function-declaration -fPIC -I/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/include -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/local/greenplum-db-6.7.1/include/postgresql/server -I/usr/local/greenplum-db-6.7.1/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2  -I/tmp/build/f8c7ee08/gpdb_src/gpAux/ext/rhel7_x86_64/include  -c -o option.o option.c
gcc -m64 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fno-aggressive-loop-optimizations -Wno-unused-but-set-variable -Wno-address -m64 -O3 -fargument-noalias-global -fno-omit-frame-pointer -g -std=gnu99   -Werror=uninitialized -Werror=implicit-function-declaration -fPIC -I/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/include -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/local/greenplum-db-6.7.1/include/postgresql/server -I/usr/local/greenplum-db-6.7.1/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2  -I/tmp/build/f8c7ee08/gpdb_src/gpAux/ext/rhel7_x86_64/include  -c -o deparse.o deparse.c
gcc -m64 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fno-aggressive-loop-optimizations -Wno-unused-but-set-variable -Wno-address -m64 -O3 -fargument-noalias-global -fno-omit-frame-pointer -g -std=gnu99   -Werror=uninitialized -Werror=implicit-function-declaration -fPIC -I/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/include -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/local/greenplum-db-6.7.1/include/postgresql/server -I/usr/local/greenplum-db-6.7.1/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2  -I/tmp/build/f8c7ee08/gpdb_src/gpAux/ext/rhel7_x86_64/include  -c -o mysql_query.o mysql_query.c
gcc -m64 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fno-aggressive-loop-optimizations -Wno-unused-but-set-variable -Wno-address -m64 -O3 -fargument-noalias-global -fno-omit-frame-pointer -g -std=gnu99   -Werror=uninitialized -Werror=implicit-function-declaration -fPIC -I/app/fdw/mysql-5.7.28-linux-glibc2.12-x86_64/include -D _MYSQL_LIBNAME=\"libmysqlclient.so\" -I. -I./ -I/usr/local/greenplum-db-6.7.1/include/postgresql/server -I/usr/local/greenplum-db-6.7.1/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2  -I/tmp/build/f8c7ee08/gpdb_src/gpAux/ext/rhel7_x86_64/include  -c -o mysql_fdw.o mysql_fdw.c
gcc -m64 -Wall -Wmissing-prototypes -Wpointer-arith -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fno-aggressive-loop-optimizations -Wno-unused-but-set-variable -Wno-address -m64 -O3 -fargument-noalias-global -fno-omit-frame-pointer -g -std=gnu99   -Werror=uninitialized -Werror=implicit-function-declaration -fPIC -shared -o mysql_fdw.so connection.o option.o deparse.o mysql_query.o mysql_fdw.o -L/usr/local/greenplum-db-6.7.1/lib    -L/tmp/build/f8c7ee08/gpdb_src/gpAux/ext/rhel7_x86_64/lib -Wl,--as-needed -Wl,-rpath,'/usr/local/greenplum-db-6.7.1/lib',--enable-new-dtags  
[gpadmin@bogon mysql_fdw_greenplum-master]$ make USE_PGXS=1 install
/usr/bin/mkdir -p '/usr/local/greenplum-db-6.7.1/lib/postgresql'
/usr/bin/mkdir -p '/usr/local/greenplum-db-6.7.1/share/postgresql/extension'
/usr/bin/mkdir -p '/usr/local/greenplum-db-6.7.1/share/postgresql/extension'
/usr/bin/install -c -m 755  mysql_fdw.so '/usr/local/greenplum-db-6.7.1/lib/postgresql/mysql_fdw.so'
/usr/bin/install -c -m 644 mysql_fdw.control '/usr/local/greenplum-db-6.7.1/share/postgresql/extension/'
/usr/bin/install -c -m 644 mysql_fdw--1.0.sql mysql_fdw--1.1.sql mysql_fdw--1.0--1.1.sql '/usr/local/greenplum-db-6.7.1/share/postgresql/extension/'
cp `mysql_config --variable=pkglibdir`/libmysqlclient.so `pg_config --libdir`/

至此安装完毕!进入服务器设置


[gpadmin@ares mysql_fdw_greenplum-master]$ psql
psql (9.4.24)
Type "help" for help.

-- 创建mysql_fdw外部插件


gp_sydb=# CREATE EXTENSION mysql_fdw;
CREATE EXTENSION

-- 创建链接server源

gp_sydb=# CREATE SERVER mysql_server1
gp_sydb-#      FOREIGN DATA WRAPPER mysql_fdw
gp_sydb-#      OPTIONS (host '192.168.10.xxx', port '3306');

-- 添加用户的映射

CREATE SERVER
gp_sydb=# CREATE USER MAPPING FOR gpadmin
gp_sydb-# SERVER mysql_server1
gp_sydb-# OPTIONS (username 'root', password 'xxxxx');
CREATE USER MAPPING
- 创建映射外部表
CREATE FOREIGN TABLE test_tabase(
    id int,
    name text)
SERVER mysql_server
    OPTIONS (dbname 'tabase', table_name 'test_tabase');
 
-- 查询表的数据
select count(*) from test_tabase;
 
-- 删除信息
drop SERVER mysql_server CASCADE;

在centos6.x版本下报错!!!!

报错


cc1: 错误:无法识别的命令行选项“-fexcess-precision=standard”
cc1: 错误:无法识别的命令行选项“-fno-aggressive-loop-optimizations”
make: *** [connection.o] 错误 1

安装gcc

[root@websvr4 ryyf]# gcc -v
使用内建 specs。
目标:x86_64-redhat-linux
配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
线程模型:posix
gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC) 

参考文档

https://baijiahao.baidu.com/s?id=1618088009618054622&wfr=spider&for=pc

先安装 yum install gcc-c++

1、下载
mkdir -p /root/gcc
cd /root/gcc
wget -c http://mirror.koddos.net/gcc/releases/gcc-4.8.5/gcc-4.8.5.tar.bz2
2、解压
tar jxf gcc-4.8.5.tar.bz2
cd gcc-4.8.5
3、预下载依赖源码包
./contrib/download_prerequisites
配置编译文件
./configure --prefix=/opt/gcc --enable-checking=release --enable-languages=c,c++ --disable-multilib # 机器是64位的,就不使用32位的包了,--disable-multilib
5、编译
make -j4 #如果有多核CPU尽量都用上,要编译很久

可能会报错 直接运行make

6、安装
make install
7、添加环境变量
echo 'export PATH=/opt/gcc/bin:$PATH' >> /etc/profile
8、生效变量
source /etc/profile
9、查看版本
gcc -v
10、有些代码里面还会用到cc这个命令来调用gcc ,而我们自己编译的目录下没有cc这个执行程序,可以做个软链接就可以了。
cd /opt/gcc/bin && ln -s gcc cc
wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz

[gpadmin@imagesvr1 mysql_fdw_greenplum-master]$ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc/libexec/gcc/x86_64-unknown-linux-gnu/4.8.5/lto-wrapper
目标:x86_64-unknown-linux-gnu
配置为:./configure --prefix=/opt/gcc --enable-checking=release --enable-languages=c,c++ --disable-multilib
线程模型:posix
gcc 版本 4.8.5 (GCC) 

这个编译的时间真长……………………

报错

[Err] ERROR:  could not load library "/usr/local/greenplum-db-6.22.0/lib/postgresql/mysql_fdw.so": /usr/local/greenplum-db-6.22.0/lib/postgresql/mysql_fdw.so: undefined symbol: _mysql_stmt_result_metadata (dfmgr.c:240)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。