LoginSignup
4
3

More than 5 years have passed since last update.

Conoha上でHyperledger Fabricをビルドするまで

Last updated at Posted at 2016-08-13

サーバはUbuntuで、メモリ1GBのプランでも行けます。
基本的にはこちらのページを参照。

hyperledger/fabricをEC2で動かす
(Qiita版)
ただし、

  • Install rocksdbの部分で、swapの設定はたぶん不要(省略)
  • チャレンジャーなので一つ前のもの(v4.5.1)ではなくmasterを入れてみた。
  • git clone https://github.com/facebook/rocksdb.git
  • make static_lib

そしてmakeして待つこと数分・・・

$ cd $GOPATH/src/github.com/hyperledger/fabric/
$ make peer
build/bin/peer
CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" GOBIN=/home/fabric/work/src/github.com/hyperledger/fabric/build/bin go install github.com/hyperledger/fabric/peer
# github.com/hyperledger/fabric/vendor/github.com/tecbot/gorocksdb
/tmp/go-build340917324/github.com/hyperledger/fabric/vendor/github.com/tecbot/gorocksdb/_obj/options.cgo2.o: In function `_cgo_4c7b26b16232_Cfunc_rocksdb_options_set_filter_deletes':
options.cgo2.c:(.text+0x892): undefined reference to `rocksdb_options_set_filter_deletes'
/tmp/go-build340917324/github.com/hyperledger/fabric/vendor/github.com/tecbot/gorocksdb/_obj/options.cgo2.o: In function `_cgo_4c7b26b16232_Cfunc_rocksdb_options_set_memtable_prefix_bloom_bits':
options.cgo2.c:(.text+0xda7): undefined reference to `rocksdb_options_set_memtable_prefix_bloom_bits'
/tmp/go-build340917324/github.com/hyperledger/fabric/vendor/github.com/tecbot/gorocksdb/_obj/options.cgo2.o: In function `_cgo_4c7b26b16232_Cfunc_rocksdb_options_set_memtable_prefix_bloom_probes':
options.cgo2.c:(.text+0xdd5): undefined reference to `rocksdb_options_set_memtable_prefix_bloom_probes'
collect2: error: ld returned 1 exit status
make: *** [build/bin/peer] Error 2

・・・ですよねー。 ということでググる。

Fabric on RHEL 6 #2098

This is the workaround I have used. Unzip into >/src/github.com/hyperledger/fabric/vendor/github.com/tecbot/gorocksdb

The commented out APIs don't seem to be used anywhere in hyperledger.

workaround.zip

このworkaround.zipとやらには、options_compression.go、options.go という2つのファイルが入っていたので、言われたとおりfabric/vendor/github.com/tecbot/gorocksdbの下に上書きコピー。

$ make peer
Building docker src-image
docker build -t hyperledger/fabric-src:latest build/image/src
Sending build context to Docker daemon 21.24 MB
Step 1 : FROM hyperledger/fabric-baseimage:latest
 ---> e4b8d691f061
Step 2 : ADD gopath.tar.bz2 $GOPATH/src/github.com/hyperledger/fabric
 ---> fe7d30e544f8
Removing intermediate container 853e02097439
Successfully built fe7d30e544f8
Building docker ccenv-image
docker build -t hyperledger/fabric-ccenv:latest build/image/ccenv
Sending build context to Docker daemon 16.97 MB
Step 1 : FROM hyperledger/fabric-src:latest
 ---> fe7d30e544f8
Step 2 : COPY bin/* /usr/local/bin/
 ---> 4c55ef05b303
Removing intermediate container 74379a6c6103
Successfully built 4c55ef05b303
build/bin/peer
CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" GOBIN=/home/fabric/work/src/github.com/hyperledger/fabric/build/bin go install github.com/hyperledger/fabric/peer
Binary available as build/bin/peer

$ cd build/bin
$ ./peer node start
08:14:46.917 [main] serve -> INFO 001 Security enabled status: false
08:14:46.917 [eventhub_producer] start -> INFO 002 event processor started
08:14:46.918 [main] serve -> INFO 003 Privacy enabled status: false
08:14:46.918 [chaincode] NewChaincodeSupport -> INFO 004 Chaincode support using peerAddress: 0.0.0.0:30303
08:14:46.918 [sysccapi] RegisterSysCC -> INFO 005 system chaincode (noop,github.com/hyperledger/fabric/bddtests/syschaincode/noop) disabled
08:14:46.949 [state] loadConfig -> INFO 006 Loading configurations...
08:14:46.949 [state] loadConfig -> INFO 007 Configurations loaded. stateImplName=[buckettree], stateImplConfigs=map[numBuckets:%!s(int=1000003) maxGroupingAtEachLevel:%!s(int=5) bucketCacheSize:%!s(int=100)], deltaHistorySize=[500]
08:14:46.949 [state] NewState -> INFO 008 Initializing state implementation [buckettree]
08:14:46.949 [buckettree] initConfig -> INFO 009 configs passed during initialization = map[string]interface {}{"maxGroupingAtEachLevel":5, "bucketCacheSize":100, "numBuckets":1000003}
08:14:46.949 [buckettree] initConfig -> INFO 00a Initializing bucket tree state implemetation with configurations &{maxGroupingAtEachLevel:5 lowestLevel:9 levelToNumBucketsMap:map[0:1 9:1000003 8:200001 3:65 1:3 4:321 2:13 7:40001 6:8001 5:1601] hashFunc:0xb5ee00}
08:14:46.949 [buckettree] newBucketCache -> INFO 00b Constructing bucket-cache with max bucket cache size = [100] MBs
08:14:46.949 [buckettree] loadAllBucketNodesFromDB -> INFO 00c Loaded buckets data in cache. Total buckets in DB = [0]. Total cache size:=0
08:14:46.949 [genesis] func1 -> INFO 00d Creating genesis block.
08:14:46.951 [consensus/controller] NewConsenter -> INFO 00e Creating default consensus plugin (noops)
08:14:46.952 [consensus/statetransfer] blockThread -> INFO 00f Validated blockchain to the genesis block
08:14:46.952 [consensus/noops] newNoops -> INFO 010 NOOPS consensus type = *noops.Noops
08:14:46.953 [consensus/noops] newNoops -> INFO 011 NOOPS block size = 500
08:14:46.953 [consensus/noops] newNoops -> INFO 012 NOOPS block wait = 1s
08:14:46.953 [main] serve -> INFO 013 Starting peer with ID=name:"jdoe" , network ID=dev, address=0.0.0.0:30303, rootnodes=, validator=true
08:14:46.954 [rest] StartOpenchainRESTServer -> INFO 014 Initializing the REST service on 0.0.0.0:5000, TLS is disabled.

たぶんうまくいったっぽい。

このままだと、世界中どこからでもAPIをたたけてしまう=誰でもchaincodeをデプロイできちゃうので、FW設定をしようと

$ sudo ufw enable

したら、、、そのままコンソールが帰ってこなくなった・・・・・。

あわててconohaコンソールから

# ufw allow 22

して復活。

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