大数据技术 在centos7中手动编译greenplum
沉沙 2018-10-12 来源 : 阅读 1944 评论 0

摘要:本篇教程探讨了大数据技术 在centos7中手动编译greenplum,希望阅读本篇文章以后大家有所收获,帮助大家对大数据技术的理解更加深入。

本篇教程探讨了大数据技术 在centos7中手动编译greenplum,希望阅读本篇文章以后大家有所收获,帮助大家对大数据技术的理解更加深入。

<

 一、编译环境

Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) 
greenplum 5.3.0

二、编译过程
2.1、下载greenplum源码
可从该位置下载需要的版本:https://github.com/greenplum-db/gpdb/releases/(此处使用5.3.0)
2.2、解压
下载后再centos中解压到指定目录,如/home/gpdb_src
2.3、安装必备的工具

psutil
lockfile (>= 0.9.1)
paramiko
setuptools
conan

注意,以上工具使用pip(>=7.x.x)安装,如果没有pip,可以参考https://pip.pypa.io/en/stable/installing/步骤进行安装。
如果pip版本太低,可使用如下命令升级:

pip install --upgrade pip

2.4、配置ld.so.conf
由于我们使用的是CentOS系统, 所以一定要加上/usr/local/lib和/usr/local/lib64的路径到/etc/ld.so.conf文件中,这一步尤为重要,目的是将常用的动态函数库加载到内存中,可以提高函数库的访问效率。另外,如果不配置这一步,在后面编译的过程中会遇到一些奇奇怪怪的缺少引用的错误
修改后的文件内容类似如下:

include ld.so.conf.d/*.conf
/usr/local/lib
/usr/local/lib64

修改完成后保存,之后运行ldconfig命令
2.5、创建gpadmin用户和配置ssh
这一步可以使用源码中自带的脚本完成,脚本位置如下:/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正常,不需要输入密码,这说明这一步成功
2.6、修改内核参数

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的时候会遇到问题,详细的问题后面会解析。
2.7、编译GPORCA
这里提一下,如果不需要优化器这一步也可以跳过。毕竟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前需要安装如下必备工具:

CMake(>=3.1)
gp-xerces
re2c(>= 0.11.3)

 2.7.1 下载安装cmake
进入https://cmake.org/download/页面下载自己需要的版本
2.7.2 下载安装gp-xerces
可以使用git下载:https://github.com/greenplum-db/gp-xerces.git
2.7.3  下载安装re2c
进入//re2c.org/install/install.html页面下载自己需要的版本
安装re3c是由于配置ninja时需要
2.7.4 下载安装Ninja
可以使用git下载:https://github.com/ninja-build/ninja.git
下载后进入ninja目录执行如下命令:

./configure.py --bootstrap

2.7.5 下载安装gporca
可以使用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

这说明编译成功了。
 2.8 安装greenplum
执行如下命令:

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为你要安装的工具如果没有pip,在2.3步安装pip本身都报类似如下错误:

Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:765) - skipping
  Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip

可以使用如下命令安装:

sudo yum -y install epel-release
sudo yum -y install python-pip

 
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命令,否则新的版本不会在缓存中更新,会一直报上述错误
7)

unable to execute gcc: No such file or directory
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4lu7Y0/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-YPgXFP-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-4lu7Y0/psutil/

yum install -y gcc
8)如果使用编译参数:--with-gssapi可能会报如下错误:

checking for library containing gss_init_sec_context... no
configure: error: could not find function 'gss_init_sec_context' required for GSSAPI

安装gssapi即可:pip install gssapi
而安装gssapi可能报如下错误:

Complete output from command python setup.py egg_info:
    In distributed package, building from C files...
    Traceback (most recent call last):
      File "", line 1, in 
      File "/tmp/pip-build-CHeKis/gssapi/setup.py", line 98, in 
        raise Exception("Could not find main GSSAPI shared library.  Please "
    Exception: Could not find main GSSAPI shared library.  Please try setting GSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to 'false'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-CHeKis/gssapi/

需要安装如下工具:yum install -y krb5-devel.x86_64
9)

checking for apr-1-config... no
configure: error: apr-1-config is required for gpfdist, unable to find binary

yum install -y apr-devel
10)

checking for library containing event_add... no
configure: error: libevent is required for gpfdist

yum install -y libevent-devel
11)

checking for curl-config... no
*** The curl-config script could not be found. Make sure it is
*** in your path, and that curl is properly installed.
*** Or see //curl.haxx.se/
configure: error: Library requirements (curl) not met.

yum install -y libcurl-devel.x86_64
12)

checking for bzlib.h... no
configure: error: header file  is required for bzip2 support

yum install -y bzip2-devel
13)安装psutil时可能报如下错误:

psutil/_psutil_common.c:9:20: fatal error: Python.h: No such file or directory
     #include 
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3gzCd8/psutil/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-EAY9ck-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-3gzCd8/psutil/

yum install -y python-devel.x86_64
   

本文由职坐标整理发布,学习更多的大数据技术相关知识,请关注职坐标大技术云计算大技术技术频道!

本文由 @沉沙 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved