ytooyamaのブログ

サーバ構築とか、仕事で発見したこととか、趣味のこととかを書いています。

そうだ、CentOS7でOVS+DPDKな環境を作ろう(前編??)

以前、こういった記事を会社のブログに書きました。

tech.virtualtech.jp

tech.virtualtech.jp

では、「CentOS 7ではどうなの?」ということで調査開始。

まずは公式のドキュメントの確認から

まず公式サイトを確認。 GCC 4.9以降が必要なのかー。

http://dpdk.org/doc/guides/linux_gsg/sys_reqs.html

CentOS 7.3だと4.8.5までしか入らない。惜しい!

gcc-4.8.5-11.el7.x86_64.rpm      20-Nov-2016 17:46     16M

試しに駄目元でCentOS 7.3のGCC 4.8.5でDPDKをビルドしたのですが、未定義のエラーがいろいろ出てしまってコンパイルが通ることはありませんでした。

GCC 4.9をソースからビルドする

そこでGCC 4.8.5を含めて必要なパッケージをインストールしたのち、GCC 4.9.4をビルドすることにしました。GCCをビルドするためにGCCをインストールするとか、なんか変な感じです。

GCCのビルドには時間がかかるので、先のドキュメントの「2.2. Compilation of the DPDK」にあるパッケージを全てインストールした状態で、以下の通り実行して帰ってきました。

# yum groupinstall -y "Development Tools"
# yum install -y epel-release glibc-devel* gcc-c++* zip wget

# curl -LO http://ftp.jaist.ac.jp/pub/GNU/gcc/gcc-4.9.4/gcc-4.9.4.tar.gz
# tar zvxf gcc-4.9.4.tar.gz
# cd gcc-4.9.4
# ./contrib/download_prerequisites
# ./configure --disable-multilib && make && make install && touch /root/buildend

ビルドが終わったら、/rootディレクトリーにbuildendというからのファイルが作られるはず。

...はず。。

ちなみにdevtoolset-3というのを入れるとGCCの新しいものを使えそうなのですが、DPDKをコンパイルしてインストールするように使っても動くのだろうか?...とか思いましたが、今回はソースからビルドをすることにしました。

Devtoolset-3 — Software Collections

いろいろ調べていたら次のようなドキュメントを発見。

Installing Operations Monitor Probe on Oracle Linux

え、Oracle LinuxでDPDK、割と簡単に動くの!? Oracle LinuxってCentOSと比べるとライブラリの新しいのが提供されていたりして動いちゃいそうな気はしますが、ねえ...といった感じ。

というところで本日の調査は終了。

ちなみに、Fedora 23のgccを上書きするというパワープレイも見つけましたが、yum updateコマンドを実行すると全て終わるような気がしたので、この方法は不採用としました。

serverfault.com

GCCから自前で用意しなくてはいけないようで非常に面倒だと感じました。 Ubuntuだったら、GCCの4も5も6もaptコマンドで入りますからね。もちろん、DPDKもOVSも。

手順が確定したら、会社と相談してどこかわかるところで公開したいと思います。

[追記] ビルド完了後の処理のログ。

...
ldconfig: /usr/local/lib/../lib64/libstdc++.so.6.0.20-gdb.py is not an ELF file - it has t
he wrong magic bytes at the start.

(注)上のエラーは無視して良さそう
https://gcc.gnu.org/ml/gcc-help/2014-08/msg00053.html

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/lib/../lib64

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.


# /usr/local/bin/gcc --version
gcc (GCC) 4.9.4
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# vi /root/.bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin
PATH=/usr/local/bin:$PATH:$HOME/bin

export PATH

# source /root/.bash_profile
# gcc --version
gcc (GCC) 4.9.4
...

この後の流れはこちらに

このブログサイトはJavaScriptを使っていますが、読み込んでいるJavaScriptは全てはてなが提供しているものであり、筆者が設置しているものではありません。