可从该位置下载需要的版本:https://github.com/greenplum-db/gpdb/releases/(此处使用 5.3.0)
下载后再 centos 中解压到指定目录,如 / home/gpdb_src
注意,以上工具使用 pip(>=7.x.x)安装,如果没有 pip,可以参考 https://pip.pypa.io/en/stable/installing / 步骤进行安装。
如果 pip 版本太低,可使用如下命令升级:
- pip install--upgrade
由于我们使用的是 CentOS 系统, 所以一定要加上 / usr/local/lib 和 / usr/local/lib64 的路径到 / etc/ld.so.conf 文件中,这一步尤为重要,目的是将常用的动态函数库加载到内存中,可以提高函数库的访问效率。另外,如果不配置这一步,在后面编译的过程中会遇到一些奇奇怪怪的缺少引用的错误
修改后的文件内容类似如下:
- include ld.so.conf.d/*.conf
- /usr/local/lib
- /usr/local/lib64
修改完成后保存,之后运行 ldconfig 命令
这一步可以使用源码中自带的脚本完成,脚本位置如下:/home/gpdb_src/concourse/scripts/setup_gpadmin_user.bash,执行如下命令:
- cd /home
- bash ./gpdb_src/concourse/scripts/setup_gpadmin_user.bash
这里说明下,这一步如果使用脚本操作,一定要把源码文件放到 gpdb_src 中,执行脚本时需要进入到与 gpdb_src 同级的目录执行,如果要手动配置也是可以的。具体的操作也不复杂,有兴趣的朋友可以读下 setup_gpadmin_user.bash 脚本。
执行完成后,进行如下两步操作验证:
- su - gpadmin
- ssh <当前主机名称>
如果切换账户正常并且 ssh 正常,不需要输入密码,这说明这一步成功
- cat >> /etc/sysctl.conf <<-EOF
- kernel.shmmax = 500000000
- kernel.shmmni = 4096
- kernel.shmall = 4000000000
- kernel.sem = 250 512000 100 2048
- kernel.sysrq = 1
- kernel.core_uses_pid = 1
- kernel.msgmnb = 65536
- kernel.msgmax = 65536
- kernel.msgmni = 2048
- net.ipv4.tcp_syncookies = 1
- net.ipv4.ip_forward = 0
- net.ipv4.conf.default.accept_source_route = 0
- net.ipv4.tcp_tw_recycle = 1
- net.ipv4.tcp_max_syn_backlog = 4096
- net.ipv4.conf.all.arp_filter = 1
- net.ipv4.ip_local_port_range = 1025 65535
- net.core.netdev_max_backlog = 10000
- net.core.rmem_max = 2097152
- net.core.wmem_max = 2097152
- vm.overcommit_memory = 2
- EOF
- cat >> /etc/security/limits.conf <<-EOF
- * soft nofile 65536
- * hard nofile 65536
- * soft nproc 131072
- * hard nproc 131072
- EOF
- cat >> /etc/ld.so.conf <<-EOF
- /usr/local/lib
- EOF
这一步很重要,否则在后期使用 greenplum 的时候会遇到问题,详细的问题后面会解析。
这里提一下,如果不需要优化器这一步也可以跳过。毕竟 greenplum 在不安装 orca 的情况下使用的是 legacy 优化器。
GPORCA 是 postgresql 新一代的优化器,在性能上有很大提升,至于为什么要有两个优化器,其实是有历史原因的,早期 legacy 是针对单节点 PostgreSQL 而构建的,主要应用于 OLTP 场景,现在的 greenplum 使用 MPP,主要应用场景变为 OLAP 场景,legacy 对此虽然进行了修改,但是从架构设计上,使得其维护和添加新的功能越来越困难,所以有了 GPORCA 优化器。
虽然 greenplum 提供了直接安装的方式,但是本人一直没有安装成功。很简单,就是执行如下命令:
- cd /home/gpdb_src/depends./configure
- make
- make install_local
本人遇到的错误是:
- Unable to connect to gpdb - oss = https: //api.bintray.com/conan/greenplum-db/gpdb-oss
- ERROR: All remotes failed
如果有知道怎么解决的朋友还请告诉我。
下面提供手动编译的方法。特别注意,安装前一定要确认当前的版本是否和 greenplum 版本相匹配,如果不匹配将无法编译 greenplum,详情参见问题 6
首先,编译 gporca 前需要安装如下必备工具:
进入 https://cmake.org/download / 页面下载自己需要的版本
可以使用 git 下载:https://github.com/greenplum-db/gp-xerces.git
进入 http://re2c.org/install/install.html 页面下载自己需要的版本
安装 re3c 是由于配置 ninja 时需要
可以使用 git 下载:https://github.com/ninja-build/ninja.git
下载后进入 ninja 目录执行如下命令:
- . / configure.py--bootstrap
可以使用 git 下载:https://github.com/greenplum-db/gporca.git
解压后进入目录执行如下命令安装:
- cmake -GNinja -H. -Bbuild
- ninja install -C build
待安装完成后,进入 / gporca/build 目录,执行 ctest 命令进行检查
如果最后输出类似如下结果:
- 100% tests passed, 0 tests failed out of 119
- Total Test time (real) = 195.48 sec
这说明编译成功了。
执行如下命令:
- cd /home/gpdb_src
- ./configure --with-perl --with-python --with-libxml --with-gssapi --prefix=/usr/local/gpdb
- make -j8
- make -j8 install
注意:这里如果跳过了第七步,则 configure 时需要使用如下命令:
- . / configure--with - perl--with - python--with - libxml--with - gssapi--disable - orca--prefix = /usr/local / gpdb
configure 有很多的组件可以加上,如果需要添加自定义可以使用./configure --help 查看,加上自己需要的组件即可
通过以上步骤,就完成了编译。虽然本人已经力求写的详细,但是还是略过了一些自认为大家一看到就能知道原因,同时环境的差异也会导致一些本人没有遇到过的错误,所以有理由相信大家编译的时候还是会遇到一些问题,如果遇到了本文没有涉及到的错误可以告诉我,大家一起讨论。
1)
安装必备工具或者升级 pip 时可能报类似如下错误:
- Could not fetch URL https://pypi.python.org/simple/conan/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:765) - skipping
可以执行如下命令:
- pip install --trusted-host pypi.python.org XXXX
- pip install --trusted-host pypi.python.org --upgrade pip
- XXXX为你要安装的工具
2)
- checking for xsltCleanupGlobals in -lxslt... no
- configure: error: library 'xslt' is required for XSLT support
执行如下命令:yum install libxslt libxslt-devel
3)
- /bin/ld: libpq/SUBSYS.o: undefined reference to symbol 'gss_delete_sec_context@@gssapi_krb5_2_MIT'
- /bin/ld: note: 'gss_delete_sec_context@@gssapi_krb5_2_MIT' is defined in DSO /lib64/libgssapi_krb5.so.2 so try adding it to the linker command line
- /lib64/libgssapi_krb5.so.2: could not read symbols: Invalid operation
- collect2: error: ld returned 1 exit status
- make[2]: *** [postgres] Error 1
- make[2]: Leaving directory `/home/greenplum/src/backend'
- make[1]: *** [all] Error 2
- make[1]: Leaving directory `/home/greenplum/src'
- make: *** [all] Error 2
类似这种错误基本都是安装步骤中第 4 步没有配置导致的
4)
- checking for flags to link embedded Perl... Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
- BEGIN failed--compilation aborted.
- no
- configure: error: could not determine flags for linking embedded Perl.
- This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not installed.
yum install perl-ExtUtils-Embed -y
5)
- checking for xmlSaveToBuffer in -lxml2... no
- configure: error: library 'xml2' (version >= 2.6.23) is required for XML support
yum install libxml2 libxml2-devel -y
6)
- checking Checking ORCA version...configure: error: Your ORCA version is expected to be 2.51.XXX
这说明你装的 orca 的版本是不匹配的,需要安装匹配版本,那么如何在安装前知道需要什么版本,执行如下命令:
- cd /home/gpdb_src/depends
- cat conanfile_orca.txt
这里在文件中可以看到如下记录:
- [requires]
- orca/v2.51.0@gpdb/stable
到 github 上找到对应版本下载安装即可。
当需要更换版本时,需要清理掉之前已经安装的版本。默认情况下安装在 / usr/local / 目录下,根据安装的路径,执行如下命令删除已经安装的版本
- rm -rf build/*
- rm -rf /usr/local/include/naucrates
- rm -rf /usr/local/include/gpdbcost
- rm -rf /usr/local/include/gpopt
- rm -rf /usr/local/include/gpos
- rm -rf /usr/local/lib/libnaucrates.so*
- rm -rf /usr/local/lib/libgpdbcost.so*
- rm -rf /usr/local/lib/libgpopt.so*
- rm -rf /usr/local/lib/libgpos.so*
注意:
1、build 位于 gporca 编译目录,其是编译时 cmake 产生的一些文件
2、如果重新安装了版本一定要执行 ldconfig 命令,否则新的版本不会在缓存中更新,会一直报上述错误
:
来源: http://www.linuxidc.com/Linux/2017-12/149770.htm