在进行镜像安装前,提供了一个sample脚本的下载,可以使用该脚本进行容器的启停。这里对该脚本进行分析。

fabric/release/linux-amd64/network_setup.sh

脚本提供了四个参数项目,

UP_DOWN="$1"
CH_NAME="$2"
CLI_TIMEOUT="$3"
IF_COUCHDB="$4" : ${CLI_TIMEOUT:=""}

第一个:up down restart参数:可以进行容器的启停,这里主要关注up,也就是了解容器是如何拉起的。

第二个:字符串参数:通道名称,这里与fabric多通道有关

第三个:数值:管理工具超时时间(单位不明)

第四个:couchdb或'':  是否使用COUCHDB(CouchDB 是一个开源的面向文档的数据库管理系统)

执行up后,首先调用networkUp函数。之后转到generateArtifacts.sh脚本

function networkUp () {
#Generate all the artifacts that includes org certs, orderer genesis block,
# channel configuration transaction
source generateArtifacts.sh $CH_NAME
解析generateArtifacts.sh执行过程
注:这块涉及到了证书相关的内容
ca证书
Membership Service Providers (MSP) https://fabric-rtd.readthedocs.io/en/latest/msp.html
x. certificates and public key infrastructure https://en.wikipedia.org/wiki/Public_key_infrastructure
后续再进行研究
  function generateCerts ()
首先使用cryptogen工具生成密钥,密钥的生成模版为crypto-config.yam文件
$CRYPTOGEN generate --config=./crypto-config.yaml
等同与
cd/opt/fabric/release/linux-amd64/
bin/cryptogen generate --config=./crypto-config.yaml
crypto-config.yaml文件内容,根据这个定义结构,生成下面的密钥认证目录和文件
OrdererOrgs:
- Name: Orderer
Domain: example.com
Specs:
- Hostname: orderer
PeerOrgs:
- Name: Org1
Domain: org1.example.com
Template:
Count:
Users:
Count:
- Name: Org2
Domain: org2.example.com
Template:
Count:
Users:
Count:

可以执行该命令,生成生成的目录结构,如果反复执行,一些目录下会多次生成密钥

密钥的存储地址为:/opt/fabric/release/linux-amd64/crypto-config

使用tree crypto-config查看目录下的文件结构
crypto-config
├── ordererOrganizations
│   └── example.com
│   ├── ca
│   │   ├── 0f63cc42f0f1fcf00a89ddd3b5da0936503c46802a07dbe45ff12882e78edf32_sk
│   │   └── ca.example.com-cert.pem
│   ├── msp
│   │   ├── admincerts
│   │   │   └── Admin@example.com-cert.pem
│   │   ├── cacerts
│   │   │   └── ca.example.com-cert.pem
│   │   ├── keystore
│   │   └── signcerts
│   │   └── ca.example.com-cert.pem
│   ├── orderers
│   │   └── orderer.example.com
│   │   ├── msp
│   │   │   ├── admincerts
│   │   │   │   └── Admin@example.com-cert.pem
│   │   │   ├── cacerts
│   │   │   │   └── ca.example.com-cert.pem
│   │   │   ├── keystore
│   │   │   │   └── 8b24878c3b0d92bfbb58db333d0ff3cb15b7d4b27401e3f40a8efa6bd2d4df05_sk
│   │   │   └── signcerts
│   │   │   └── orderer.example.com-cert.pem
│   │   └── tls
│   │   ├── ca.crt
│   │   ├── server.crt
│   │   └── server.key
│   └── users
│   └── Admin@example.com
│   ├── msp
│   │   ├── admincerts
│   │   │   └── ca.example.com-cert.pem
│   │   ├── cacerts
│   │   │   └── ca.example.com-cert.pem
│   │   ├── keystore
│   │   │   └── f11e42721d96e1dd5408f33a81dd74759a9d1ca294cc1dade6b8bf7b48dc1c9a_sk
│   │   └── signcerts
│   │   └── Admin@example.com-cert.pem
│   └── tls
│   ├── ca.crt
│   ├── server.crt
│   └── server.key
└── peerOrganizations
├── org1.example.com
│   ├── ca
│   │   ├── 94cbaa1ffab32105d323007ffe831bbc14be58d31b1e8e534fc48c8dfa405ef1_sk
│   │   └── ca.org1.example.com-cert.pem
│   ├── msp
│   │   ├── admincerts
│   │   │   └── Admin@org1.example.com-cert.pem
│   │   ├── cacerts
│   │   │   └── ca.org1.example.com-cert.pem
│   │   ├── keystore
│   │   └── signcerts
│   │   └── ca.org1.example.com-cert.pem
│   ├── peers
│   │   ├── peer0.org1.example.com
│   │   │   ├── msp
│   │   │   │   ├── admincerts
│   │   │   │   │   └── Admin@org1.example.com-cert.pem
│   │   │   │   ├── cacerts
│   │   │   │   │   └── ca.org1.example.com-cert.pem
│   │   │   │   ├── keystore
│   │   │   │   │   └── e300201ec6785972a88f89d6586ed913d46d228d6cb2fe0a7043a46a61dd4402_sk
│   │   │   │   └── signcerts
│   │   │   │   └── peer0.org1.example.com-cert.pem
│   │   │   └── tls
│   │   │   ├── ca.crt
│   │   │   ├── server.crt
│   │   │   └── server.key
│   │   └── peer1.org1.example.com
│   │   ├── msp
│   │   │   ├── admincerts
│   │   │   │   └── Admin@org1.example.com-cert.pem
│   │   │   ├── cacerts
│   │   │   │   └── ca.org1.example.com-cert.pem
│   │   │   ├── keystore
│   │   │   │   └── e38cc67f6a49fd60aa44acc8fd328f00778b3df4868b2bfb8e254141d75e9a73_sk
│   │   │   └── signcerts
│   │   │   └── peer1.org1.example.com-cert.pem
│   │   └── tls
│   │   ├── ca.crt
│   │   ├── server.crt
│   │   └── server.key
│   └── users
│   ├── Admin@org1.example.com
│   │   ├── msp
│   │   │   ├── admincerts
│   │   │   │   └── ca.org1.example.com-cert.pem
│   │   │   ├── cacerts
│   │   │   │   └── ca.org1.example.com-cert.pem
│   │   │   ├── keystore
│   │   │   │   └── 10c59c2596366e4a6e1046120a10a7977c019458786ac86b3f99d64474c97529_sk
│   │   │   └── signcerts
│   │   │   └── Admin@org1.example.com-cert.pem
│   │   └── tls
│   │   ├── ca.crt
│   │   ├── server.crt
│   │   └── server.key
│   └── User1@org1.example.com
│   ├── msp
│   │   ├── admincerts
│   │   │   └── ca.org1.example.com-cert.pem
│   │   ├── cacerts
│   │   │   └── ca.org1.example.com-cert.pem
│   │   ├── keystore
│   │   │   └── 78730dac6a0358428e3556275567883bc1c7e818875a9925f4e7c1517053f438_sk
│   │   └── signcerts
│   │   └── User1@org1.example.com-cert.pem
│   └── tls
│   ├── ca.crt
│   ├── server.crt
│   └── server.key
└── org2.example.com
├── ca
│   ├── 683f20c00dd655b5ed6073098c62acbd1efa660d9f5f585258a3a4e61739ef9c_sk
│   └── ca.org2.example.com-cert.pem
├── msp
│   ├── admincerts
│   │   └── Admin@org2.example.com-cert.pem
│   ├── cacerts
│   │   └── ca.org2.example.com-cert.pem
│   ├── keystore
│   └── signcerts
│   └── ca.org2.example.com-cert.pem
├── peers
│   ├── peer0.org2.example.com
│   │   ├── msp
│   │   │   ├── admincerts
│   │   │   │   └── Admin@org2.example.com-cert.pem
│   │   │   ├── cacerts
│   │   │   │   └── ca.org2.example.com-cert.pem
│   │   │   ├── keystore
│   │   │   │   └── 000e0b35ff61c8e2c07f516346daf11aeabe5d0f5b6914c179ff11ad7c4f678e_sk
│   │   │   └── signcerts
│   │   │   └── peer0.org2.example.com-cert.pem
│   │   └── tls
│   │   ├── ca.crt
│   │   ├── server.crt
│   │   └── server.key
│   └── peer1.org2.example.com
│   ├── msp
│   │   ├── admincerts
│   │   │   └── Admin@org2.example.com-cert.pem
│   │   ├── cacerts
│   │   │   └── ca.org2.example.com-cert.pem
│   │   ├── keystore
│   │   │   └── 55d455f9d1bf47f0320484b322791f43e94d8e7e5e8ed8383f7daf1adeb2c2d2_sk
│   │   └── signcerts
│   │   └── peer1.org2.example.com-cert.pem
│   └── tls
│   ├── ca.crt
│   ├── server.crt
│   └── server.key
└── users
├── Admin@org2.example.com
│   ├── msp
│   │   ├── admincerts
│   │   │   └── ca.org2.example.com-cert.pem
│   │   ├── cacerts
│   │   │   └── ca.org2.example.com-cert.pem
│   │   ├── keystore
│   │   │   └── 20b446c7b6bf5006fccb1fc11168c56e48e937e2775bd46eec627fe7d37d5101_sk
│   │   └── signcerts
│   │   └── Admin@org2.example.com-cert.pem
│   └── tls
│   ├── ca.crt
│   ├── server.crt
│   └── server.key
└── User1@org2.example.com
├── msp
│   ├── admincerts
│   │   └── ca.org2.example.com-cert.pem
│   ├── cacerts
│   │   └── ca.org2.example.com-cert.pem
│   ├── keystore
│   │   └── b72634c677b36bb05718416db8dbdb5dc118ee54a3db8a2b7a6415df87c92e8b_sk
│   └── signcerts
│   └── User1@org2.example.com-cert.pem
└── tls
├── ca.crt
├── server.crt
└── server.key

function replacePrivateKey ()

复制一个docker-compose-e2e.yaml,然后将CA的密码替换进去

 cp docker-compose-e2e-template.yaml docker-compose-e2e.yaml

       generateChannelArtifacts()

      执行configtxgen生成创世块

export FABRIC_CFG_PATH=$PWD
./bin/configtxgen -profile TwoOrgsOrdererGenesis -outputBlock ./channel-artifacts/genesis.block

这里需要设置FABRIC_CFG_PATH,因为configtxgen是根据configtx.yaml这个文件取的内容,默认的名称是写在代码中,可以通过参数进行修改。

会生成多个块,都放在channel-artifacts文件夹下面。默认的通道名是:CHANNEL_NAME:="mychannel"

    $CONFIGTXGEN -profile TwoOrgsChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
$CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP
$CONFIGTXGEN -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org2MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org2MSP

generateArtifacts.sh文件执行完毕

继续network_setup.sh的内容。

需要选择是否使用COUCHDB,CouchDB 是一个开源的面向文档的数据库管理系统

之后使用docker-compose -f   docker-compose-cli.yaml 开始启动容器了。这里很奇怪没有使用新生成的docker-compose-e2e.yaml。这个后续要研究一下。

function networkUp () {
#Generate all the artifacts that includes org certs, orderer genesis block,
# channel configuration transaction
source generateArtifacts.sh $CH_NAME if [ "${IF_COUCHDB}" == "couchdb" ]; then
CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE -f $COMPOSE_FILE_COUCH up -d 2>&1
else
CHANNEL_NAME=$CH_NAME TIMEOUT=$CLI_TIMEOUT docker-compose -f $COMPOSE_FILE up -d 2>&1
fi
if [ $? -ne ]; then
echo "ERROR !!!! Unable to pull the images "
exit
fi
docker logs -f cli
}

至此启动过程结束。

fabric-network_setup.sh安装脚本分析的更多相关文章

  1. iredmail安装脚本分析(一)---iRedmail.sh

    iredmail是一套以postfix为核心的整合邮件系统的安装脚本,可以达到快速部署邮件服务器的目的.为了让自己不遗忘shell的语法,所以闲来无事,学习一下他的代码. 我从官网下载他的最新版,解压 ...

  2. iredmail安装脚本分析(三)---conf/global DISTRO值的来源及操作系统的判断

    作者在引入conf/global 文件时,就已经对操作系统的类型进行判断,同时也对DISTRO进行了赋值. 部分代码,如图: 显然文件里的KERNEL_NAME的值就是判断完成的操作系统,具体分析该值 ...

  3. 带你走进脚本世界,ijkplayer之【init-ios.sh】脚本分析

    前言 集成ijkplayer,需要执行脚本init-ios.sh,那么init-ios.sh脚本干嘛用的了,花了半天时间,学习了下shell脚本,感觉脚本语言学起来还是比较容易上手的,现在仅仅能看懂了 ...

  4. iredmail安装脚本分析(二)---get_all.sh 文件所在目录为PKGS

    经过上面的一系列分析后,进入到获取安装包的步骤,作者在此处单独写了一个脚本,get_all.sh,我们继续分析这个脚本 _ROOTDIR="$(pwd)" CONF_DIR=&qu ...

  5. fabric镜像安装脚本分析

    #!/bin/bash # # Copyright IBM Corp. All Rights Reserved. # # SPDX-License-Identifier: Apache-2.0 # e ...

  6. Hadoop的shell脚本分析

    你会发现hadoop-daemon.sh用于启动单独的本机节点 而hadoop-daemons.sh 会批量的ssh到别的机器启动 前记: 这些天一直学习hadoop,学习中也遇到了许多的问题,主要是 ...

  7. Hyperledger Fabric(v1.2.0)代码分析1——channel创建

    Hyperledger Fabric(v1.2.0)代码分析1--channel创建 0. e2e_cli Hyperledger Fabric提供了一个e2e的例子,该例中创建了一个基础的区块链网络 ...

  8. 使用shell脚本分析Nagios的status.dat文件

    前言 Nagios的安装和配置以及批量添加监控服务器在我前面的文章中已经讲的很详细了. 我们知道,Nagios的网页控制页面(一般为http://nagio.domain.com/nagios)里可以 ...

  9. Ubuntu下Hyperledger Fabric v0.6安装部署

    系统环境:虚拟机VMware Workstation中的Ubuntu 16.04LTS 1.环境准备 1.1安装Docker Docker安装命令: curl –fsSL https://get.do ...

随机推荐

  1. Kafka研究【一】:bring up环境

    kafka是干什么的,有和特性,我这里就不多说,详情自己研究官方文档. 0. 背景介绍 我需要在三台机器上分别部署kafka broker的实例,构建成一个集群.kafka的broker集群,是基于z ...

  2. ecstore开启发送邮件日志,并且排查邮件发布出去原因

    config.php里 define("MAIL_LOG", true);//发送邮件日志开启2017-04-19 10:29:31 解决sendmail connection r ...

  3. Modelsim使用流程---基于TCL命令的仿真

    Modelsim使用流程---基于TCL命令的仿真 本文使用的Modelsim版本为Modelsim SE-64 10.1.c 1.File -> new -> Project 2.添加或 ...

  4. Linux ssh服务器配置

    配置文件在/etc/sshd_config,注意只有root可rw,其他所有用户权限为---. 配置说明可参考man sshd_config. 如果更改了服务器端口号,并且启用了SELinux,需要执 ...

  5. Problem 1 :nslookup,dig,host及网络相关命令

    网络基础命令 [root@localhost sysconfig]# netstat -rn Kernel IP routing table Destination Gateway Genmask F ...

  6. PREV-9_蓝桥杯_大臣的旅费

    问题描述 很久以前,T王国空前繁荣.为了更好地管理国家,王国修建了大量的快速路,用于连接首都和王国内的各大城市. 为节省经费,T国的大臣们经过思考,制定了一套优秀的修建方案,使得任何一个大城市都能从首 ...

  7. jquery zTree异步搜索的例子--搜叶子节点

    参考博客:https://www.cnblogs.com/henuyuxiang/p/6677397.html 前台代码 <%@ page language="java" c ...

  8. spring4.0之一:简介

    我们共同来构建更好的企业应用.Spring帮助全世界的开发团队构建简单.便携.快速和灵活的基于JVM的系统和应用.这两句话已经足以说明Spring的目标,它针对的领域是企业应用,这套框架构建的应用有着 ...

  9. PHP中常用的数组函数总结

    整理了一份PHP开发中数组操作大全,包含有数组操作的基本函数,数组的分段和填充,数组与栈,数组与列队,回调函数,排序,计算,其他的数组函数等. 一,数组操作的基本函数 数组的键名和值 array_va ...

  10. python:数据类型

    一.数据类型 1.数字int型 主要进行计算 bit_length() 当十进制用二进制表示时,最少使用的位数 a = 13 b = a.bit_length() print (b) 2.布尔值boo ...