04-Docker-Centos 7.2 之 虚拟机peer orderer 部署并测试e2e_cli

刚开始着手,这一篇幅比较凌乱...感兴趣的可以阅读我的 下一篇博文 梳理的更加,部署更快捷。

1、https://jingyan.baidu.com/article/3065b3b6a00892becef8a467.html按照这个指导准备就绪。然后我安装的系统是最小化的,所以在后续的使用中例如ifconfig、wget的工具需要再次的适配安装,以及还有yum的升级都是需要注意的,另外如果涉及到要升级其他的程序如Python,要做好依赖的修改工作


2、开始调试的时候ifconfig 命令不存在按照这个指导解决
https://blog.csdn.net/Dandelion_drq/article/details/53503487
为啥呢,因为我把虚拟机全部后台运行,然后打开神器CRT来连接他们这个时候要用到查看IP,一是省去了很多鼠标切换麻烦,而且习惯了他的简洁流畅和文件上下载的工具。
https://www.baidu.com/link?url=v67Oog7fdymtyRnUSV_nrxoHSV6cVxa6wReRGPVxqbIMdlxgWei7t2gsralwS57Kz6VbifesbwlkNHqGVTkJc_&wd=&eqid=d4d10483000112be000000035abda82d
最后成功远程。

3、紧接着想升级yum 于是乎就动手了
http://www.osyunwei.com/archives/444.html
but 感觉升不升级没啥鸟区别,不过想感受这个过程就去装个×


4、开始跟随这个博文http://www.cnblogs.com/aberic/p/7527831.html撸起袖子撸代码


4.1 首先搞定Docker 的安装
   
$ sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate  docker-selinux docker-engine-selinux docker-engine
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
输入进去马上就出现了下面这一行:
Loaded plugins: fastestmirror Determining fastest mirrors
而不是成功的信息,或者没有消息就是最好的消息
所以我度娘了以下,渡出一下网址

https://blog.csdn.net/pk0071/article/details/14170065


主要内容如下:
linux下yum命令出现Loaded plugins: fastestmirror Determining fastest mirrors(已加载插件:fastestmirror)
fastestmirror是yum的一个加速插件,这里是插件提示信息是插件不能用了。
不能用就先别用呗,禁用掉,先yum了再说。
1.修改插件的配置文件
# vi  /etc/yum/pluginconf.d/fastestmirror.conf  
enabled = 1//由1改为0,禁用该插件
...............................
2.修改yum的配置文件
# vi /etc/yum.conf
.........................
plugins=1//改为0,不使用插件
........................

所以按照以上的信息进行更改是药方
然后我又copy了一遍命令由于我的失误(多按了另个数字)造成了异常,异常信息如下:
[root@localhost docker]# yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
Repository '5': Error parsing config: Error parsing "baseurl = '5'": URL must be http, ftp, file or https not ""
于是我就蒙逼了吗,所以我就开始尝试解决这个问题
首先:
[root@localhost docker]# whereis centos-media
centos-media:[root@localhost docker]# 
不好使,没有啥指导性意义
其次开始度娘,渡劫了半天找到了下面的网址
https://blog.csdn.net/sheepseven/article/details/40826823
虽然懂了,但是不知道文中所指的这个文件在哪里于是乎又开启度娘
http://blog.163.com/linxin.zh_5/blog/static/59332602201463054447927/
受到这个网址的启发,找到了以下目录中的文件
[root@localhost yum.repos.d]# ll
总用量 32
-rw-r--r--. 1 root root   45 3月  30 11:47 5.repo
-rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 8月  30 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo


其中作祟的当属
-rw-r--r--. 1 root root   45 3月  30 11:47 5.repo

所以果断的将其残忍的删除

然后再再一次的执行
[root@localhost yum.repos.d]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
[root@localhost yum.repos.d]#
没有回馈消息,就证明是好消息呵呵,接着敲击下面的代码
$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test
$ sudo yum-config-manager --disable docker-ce-edge
--通过缓存机制快速下载docker--
$ sudo yum makecache fast


