Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Trema v0.6.0 & Open vSwitch 2.4.0 のRPi2(Raspbian)でのセットアップメモ

More than 5 years have passed since last update.

※ 2015/09に修正


  • ユーザ
$ whoami
  • 実行したアップデート
$ sudo apt-get -y update && sudo apt-get -y upgrade
$ sudo rpi-update
  • 環境
$ cat /etc/debian_version

$ uname -a
Linux raspberrypi 4.1.6-v7+ #810 SMP PREEMPT Tue Aug 18 15:32:12 BST 2015 armv7l GNU/Linux

$ which ruby

$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [armv7l-linux-eabihf]

$ gem -v


$ gem install trema -V
  • チェック
$ trema --version
trema version 0.6.0

$ gem which trema

Open vSwitchのセットアップ(ソースから)

  • ダウンロード
$ wget http://openvswitch.org/releases/openvswitch-2.4.0.tar.gz
  • 解凍
$ tar xzf openvswitch-2.4.0.tar.gz
  • ビルド(解凍されたディレクトリのINSTALL.Debianを見ながら)
$ sudo apt-get -y install build-essential fakeroot
$ cd openvswitch-2.4.0 && dpkg-checkbuilddeps
$ sudo apt-get install [出力されたパッケージ]
$ # .deb ファイルを作る(testが有効だと時間がかかるのでやめた)
$ DEB_BUILD_OPTIONS='nocheck' fakeroot debian/rules binary
  • インストール
$ dpkg -l | grep openvswitch # で出てきたものを消す
$ sudo apt-get purge openvswitch-switch
$ sudo apt-get purge openvswitch-common

$ # 以下1でdkmsをインストールしろと言われてしたが、
$ sudo apt-get install dkms

$ # このようにエラーが出る。
$ # Your kernel headers for kernel 4.1.6-v7+ cannot be found at
$ # /lib/modules/4.1.6-v7+/build or /lib/modules/4.1.6-v7+/source.
$ # [apt-cache search linux-headers-$(uname -r)] で見つからないのでこのまま進む

$ # 1
$ sudo dpkg -i openvswitch-datapath-dkms_2.4.0-1_all.deb

$ sudo dpkg -i openvswitch-common_2.4.0-1_armhf.deb
$ sudo dpkg -i openvswitch-switch_2.4.0-1_armhf.deb
  • スタート
$ sudo service openvswitch-switch start
ovsdb-server is already running.
ovs-vswitchd is already running.
Enabling remote OVSDB managers.

Hello Trema


  • まず、IPv6を有効に
    • 今すぐ
  $ sudo modprobe ipv6
  • そしてこれからも(boot時にenable)
  $ echo ipv6 | sudo tee -a /etc/modules
  • 理由は、あらかじめIPv6が有効でないと下記でエラー(No such file ...)になるから。
  sh "sudo /sbin/sysctl -w net.ipv6.conf.#{bridge_name}.disable_ipv6=1 -q"

Hello! (yay! :smile:)

$ git clone https://github.com/trema/hello_trema.git
$ cd hello_trema
$ trema run lib/hello_trema.rb -c trema.conf
[sudo] password for pi:
Trema started.
Hello 0xabc!

$ bundle install --binstubs
$ bundle exec ./bin/trema run ./lib/hello_trema.
[sudo] password for pi:
Trema started.
Hello 0xabc!



  • 余計なファイルを消す
$ rm -v /tmp/HelloTrema.*
removed `/tmp/HelloTrema.log'
removed `/tmp/HelloTrema.pid'
  • スイッチを消す(*.confに書いてあるdatapath_idを参照)
$ sudo ovs-vsctl del-br br0xabc
  • またログを見る(.rbに書いたコントローラ名を参照(class HelloTrema < Trema::Controller))のも良い
$ less /tmp/HelloTrema.log
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away


No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
Help us understand the problem. What is going on with this article?