git fabric 1.0.0公式ソースコードをコンパイルしdocker imagesを生成(rc 2バージョン2017年6月26日)
22998 ワード
git fabric 1.0.0公式ソースコードをコンパイルしdocker imagesを生成(rc 2バージョン2017年6月26日)
システム環境:centos 7 64ビットdocker docker-compose
centos yum倉庫帯のdockerは使用しないでください.バージョンが低すぎます.docker公式のrepoの中のバージョンをインストールします
一.fabricユーザーの追加とソースコードを格納するディレクトリの設定
二.goの開発環境と必要なコンポーネントのインストール
rootユーザーでインストール
fabricユーザーでgocovをインストール
gocov-xmlのインストール
三.その他必要な部品を取り付ける
rootユーザーでインストール
四.fabric環境変数の設定
五.プロジェクトディレクトリに入る
六.goソースディレクトリ構造の構築(src/github.com/hyperledgerを必ず構築しなければならない.そうしないとgoを使用してコンパイルできない)
七.fabricのソースコードを引き出す
八.コンパイル生成protoc-gen-go
九.fabric docker環境のコンパイル
Got permission denied while trying to connect to the Docker daemon socket atが表示された場合unix:///var/run/docker.sock この間違い.解決策:1.fabricユーザーをsudoグループa.rootユーザー登録b.vim/etc/sudoers c.fabric ALL=(ALL)ALL一行をroot ALL=(ALL)に追加するALLの下2.sudo usermod-a-G docker$USER 3.newgrp-docker 4.newgrp-
十.ファイルまたはコマンドが見つからないエラーが発生した場合、go関連ファイルをfabricコンパイル環境にコピーします.
十一.fabric ca環境のコンパイル
十二.e 2 eアプリケーションの導入とテスト
cd$GOPATH/src/github.com/hyperledger/fabric/examples/e 2 e_をワンクリックで起動cli ./network_setup.sh up mytestchannel
A.プロファイルの生成
B.実行後、コンソールの出力内容は以下の通りである.
C. Run the generateCfgTrx.sh shell script
D.コンソール出力
E.fabricネットワークの起動
まずmakeから出たイメージをlatestにtagします
次にdockerコンテナを起動します
十三.問題の解決
A.mac osで次のエラーが発生しました.
解決策、gnu-tarの更新
B.mac osで'ltdl.h'file not foundエラーが発生
C.goimports:command not foundエラーが発生
make linterで次のエラーが発生しました.
ただし$GOPATH/src/github.com/hyperledger/fabric/scripts/golinter.shは正常に実行できます
D.make中にIPv 4 forwarding is disabled.Networking will not work.という警告が表示されます.
E.e 2 e例を実行中に次のエラーが発生しました.
1.チャンネルを作成できません
F.関連知識点
1.gitは特定のバージョンを抽出する
システム環境:centos 7 64ビットdocker docker-compose
centos yum倉庫帯のdockerは使用しないでください.バージョンが低すぎます.docker公式のrepoの中のバージョンをインストールします
$ sudo tee /etc/yum.repos.d/docker.repo <'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
yum update
yum install docker-engine
systemctl enable docker
systemctl restart docker
一.fabricユーザーの追加とソースコードを格納するディレクトリの設定
useradd fabric
# .
mkdir /home/fabric/fabric
二.goの開発環境と必要なコンポーネントのインストール
rootユーザーでインストール
wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
tar -xzvf go1.8.1.linux-amd64.tar.gz
mv ./go /usr/local
// etc/profile,
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
source /etc/profile
# , go 1.8
go version
go version go1.8 darwin/amd64
# , :
# 1. root gopm
export GOPATH=/usr/local
go get -u github.com/gpmgo/gopm
# /usr/local/bin gopm
# 2. fabric , gopm goimports
export GOPATH=/home/fabric/fabric
gopm get -g -d golang.org/x/tools/cmd/goimports
# go install goimports
go install golang.org/x/tools/cmd/goimports
# /home/fabric/fabric/bin goimports
fabricユーザーでgocovをインストール
GOPATH=/home/fabric/fabric
gopm get -g -d golang.org/x/tools/cover
gopm get -g -d github.com/axw/gocov/gocov
go install github.com/axw/gocov/gocov
# /home/fabric/fabric/bin gocov
gocov-xmlのインストール
GOPATH=/home/fabric/fabric
gopm get -g -d github.com/AlekSi/gocov-xml
go install github.com/AlekSi/gocov-xml
# /home/fabric/fabric/bin gocov-xml
三.その他必要な部品を取り付ける
rootユーザーでインストール
#centos
yum install -y gcc libtool libltdl-dev libtool-ltdl-devel openssl
四.fabric環境変数の設定
vim ~/.bashrc
export GOPATH=/home/fabric/fabric
#
source ~/.bashrc
五.プロジェクトディレクトリに入る
cd $GOPATH
六.goソースディレクトリ構造の構築(src/github.com/hyperledgerを必ず構築しなければならない.そうしないとgoを使用してコンパイルできない)
cd $GOPATH
mkdir -p src/github.com/hyperledger
七.fabricのソースコードを引き出す
cd $GOPATH/src/github.com/hyperledger
git clone https://github.com/hyperledger/fabric.git
八.コンパイル生成protoc-gen-go
# protoc-gen-go
cd $GOPATH
gopm get -g -d github.com/golang/protobuf/protoc-gen-go
go install github.com/golang/protobuf/protoc-gen-go
# $GOPATH/bin protoc-gen-go
九.fabric docker環境のコンパイル
cd $GOPATH/src/github.com/hyperledger/fabric
make docker
Got permission denied while trying to connect to the Docker daemon socket atが表示された場合unix:///var/run/docker.sock この間違い.解決策:1.fabricユーザーをsudoグループa.rootユーザー登録b.vim/etc/sudoers c.fabric ALL=(ALL)ALL一行をroot ALL=(ALL)に追加するALLの下2.sudo usermod-a-G docker$USER 3.newgrp-docker 4.newgrp-
groups ${USER} | cut -d' ' -f1
参照:https://techoverflow.net/2017/03/01/solving-docker-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/十.ファイルまたはコマンドが見つからないエラーが発生した場合、go関連ファイルをfabricコンパイル環境にコピーします.
cp $GOPATH/bin/protoc-gen-go $GOPATH/src/github.com/hyperledger/fabric/build/docker/gotools/bin/
cp $GOPATH/bin/gocov $GOPATH/src/github.com/hyperledger/fabric/build/docker/gotools/bin/
十一.fabric ca環境のコンパイル
cd /root
git clone https://github.com/hyperledger/fabric-ca.git
cd fabric-ca
make docker
十二.e 2 eアプリケーションの導入とテスト
cd$GOPATH/src/github.com/hyperledger/fabric/examples/e 2 e_をワンクリックで起動cli ./network_setup.sh up mytestchannel
A.プロファイルの生成
cd $GOPATH/src/github.com/hyperledger/fabric
make configtxgen
B.実行後、コンソールの出力内容は以下の通りである.
build/bin/configtxgen
CGO_CFLAGS=" " GOBIN=/root/fabric/src/github.com/hyperledger/fabric/build/bin go install -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0-snapshot-eba4a20 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.0 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/common/configtx/tool/configtxgen
Binary available as build/bin/configtxgen
C. Run the generateCfgTrx.sh shell script
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli
./generateCfgTrx.sh mytestchannel
D.コンソール出力
[root@fabric e2e_cli]# ./generateCfgTrx.sh mytestchannel
Channel name - mytestchannel
Building configtxgen
build/bin/configtxgen
CGO_CFLAGS=" " GOBIN=/root/fabric/src/github.com/hyperledger/fabric/build/bin go install -tags "nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/metadata.Version=1.0.0-snapshot-eba4a20 -X github.com/hyperledger/fabric/common/metadata.BaseVersion=0.3.0 -X github.com/hyperledger/fabric/common/metadata.BaseDockerLabel=org.hyperledger.fabric -X github.com/hyperledger/fabric/common/metadata.DockerNamespace=hyperledger -X github.com/hyperledger/fabric/common/metadata.BaseDockerNamespace=hyperledger" github.com/hyperledger/fabric/common/configtx/tool/configtxgen
Binary available as build/bin/configtxgen
Generating genesis block
2017/04/19 16:14:03 Loading configuration
2017/04/19 16:14:03 Looking for configtx.yaml in: /root/fabric/src/github.com/hyperledger/fabric/common/configtx/tool
2017/04/19 16:14:03 Found configtx.yaml there
2017/04/19 16:14:03 Checking for MSPDir at: .
2017/04/19 16:14:03 Checking for MSPDir at: .
2017/04/19 16:14:03 Checking for MSPDir at: .
2017/04/19 16:14:03 Generating genesis block
2017/04/19 16:14:03 Writing genesis block
Generating channel configuration transaction
2017/04/19 16:14:03 Loading configuration
2017/04/19 16:14:03 Looking for configtx.yaml in: /root/fabric/src/github.com/hyperledger/fabric/common/configtx/tool
2017/04/19 16:14:03 Found configtx.yaml there
2017/04/19 16:14:03 Checking for MSPDir at: .
2017/04/19 16:14:03 Checking for MSPDir at: .
2017/04/19 16:14:03 Checking for MSPDir at: .
2017/04/19 16:14:03 Generating new channel configtx
2017/04/19 16:14:03 Creating no-op MSP instance
2017/04/19 16:14:03 Obtaining default signing identity
2017/04/19 16:14:03 Creating no-op signing identity instance
2017/04/19 16:14:03 Serialinzing identity
2017/04/19 16:14:03 signing message
2017/04/19 16:14:03 signing message
2017/04/19 16:14:03 Writing new channel tx
E.fabricネットワークの起動
まずmakeから出たイメージをlatestにtagします
docker tag hyperledger/fabric-orderer:x86_64-1.0.0-snapshot-<xxxxxxx> hyperledger/fabric-orderer
docker tag hyperledger/fabric-peer:x86_64-1.0.0-snapshot-<xxxxxxx> hyperledger/fabric-peer
次にdockerコンテナを起動します
cd $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli
CHANNEL_NAME=mytestchannel docker-compose up -d
十三.問題の解決
A.mac osで次のエラーが発生しました.
Error processing tar file(bzip2 data invalid: bad magic value in continuation file):
解決策、gnu-tarの更新
brew install gnu-tar --with-default-names
B.mac osで'ltdl.h'file not foundエラーが発生
brew install libtool openssl
C.goimports:command not foundエラーが発生
make linterで次のエラーが発生しました.
LINT: Running code checks..
Checking ./bccsp
./scripts/golinter.sh: line 22: goimports: command not found
make: *** [linter] 127
ただし$GOPATH/src/github.com/hyperledger/fabric/scripts/golinter.shは正常に実行できます
make gotools
# ,
git config --global http.proxy "192.168.0.50:8016"
git config --global https.proxy "192.168.0.50:8016"
# git , gotools git ,
git clone https://go.googlesource.com/tools
# tools ,
# $GOPATH/src/github.com/hyperledger/fabric/gotools/build/gopath/src/golang.org/x/ 。
# make gotools
cd $GOPATH/src/github.com/hyperledger/fabric
make gotools
D.make中にIPv 4 forwarding is disabled.Networking will not work.という警告が表示されます.
sysctl -w net.ipv4.ip_forward=1
# docker
systemctl restart docker
E.e 2 e例を実行中に次のエラーが発生しました.
1.チャンネルを作成できません
vim $GOPATH/src/github.com/hyperledger/fabric/examples/e2e_cli/docker-compose.yaml
# docker-compose.yaml 。 cli host
extra_hosts:
- "orderer0:10.211.55.8"
- "peer0:10.211.55.8"
- "peer1:10.211.55.8"
- "peer2:10.211.55.8"
- "peer3:10.211.55.8"
# script.sh , peer , :
if [ $1 -eq 0 ]; then
CORE_PEER_ADDRESS=peer$1:7051
elif [ $1 -eq 1 ]; then
ORE_PEER_ADDRESS=peer$1:8051
elif [ $1 -eq 2 ]; then
ORE_PEER_ADDRESS=peer$1:9051
elif [ $1 -eq 3 ]; then
ORE_PEER_ADDRESS=peer$1:10051
fi
F.関連知識点
1.gitは特定のバージョンを抽出する
git reset --hard <commitlevel >