为rh-postgresql10安装mysql-fdw
为rh-postgresql10安装mysql-fdw
由于种种原因需要在postgresql和mysql直接同步数据,如果自己写程序去select然后update的话效率太低,于是网上找解决方案,找到这个postgresql的mysql-fdw的扩展。
这个扩展可以为postgresql配置一个外部数据源,然后添加外部表,之后就可以实现postgreql和mysql直接的直接update了。
下载mysql-fdw的源码包
本次环境和CentOS 7.9
数据库版本是rh-postgresql10
wget https://download.postgresql.org/pub/repos/yum/srpms/10/redhat/rhel-7-x86_64/mysql_fdw_10-2.5.5-1.rhel7.src.rpm
rpm -ivh mysql_fdw_10-2.5.5-1.rhel7.src.rpm
调整spec文件
%global sname mysql_fdw
%global mysqlfdwmajver 2
%global mysqlfdwmidver 5
%global mysqlfdwminver 5
%global pgmajorversion 10
%global pginstdir /opt/rh/rh-postgresql%{pgmajorversion}/root/
%ifarch ppc64 ppc64le
%pgdg_set_ppc64le_compiler_at10
%endif
Summary: PostgreSQL Foreign Data Wrapper (FDW) for the MySQL
Name: %{sname}%{pgmajorversion}
Version: %{mysqlfdwmajver}.%{mysqlfdwmidver}.%{mysqlfdwminver}
Release: 1%{?dist}
License: BSD
Source0: https://github.com/EnterpriseDB/%{sname}/archive/REL-%{mysqlfdwmajver}%{mysqlfdwmidver}_%{mysqlfdwminver}.tar.gz
Patch0: %{sname}-pg%{pgmajorversion}-makefile-pgxs.patch
URL: https://github.com/EnterpriseDB/mysql_fdw
BuildRequires: rh-postgresql%{pgmajorversion}-postgresql-devel pgdg-srpm-macros
Requires: rh-postgresql%{pgmajorversion}-postgresql-server
%if 0%{?rhel} && 0%{?rhel} <= 6
BuildRequires: mysql-devel
Requires: mysql-libs mysql-devel
%else
BuildRequires: mariadb-devel
Requires: mariadb-devel
%endif
%ifarch ppc64 ppc64le
%pgdg_set_ppc64le_min_requires
%endif
%description
This PostgreSQL extension implements a Foreign Data Wrapper (FDW) for
the MySQL.