[关闭]
@tony-yin 2018-04-25T02:26:57.000000Z 字数 3160 阅读 894

Ceph 编译(Giant版本)

Ceph


如今入门Ceph的时候,大家一般用ceph-deploy工具比较多,这个工具的确很强大,很方便,对应的也就是很无脑。如果之后想深入Ceph或者想在生产环境中部署Ceph的话,就得熟悉Ceph源码编译了。这对我们熟悉Cephfeature的变化,component的相互关系以及围绕Ceph各种定制化扩展都大有裨益。本文就笔者Ceph源码编译过程和遇到的问题作出分享,希望有人能够得益于此。

环境声明

源码下载

指定 giant 分支

  1. git clone -b giant git://github.com/ceph/ceph.git

下载子模块

  1. git submodule update --init --recursive

这一步我始终更新不了,尝试了一些办法未果,所以就去直接手动下载了源码,这个问题以后有时间看下

预检

  1. cd ceph
  2. ./autogen.sh
  3. ./configure

Autogen

这一步会频繁的报错一些m4文件没有,这需要我们手动创建这些m4文件夹即可,

一开始我在ceph根目录创建了m4文件夹,并生成了包括acx_pthread.m4在内的文件,但是还是报错:acx_pthread.m4 not exist,后来发现这时候已经切换目录了,不止一个地方需要m4文件夹,一共有这几个地方需要手动创建目录:mkdir m4

  1. ./src/rocksdb/m4
  2. ./src/gtest/m4
  3. ./src/erasure-code/jerasure/jerasure/m4
  4. ./src/erasure-code/jerasure/gf-complete/m4
  5. ./m4

如果还是报错一些文件不存在,并且通过上述方法不能自行初始化生成的话,可以从网上或者已经编译过的ceph环境拷贝过来

  1. 报错:umdefined macro

下载地址:https://www.gnu.org/software/autoconf-archive/ax_check_classpath.html#ax_check_classpath

Configure

这一步是编译过程中可能出错的次数最多的,因为可能会因为你的环境缺少相应的包不断报错。不过数量虽多,解决起来还是比较容易的,就根据报错的缺包对应下载安装就好了,下面我先给出一个所有包的安装步骤,然后再针对每个报错环节给出具体的解决方案

总体解决方案

  1. # 1. 通过yum安装所有可以安装的包
  2. yum install -y yasm libuuid-devel libblkid-devel libudev-devel cryptopp-devel fuse-devel libunwind-devel libedit-devel libatomic_ops-devel snappy-devel leveldb-devel libaio-devel xfsprogs-devel boost*
  3. # 2. 部分yum不能安装的可以通过rpm安装
  4. wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.2.1/gperftools-2.2.1.tar.gz
  5. tar -zxvf gperftools-2.2.1.tar.g
  6. cd gperftools-2.2.1
  7. ./configure
  8. make
  9. make install

具体解决方案

1.yasm

报错:

  1. yasm command not found

解决:

  1. yum install yasm -y

2.libuuid

报错:

  1. configure: error: libuuid not found

解决:

  1. yum install libuuid-devel -y

3.libblkid

报错:

  1. configure: error: blkid/blkid.h not found (libblkid-dev, libblkid-devel)

解决:

  1. yum install libblkid-devel -y

4.libudev

报错

  1. configure: error: libudev.h not found (libudev-dev, libudev-devel)

解决:

  1. yum install libudev-devel -y

5.crypto

报错:

  1. configure: error: no suitable crypto library found

解决:

  1. yum install cryptopp-devel -y

6.fuse

报错:

  1. configure: error: no FUSE found (use --without-fuse to disable)

解决:

  1. yum install fuse-devel -y

7.tcmalloc

报错:

  1. configure: error: no tcmalloc found (use --without-tcmalloc to disable)

解决:

  1. # 1. 需要先安装libunwind-devel,被gperftools依赖
  2. yum install libunwind-devel -y
  3. # 2. 安装tcmalloc(yum无法安装,需要通过rpm的方式)
  4. wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.2.1/gperftools-2.2.1.tar.gz
  5. tar -zxvf gperftools-2.2.1.tar.g
  6. cd gperftools-2.2.1
  7. ./configure
  8. make
  9. make install

8.libedit

报错:

  1. configure: error: No usable version of libedit found.

解决:

  1. yum install libedit-devel -y

9.libatomic-ops

报错:

  1. configure: error: no libatomic-ops found (use --without-libatomic-ops to disable)

解决:

  1. yum install libatomic_ops-devel -y

10.libsnappy

报错:

  1. configure: error: libsnappy not found

解决:

  1. yum install snappy-devel -y
  2. or
  3. wget ftp://195.220.108.108/linux/centos/6.9/os/x86_64/Packages/snappy-devel-1.1.0-1.el6.x86_64.rpm
  4. rpm -ivh snappy-devel-1.1.0-1.el6.x86_64.rpm

11.libleveldb

报错:

  1. configure: error: libleveldb not found

解决:

  1. yum install leveldb-devel

12.libaio

报错:

  1. configure: error: libaio not found

解决:

  1. yum install libaio-devel -y

13.libxfs

报错:

  1. configure: error: xfs/xfs.h not found (--without-libxfs to disable)

解决:

  1. yum -y install xfsprogs-devel

14.boost

报错:

  1. Can't find boost spirit headers

解决:

  1. yum install boost* -y

编译安装

机器配置不好的话,编译需要时间比较长。可以使用make -j增加并发度,4表示同时执行的make方法数。

  1. make -j4
  2. make install(可选)

小结

ceph手动源码编译遇到的问题还是蛮多的,如果不自己动手经历一下的话很多东西都不知道,当然这都是经验的积累,不断地锻炼自己解决问题的能力,要学会见招拆招,通过问题发现原理和本质。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注