Skip to content

在ARM上编译安装Greenplum并制作RPM安装包

此教程打包版本为:greenplum 6.26.1

Python版本:Python 2.7.9

其他版本可参考

编译安装最新版Greenplum

本例使用阿里云的ARM架构的Centos7.9系统,登录该操作系统,执行如下脚本:

bash
yum -y update
yum -y upgrade

# 【现在GP官方仓库没有了,这段步骤可以不执行】
# 下载最新源代码
yum install -y git
git clone https://github.com/greenplum-db/gpdb.git
# 实际可能会出错,建议使用源码
yum install -y wget 
wget https://github.com/greenplum-db/gpdb/releases/download/6.26.1/6.26.1-src-full.tar.gz

# 【自行上传官方的源码包,继续执行,仓库只有一个6.26.1的源码包】
tar -xvf 6.26.1-src-full.tar.gz
mv gpdb_src greenplum-6.26.1
cd greenplum-6.26.1
sh README.CentOS.bash
./configure --with-perl --with-python --with-libxml --with-gssapi --prefix=/usr/local/greenplum-6.26.1
make -j $(nproc)
make install

本文档使用到的源码包:https://gitee.com/liuli-ke/greenplum.git 的源代码目录下

制作Greenplum的RPM安装包

安装rpm-build

bash
yum install -y rpm-build

在/root目录下建rpmbuild目录

bash
mkdir -p /root/rpmbuild/{BUILD,RPMS,BUILDROOT,SRPMS,SOURCES,SPECS}

此目录结构可以安装rpmdevtools,用其创建

bash
yum install -y rpmdevtools
rpmdev-setuptree

编辑greenplum6.26.1.spec

bash
vi /root/rpmbuild/SPECS/greenplum6.26.1.spec
bash
%define version 6.26.1
%define directory /usr/local
%define __os_install_post %{nil}
%define debug_package %{nil}
%define __jar_repack 0

Name: greenplum
Version: %{version}
Release: 1%{?dist}
License: Apache License Version 2.0
Summary: Greenplum Database (GPDB) is an advanced, fully featured, open source data warehouse, based on PostgreSQL.
Packager: liulike
Vendor: 流漓·客
# Url
Group: Applications/Databases
Source: %{name}-%{version}.tar.gz
# Patch:
# BuildRequires:
Requires: epel-release apr-devel bison bzip2-devel cmake3 flex gcc gcc-c++ krb5-devel libcurl-devel
Requires: libevent-devel libkadm5 libyaml-devel libxml2-devel libzstd-devel openssl-devel perl-ExtUtils-Embed python3-devel
Requires: python3-pip readline-devel xerces-c-devel zlib-devel postgresql postgresql-devel
# PreReq:
# Providers:
BuildRoot: %{_tmppath}/%{name}-%{version}-build


%description
使用Greenplum 6.26.1的官方源码,基于Centos7.9-ARM系统完成的RPM包
%prep
%setup -q
%build
 ./configure --with-perl --with-python --with-libxml --with-gssapi -prefix=/usr/local/greenplum-6.26.1
make %{?_smp_mflags}

%install
make install DESTDIR=%{buildroot} %{?_smp_mflags}
%pre
%preun
%post
%postun
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
%{directory}/%{name}-%{version}
%changelog

注意:epel-release在离线环境可能比较麻烦,可以去掉取消校验

修改greenplum源代码目录名为greenplum-6.26.1并压缩:

bash
tar czvf greenplum-6.26.1.tar.gz greenplum-6.26.1

把greenplum源码包复制到rpmbuild源代码目录

bash
cp greenplum-6.26.1.tar.gz /root/rpmbuild/SOURCES/

制作rpm安装包:

bash
rpmbuild -ba /root/rpmbuild/SPECS/greenplum6.26.1.spec

查看制作好的rpm安装包:

bash
ll /root/rpmbuild/RPMS/aarch64/
total 11908
-rw-r--r--. 1 root root 12192948 1月  24 11:32 greenplum-6.26.1-1.el7.aarch64.rpm