SUSE 12环境编译glusterfs 11

GlusterFS官方文档 GlusterFS Install Guide 介绍了gluster官方软件仓库中提供了主流发行版的安装软件包。其中Red Hat/CentOS和Ubuntu/Debian提供软件仓库方式自动安装,SUSE发行版则通过 SUSE Open Build Service (OBS) 的下载仓库提供了不同SUSE版本的安装软件包。

SUSE的 SUSE Open Build Service (OBS) 只提供了较新发布版本对应的 GlusterFS SUSE安装包 ,例如 Tumbleweed, SLES 15, and OpenSUSE Leap 15.1。

备注

本文实践是在 SUSE Linux 12 SP5环境,编译最新的 GlusterFS 11,以配合 CentOS 7环境编译GlusterFS 11 所部署的 在SLES 12 sp5中部署GlusterFS 11客户端

但是实际上线上生产环境,依然运行着非常古老的SUSE Linux版本,例如 SELS 12 SP3,官方下载仓库只提供了非常陈旧的已经不再维护的发行包。为了能够在实际生产环境稳定运行,需要自己编译安装GlusterFS稳定版本。

备注

我在SUSE Enterprise Linux Server SELS 12 SP3版本上折腾了很久才完成GlusterFS的软件包编译,过程曲折,也迫使我对SUSE Linux比较深入的学习和探索,积累了一些经验。整个探索过程我记录在 SUSE编译glusterfs尝试 ,不过太冗长了,所以我重新在这里整理一个完整的正确方法,提供一个简明指南。如果你对为何我采用这个步骤有疑问,也可以参考原始记录 SUSE编译glusterfs尝试

编译准备工作

在服务器上安装完 SUSE Linux 12 SP5

在开始编译之前,首先要对编译工作环境进行配置:

SUSE SDK

要在 SUSE Linux 环境编译软件,首先需要 SUSE 开发SDK。对于企业内部大规模批量部署,建议采用 SUSE部署SMT服务器 。不过,suse SMT需要订购服务,所以还是采用 直接下载 SUSE Linux enterprise Software Development Kit Downloads ,将 下载 SLE SDK iso镜像,然后通过 使用SUSE的DVD iso构建安装仓库 方式添加到主机repo后,就可以通过 zypper安装依赖软件包。

挂载SUSE Linux 安装光盘和SDK光盘的ISO镜像
# 安装盘
zypper ar -c -t yast2 "iso:/?iso=/home/SLE-12-SP5-Server-DVD-x86_64-GM-DVD1.iso" "SLES12-SP5"
# SDK盘
zypper ar -c -t yast2 "iso:/?iso=/home/SLE-12-SP5-SDK-DVD-x86_64-GM-DVD1.iso" "SLES12-SP5-SDK-1"
zypper ar -c -t yast2 "iso:/?iso=/home/SLE-12-SP5-SDK-DVD-x86_64-GM-DVD2.iso" "SLES12-SP5-SDK-2"

然后检查仓库:

执行 zypper repos 检查添加的ISO仓库
zypper repos

显示如下:

执行 zypper repos 检查添加的ISO仓库
Repository priorities are without effect. All enabled repositories share the same priority.

# | Alias             | Name              | Enabled | GPG Check | Refresh
--+-------------------+-------------------+---------+-----------+--------
1 | SLES12-SP5        | SLES12-SP5        | Yes     | ( p) Yes  | No
2 | SLES12-SP5-12.5-0 | SLES12-SP5-12.5-0 | No      | ----      | ----
3 | SLES12-SP5-SDK-1  | SLES12-SP5-SDK-1  | Yes     | ( p) Yes  | No
4 | SLES12-SP5-SDK-2  | SLES12-SP5-SDK-2  | Yes     | ( p) Yes  | No

接下来就可以安装所有编译GlusterFS所依赖的开发库以及开发工具了。

安装开发库和工具

  • 根据GlusterFS官方 Building GlusterFS 文档,在SUSE SELS 12 SP5的安装和Red Hat RHEL编译环境相似的软件包:

执行 zypper install 安装必要编译依赖
# 参考GlusterFS在CentOS上编译经验安装以下软件包
zypper in -y autoconf automake bison dos2unix flex                   \
  fuse-devel glib2-devel libacl-devel libaio-devel libattr-devel     \
  libcurl-devel rdma-core-devel libtirpc-devel                       \
  libtool libxml2-devel lvm2-devel make libopenssl-devel pkg-config  \
  python-devel python-netifaces                                      \
  python-sphinx python-webob python-xattr                            \
  readline-devel rpm-build sqlite3-devel systemtap-sdt-devel          \
  tar gperftools gperftools-devel liburcu-devel

# 根据编译经验,可能还需要安装以下开发库
zypper in -y libuuid-devel libacl-devel libxml2-devel liburcu-devel
zypper in -y python-devel libtirpc-devel libcurl-devel fuse-devel

备注

使用 zypper in 执行会提示一些在CentOS上软件包名找不到对应软件包,则通过搜索尽可能找到兼容包:

