Hyperledger02
docker 思想
模块化: 集装箱
标准化: 运输标准化, 存储方式标准化,API接口的标准化
安全性: 隔离
docker解决什么问题
- devops
- 我这程序程序没问题啊
- 系统好卡.哪个程序死循环了
- 弹性计算,抗住双十一
docker核心技术
标准化,标准化,标准化
build ship run
- 构建镜像发布到仓库
- 去仓库拉镜像到本地
- 把本地的镜像运行起来,运行中容器中
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环境搭建
安装xshell
http://www.netsarang.com/products/xsh_overview.html购买阿里云服务器

使用Ubuntu14.04版操作

乞丐版1核1G, 便宜好用.安装git
apt-get update //更新软件源 不更新的话可能下载的软件版本会很旧
apt-get install git


- 安装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

- 安装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目录

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

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

启动失败, 查看报错日志 很容易理解
hyperledger是一个区块链网络, 有很多个节点需要被启动起来, 需要使用docker compose来启动一组机器,并且组网.
- 安装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


- 解决网络报错问题
阿里云的服务器是改良过的linux服务器, 里面有一句网络超时的配置需要注释掉,
注意,如果是原版的Ubuntu服务器或者用腾讯云,aws的服务器, 这个错误是不会出现的
编辑/etc/resolv.conf
注释掉 options timeout:2 attempts:3 rotate single-request-reopen

注释掉箭头指向的一行
- 重启fabirc网络
./byfn.sh -m down
./byfn.sh -m up


如果看到 all good, BYFN execution completed.
end 这样的信息, 说明你的hyperledger fabirc的环境是没有问题了. 一定要保证你可以看到这个信息,
否则后续的课程, 没法正常进行.
过程详解
- 启动6台节点(每个节点可以理解为一台电脑)


org1 机构1里面的peer0 和 peer1
org2 机构2里面的peer0 和 peer1
orderer是排序节点
cli 是client(命令行客户端,后续cli进行的操作会替换成java,或者node sdk的调用)
创建channel

让每个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的更多相关文章
随机推荐
- VUE插件整理
转自:https://blog.csdn.net/miaozhenzhong/article/details/80138174 1.VsCode官方插件地址: https://marketplace. ...
- flex 遇到white-space:nowrap
背景,做一个前面图片宽度固定,后面宽度自适应,使用到了flex布局,但是想让后面div里文字不换行,超出以点点表示时,这时布局就乱了,查了下,原来flex布局与white-space:nowrap有影 ...
- flexible.js在华某为手机上使用rem时,页面宽度超出手机屏幕宽度
问题:手机端项目在华为的某款手机上显示时页面内容没有自适应手机宽度,出现横向滚动条 原因:手机获取手机屏幕宽度并计算出rem时出现偏差,明显宽余真实手机屏宽度 解决方案一:在页面里获取页面最外层dom ...
- vs2017中的scanf_s
在visual studio 2017中格式化输入函数不同于其他c/c++编译器使用scanf,而是使用scanf_s. scanf_s相比较于scanf来说更安全,因为使用scanf_s函数需要有一 ...
- Failed to introspect bean class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClass
依赖引入 错误可能版本 不对 Failed to introspect bean class [org.springframework.orm.hibernate5.LocalSessionFact ...
- JS如何给ul下的所有li绑定点击事件,点击使其弹出下标和内容
这是一个非常常见的面试题,出题方式多样,但考察点相同,下面我们来看看这几种方法:方法一: var itemli = document.getElementsByTagName("li&quo ...
- jQuery(一)初识
jQuery 的功能概括 1.html 的元素选取 2.html的元素操作 3.html dom遍历和修改 4.js特效和动画效果 5.css操作 6.html事件操作 7.ajax异步请求方式 se ...
- I/O流、字符集
1)InputStream.OutPutStream是输出输入的基础流,均为抽象类,提供了read和writer方法,所有的子类均实现read和writer方法,read在遇到输入源的结尾时返回-1. ...
- php柱状图多系列动态实现
<?php require_once 'data.php'; require_once 'jpgraph/src/jpgraph.php'; require_once"jpgraph/ ...
- LINUX SSH 建立密钥对
配置私钥和公钥 先检查一下服务器的ssh配置文件 /etc/ssh/sshd_config RSAAuthentication yes # 启用 RSA 认证 默认为 yes PubkeyAuthen ...