$ sudo yum install docker-ce
docker-ce-test/x86_64/primary_ FAILED                                          ============-]  0.0 B/s |  29 MB  --:--:-- ETA 
https://download.docker.com/linux/centos/7/x86_64/test/repodata/0d74012c350ef8ca0e2b1cec728b02c43f3f7875d30b3100ddf61e4139a0e48a-primary.sqlite.bz2: [Errno 12] Timeout on https://download.docker.com/linux/centos/7/x86_64/test/repodata/0d74012c350ef8ca0e2b1cec728b02c43f3f7875d30b3100ddf61e4139a0e48a-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
正在尝试其它镜像。


到此步骤的时候由于网速较差,等了一会真的是龟速下载,所以果断的切换思路到另外一条路上链接如下:
http://www.cnblogs.com/aberic/p/7531276.html
所以如果在网络情况还不是很理想的情况下,选择离线安装也不失为一个上策。
下载地址https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
下载好对应的版本后上传到linux的某个文件夹下,然后进行安装,安装之后启动
[root@localhost docker]# docker --version
Docker version 18.03.0-ce, build 0520e24
[root@localhost docker]# systemctl start docker
[root@localhost docker]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.


---------------------------------------------------------------------------------------------------------------------------------------------
--以下是docker的其他安装方式和说明
$ yum list docker-ce --showduplicates | sort -r docker-ce.x86_64 18.03.ce-1.el7.centos docker-ce-stable
$ sudo yum install
$ sudo systemctl start docker
$ sudo docker run hello-world
$ sudo yum install /path/to/package.rpm
$ sudo systemctl start docker
$ sudo docker run hello-world
$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh
$ sudo yum remove docker-ce
$ sudo rm -rf /var/lib/docker
---------------------------------------------------------------------------------------------------------------------------------------------




紧接着下载docker-compose(docker的组件)
安装方式和对应链接(还是那句话网络不给力就考虑离线下载吧):
https://github.com/docker/compose/releases




紧接着下载go并安装 


接着处理镜像加速,如果不是镜像加速那么将近10个G的东东下载很痛苦,除非网速能带你飞或者VPN加速
1.      首先需要有阿里云账号,没有就注册阿里云开发账号(以下镜像加速地址为我私人哟):
https://dev.aliyun.com/
2.      进入加速器页面:
https://cr.console.aliyun.com/#/accelerator
------
sudo mkdir -p /etc/docker(如果已有切莫重建)
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://h8yussnh.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
------
在紧接着
mkdir -p /opt/gopath/src/github.com/hyperledger/
紧接着检测是有安装git,没有的话就安装
紧接着
cd /opt/gopath/src/github.com/hyperledger/
[root@localhost hyperledger]# git clone https://github.com/hyperledger/fabric.git
[root@localhost hyperledger]# cd fabric/
[root@localhost fabric]# git checkout -b v1.0.0


再然后下载相关的镜像文件,当然也可以选择更高版本的自己来匹配(当然还是要在镜像加速成功的前提或者网速极佳的情况下,如非这样还是建议离线)
命令如下:docker pull hyperledger/fabric-tools:x86_64-1.0.0&&docker pull hyperledger/fabric-couchdb:x86_64-1.0.0&&docker pull hyperledger/fabric-kafka:x86_64-1.0.0&&docker pull hyperledger/fabric-orderer:x86_64-1.0.0&&docker pull hyperledger/fabric-peer:x86_64-1.0.0&&docker pull hyperledger/fabric-ca:x86_64-1.0.0&&docker pull hyperledger/fabric-ccenv:x86_64-1.0.0&&docker pull hyperledger/fabric-baseimage:x86_64-0.4.7&&docker pull hyperledger/fabric-baseos:x86_64-0.4.7&&docker pull hyperledger/fabric-zookeeper:x86_64-1.0.6&&docker pull hyperledger/fabric-javaenv:x86_64-1.0.6&&docker pull hyperledger/fabric-membersrvc:latest