zypper install 安装依赖的一些调整说明
pkgconfig => pkg-config
openssl-devel => libopenssl-devel
sqlite-devel => sqlite3-devel
libibverbs-devel => rdma-core-devel # 这是 Library & drivers for direct userspace use of InfiniBand/iWARP/RoCE hardware 在openSUSE Leap 15.5 提供,在suse sels 12 用 rdma-core-devel 就可
librdmacm-devel # 在openSUSE Leap 15.5 提供,在suse sels 12 用 rdma-core-devel 就可 https://github.com/linux-rdma/rdma-core
pyxattr => python-xattr
pyliblzma => python-pyliblzma 但是这个包只在openSUSE 15提供

当后续在编译GlusterFS执行 ./configure 时会提示某些头文件缺失,则对应安装软件包 xxxx-devel

GlusterFS的编译依赖 userspace-rcu-devel ,这个软件包仅见于 SUSE SELS 15 ,对于早期SUSE发行版对应软件包名是 liburcu-devel ,不过需要修订spec文件。见下文。

备注

之前 SUSE 12环境编译glusterfs 6 实践经验有所调整:

'rdma-core-devel' providing 'libibverbs-devel' is already installed.
'rdma-core-devel' providing 'librdmacm-devel' is already installed.

也就是说在 12SP5 只要安装一个 rdma-core-devel 就可以取代 libibverbs-devellibrdmacm-devel

备注

在后续编译过程中,执行 ./configure 时会提示某些头文件缺失,则对应安装软件包 xxxx-devel

下载代码库

下载 glusterfs-11.0 源代码tgz包
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}

编译准备

  • 编译配置:

配置glusterfs
./autogen.sh
# 和CentOS 7一样,内核版本还不支持io_uring
./configure --disable-linux-io_uring
配置glusterfs
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            : yes
With Python          : 3.4
Cloudsync            : yes
Metadata dispersal   : no
Link with TCMALLOC   : yes
Enable Brick Mux     : no
Building with LTO    : no

编译

  • 编译:

    make
    

编译报错 error: field 'available' has incomplete type

编译报错:

编译出错,不兼容类型 error: field ‘available’ has incomplete type
  CC       libglusterfs_la-async.lo
In file included from async.c:68:0:
glusterfs/async.h:135:28: error: field 'available' has incomplete type
     struct __cds_wfs_stack available;
                            ^
async.c: In function 'gf_async_init':
async.c:648:5: error: implicit declaration of function '__cds_wfs_init' [-Werror=implicit-function-declaration]
     __cds_wfs_init(&gf_async_ctrl.available);
     ^
cc1: some warnings being treated as errors
Makefile:1372: recipe for target 'libglusterfs_la-async.lo' failed
make[4]: *** [libglusterfs_la-async.lo] Error 1
make[4]: Leaving directory '/home/glusterfs-11.0/libglusterfs/src'
Makefile:816: recipe for target 'all' failed
make[3]: *** [all] Error 2
make[3]: Leaving directory '/home/glusterfs-11.0/libglusterfs/src'
Makefile:455: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/glusterfs-11.0/libglusterfs'
Makefile:585: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/glusterfs-11.0'
Makefile:479: recipe for target 'all' failed
make: *** [all] Error 2

这个问题在 compiling on SLES 12-SP5 fails : glusterfs/async.h error: field available has incomplete type #1515 有说明,原因似乎需要将 urcu 升级到更高版本(可能需要 0.10 以上版本),而SLES 12.5提供的 liburcu-devel0.8.8

Userspace RCU 下载最新版本:

自行编译安装 Userspace RCU
wget https://lttng.org/files/urcu/userspace-rcu-0.14.0.tar.bz2
tar xfj userspace-rcu-0.14.0.tar.bz2
./configure
make
make install
ldconfig

备注

编译 Userspace RCU 需要C++11 feature支持,所以 在SuSE 12 SP5中升级gcc 完成后在执行上述 Userspace RCU 编译

完成 Userspace RCU 编译安装之后,重新完成一次 GlusterFS.configuremake 就可以顺利完成

安装

  • 在SuSE SLES12 SP3上虽然编译可以顺利完成,但是源代码中缺少一个对应SuSE脚本,所以会导致 sudo make install 执行失败中断。由于SuSE运行环境接近RedHat,所以借用Redhat版本复制脚本:

    cp extras/init.d/glustereventsd-Redhat extras/init.d/glustereventsd-SuSE
    cp extras/init.d/glustereventsd-Redhat.in extras/init.d/glustereventsd-SuSE.in
    

上述fix步骤重要,否则会导致安装不完整,会无法正常运行

  • 安装:

    sudo make install
    

备注

安装后可能需要执行一次 ldconfig 确保动态库加载,否则直接执行 gluster 可能会报找不到库文件,参见 SUSE 12环境编译glusterfs 6

  • 将编译后的 glusterfs 源代码目录复制到相同操作系统环境中,并且按照上文方式安装了所有依赖库,就可以同样执行 sudo make install 进行安装。

