CentOS 7环境编译GlusterFS 11¶
备注
本文实践在CentOS 7上完成,其他平台编译方法摘录原文以备参考 源代码编译安装GlusterFS
准备工作¶
我走的弯路(实际不需要)¶
不要 激活EPEL 以便安装 :
yum install epel-release
不要 激活 OpenStack环境软件仓库 以便能够安装
python-paste-deploy
/python-eventlet
/python2-simplejson
:
yum install centos-release-openstack-train
警告
这里我走了弯路,因为官方原文中安装依赖有4个软件包在CentOS 7中找不到,我通过rpm搜索找到了提供软件包的仓库( EPEL
和 OpenStack
),但是实际上这会引入高版本Python 3.6以及 mock
(基于Python 3.6),反而导致 make glusterrpm
失败。见下文
原文中有以下4个软件包在CentOS7中不存在:
cmockery2-devel
python-eventlet
python-paste-deploy
python-simplejson
原因是是:
cmockery2-devel
需要激活EPEL(不过我在 CentOS 7环境编译GlusterFS 11 遇到make glusterrpms
报错,参考 Compilation failed on glusterfs master branch(python2.7 (default) and python3.6) 不应该使用EPEL避免引入python 3以及python 3版本的mock
否则无法构建GlusterFS rpm:
RHEL7 and CentOS7 are "python2 machines." Building with python3 is not supported.
E.g. Building packages in CBS for CentOS Storage SIG packages cannot use EPEL.
python-paste-deploy
/python-eventlet
是 OpenStack Atlas 仓库提供,不使用OpenStack可能可以忽略,不过我参考 phone.net 搜索对应于不同 CentOS 的 OpenStack Atlas 版本,例如对于 CentOS 7.9.2009 有多个版本,即rocky
,train
,queens
,stein
,激活仓库python-simplejson
改名成python2-simplejson
也是 OpenStack Atlas 仓库提供
经过实践, CentOS 7应该不要安装这4个软件包 可以避免引入 Python 3.6 (EPEL)
实际需要的步骤¶
需要先激活 CentOS SIG部署Gluster 以便能够安装
userspace-rcu-devel
:
yum install centos-release-gluster
备注
如果你的CentOS(例如aliOS)没有提供上述 centos-release-gluster
,并且发行版也没有提供 userspace-rcu-devel
,则可以尝试直接从 CentOS 7.9.2009 storage u 直接下载安装 userspace-rcu-devel
:
rpm -ivh http://mirror.centos.org/centos-7/7.9.2009/storage/x86_64/gluster-9/Packages/u/userspace-rcu-0.10.0-3.el7.x86_64.rpm
rpm -ivh http://mirror.centos.org/centos-7/7.9.2009/storage/x86_64/gluster-9/Packages/u/userspace-rcu-devel-0.10.0-3.el7.x86_64.rpm
使用 yum 在CentOS / Enterprise Linux 7上安装编译环境:
:<<'EOF'
官方原文安装依赖:
yum install autoconf automake bison cmockery2-devel dos2unix flex \
fuse-devel glib2-devel libacl-devel libaio-devel libattr-devel \
libcurl-devel libibverbs-devel librdmacm-devel libtirpc-devel \
libtool libxml2-devel lvm2-devel make openssl-devel pkgconfig \
pyliblzma python-devel python-eventlet python-netifaces \
python-paste-deploy python-simplejson python-sphinx python-webob \
pyxattr readline-devel rpm-build sqlite-devel systemtap-sdt-devel \
tar userspace-rcu-devel
EOF
:<<'EOF'
需要激活CentOS SIG repos才能安装 userspace-rcu-devel
我的实践去除了官方文档中的4个软件包:
cmockery2-devel
python-eventlet
python-paste-deploy
python-simplejson
增加了:
gperftools
gperftools-devel
EOF
yum install autoconf automake bison dos2unix flex \
fuse-devel glib2-devel libacl-devel libaio-devel libattr-devel \
libcurl-devel libibverbs-devel librdmacm-devel libtirpc-devel \
libtool libxml2-devel lvm2-devel make openssl-devel pkgconfig \
pyliblzma python-devel python-netifaces \
python-sphinx python-webob \
pyxattr readline-devel rpm-build sqlite-devel systemtap-sdt-devel \
tar userspace-rcu-devel gperftools gperftools-devel
备注
CentOS 7.2没有提供 python-netifaces
(在CentOS 7.9则有)
下载¶
GlusterFS官方下载 源代码包
glusterfs-11.0
:
gluster_version=11.0
wget https://download.gluster.org/pub/gluster/glusterfs/11/LATEST/glusterfs-${gluster_version}.tar.gz
tar xfz glusterfs-${gluster_version}.tar.gz
cd glusterfs-${gluster_version}
配置编译¶
使用
autogen
生成configure
脚本:
./autogen.sh
针对CentOS 7使用以下编译配置:
./configure --without-libtirpc --disable-linux-io_uring
编译配置显示如下:
GlusterFS configure summary
===========================
FUSE client : yes
epoll IO multiplex : yes
fusermount : yes
readline : no
georeplication : yes
Linux-AIO : yes
Linux io_uring : no
Use liburing : no
Enable Debug : no
Run with Valgrind : no
Sanitizer enabled : none
XML output : yes
Unit Tests : no
Track priv ports : yes
POSIX ACLs : yes
SELinux features : yes
firewalld-config : no
Events : yes
EC dynamic support : x64 sse avx
Use memory pools : no
Nanosecond m/atimes : yes
Server components : yes
Legacy gNFS server : no
IPV6 default : no
Use TIRPC : no
With Python : 2.7
Cloudsync : yes
Metadata dispersal : no
Link with TCMALLOC : yes
Enable Brick Mux : no
Building with LTO : no
配置报错及处理¶
tcmalloc
库错误:configure: error: tcmalloc library needs to be present
参考 Install tcmalloc on CentOS 安装 gperftools
相关包:
yum install gperftools gperftools-devel
io_uring
错误:configure: error: Install liburing library and headers or use --disable-linux-io_uring
io_uring
是Linux内核5.1引入的特性,GlusterFS需要使用用户空间 liburing helper
库,对于不支持的主机,使用 --disable-linux-io_uring
关闭这个支持选项
编译和安装¶
编译和安装GlusterFS非常简单:
make
sudo make install
编译RPMs¶
在基于 RPM 的系统中,如 Fedora 可以非常容易直接构建RPM包
yum install mock rpm-build selinux-policy-devel bash-completion
备注
CentOS 7.2 没有提供 mock
不过不影响编译RPM包
然后执行以下命令构建GlusterFS RPMs:
cd extras/LinuxRPM
make glusterrpms
构建GlusterFS RPMs输出信息显示,实际上构建参数增加了一个 --enable-gnfs
,其余参数就是之前我编译GlusterFS参数:
cd ../.. && \
rm -rf autom4te.cache && \
./autogen.sh && \
./configure --enable-gnfs --with-previous-options
... GlusterFS autogen ...
编译RPMs错误处理¶
缺少
pkgconfig
依赖:... rpmbuild --define '_topdir /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild' -bs rpmbuild/SPECS/glusterfs.spec Wrote: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/SRPMS/glusterfs-11.0-0.0.el7.src.rpm mv rpmbuild/SRPMS/* . rpmbuild --define '_topdir /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild' --with gnfs -bb rpmbuild/SPECS/glusterfs.spec error: Failed build dependencies: pkgconfig(bash-completion) is needed by glusterfs-11.0-0.0.el7.x86_64 make: *** [rpms] Error 1
但是,很奇怪,系统已经安装过 pkgconfig
: pkgconfig-0.27.1-4.el7.x86_64 already installed and latest version
rpmbuild/SPECS/glusterfs.spec
中有如下配置:
%global bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null)
%if "%{bashcompdir}" == ""
%global bashcompdir ${sysconfdir}/bash_completion.d
%endif
这里如果手工执行 pkg-config --variable=completionsdir bash-completion
是没有任何输出信息
我Google了一下,原来系统有提供一个独立的 bash-completion
- RPM resource pkgconfig(bash-completion) ,安装这个软件包:
yum install bash-completion
然后手工执行 pkg-config --variable=completionsdir bash-completion
就有输出信息了:
/usr/share/bash-completion/completions
然后就能够重新开始 make glusterrpms
缺少
python2-gluster
文件错误:... Processing files: python2-gluster-11.0-0.0.el7.x86_64 error: Directory not found: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/BUILDROOT/glusterfs-11.0-0.0.el7.x86_64/usr/lib/python2.7/site-packages/gluster error: File not found by glob: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/BUILDROOT/glusterfs-11.0-0.0.el7.x86_64/usr/lib/python2.7/site-packages/gluster/__init__.* error: File not found: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/BUILDROOT/glusterfs-11.0-0.0.el7.x86_64/usr/lib/python2.7/site-packages/gluster/cliutils RPM build errors: Directory not found: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/BUILDROOT/glusterfs-11.0-0.0.el7.x86_64/usr/lib/python2.7/site-packages/gluster File not found by glob: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/BUILDROOT/glusterfs-11.0-0.0.el7.x86_64/usr/lib/python2.7/site-packages/gluster/__init__.* File not found: /home/huatai/glusterfs-11.0/extras/LinuxRPM/rpmbuild/BUILDROOT/glusterfs-11.0-0.0.el7.x86_64/usr/lib/python2.7/site-packages/gluster/cliutils make: *** [rpms] Error 1
我检查了我之前直接 make
安装的 make install
,在主机系统中也没有 /usr/lib/python2.7/site-packages/gluster
,这说明之前编译也没有支持python。奇怪,从 configure
输出显示是有 With Python : 2.7
参考 Bug 1510685 - Python modules not found when multiple versions of Python installed 可以通过如下命令检查系统 python 的
python2 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
输出显示:
/usr/lib/python2.7/site-packages
参考 Compilation failed on glusterfs master branch(python2.7 (default) and python3.6) ,对于CentOS 7这样同时安装了Python 2.7(默认)以及Python 3.6的系统,需要在执行 make glusterrpms
前先指定 PYTHON
PYTHON=/usr/bin/python2.7 make glusterrpms
不过并没有解决我的问题。在这个issue中我看到一个提示:
RHEL7 and CentOS7 are "python2 machines." Building with python3 is not supported.
E.g. Building packages in CBS for CentOS Storage SIG packages cannot use EPEL.
也就是说,我在 源代码编译安装GlusterFS 为了安装 cmockery2-devel
激活了 EPEL
画蛇添足导致了问题。尝试卸载 python36
, 明白了
Dependencies Resolved
====================================================================================
Package Arch Version Repository Size
====================================================================================
Removing:
python3 x86_64 3.6.8-18.el7 @updates 39 k
Removing for dependencies:
mock noarch 2.17-1.el7 @epel 814 k
mock-core-configs noarch 36.17-1.el7 @epel 313 k
python3-libs x86_64 3.6.8-18.el7 @updates 35 M
python3-pip noarch 9.0.3-8.el7 @base 9.1 M
python3-setuptools noarch 39.2.0-10.el7 @base 3.6 M
python3-templated-dictionary noarch 1.1-1.el7 @epel 29 k
python36-chardet noarch 3.0.4-1.el7 @epel 1.4 M
python36-distro noarch 1.5.0-1.el7 @epel 154 k
python36-idna noarch 2.10-1.el7 @epel 850 k
python36-jinja2 noarch 2.11.1-1.el7 @epel 1.2 M
python36-markupsafe x86_64 0.23-3.el7 @epel 100 k
python36-pyroute2 noarch 0.4.13-2.el7 @epel 1.8 M
python36-pysocks noarch 1.6.8-7.el7 @epel 101 k
python36-requests noarch 2.14.2-2.el7 @epel 533 k
python36-rpm x86_64 4.11.3-10.el7 @epel 905 k
python36-six noarch 1.14.0-3.el7 @epel 138 k
python36-urllib3 noarch 1.25.6-2.el7 @epel 865
原来激活了 EPEL
后,会导致安装 mock
工具时,由于 EPEL
提供了更高版本的基于 python36
的版本,导致没有安装CentOS 7发行版提供的针对 python2.7
的低版本 mock
解决方法是移除 python36
(会关联卸载 EPEL
版本的 mock
),关闭 EPEL ,然后重新安装 mock
(此时会安装CentOS 7发行版的 mock
):
yum remove -y python36