完成上步之后:查看所拉取的相关镜像,然后将其tag打成latest
[root@localhost fabric]# docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
hyperledger/fabric-baseimage    x86_64-0.4.7        390ac2e95bc7        4 days ago          1.41GB
hyperledger/fabric-baseos       x86_64-0.4.7        c0e784934c4e        4 days ago          152MB
hyperledger/fabric-zookeeper    x86_64-1.0.6        205a873eee5d        5 weeks ago         1.32GB
hyperledger/fabric-javaenv      x86_64-1.0.6        b39e5e521f2a        5 weeks ago         1.41GB
hyperledger/fabric-tools        x86_64-1.0.0        0403fd1c72c7        8 months ago        1.32GB
hyperledger/fabric-couchdb      x86_64-1.0.0        2fbdbf3ab945        8 months ago        1.48GB
hyperledger/fabric-kafka        x86_64-1.0.0        dbd3f94de4b5        8 months ago        1.3GB
hyperledger/fabric-orderer      x86_64-1.0.0        e317ca5638ba        8 months ago        179MB
hyperledger/fabric-peer         x86_64-1.0.0        6830dcd7b9b5        8 months ago        182MB
hyperledger/fabric-ccenv        x86_64-1.0.0        7182c260a5ca        8 months ago        1.29GB
hyperledger/fabric-ca           x86_64-1.0.0        a15c59ecda5b        8 months ago        238MB
hyperledger/fabric-membersrvc   latest              b3654d32e4f9        17 months ago       1.42GB


将这些镜像打成tag为latest的版本(以此版本为准稳定版了)
docker tag 390ac2e95bc7 docker.io/hyperledger/fabric-baseimage:latest&&docker tag c0e784934c4e docker.io/hyperledger/fabric-baseos:latest&&docker tag 205a873eee5d docker.io/hyperledger/fabric-zookeeper:latest&&docker tag b39e5e521f2a docker.io/hyperledger/fabric-javaenv:latest&&docker tag 0403fd1c72c7 docker.io/hyperledger/fabric-tools:latest&&docker tag 2fbdbf3ab945 docker.io/hyperledger/fabric-couchdb:latest&&docker tag dbd3f94de4b5 docker.io/hyperledger/fabric-kafka:latest&&docker tag e317ca5638ba docker.io/hyperledger/fabric-orderer:latest&&docker tag 6830dcd7b9b5 docker.io/hyperledger/fabric-peer:latest&&docker tag 7182c260a5ca docker.io/hyperledger/fabric-ccenv:latest&&docker tag a15c59ecda5b docker.io/hyperledger/fabric-ca:latest&&docker tag b3654d32e4f9 docker.io/hyperledger/fabric-membersrvc:latest




在紧接着就是运行测试了
[root@localhost hyperledger]# pwd
/opt/gopath/src/github.com/hyperledger
[root@localhost hyperledger]# git clone -b master https://github.com/hyperledger/fabric-samples.git&&
[root@localhost hyperledger]# cd fabric-samples/
[root@localhost fabric-samples]# git checkout -b v1.0
切换到一个新分支 'v1.0'




接下来下载测试运行所需的二进制文件并将其解压到fabric-samples目录下完成之后效果如下:
[root@localhost fabric-samples]# ll
总用量 44
drwxr-xr-x. 5 root root  4096 3月  31 17:12 balance-transfer
drwxr-xr-x. 4 root root  4096 3月  31 17:12 basic-network
drwxr-xr-x. 7 root root    83 3月  31 17:12 chaincode
drwxr-xr-x. 3 root root  4096 3月  31 17:12 chaincode-docker-devmode
drwxr-xr-x. 2 root root  4096 3月  31 17:12 fabcar
drwxr-xr-x. 3 root root  4096 3月  31 17:12 fabric-ca
drwxr-xr-x. 6 root root  4096 3月  31 17:12 first-network
drwxr-xr-x. 4 root root    52 3月  31 17:12 high-throughput
-rw-r--r--. 1 root root 11358 3月  31 17:12 LICENSE
-rw-r--r--. 1 root root   470 3月  31 17:12 MAINTAINERS.md
-rw-r--r--. 1 root root   522 3月  31 17:12 README.md
drwxr-xr-x. 2 root root    46 3月  31 17:12 scripts
[root@localhost fabric-samples]# ll
总用量 81488
drwxr-xr-x. 5 root root     4096 3月  31 17:12 balance-transfer
drwxr-xr-x. 4 root root     4096 3月  31 17:12 basic-network
drwxr-xr-x. 7 root root       83 3月  31 17:12 chaincode
drwxr-xr-x. 3 root root     4096 3月  31 17:12 chaincode-docker-devmode
-rw-r--r--. 1 root root 15247600 9月  22 2017 configtxgen
-rw-r--r--. 1 root root 16680746 9月  22 2017 configtxlator
-rw-r--r--. 1 root root  7657096 9月  22 2017 cryptogen
drwxr-xr-x. 2 root root     4096 3月  31 17:12 fabcar
drwxr-xr-x. 3 root root     4096 3月  31 17:12 fabric-ca
drwxr-xr-x. 6 root root     4096 3月  31 17:12 first-network
-rw-r--r--. 1 root root      441 9月  22 2017 get-byfn.sh
-rw-r--r--. 1 root root      757 9月  22 2017 get-docker-images.sh
drwxr-xr-x. 4 root root       52 3月  31 17:12 high-throughput
-rw-r--r--. 1 root root    11358 3月  31 17:12 LICENSE
-rw-r--r--. 1 root root      470 3月  31 17:12 MAINTAINERS.md
-rw-r--r--. 1 root root 20429186 9月  22 2017 orderer
-rw-r--r--. 1 root root 23364112 9月  22 2017 peer
-rw-r--r--. 1 root root      522 3月  31 17:12 README.md
drwxr-xr-x. 2 root root       46 3月  31 17:12 scripts


再接下来进行(准备)运行测试:
[root@localhost e2e_cli]# bash network_setup.sh up
setting to default channel 'mychannel'
mychannel


Building cryptogen
make: 进入目录“/opt/gopath/src/github.com/hyperledger/fabric”
Building release/linux-amd64/bin/configtxgen for linux-amd64
mkdir -p release/linux-amd64/bin
CGO_CFLAGS=" " GOOS=linux GOARCH=amd64 go build -o /opt/gopath/src/github.com/hyperledger/fabric/release/linux-amd64/bin/configtxgen -tags "experimental nopkcs11" -ldflags "-X github.com/hyperledger/fabric/common/tools/configtxgen/metadata.Version=1.1.1-snapshot-e060a26" github.com/hyperledger/fabric/common/tools/configtxgen
# github.com/hyperledger/fabric/common/tools/configtxgen
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exec: "gcc": executable file not found in $PATH
如果报了以上错误那就要进行相对工具的安装(毕竟前提是最小配置的操作系统,因此很多工具要后来再装。gcc等工具是用来进行编译的工具因此必不可少)命令如下:
yum install gcc&&yum install gcc-c++&&yum install gdb
想查看他们是否安装成功的命令如下例如:
which gcc
再一次运行测试:
[root@localhost e2e_cli]# bash network_setup.sh up
.....
2018-03-31 09:59:47.363 UTC [grpc] Printf -> DEBU 003 grpc: addrConn.resetTransport failed to create client
会报这样的错误
如果这样的话,首先关闭防火墙
systemctl status firewalld.service  查看状态
systemctl stop firewalld.service    停止
systemctl disable firewalld.service 禁用


然后再运行测试
[root@localhost e2e_cli]# bash network_setup.sh up
Starting orderer.example.com ... error
ERROR: for orderer.example.com  Cannot start service orderer.example.com: b'driver failed programming external connectivity on endpoint orderer.example.com (b673296d8469e53d74d2dca8a65e288d70a0155f4f692993a5eca67fe4df98ea):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 7050 -j DNAT --to-destination 172.18.0.14:7050 ! -i br-a8728edb1ffc: iptables: No chain/target/match by that name.\n (exit status 1))'
又有了新的错误
发现暂时还不能停掉防火墙于是又将其打开
systemctl start firewalld.service 禁用
再一次进行运行测试:
bash network_setup.sh up
setting to default channel 'mychannel'
crypto-config directory already exists.
peer1.org1.example.com is up-to-date
zookeeper2 is up-to-date
peer1.org2.example.com is up-to-date
zookeeper0 is up-to-date
peer0.org2.example.com is up-to-date
zookeeper1 is up-to-date
peer0.org1.example.com is up-to-date
kafka0 is up-to-date
kafka2 is up-to-date
kafka1 is up-to-date
kafka3 is up-to-date
Starting orderer.example.com ... done
cli is up-to-date


 ____    _____      _      ____    _____           _____   ____    _____ 
/ ___|  |_   _|    / \    |  _ \  |_   _|         | ____| |___ \  | ____|
\___ \    | |     / _ \   | |_) |   | |    _____  |  _|     __) | |  _|  
 ___) |   | |    / ___ \  |  _ <    | |   |_____| | |___   / __/  | |___ 
|____/    |_|   /_/   \_\ |_| \_\   |_|           |_____| |_____| |_____|


Channel name : mychannel
Check orderering service availability...
Attempting to fetch system channel 'testchainid' ...3 secs
Attempting to fetch system channel 'testchainid' ...7 secs
Attempting to fetch system channel 'testchainid' ...10 secs
Attempting to fetch system channel 'testchainid' ...14 secs
Attempting to fetch system channel 'testchainid' ...19 secs
Attempting to fetch system channel 'testchainid' ...25 secs
Attempting to fetch system channel 'testchainid' ...29 secs
Attempting to fetch system channel 'testchainid' ...36 secs
Attempting to fetch system channel 'testchainid' ...41 secs
Attempting to fetch system channel 'testchainid' ...49 secs
Attempting to fetch system channel 'testchainid' ...52 secs
Attempting to fetch system channel 'testchainid' ...56 secs
Attempting to fetch system channel 'testchainid' ...59 secs
Attempting to fetch system channel 'testchainid' ...62 secs
2018-03-31 09:59:47.354 UTC [msp] GetLocalMSP -> DEBU 001 Returning existing local MSP
2018-03-31 09:59:47.354 UTC [msp] GetDefaultSigningIdentity -> DEBU 002 Obtaining default signing identity
2018-03-31 09:59:47.363 UTC [grpc] Printf -> DEBU 003 grpc: addrConn.resetTransport failed to create client transport: connection error: desc = "transport: Error while dialing dial tcp: lookup orderer.example.com on 127.0.0.11:53: no such host"; Reconnecting to {orderer.example.com:7050 }
Error: Error connecting due to  rpc error: code = Unavailable desc = grpc: the connection is unavailable
Usage:
  peer channel fetch [outputfile] [flags]


Flags:
  -c, --channelID string   In case of a newChain command, the channel ID to create.


Global Flags:
      --cafile string              Path to file containing PEM-encoded trusted certificate(s) for the ordering endpoint
      --logging-level string       Default logging level and overrides, see core.yaml for full syntax
  -o, --orderer string             Ordering service endpoint
      --test.coverprofile string   Done (default "coverage.cov")
      --tls                        Use TLS when communicating with the orderer endpoint
  -v, --version                    Display current version of fabric peer server


!!!!!!!!!!!!!!! Ordering Service is not available, Please try again ... !!!!!!!!!!!!!!!!
================== ERROR !!! FAILED to execute End-2-End Scenario ==================
这个有可能是版本的问题
因此切换fabric的branch看看:
[root@localhost fabric]# git checkout release-1.1
切换到分支 'release-1.1'
[root@localhost fabric]# git branch
* release-1.1
  v1.0.0

不知道我下载的时候哪里不对劲,我git下来的两个版本的e2e_cli/base/docker-compose-base.yaml是不同的,我在VMware虚拟机上部署时也遇到这个问题了。然后将我阿里云上成功的版本打包迁移到虚拟机上就OK了。
另外fabric可以到这里fabric,如无积分请@我
fabric-samples在这里下载fabric-samples 如无积分请@我
如有不妥还望继续留言
 _____   _   _   ____            _____   ____    _____ 
| ____| | \ | | |  _ \          | ____| |___ \  | ____|
|  _|   |  \| | | | | |  _____  |  _|     __) | |  _|  
| |___  | |\  | | |_| | |_____| | |___   / __/  | |___ 
|_____| |_| \_| |____/          |_____| |_____| |_____|






































你可能感兴趣的:(Git,docker,linux进阶学习,区块链)