编译RPM

参考 CentOS 7环境编译GlusterFS 11 安装SUSE构建rpm的依赖软件包
# 参考 https://software.opensuse.org/download/package?package=python-mock&project=Cloud%3ATools 通过仓库安装:
#zypper addrepo https://download.opensuse.org/repositories/Cloud:Tools/SLE_12_SP5/Cloud:Tools.repo
#zypper refresh
#zypper install python-mock

# 也可以直接从 https://download.opensuse.org/repositories/Cloud:/Tools/SLE_12_SP5/ 下载:
wget https://download.opensuse.org/repositories/Cloud:/Tools/SLE_12_SP5/noarch/python3-mock-4.0.2-70.29.noarch.rpm
rpm -ivh python3-mock-4.0.2-70.29.noarch.rpm

# 参考 CentOS 安装rpm构建所需依赖工具包
zypper in -y rpm-build selinux-policy-devel bash-completion

备注

CentOS 7环境编译GlusterFS 11 依赖的 mock rpm包在SUSE平台对应是 python-mock ,不过这个包 pyton-mock安装包 只在OpenSUSE12提供,位于 python-mock from Cloud:Tools project (实际上就是 OpenStack Atlas 项目提供的工具包) 提供了仓库安装方法

  • 执行rpm构建:

执行构建GlusterFS RPMs
cd extras/LinuxRPM
make glusterrpms

编译RPM报错 error: Bad owner/group

  • 执行 make glusterrpms 报错:

执行 make glusterrpms 报错 error: Bad owner/group
...
cp ../../glusterfs.spec ./rpmbuild/SPECS
rpmbuild --define '_topdir /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild' -bs rpmbuild/SPECS/glusterfs.spec
error: Bad owner/group: /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild/SOURCES/glusterfs-11.0.tar.gz
Makefile:567: recipe for target 'srcrpm' failed
make: *** [srcrpm] Error 1

检查 /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild/SOURCES/glusterfs-11.0.tar.gz 文件叔主就会看到系统缺少一个 1001 对应的 group :

glusterfs-11.0.tar.gz 文件属主group缺失
ls -lh /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild/SOURCES/glusterfs-11.0.tar.gz
-rw-r--r-- 1 root 1001 8.1M Jul 25 07:59 /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild/SOURCES/glusterfs-11.0.tar.gz

原来这个软件包目录上是我从其他服务器上复制过来的 tar 包,所以解压缩以后属主group依然是另一个系统的用户group,在本地不存在。简单修复一下整个源代码目录属主为当前用户属主的组即可。

编译RPM报错 error: Failed build dependencies

在 SUSE SLES 12 环境下编译RPM会有依赖错误:

执行 make glusterrpms 报错 error: Failed build dependencies
...
rpmbuild --define '_topdir /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild' -bs rpmbuild/SPECS/glusterfs.spec
Wrote: /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild/SRPMS/glusterfs-11.0-0.0.src.rpm
mv rpmbuild/SRPMS/* .
rpmbuild --define '_topdir /home/glusterfs-11.0/extras/LinuxRPM/rpmbuild' --with gnfs -bb rpmbuild/SPECS/glusterfs.spec
error: Failed build dependencies:
        userspace-rcu-devel >= 0.7 is needed by glusterfs-11.0-0.0.x86_64
        liburing-devel is needed by glusterfs-11.0-0.0.x86_64
Makefile:571: recipe for target 'rpms' failed
make: *** [rpms] Error 1

所以编译RPM还需要做一些修订

  • GlusterFS源代码中根目录下 glusterfs.spec 配置了 BuildRequires:    userspace-rcu-devel >= 0.7 ,这个依赖需要修改成 SELS 12 SP3对应的 liburcu-devel (版本是 0.8),所以修改源代码根目录下 glusterfs.spec.in ,将:

    BuildRequires:    userspace-rcu-devel >= 0.7
    

修改成:

BuildRequires:    liburcu-devel >= 0.7
  • 我尝试修改 extras/LinuxRPM 目录下的 Makefile.amautogen: 段落将 ./configure --enable-gnfs --with-previous-options 修订为 ./configure --disable-linux-io_uring (注意,不是修改 Makefile.in ,这个 Makefile.inMakefile 会被 Makefile.am 覆盖):

修改 Makefile 设置 configure 参数
autogen:
        cd ../.. && \
        rm -rf autom4te.cache && \
        ./autogen.sh && \
        ./configure --disable-linux-io_uring

不过,比较奇怪,虽然这里 autoconfig 输出信息已经是 ./configure --disable-linux-io_uring ,但实际报错依旧

警告

实在没有时间和精力折腾了,虽然还是没能搞成SUSE的rpm包(其他折腾见 suse12编译glusterfs6的Makefile错误解决尝试 ),但是项目工作还是能完成的(因为我通过源代码编译能 make install ),暂时就这样吧…

参考