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!