LoginSignup
2
0

More than 1 year has passed since last update.

【Hyperledger Fabric v2.4.1】動作環境の構築①

Last updated at Posted at 2022-01-29

目的

仮想ソフトウェア(VirtualBox)を使用して、Linux ゲスト OS(Ubuntu)を導入し、その上に Hyperledger Fabric v2.4.1(執筆時の最新) の動作環境を構築します。
本ページでは、Hyperledger Fabric v2.4.1 のインストールに必要な準備までを記載しています。

必要なツールおよびソフトウェア

作業ステップ

本ページでは、太字のステップのみ記載しています。

  • ステップ①:Ubuntu Linux ゲストOSのインストールと初期設定
  • ステップ②:必要なツールおよびソフトウェアのインストール
  • ステップ③:Hyperledger Fabric のインストール

ステップ①:Ubuntu Linux ゲストOSのインストールと初期設定

以下の手順に従って、Ubuntu Linux ゲストOSのインストール(VirtualBox と Vagrant のインストールを含みます)と初期設定をします。

ここでは、ゲスト OS のメモリをデフォルトの1024MBから4096MBへします。

  • コメントの解除(#の削除)
  • vb.memory の設定値を変更
$ cp -p Vagrantfile Vagrantfile.bak
$ vi Vagrantfile
$ diff Vagrantfile.bak Vagrantfile
52c52
<   # config.vm.provider "virtualbox" do |vb|
---
>    config.vm.provider "virtualbox" do |vb|
57,58c57,58
<   #   vb.memory = "1024"
<   # end
---
>      vb.memory = "4096"
>    end

ステップ②:必要なツールおよびソフトウェアのインストール

Docker と Docker Compose のインストール

Dockerのインストール

~$ sudo snap install docker
docker 20.10.8 from Canonical✓ installed
~$ docker --version
Docker version 20.10.8, build 3967b7d28e

Dockerの起動確認

~$ snap services
Service         Startup  Current   Notes
docker.dockerd  enabled  active    -
lxd.activate    enabled  inactive  -
lxd.daemon      enabled  inactive  socket-activated

docker グループへの追加(任意)

~$ sudo addgroup --system docker
Adding group `docker' (GID 119) ...
Done.
~$ sudo adduser $USER docker
Adding user `vagrant' to group `docker' ...
Adding user vagrant to group docker
Done.
~$ newgrp docker
vagrant@ubuntu-focal:~$ sudo snap disable docker
docker disabled
vagrant@ubuntu-focal:~$ sudo snap enable docker
docker enabled
vagrant@ubuntu-focal:~$ exit
exit
~$ exit
logout
Connection to 127.0.0.1 closed.

$ vagrant ssh
 (中略)
~$ docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

バージョン確認

~$ docker --version
Docker version 20.10.8, build 3967b7d28e
~$
~$ docker-compose --version
docker-compose version 1.25.5, build unknown

Go 言語のインストール

スマートコントラクト(チェーンコード)の開発向けに、Go 言語をインストールします。

~$ wget https://go.dev/dl/go1.17.6.linux-amd64.tar.gz
--2022-01-29 16:46:22--  https://go.dev/dl/go1.17.6.linux-amd64.tar.gz
Resolving go.dev (go.dev)... 216.239.34.21, 216.239.32.21, 216.239.38.21, ...
 (中略)
go1.17.6.linux-amd64.tar 100%[==================================>] 128.58M  21.0MB/s    in 6.5s

2022-01-29 16:46:29 (19.9 MB/s) - ‘go1.17.6.linux-amd64.tar.gz’ saved [134830580/134830580]

~$ sudo tar -C /usr/local -xzf go1.17.6.linux-amd64.tar.gz
~$ echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.profile
~$ . ~/.profile
~$ go version
go version go1.17.6 linux/amd64

Node.js と npm のインストール

Hyperledger Fabric SDK for Node.js を使用するために、Node.js をインストールします。
インストールはnコマンドで行っています。

Node.js , npm と n のインストール

~/$ sudo apt install nodejs npm
Reading package lists... Done
 (中略)
Setting up node-libnpx (10.2.1-2) ...
Setting up npm (6.14.4+ds-1ubuntu2) ...
Setting up libwww-perl (6.43-1) ...
Setting up liblwp-protocol-https-perl (6.07-2ubuntu2) ...
Setting up libxml-parser-perl (2.46-1) ...
Setting up libxml-twig-perl (1:3.50-2) ...
Setting up libnet-dbus-perl (1.2.0-1) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...

~$ sudo npm install n -g
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@8.0.2
added 1 package from 2 contributors in 1.101s

Nodeのバージョンアップ

~$ sudo n lts
  installing : node-v16.13.2
       mkdir : /usr/local/n/versions/node/16.13.2
       fetch : https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.xz
   installed : v16.13.2 (with npm 8.1.2)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
If "node --version" shows the old version then start a new shell, or reset the location hash with:
hash -r  (for bash, zsh, ash, dash, and ksh)
rehash   (for csh and tcsh)

~/work$ hash -r

バージョン確認

~$ node --version
v16.13.2
~$ npm -v
8.1.2

古いバージョンを削除

~$ sudo apt purge nodejs npm
Reading package lists... Done
Building dependency tree
 (中略)
Removing nodejs (10.19.0~dfsg-3ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
(Reading database ... 71721 files and directories currently installed.)
Purging configuration files for npm (6.14.4+ds-1ubuntu2) ...
Purging configuration files for node-duplexer3 (0.1.4-5) ...

make、gcc/g++、libtool のインストール

ネイティブコードを含んだモジュールをビルドするために必要なソフトウェアをインストールします。

~$ sudo apt -y install make gcc g++ libtool
Reading package lists... Done
Building dependency tree
 (中略)
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for install-info (6.7.0.dfsg.2-5) ...

ステップ③:Hyperledger Fabric のインストールと動作確認

以下に続きます。

参考文献

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