LoginSignup
4
2

More than 5 years have passed since last update.

CentOS6でmcrouterをビルドする手順

Posted at

mcrouterをビルドする

Facebookがmcrouterを発表してしばらく経つが、実はCentOS6でのビルド方法がなかなか見つからない。依存するパッケージが少し多めなのと公式のドキュメントがUbuntu 13.10/14.04をターゲットにしているからと思われる。それにいまならDockerがある。
それでもCentOS6上で動くmcrouterが必要な方に参照いただきたい。

依存性

以下のものは僕がビルドに成功したバージョン。より新しい/古いバージョンでもうまくいく可能性がある。

Build Dependencies

  • libtool-2.4.4
  • autoconf-2.69
  • automake-1.13
  • gcc-4.8.4
  • ragel-6.9

Runtime Dependencies

  • gflags (epelのパッケージでOK)
  • glog-0.3.3
  • boost-1.55.0
  • double-conversion (github master)
  • folly (github 0.22.0)
  • mcrouter (github master)

手順

yumで入るものはここで入れておく。epel必須

yum install -y bzip2-devel  libevent-devel libcap-devel scons
yum install -y jemalloc-devel gmp-devel mpfr-devel libmpc-devel m4 wget
yum install -y python-devel bzip2-devel rpmbuild
yum install -y m4 cmake libicu-devel chrpath openmpi-devel
yum install -y mpich-devel openssl-devel
yum install -y glibc-devel.i686 glibc-devel.x86_64 gcc gcc-c++ zlib-devel
yum install -y gmp-devel mpfr-devel libmpc-devel
yum install -y gflags-devel

# glog-0.3.3はtarballからrpmbuild

wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz
rpmbuild -tb -D'NAME glog' -D'VERSION 0.3.3' glog-0.3.3.tar.gz
yum install -y ~/rpmbuild/RPMS/x86_64/glog-0.3.3-1.x86_64.rpm  ~/rpmbuild/RPMS/x86_64/glog-devel-0.3.3-1.x86_64.rpm

cd /usr/local/src
wget http://ftpmirror.gnu.org/libtool/libtool-2.4.4.tar.gz
wget http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
wget http://ftpmirror.gnu.org/automake/automake-1.13.tar.gz
wget http://www.colm.net/files/ragel/ragel-6.9.tar.gz

tar xvzf ragel-6.9.tar.gz && cd ragel-6.9
./configure && make && make install

cd /usr/local/src
tar xvzf autoconf-2.69.tar.gz && cd autoconf-2.69
./configure --prefix=/opt/autotools && make && sudo make install

cd /usr/local/src
tar xvzf automake-1.13.tar.gz && cd automake-1.13
./configure --prefix=/opt/autotools && make && sudo make install

cd /usr/local/src
tar xvzf libtool-2.4.4.tar.gz && cd libtool-2.4.4
./configure --prefix=/opt/autotools && make && sudo make install

# gcc-4.8.4は標準インストールされたgccのオプション情報を参照してビルドする。
# 適宜 --enable-static --disable-shared --enable-languages=c,c++などを追加

wget http://ftpmirror.gnu.org/gcc/gcc-4.8.4/gcc-4.8.4.tar.bz2
tar xvjf gcc-4.8.4.tar.bz2
cd gcc-4.8.4
mkdir obj
cd obj
../configure --prefix=/opt/gcc --enable-bootstrap --disable-shared --enable-static --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++ --disable-dssi --with-ppl --with-cloog --with-tune=generic --build=x86_64-redhat-linux --with-gmp --with-mpfr --with-mpc  --with-arch_32=i686
make && sudo make install

# パスを通しておく

export PATH=/opt/autotools/bin:$PATH
export PATH=/opt/gcc/bin:$PATH

# ここ、boostのコンパイルがキモかも知れない

cd /usr/local/src
wget http://downloads.sourceforge.net/project/boost/boost/1.55.0/boost_1_55_0.tar.gz
wget tar xvzf boost_1_55_0.tar.gz
cd boost_1_55_0
./bootstrap.sh
./b2 architecture=x86 address-model=64 link=static
./bjam architecture=x86 address-model=64 link=static install
cd /usr/local/src
wget -O double-conversion.zip https://github.com/floitsch/double-conversion/archive/master.zip
unzip double-conversion.zip
cd double-conversion-master
cmake . && make && sudo make install
cd /usr/local/src
wget -O folly-0.22.0.zip 'https://github.com/facebook/folly/archive/v0.22.0.zip'
unzip folly.zip
cd folly-master/folly

# configure.acに細工を入れる。これがないとpthread_atforkの検出に失敗する。

sed '/Checks for library functions/ iAC_CHECK_LIB([pthread], [pthread_create])\n' configure.ac > configure.ac.new
autoreconf -ivf
./configure --disable-shared --enable-static && make && make install

mcrouterをビルド

cd /usr/local/src
wget -O mcrouter-master.tar.gz https://github.com/facebook/mcrouter/archive/master.tar.gz
tar xvzf mcrouter-master.tar.gz
cd mcrouter-master/mcrouter
autoreconf -ivf
./configure && make && make install

ところどころstaticライブラリにすることで実行環境にライブラリをインストールしなくてすむようにしているが、場合によってはsharedライブラリのほうが都合がいいかもしれない。

rpmパッケージも作ってみた。specファイルは以下。
上記、最終段階まで完了させた環境でのみビルド可能。
https://gist.github.com/shivaken/a911d50a9f0069ed7bfa

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2