Ceph编译

Posted by elrond on November 26, 2021

build Ceph

编译需要的时间比较长,建议在screen里面编译,防止terminal连接中断

如果在根目录挂载的文件系统下编译,根目录至少有100G可用空间 如果是其他目录单独挂载的文件系统下编译,根目录至少有50G可用空间,其他目录至少有100G空间

1. 环境

组件名称 版本 备注
操作系统 CentOS Linux release 7.8.2003 (Core)  
内核 3.10.0-1127.el7.x86_64  
Ceph分支版本 v15.2.15  

2. 下载Ceph代码

git clone git@github.com:ceph/ceph.git

3. 选择分支

我这里选择tag v15.2.15

git checkout v15.2.15

4. update submodule

git submodule update --init --recursive

5. 下载依赖

如果使用官方提供的 install-deps.sh 会有几个包装不上,例如golang-github-prometheus-prometheus,手动安装依赖

yum install -y redhat-lsb-core yum-utils java-devel sharutils checkpolicy selinux-policy-devel python-cherrypy python-werkzeug bc gperf cmake cryptsetup fuse-devel gcc-c++ gdbm gperftools-devel jq leveldb-devel libaio-devel libblkid-devel libcurl-devel libudev-devel libtool libxml2-devel make parted perl pkgconfig python python-devel python-nose python-requests python-virtualenv snappy-devel udev util-linux valgrind-devel which xfsprogs xfsprogs-devel xmlstarlet yasm boost-random btrfs-progs nss-devel keyutils-libs-devel libibverbs-devel openldap-devel openssl-devel Cython python-prettytable python-sphinx python34-devel python34-setuptools python34-Cython lttng-ust-devel libbabeltrace-devel expat-devel redhat-rpm-config junit fcgi-devel selinux-policy-doc rdma-core-devel devtoolset-8-gcc-c++ lz4-devel liboath-devel librabbitmq-devel python2-Cython python36-Cython python36-setuptools python36-devel CUnit-devel librdmacm-devel cmake3 libcap-ng-devel libnl3-devel librdkafka-devel fuse3-devel python36-sphinx

6. 安装devtoolset

安装devtoolset主要为了解决ceph使用了C++17的特性,但CentOS7默认源安装的GCC版本不兼容问题,错误信息如下

GCC 7+ required due to C++17 requirements
yum install centos-release-scl
yum install devtoolset-8
# 每次编译source一下
source /opt/rh/devtoolset-8/enable

7. 编译二进制

编译服务器CPU越多编译越快,24核的半小时编译完成,8核每次编译两个多小时

cd build
make -j$(nproc)

编译完最后输出如下

ceph-compile

编译产物 build/bin 下的二进制文件

8. 编译rpm

8.1. 先编译dist包

./make-dist

编译产物 ceph-15.2.15-0-g2dfb188.tar.bz2 boost_1_72_0.tar.bz2 dashboard_frontend.tar rook_ceph_client.tar

8.2. 编译rpm包

8.2.1. 编译srpm包

./make-srpm.sh

编译产物 ceph-15.2.15-0.g2dfb188.el7.src.rpm

8.2.2. 编译rpm包

编译rpm包时默认spec文件中有make,所以编译耗时跟编译二进制是一样的

rpmbuild -D"_sourcedir `pwd`" -D"_specdir `pwd`" -D"_srcrpmdir `pwd`" -ba ceph.spec
Provides: ceph-debuginfo = 2:15.2.15-0.g2dfb188.el7 ceph-debuginfo(x86-64) = 2:15.2.15-0.g2dfb188.el7
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
检查未打包文件:/usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/ceph-15.2.15-0.g2dfb188.el7.x86_64
写道:/mnt/vdb/ceph/ceph-15.2.15-0.g2dfb188.el7.src.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-base-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/noarch/cephadm-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-common-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-mds-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-mon-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-mgr-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-dashboard-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-diskprediction-local-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-diskprediction-cloud-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-modules-core-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-rook-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-k8sevents-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-mgr-cephadm-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-fuse-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/rbd-fuse-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/rbd-mirror-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-immutable-object-cache-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/rbd-nbd-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-radosgw-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-resource-agents-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-osd-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/librados2-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/librados-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libradospp-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/librgw2-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/librgw-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/python36-rgw-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/python36-rados-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libradosstriper1-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libradosstriper-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/librbd1-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/librbd-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/python36-rbd-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libcephfs2-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libcephfs-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/python36-cephfs-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/python36-ceph-argparse-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/python36-ceph-common-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-test-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libcephfs_jni1-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/libcephfs_jni-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/cephfs-java-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/rados-objclass-devel-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-selinux-15.2.15-0.g2dfb188.el7.x86_64.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-grafana-dashboards-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/noarch/ceph-prometheus-alerts-15.2.15-0.g2dfb188.el7.noarch.rpm
写道:/root/rpmbuild/RPMS/x86_64/ceph-debuginfo-15.2.15-0.g2dfb188.el7.x86_64.rpm
执行(%clean): /bin/sh -e /var/tmp/rpm-tmp.6GS8ro
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd ceph-15.2.15-0-g2dfb188
+ rm -rf /root/rpmbuild/BUILDROOT/ceph-15.2.15-0.g2dfb188.el7.x86_64
+ exit 0

编译产物 /root/rpmbuild/RPMS/x86_64/

9. 参考

Ceph 依赖包部分是小甲鱼友情指导