IPFSはP2Pネットワークで動作するHTTP代替プロトコル。すごそう。

前回まで

情報源

IPFSはコンテンツ指向

同じコンテンツは同じURIで表現される。コンテンツは複数のマシン(ピア)がもっており、そのうち最寄りのピアから取得する。URIは同じでも取得先は複数ある。HTTPと比べて次の長所がある。

項目 説明
耐障害性 コンテンツは複数ピアにあるためサーバダウンしたら閲覧不能になることはなく他のピアから取得できる
負荷分散 コンテンツは複数ピアにあるため一箇所に負荷が集中せずダウンしづらい
耐検閲性 コンテンツは複数ピアにあるため特定サーバをアクセス遮断するだけでは防ぎきれない
耐改竄性 コンテンツはハッシュキーでアクセスしているため改竄不能

現代のネットはプロパガンダやフェイクであふれている。国やGAFAにより民主主義や正しい情報が歪められ、一部の権力者にすべてを支配されている。これを打開するため情報の民主化が必要。その仕組みとしてIPFSが使える。すべての人に開かれた健全かつ堅牢なネットワーク・プロトコル。

IPFSのインストール

kubo(旧go-ipfs)から最新バージョンを確認し、自分のCPUアーキテクチャやOSに合ったバイナリを選ぶ。

今回はラズパイ4 RaspberryPiOS 32bitOSなので ARM版を選んだ。

VER=v0.14.0
NAME=kubo_$VER_linux-arm.tar.gz
wget https://dist.ipfs.io/kubo/$VER/$NAME
tar xvzf $NAME
cd go-ipfs/
sudo ./install.sh

バージョン確認

$ ipfs version
ipfs version 0.14.0

ヘルプ確認

$ ipfs-update help
NAME:
   ipfs-update - Update ipfs.

USAGE:
   ipfs-update [global options] command [command options] [arguments...]

VERSION:
   1.8.0-dev

COMMANDS:
   versions  Print out all available versions.
   version   Print out currently installed version.
   install   Install a version of ipfs.
   stash     stashes copy of currently installed ipfs binary
   revert    Revert to previously installed version of ipfs.
   fetch     Fetch a given version of ipfs, or "latest" for the latest stable version or "beta" for the latest stable or RC version. Default: latest.
   help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --verbose         Print verbose output. (default: false)
   --distpath value  specify the distributions build to use
   --help, -h        show help (default: false)
   --version, -v     print the version (default: false)

アップデータ

こいつを入れたら簡単にipfsをバージョンアップできる。

じつは私の環境にはすでに0.13.0が入っていた。これを0.14.0にアップデートしたい。そこでipfs-updateを使う。

インストール

wget https://dist.ipfs.io/ipfs-update/v1.8.0/ipfs-update_v1.8.0_linux-arm.tar.gz
tar xvzf ipfs-update_v1.8.0_linux-arm.tar.gz
cd ipfs-update
sudo ./install.sh

以下メッセージが出たら完了。

installed /usr/local/bin/ipfs-update

バージョン確認

$ ipfs-update version
v0.13.0

最新バージョンの確認

$ ipfs-update versions
Error fetching: ipfs api shell not up
Fetching with HTTP: "https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/versions"
v0.14.0
v0.14.0-rc1
v0.13.1
v0.13.0
...

よくわからんエラーが出てるが、執筆時点でv0.14.0が最新らしい。

アップデート

バージョンを指定する必要がある。

sudo ipfs-update install v0.14.0

しばらくすると以下のような感じでsuccess!だのInstallation complete!となればOK。

fetching go-ipfs version v0.14.0
Error fetching: stat /root/.ipfs: no such file or directory
Fetching with HTTP: "https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/v0.14.0/go-ipfs_v0.14.0_linux-arm.tar.gz"
binary downloaded, verifying...
success! tests all passed.
stashing old binary
installing new binary to /usr/local/bin/ipfs
checking if repo migration is needed...

Installation complete!
ちなみに`sudo`がないとパーミッションエラーになる。
$ ipfs-update install v0.14.0
fetching go-ipfs version v0.14.0
Error fetching: ipfs api shell not up
Fetching with HTTP: "https://ipfs.io/ipns/dist.ipfs.io/go-ipfs/v0.14.0/go-ipfs_v0.14.0_linux-arm.tar.gz"
binary downloaded, verifying...
success! tests all passed.
stashing old binary
install failed, reverting changes...
ERROR: install failed: could not move old binary: remove /usr/local/bin/ipfs: permission denied 

バージョン確認

指定したバージョンになっている。OK!

$ ipfs version
ipfs version 0.14.0
$ ipfs-update version
v0.14.0