LoginSignup
5
4

More than 5 years have passed since last update.

Storjにストレージを公開する方法

Last updated at Posted at 2018-04-03

さくらのクラウド上に用意したVMで、そのディスクをStorjに公開する(そして報酬を得る)方法の作業メモ。

Storjでストレージを「使う」方については別途まとめる予定。(追記:2018/04/12時点では新規アカウント発行は受け付けていない模様。https://qiita.com/kikuzo/items/ad4ac72c18ffd494f4e0)

前提と事前準備、参考ページ情報

作業手順

上記本家のGitHubのREADME.mdに従ってやっていくのだけど、多少補完が必要。
ポイントとしては、 StorjShareは、"daemon"と"farming node"の2つのプロセスで構成されていて、configファイルも2つ用意しなければならない ということ。

インストール

ubuntu@storj:~$ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
ubuntu@storj:~$ nvm install --lts
ubuntu@storj:~$ sudo apt-get install git python build-essential
ubuntu@storj:~$ npm install --global storjshare-daemon

設定

上記のインストールプロセスを実行すると、~/.config/storjshareというディレクトリができているので、そこにconfigを書いていく。

daemonのの設定
~/.config/storjshare/configというファイルを自前で作る。

~/.config/storjshare/config
{
  "daemonRpcPort": 45015,
  "daemonRpcAddress": "127.0.0.1",
  "daemonLogFilePath": "/home/ubuntu/.config/storjshare/logs/daemon.log",
  "daemonLogVerbosity": 3
}

farming nodeの設定
コマンドラインからstorjshareコマンドを叩いて作る。

ubuntu@storj:~$ storjshare create --storj 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --storage /storj --size 900GB

--storj 0xXXXXX..の部分には、ethereumの口座アドレスを指定します。
--storage /storj の部分は公開するストレージのディレクトリを指定します。(なおこの例では/(root)直下に作成したためsudo chown ubuntu:ubuntu /storjしてオーナーを変更する必要がありました。)

このコマンドを実行すると、(OS設定のデフォルトエディタで)configファイルを編集中の状態になるようなので、":wq!"など(vimの場合)で適当に保存します。すると、~/.config/storjshare/configs/の下にランダムに生成されたノード名でconfigファイルが作成されています。


ubuntu@storj:~/.config/storjshare/configs$ ls -la
合計 12
drwxr-xr-x 2 ubuntu ubuntu 4096  4月  3 14:04 .
drwxr-xr-x 5 ubuntu ubuntu 4096  4月  3 13:57 ..
-rw-r--r-- 1 ubuntu ubuntu 3122  4月  3 12:57 609e822937e8ae191289ac8255e1d7f6d0918448.json
ubuntu@storj:~/.config/storjshare/configs$ 

farming nodeのconfigを変更します。変更する箇所は以下の2箇所。コメントもたくさん書いてあるので分かりやすいと思います。

~/.config/storjshare/configs/609e822937e8ae191289ac8255e1d7f6d0918448.json

...

"rpcAddress": "xxx.xxx.xxx.xxx",

...

"doNotTraverseNat": true,

...

rpcAddressのxxx....は当該ノードの公開IPアドレスです。doNotTraverseNatは、NAT未使用(=グローバルアドレスを使用する)ためtrueに設定します。(自宅でNAT配下でディスクを公開する場合などはこのあたりの設定をいじります。今回は未検証。) また、rpcAddressはstorjshare createコマンドで引数でも指定できるっぽい。

ポートの公開
さくらのクラウドコントロールパネル側でパケットフィルタを設定している場合には、TCPのポート4000をallowするように設定変更しておきます。なお、daemonの公開ポート45015は公開する必要はありません(むしろ公開してはなりません)。これはfarming nodeからローカルでのみ接続するようです。

実行

configファイルが準備できたら、daemon、farming nodeの順に起動します。

ubuntu@storj:~$ storjshare daemon

  * starting daemon in background
ubuntu@storj:~$ storjshare start --config /home/ubuntu/.config/storjshare/configs/609e822937e8ae191289ac8255e1d7f6d0918448.json

  * starting node with config at /home/ubuntu/.config/storjshare/configs/609e822937e8ae191289ac8255e1d7f6d0918448.json
ubuntu@storj:~$ 

動作確認方法

コマンドでステータスが見られます。

ubuntu@storj:~$ storjshare status

┌─────────────────────────────────────────────┬─────────┬──────────┬──────────┬─────────┬───────────────┬─────────┬──────────┬───────────┬──────────────┐
│ Node                                        │ Status  │ Uptime   │ Restarts │ Peers   │ Allocs        │ Delta   │ Port     │ Shared    │ Bridges      │
├─────────────────────────────────────────────┼─────────┼──────────┼──────────┼─────────┼───────────────┼─────────┼──────────┼───────────┼──────────────┤
│ 609e822937e8ae191289ac8255e1d7f6d0918448    │ running │ 1m 20s   │ 0        │ 142     │ 0             │ 42ms    │ 4000     │ ...       │ connected    │
│   → /storj                                  │         │          │          │         │ 0 received    │         │ (TCP)(...%)    │              │
└─────────────────────────────────────────────┴─────────┴──────────┴──────────┴─────────┴───────────────┴─────────┴──────────┴───────────┴──────────────┘
ubuntu@storj:~$ 

Bridgesのステータスは初めての起動直後はまだconnectedになっていませんが、数分経つとconnectedに変わります。

この他、ログファイルが~/.config/storjshare/logs/に生成されています。

簡単なまとめ

Storjは昨今の仮想通貨がらみで投資目的で注目している人が多いと思いますが、この例のようにクラウドでリソースを用意・提供してStorjコインを得るのは全くコスト的に釣り合いません。クラウド利用料>>>Storjからの報酬、です(具体的に金額がわかってきたら追記予定)。この検証は純粋に分散システム、分散ストレージの評価の目的で実施したものです。

5
4
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
5
4