sudo yum install git
sudo yum remove golang sudo yum autoremove
網上使用 crul 或者 wget 下載go 我沒有下載下來 附上GO安裝連接java
我推薦使用本地下載, 而後上傳到指定目錄python
下載地址linux
# curl -O https://www.golangtc.com/download/go1.9.2.linux-amd64.tar.gz # wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
解壓:c++
tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
先建立一個go的標準目錄,不少地方會用到git
mkdir -p /opt/gopath/src/github.com/hyperledger/
編輯 profilegithub
vi /etc/profile
在/etc/profile文件末尾(全部用戶有效)添加:golang
export GOROOT=/usr/local/go export GOBIN=$GOROOT/bin export PATH=$PATH:$GOBIN export GOPATH=/opt/gopath
環境變量生效:docker
source /etc/profile
執行flask
[root@nbfin hyperledger]# go version go version go1.9.2 linux/amd64
參考:https://docs.docker.com/engine/installation/linux/docker-ce/centos/bootstrap
sudo yum remove docker \ docker-common \ container-selinux \ docker-selinux \ docker-engine
安裝yum-utils和wget
sudo yum install -y yum-utils sudo yum install -y wget
配置系統鏡像(若是沒有配置)
cd /etc/yum.repos.d sudo wget http://mirrors.163.com/.help/CentOS7-Base-163.repo sudo yum clean all sudo yum makecache sudo yum update -y
添加stable repository
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
安裝docker-ce
sudo yum makecache fast sudo yum install docker-ce
啓動docker
sudo systemctl start docker
殺死全部正在運行的容器 docker kill $(docker ps -a -q) 刪除全部已經中止的容器 docker rm $(docker ps -a -q) 強制刪除全部鏡像 docker rmi -f $(docker images -q) docker清除全部容器: docker rm -f $(docker ps -qa) ubuntu下非root帳戶須要sudo docker rm -f $(sudo docker ps -qa) 咱們跑不一樣的腳本.好比frbric的,sample的,還有sdk的,若是有正在運行的image,跑以前先清一下docker網絡環境 docker rm $(docker ps -qa) docker network prune 查看運行中某個image的日誌 docker logs -f orderer.example.com
1.3.4 配置快速docker鏡像
sudo curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f8c3f422.m.daocloud.io
重啓docker服務
sudo systemctl restart docker
重啓docker服務生效
sudo service docker restart
輸入docker version查看版本
[root@nbfin yum.repos.d]# docker version Client: Version: 18.06.0-ce API version: 1.38 Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:08:18 2018 OS/Arch: linux/amd64 Experimental: false Server: Engine: Version: 18.06.0-ce API version: 1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: 0ffa825 Built: Wed Jul 18 19:10:42 2018 OS/Arch: linux/amd64 Experimental: false
參考:https://docs.docker.com/compose/install/
yum install docker-ce
執行docker-compose version,獲得結果
[root@nbfin yum.repos.d]# docker-compose version docker-compose version 1.20.1, build 5d8c71b docker-py version: 3.1.4 CPython version: 3.6.4 OpenSSL version: OpenSSL 1.0.1t 3 May 2016 [root@nbfin yum.repos.d]#
1.5 安裝pip及其餘包
安裝gcc
sudo yum install -y gcc gcc-c++ kernel-devel sudo yum install -y python-devel libxslt-devel libffi-devel openssl-devel
下載get-pip.py
wget https://bootstrap.pypa.io/get-pip.py
安裝pip
sudo python get-pip.py
安裝其餘包
sudo pip install --upgrade pip sudo pip install behave nose docker-compose sudo pip install -I flask python-dateutil pytz pyyaml couchdb flask-cors request pyOpenSSL pysha3 grpcio sudo pip install urllib3 ndg-httpsclient pyasn1 ecdsa python-slugify grpcio-tools jinja2 b3j0f.a
cd /opt/gopath/src/github.com/hyperledger/ git clone https://gitee.com/ossea/fabric.git
2. checkout 1.1
cd fabric git checkout release-1.1
3. 查看版本
[root@nbfin fabric]# git branch -a master * release-1.1 remotes/origin/HEAD -> origin/master remotes/origin/feature/ca remotes/origin/feature/convergence remotes/origin/master remotes/origin/release-1.0 remotes/origin/release-1.1 remotes/origin/release-1.2 remotes/origin/v0.6 remotes/origin/v1.0.0-preview [root@nbfin fabric]#
4. 查看確認執行的腳本( 爲啥確認? 由於我這裏被坑屢次)
[root@nbfin scripts]# cat /opt/gopath/src/github.com/hyperledger/fabric/scripts/bootstrap.sh #!/bin/bash # # Copyright IBM Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0 # # if version not passed in, default to latest released version export VERSION=${1:-1.1.0} # if ca version not passed in, default to latest released version export CA_VERSION=${2:-$VERSION} # current version of thirdparty images (couchdb, kafka and zookeeper) released export THIRDPARTY_IMAGE_VERSION=0.4.6
注意這裏export VERSION=${1:-1.1.0} 和 export THIRDPARTY_IMAGE_VERSION=0.4.6 這兩個是fabric1.1須要鏡像對應的版本 若是是fabric1.2 這裏會對應的是1.2 和0.4.10 網上不少curl bootstrap.sh 1.1.0 這樣的 注意了 裏面的變量也許給寫死了...
5.執行bootstrap.sh 會下載所須要的鏡像文件還有指定的二進制文件 和配置文件(此處的bin 和config稍後處理)
[root@nbfin scripts]# ./bootstrap.sh ===> Downloading platform specific fabric binaries % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 35.4M 100 35.4M 0 0 4243k 0 0:00:08 0:00:08 --:--:-- 7524k ===> Downloading platform specific fabric-ca-client binary % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6109k 100 6109k 0 0 1570k 0 0:00:03 0:00:03 --:--:-- 1571k ===> Pulling fabric Images ==> FABRIC IMAGE: peer
6. 查看鏡像文件 這裏有個坑說一下 不少多網上博文下載的鏡像 若是有衝突 好比下載了某個1.2版本,能夠刪掉, 也須要標註tag 爲latest 我常常出現版本不對 網絡不通暢
[root@nbfin scripts]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hyperledger/fabric-ca latest 72617b4fa9b4 4 months ago 299MB hyperledger/fabric-ca x86_64-1.1.0 72617b4fa9b4 4 months ago 299MB hyperledger/fabric-tools latest b7bfddf508bc 4 months ago 1.46GB hyperledger/fabric-tools x86_64-1.1.0 b7bfddf508bc 4 months ago 1.46GB hyperledger/fabric-orderer latest ce0c810df36a 4 months ago 180MB hyperledger/fabric-orderer x86_64-1.1.0 ce0c810df36a 4 months ago 180MB hyperledger/fabric-peer latest b023f9be0771 4 months ago 187MB hyperledger/fabric-peer x86_64-1.1.0 b023f9be0771 4 months ago 187MB hyperledger/fabric-javaenv latest 82098abb1a17 4 months ago 1.52GB hyperledger/fabric-javaenv x86_64-1.1.0 82098abb1a17 4 months ago 1.52GB hyperledger/fabric-ccenv latest c8b4909d8d46 4 months ago 1.39GB hyperledger/fabric-ccenv x86_64-1.1.0 c8b4909d8d46 4 months ago 1.39GB hyperledger/fabric-zookeeper latest 92cbb952b6f8 5 months ago 1.39GB hyperledger/fabric-zookeeper x86_64-0.4.6 92cbb952b6f8 5 months ago 1.39GB hyperledger/fabric-kafka latest 554c591b86a8 5 months ago 1.4GB hyperledger/fabric-kafka x86_64-0.4.6 554c591b86a8 5 months ago 1.4GB hyperledger/fabric-couchdb latest 7e73c828fc5b 5 months ago 1.56GB hyperledger/fabric-couchdb x86_64-0.4.6 7e73c828fc5b 5 months ago 1.56GB
7. 正戲開始 啓動fabric
cd /opt/gopath/src/github.com/hyperledger/fabric/examples/e2e_cli ./network_setup.sh up #################執行成功 2018-08-03 06:10:51.515 UTC [main] main -> INFO 008 Exiting..... ===================== Query on PEER3 on channel 'mychannel' is successful ===================== ===================== All GOOD, End-2-End execution completed ===================== _____ _ _ ____ _____ ____ _____ | ____| | \ | | | _ \ | ____| |___ \ | ____| | _| | \| | | | | | _____ | _| __) | | _| | |___ | |\ | | |_| | |_____| | |___ / __/ | |___ |_____| |_| \_| |____/ |_____| |_____| |_____|
這個指令具體進行了以下操做:
8. ctrl+c 退出 關閉網絡 須要關閉是由於啓動的docker容器還在運行 運行其它網絡時會有衝突
./network_setup.sh down
fabric-sdk-java1.1 環境搭建
1. 項目獲取
cd /opt/gopath/src/github.com/hyperledger git clone https://gitee.com/ossea/fabric-sdk-java.git
2. 版本檢出
cd fabric-sdk-java git checkout release-1.1
3. 運行程序
cd /opt/gopath/src/github.com/fabric-sdk-java/src/test/fixture/sdkintegration ./fabric.sh up
這裏就其實就是執行了 docker-composed 的啓動 若是鏡像沒有在運行 應該不會報錯的
常常用的對應的命令 就是 fabric.sh clean fabric.sh clean fabric.sh down
1. 獲取項目
cd C:\Users\ossea\Desktop\bc_new> git clone https://github.com/hyperledger/fabric-sdk-java.git cd fabric-sdk-java git checkout release-1.1
2. 修改pom.xml 在properties中加入下面一句話:<os.detected.classifier>windows-x86_64</os.detected.classifier> 這是對應的系統的 所須要的下載的二進制文件
<properties> <grpc.version>1.13.2</grpc.version><!-- CURRENT_GRPC_VERSION --> <protobuf.version>3.6.0</protobuf.version> <bouncycastle.version>1.60</bouncycastle.version> <httpclient.version>4.5.6</httpclient.version> <skipITs>true</skipITs> <alpn-boot-version>8.1.7.v20160121</alpn-boot-version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <jacoco.version>0.7.9</jacoco.version> <log4j.version>1.2.17</log4j.version> <org.hyperledger.fabric.sdktest.ITSuite>IntegrationSuite.java</org.hyperledger.fabric.sdktest.ITSuite> <gpg.executable>gpg2</gpg.executable> <os.detected.classifier>windows-x86_64</os.detected.classifier> </properties>
3. 編譯項目
mvn install
看到最後成功
[INFO] Installing C:\Users\ossea\Desktop\bc_new\fabric-sdk-java\target\fabric-sd k-java-1.3.0-SNAPSHOT.jar to C:\Users\ossea\repository\org\hyperledger\fabric-sd k-java\fabric-sdk-java\1.3.0-SNAPSHOT\fabric-sdk-java-1.3.0-SNAPSHOT.jar [INFO] Installing C:\Users\ossea\Desktop\bc_new\fabric-sdk-java\pom.xml to C:\Us ers\ossea\repository\org\hyperledger\fabric-sdk-java\fabric-sdk-java\1.3.0-SNAPS HOT\fabric-sdk-java-1.3.0-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 27.923 s [INFO] Finished at: 2018-08-03T14:49:35+08:00 [INFO] ------------------------------------------------------------------------ C:\Users\ossea\Desktop\bc_new\fabric-sdk-java>
4. 刪掉.project 和 .classpath文件 從新生成
mvn eclipse:eclipse
5. 配置eclipse中的maven配置文件 和系統中對應的MAVEN_HOME保持一致
6. eclise導入maven項目
出現這個錯誤稍後處理
出現以下錯誤在藍色條上點擊鼠標右鍵 選擇 Quick Fix
選擇第二條 Finish
修改TestConfig.java
這裏須要注意一下 被坑的厲害
必定注意到第一個紅框是服務器地址
第二個紅框是對應的版本號!!
會讀取認證證書
執行End2endIT的junit的測試
若是不用 mvn ecclipse:eclipse 生成 而是直接導入進來的話 會須要 吧src/test/java目錄設置成 use as source folder 而且須要 工程添加junit的支持
最後運行成功顯示
... ..... ...... -----END CERTIFICATE----- Transaction action 1 has 4 chaincode input arguments Transaction action 1 has chaincode input argument 0 is: deploy Transaction action 1 has chaincode input argument 1 is: bar Transaction action 1 has chaincode input argument 2 is: ?E???)??github.com/example_cc??example_cc_go??1????init??a??500?... Transaction action 1 has chaincode input argument 3 is: ? ??????????????????????????????????????Org1MSP??????Org2MSP????... Transaction action 1 proposal response status: 200 Transaction action 1 proposal response payload: ??example_cc_go??1??escc"?vscc*Z? ??????????????????????????????... Transaction action 1 proposal chaincodeIDName: lscc, chaincodeIDVersion: 1.1.0, chaincodeIDPath: Transaction action 1 has 2 name space read write sets Namespace example_cc_go write set 0 key a has value '500' Namespace example_cc_go write set 1 key b has value '300' Namespace lscc read set 0 key example_cc_go version [0:0] Namespace lscc write set 0 key example_cc_go has value '??example_cc_go??1??escc"?vscc*Z? ??????????????????????????????...' current block number 0 has data hash: f8bb2ebd01ef813ed1c82b24a4ca0afa82c7082a7cfaa4533947746fd6e4e7b5 current block number 0 has previous hash id: current block number 0 has calculated block hash is dd4e47ac3327485408947e935c11d87d3155cdbb95ca415999bcb55c963e4f6a current block number 0 has 1 envelope count: Transaction number 1 has transaction id: Transaction number 1 has channel id: bar Transaction number 1 has epoch: 0 Transaction number 1 has transaction timestamp: 八月 3, 2018 16:39:10 下午 Transaction number 1 has type id: ENVELOPE Transaction number 1 has nonce : df35cca706b77debbbf4c6acd35888d0f23d48ff402e2c8a Transaction number 1 has submitter mspid: OrdererMSP, certificate: -----BEGIN CERTIFICATE----- MIICCzCCAbKgAwIBAgIQUcfZvWT8UgJJ30cDzW15bDAKBggqhkjOPQQDAjBpMQsw CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy YW5jaXNjbzEUMBIGA1UEChMLZXhhbXBsZS5jb20xFzAVBgNVBAMTDmNhLmV4YW1w bGUuY29tMB4XDTE4MDIyNTEyNDMyOVoXDTI4MDIyMzEyNDMyOVowWDELMAkGA1UE BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz Y28xHDAaBgNVBAMTE29yZGVyZXIuZXhhbXBsZS5jb20wWTATBgcqhkjOPQIBBggq hkjOPQMBBwNCAARQfP/qUmnEcXIlE5PlkR4RCMn2XykMsPFZN0k1XfpkSA4KP0nC ALUgiITKLsOQohYA7oDaFQD/ZhaRswgwEgmNo00wSzAOBgNVHQ8BAf8EBAMCB4Aw DAYDVR0TAQH/BAIwADArBgNVHSMEJDAigCAZtRU3kIVNroUKD5QVcPw8VpuHhyOT OtWpwxnSk/LUkjAKBggqhkjOPQQDAgNHADBEAiApAQ0e/qdVsd5qtXGHqYKRt30Y LPaGPmy8wbX8+/KDhwIgXtt1TL97Z0rfq7iKXzXLRNk8jNntsrmRFoLVstXr3dA= -----END CERTIFICATE----- That's all folks!