20
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

hyperledger/fabricをEC2で動かす

Last updated at Posted at 2016-06-07

ブログにも書いたが
hyperledger/fabricをEC2で動かそうとして結構はまったのでセットアップをまとめた。

Docment

Docs
prerequisites

Environment

  • AWS EC2 t2.micro
  • Ubuntu Server 14.04 LTS (HVM)
  • Storage 50GB
    環境に19GBほど使うのでデフォルトだと動かない

Foundation

基本的なもの。

sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install git 
sudo apt-get -y install gcc
sudo apt-get -y install g++
sudo apt-get -y install make
sudo apt-get -y install unzip

Add required library

Fabricで使うライブラリ

sudo apt-get -y install zlib1g-dev
sudo apt-get -y install libsnappy-dev
sudo apt-get -y install libbz2-dev

Install go

goの環境を作る。今回は1.6.2を使用した

cd /tmp
wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.6.2.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >>  $HOME/.bash_profile

mkdir $HOME/go
mkdir $HOME/work

echo 'export GOROOT=$HOME/go' >> $HOME/.profile
echo 'export PATH=$PATH:$GOROOT/bin' >>  ~/.profile
echo 'export GOPATH=$HOME/work' >> $HOME/.bash_profile
. $HOME/.bash_profile

Install rocksdb

"virtual memory exhausted: Cannot allocate memory"を回避するための設定

sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c 'echo "/swapfile       none    swap    sw      0       0 " >> /etc/fstab'
echo 10 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
sudo chown root:root /swapfile 
sudo chmod 0600 /swapfile 

rocksdbをインストール

masterを使うと互換性がなくエラーを吐く内容
ので一つ前のもの(v4.5.1)を入れる

cd /tmp
wget https://github.com/facebook/rocksdb/archive/v4.5.1.tar.gz
tar xzvf v4.5.1.tar.gz
cd rocksdb-4.5.1
make
sudo make install

Install docker

dockerをインストールする


sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo sh -c "echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' >> /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install -y linux-image-extra-$(uname -r)
sudo apt-get purge lxc-docker
sudo apt-cache policy docker-engine
sudo apt-get -y install apparmor
sudo apt-get -y install docker-engine

dockerの権限を変更

一度ログアウトしてもう一度ログインする。

sudo gpasswd -a $USER docker
exit

Prevent [java] <defunct>

デフォルトだとストレージドライバーがaufsで上のエラーが出てしまうので(Issues) ストレージドライバーをdevicemapperに変更する

sudo service docker stop
sudo docker daemon --storage-driver=devicemapper &
sudo docker run hello-world

Fabric

cd $GOPATH/src
mkdir -p github.com/hyperledger
cd github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
cd work/src/github.com/hyperledger/fabric
sudo chown -R $USER:$USER /var/hyperledger

Sample

make peer
cd build/bin
./peer node start
20
22
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
20
22

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?