Building ceph for Raspbian

The nproc fix mentioned below is probably not required. Nor, probably, is the swappiness setting.

# cat /etc/profile.d/ceph.sh
export PATH="$PATH:/usr/local/ceph/bin"
export MANPATH="$MANPATH:/usr/local/ceph/share/man"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/ceph/lib"
export PYTHONPATH="$PYTHONPATH:/usr/local/ceph/lib/python2.7/site-packages"
#

Files installed in /lib/systemd/system refer to /usr/lib/ceph. Do:

ln -s /usr/local/ceph/libexec/ceph /usr/lib

useradd -M -d /var/lib/ceph -s /sbin/nologin ceph

make install puts files in wrong directories

ceph-detect-init, ceph-disk, easy_install and related libraries were installed erroneously into /usr/local/bin and /usr/local/lib respectively.

Couldn't find virtualenv 26/9/17

apt-get -y install virtualenv

Then:

ImportError: No module named setuptools.command.egg_info

apt-get -y install python-setuptools

(might be able to avoid the above by not building the python bindings, etc.)

make failed again 23/9/17

Out of memory again.

Restarted from scratch with this configuration:

#!/bin/sh

./configure                             \
        --prefix=/usr/local/ceph-10.2.9 \
        --with-tcmalloc-minimal         \
        --without-libxfs                \
        --without-mds                   \
        --without-mon                   \
        --without-rados                 \
        --without-rbd                   \
        --without-cython                \
        --without-radosgw               \
        --without-selinux               \
        --without-radosstriper          \
        --without-debug                 \
        --without-profiler              \
        --without-man-pages             \
        --without-ocf                   \
        --without-openldap              \
        --disable-coverage              \
        --disable-valgrind

AND

echo "90" > /proc/sys/vm/swappiness

make failed at 11:00 22/9/17

Error was "out of virtual memory" while compiling test code.

Restarted from scratch with nproc returning "2" and configuration:

./configure                             \
        --prefix=/usr/local/ceph-10.2.9 \
        --with-tcmalloc-minimal         \
        --without-libxfs                \
        --without-mds                   \
        --without-mon                   \
        --without-debug                 \
        --without-profiler              \
        --without-man-pages             \
        --without-ocf                   \
        --without-openldap              \
        --disable-coverage              \
        --disable-valgrind

Versions of things

root@pi:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

ceph version: 10.2.9
gcc version: 6.3.0 (standard on Raspbian)
GNU make 4.1 (standard on Raspian)

apt-get -y install cython
apt-get -y install libsnappy-dev
apt-get -y install libleveldb-dev
apt-get -y install libblkid-dev
apt-get -y install libudev-dev
apt-get -y install libkeyutils-dev
apt-get -y install libcrypto++-dev
apt-get -y install libfuse-dev
apt-get -y install libtcmalloc-minimal4 (** see below under notes for libgoogle-perftools-dev)
apt-get -y install libatomic-ops-dev
apt-get -y install libaio-dev
apt-get -y install libboost-dev
apt-get -y install libboost-iostreams-dev
apt-get -y install libboost-thread-dev
apt-get -y install libboost-random-dev
apt-get -y install libboost-program-options-dev
apt-get -y install libldap2-dev

apt-get -y install libgoogle-perftools-dev

apt-get -y install python-setuptools

apt-get-y install texinfo (for man pages)

Notes about deprecated libgoogle-perftools-dev

Used in src/perfglue/heap_profiler.cc like this:

#ifdef HAVE_GPERFTOOLS_HEAP_PROFILER_H
  #include 
#else
  #include 
#endif

#ifdef HAVE_GPERFTOOLS_MALLOC_EXTENSION_H
  #include 
#else
  #include 
#endif

Note, however, that using libgoogle-perftools-dev causes the following warnings:

/usr/include/google/heap-profiler.h:35:2: warning: #warning "google/heap-profiler.h is deprecated. Use gperftools/heap-profiler.h instead" [-Wcpp]
 #warning "google/heap-profiler.h is deprecated. Use gperftools/heap-profiler.h instead"
  ^~~~~~~
In file included from perfglue/heap_profiler.cc:29:0:
/usr/include/google/malloc_extension.h:34:2: warning: #warning "google/malloc_extension.h is deprecated. Use gperftools/malloc_extension.h instead" [-Wcpp]
 #warning "google/malloc_extension.h is deprecated. Use gperftools/malloc_extension.h instead"

Note: This package also installs /usr/lib/libtcmalloc_minimal.so!

The "deprecated" warning should go away if configure is run before the dev package is installed (rather than after, which was the case here). Check src/acconfig.h to see if detected by configure.

Other configuration

./configure --prefix=/usr/local/ceph-10.2.9 --with-tcmalloc-minimal --without-libxfs

Can't compile XFS libraries because they test for and require a 64-bit environment (the xfs.h header actually tests for a 64-bit off_t type) and Raspbian is 32-bit.

Problem: configure can't find the tcmalloc library
ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so

make

Problem: the Makefile uses a program called nproc to determine the number of CPUs and then passes this number via the "-j" parameter to make to parallelize the build. Unfortunately this causes the build to use up all of RAM and all of swap.
Solution: write a short shellscript which just outputs "1", call it nproc and place it in the PATH before everything else.

The build needs lots of swap space. Some object files require all of the available RAM plus 2GB (or more) of swap space to compile. The default amount of swap space is only 100M and so things grind to a halt if left unchanged. Plug in an external USB drive, create a swap partition of 20G (mkswap /dev/sdX + swapon -p 0 /dev/sdX) and then run make.

Also did the build in a separate partition of the same USB drive (50G ext4 mounted on /build).

Tags: