docker 思想

模块化: 集装箱

标准化: 运输标准化, 存储方式标准化,API接口的标准化

安全性: 隔离

docker解决什么问题

  • devops
  • 我这程序程序没问题啊
  • 系统好卡.哪个程序死循环了
  • 弹性计算,抗住双十一

docker核心技术

标准化,标准化,标准化

build ship run

  1. 构建镜像发布到仓库
  2. 去仓库拉镜像到本地
  3. 把本地的镜像运行起来,运行中容器中

docker仓库镜像

  • 联合分层文件系统

  • 容器

    其实就是一个虚拟机进程

  • 仓库

    hub.docker.com

docker 安装

https://yq.aliyun.com/articles/110806?spm=5176.8351553.0.0.5d4e1991URD8Ia

# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

docker初体验

参数要写到镜像的前面

docker pull xxx:TAG
docker images //显示本地安装了哪些镜像
docker pull hello-world //拉取镜像
docker run hello-world //运行镜像
docker rmi //移出镜像
docker pull ubuntu
docker run ubuntu echo hello world

docker 运行nginx

  • 复杂的持久运行的容器
  • 前台运行& 后台运行
  • 进入容器内部
docker ps  //显示正在运行的镜像
docker ps -a //查看所用运行过的容器 包括状态 docker run nginx -d //后台运行镜像 docker exec -it cli bash

docker 网络

-p 让容器的端口跟主机对应起来

docker run -p 80:80 nginx //把容器80端口和主机80对应

dockerfile

FROM xxx:latest

MAINTAINER zzh

CMD echo helloworld

hyperledger环境搭建

  1. 安装xshell

    http://www.netsarang.com/products/xsh_overview.html

  2. 购买阿里云服务器



    使用Ubuntu14.04版操作



    乞丐版1核1G, 便宜好用.

  3. 安装git

apt-get update //更新软件源 不更新的话可能下载的软件版本会很旧
apt-get install git



  1. 安装docker-ce

请不要直接apt-get 安装docker, 这会安装docker的旧版本

如果安装了docker的旧版本,请卸载

参考文档

https://yq.aliyun.com/articles/110806?spm=5176.8351553.0.0.5d4e1991URD8Ia

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

  1. 安装hyperledger的工具和docker镜像

    官方文档:

    http://hyperledger-fabric.readthedocs.io/en/release-1.1/samples.html#binaries
curl -sSL https://goo.gl/6wtTN5 | bash -s 1.1.0

goo.gl短地址被墙, 服务器需要翻墙. 或者直接采用下面解析后的地址

https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh

https://raw.githubusercontent.com/cscjoke/note/master/Hyperledger/bootstrap.sh







有几个镜像下载失败, 原因是0.4.10的 zookeeper 和 kafka couchdb并没有同步到仓库,zookeeper和Kafka的0.4.6版本可以拉取

fabric-ca1.2版本也没有同步到仓库

.

curl -sSL https://raw.githubusercontent.com/cscjoke/note/master/Hyperledger/bootstrap.sh | bash -s 1.1.0  //使用自定义的脚本

全套环境搞定后 截图如下



脚本默认下载好了 fabirc-sample

切换到fabirc-sample目录

  1. 生成创始区块,channel的配置文件
./byfn.sh -m generate

  1. 启动fabirc的测试网络
./byfn.sh -m up



启动失败, 查看报错日志 很容易理解

hyperledger是一个区块链网络, 有很多个节点需要被启动起来, 需要使用docker compose来启动一组机器,并且组网.

  1. 安装docker compose
curl -L https://github.com/docker/compose/releases/download/1.20.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

参考文档 https://github.com/docker/compose/releases

  1. 解决网络报错问题

    阿里云的服务器是改良过的linux服务器, 里面有一句网络超时的配置需要注释掉,

    注意,如果是原版的Ubuntu服务器或者用腾讯云,aws的服务器, 这个错误是不会出现的
编辑/etc/resolv.conf
注释掉 options timeout:2 attempts:3 rotate single-request-reopen



注释掉箭头指向的一行

  1. 重启fabirc网络
./byfn.sh -m down
./byfn.sh -m up

如果看到 all good, BYFN execution completed.

end 这样的信息, 说明你的hyperledger fabirc的环境是没有问题了. 一定要保证你可以看到这个信息,

否则后续的课程, 没法正常进行.

过程详解

  1. 启动6台节点(每个节点可以理解为一台电脑)



org1 机构1里面的peer0 和 peer1

org2 机构2里面的peer0 和 peer1

orderer是排序节点

cli 是client(命令行客户端,后续cli进行的操作会替换成java,或者node sdk的调用)

  1. 创建channel

  2. 让每个peer加入channel

  • org1的peer0加入

  • org1的peer1加入

  • org2的peer0加入

  • org2的peer1加入

  • 更新锚节点 (anchor peer)

  • 锚节点的作用就是让两个不同的机构(org)可以彼此通讯

  • 在org1的peer0上安装链码(智能合约)

  • 在org2的peer0上安装链码





  • 在org2的peer0上实例化链码

  • 在org1的peer0上执行查询





  • 在org1的peer0上执行invoke事物 进行转账



  • 在org2的peer1上安装链码



  • 在org2的peer1上进行查询



  • 大功告成

Hyperledger02的更多相关文章

随机推荐

  1. Introduction to CQRS

    原文链接:  http://www.codeproject.com/Articles/555855/Introduction-to-CQRS What is CQRS CQRS means Comma ...

  2. 一个nginx反向代理, 负载均衡的例子

    #/etc/nginx/conf.d/master.conf #区分大小写 #设定负载均衡的服务器列表 upstream master.balancing { #weigth参数表示权值,权值越高被分 ...

  3. iOS之ShareSDK各社交平台申请AppKey的网址及申请流程汇总

    平台 开放平台地址 APPkey 申请流程 新浪微博 http://open.weibo.com http://bbs.mob.com/thread-89-1-4.html 新浪微博开放平台接入tip ...

  4. jQuery获取data-*属性值

    下面就详细介绍四种方法获取data-*属性的值 <li id="getId" data-id="122" data-vice-id="11&qu ...

  5. CentOS 7.4使用yum源安装php7.2

    1.如果之前已经安装我们先卸载一下 yum -y remove php* 2.由于linux的yum源不存在php7.x,所以我们要更改yum源 rpm -Uvh https://dl.fedorap ...

  6. z-blog博客组插件openSug.js百度搜索下拉框提示代码

      z-blog安装openSug插件即可获得带有“搜索框提示”功能的搜索框,让z-blog搜索更便捷! https://www.opensug.org/.../opensug_z-blog_v1.0 ...

  7. latex01-LaTeX环境的安装与配置

    以Tex Live (跨平台的发行版软件)为例. 1.官网下载iso镜像文件 2.用advanced.bat 安装(管理员权限) 选择要安装的包(主要是去掉多余的语言包) 测试Tex Live 是否正 ...

  8. 学会了 python 的pip方法安装第三方库

    超级开心啊!!!!!!!!!!!!! win10 打开cmd Installing with get-pip.py To install pip, securely download get-pip. ...

  9. List排序方法

    可用使用Collections.sort(List<T> list)和Collections.sort(List<T> list, Comparator<? super ...

  10. java第二章 变量和运算符

      Java 基础应用编程——  变量和运算符 1.Java程序结构          数据类型:确定要存储在内存中的数据的类型.          变量:是存储数据的基本单元 2.变量的概念   变 ...