LoginSignup
2
2

More than 3 years have passed since last update.

Raspberry PIでStorjを動かす

Last updated at Posted at 2019-09-21

はじめに

Storjのベータ版に参加できることになったので、手元の機材で環境構築しました。

ハードウェア情報

環境構築

Dockerのインストール

Raspbian StretchにDockerをインストールする。
基本的には 公式ドキュメント通りだが、リポジトリの追加のところはRaspbian用に変更している。

$ sudo apt-get remove docker docker-engine docker.io containerd runc

$ sudo apt-get update

$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
    software-properties-common

$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

$ sudo apt-key fingerprint 0EBFCD88

$ echo  "deb [arch=armhf] https://download.docker.com/linux/raspbian stretch stable" | sudo tee /etc/apt/sources.list.d/docker.list

$ cat /etc/apt/sources.list.d/docker.list
deb [arch=armhf] https://download.docker.com/linux/raspbian stretch stable

$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

$ apt-cache madison docker-ce
 docker-ce | 5:19.03.2~3-0~raspbian-stretch | https://download.docker.com/linux/raspbian stretch/stable armhf Packages

$ sudo apt-get install docker-ce=5:19.03.2~3-0~raspbian-stretch docker-ce-cli=5:19.03.2~3-0~raspbian-stretch containerd.io

HDDマウント

  • 今回はNASをマウントし、そこにStorjのデータを保存します。
$ sudo mkdir /mnt/storj
$ sudo mount -t nfs 192.168.11.17:/FS01/Storj /mnt/storj
  • マウントパスにStorjのデータ保存領域を作ります。
$ mkdir /mnt/storj/data
$ sudo chmod 777 -R /mnt/storj/data/

ポートフォワーディング

ルータの28967番ポートをRaspberry PIまでフォワーディングする。

認証ファイルの作成

  • Identity Tokenを使って、認証ファイルを作成する。

  • 認証用バイナリをダウンロード

$ mkdir storj
$ cd storj
$ wget https://github.com/storj/storj/releases/download/v0.21.1/identity_linux_arm.zip
$ unzip identity_linux_arm.zip
$ chmod +x identity_linux_arm
  • コマンドを実行し、認証ファイルを生成する。
    コマンド実行したら完了まで結構時間掛かります。
$ ./identity_linux_arm create storagenode
2019-09-20T10:34:30.795+0100    INFO    running on version v0.21.1
Generating key with a minimum a difficulty of 30...
Generated 1685050 keys; best difficulty so far: 30
Found a key with difficulty 30!
Unsigned identity is located in "/home/pi/.local/share/storj/identity/storagenode"
Please *move* CA key to secure storage - it is only needed for identity management!
        /home/pi/.local/share/storj/identity/storagenode/ca.key
  • 作成した認証ファイルはここに保存されます。
$ ls /home/pi/.local/share/storj/identity/storagenode/ca.key
  • 認証ファイルに、参加登録したときにメールで受け取ったidentity tokenを使って署名をする。
$ ./identity_linux_arm authorize storagenode <email:characterstring>
  • 署名した認証ファイルはバックアップしておきましょう。

Storj Storage Node構築

  • storageNode用のコンテナをダウンロード
$ sudo docker pull storjlabs/storagenode:beta
  • Storjコンテナの起動
$ sudo docker run -d --restart unless-stopped -p 28967:28967 \
    -e WALLET="<Storj Tokenを受け取るEthereumのアドレス>" \
    -e EMAIL="<登録したメールアドレス>" \
    -e ADDRESS="<自分のドメイン名>:28967" \
    -e BANDWIDTH="60TB" \
    -e STORAGE="500GB" \
    --mount type=bind,source="<identity-dir>",destination=/app/identity \
    --mount type=bind,source="<storage-dir>",destination=/app/config \
    --name storagenode storjlabs/storagenode:beta

Dashboard

  • CLIでノードのステータスを見る
$ docker exec -it storagenode /app/dashboard.sh


Storage Node Dashboard ( Node Version: v0.20.1 )

======================

ID           <NodeID>
Last Contact 0s ago
Uptime       13h22m26s

                   Available       Used     Egress     Ingress
     Bandwidth       60.0 TB     0.8 GB        0 B      0.8 GB (since Sep 1)
          Disk      500.0 GB     4.6 MB

Bootstrap bootstrap.storj.io:8888
Internal  127.0.0.1:7778
External  <domain名>:<port番号>

Neighborhood Size 258

Storjのバージョンを自動でアップデートさせる

watchtowerを使用して、storagenodeのDockerコンテナーを自動更新することができます。
Watchtowerは6時間ごとに新しいバージョンを探し、新しいバージョンが検出されるとストレージノードを自動的に更新します。

$ sudo docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock storjlabs/watchtower storagenode watchtower --stop-timeout 300s --interval 21600

参考資料

2
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
2
2