如何只安装 Hyperledger Fabric 的二进制文件?

How do I install Hyperledger Fabric's binaries only?

我想要 install/download HLF 二进制文件,没有图像和织物样本。我该怎么做?

这是我目前尝试过的方法:

  1. 我已按照 https://hyperledger-fabric.readthedocs.io/en/release-1.4/install.html 上的说明进行操作,但这也会安装图像(这是不需要的)。
  2. 我查看了 hlf 存储库,但那里没有 /bin/ 目录,并且对 'contigtxgen' 和其他目录进行名称搜索除了在存储库中的其他脚本中使用之外没有产生任何结果
  3. 用谷歌搜索任何提到的 hlf 的二进制安装,但没有得到肯定的结果

期望的结果是一个 cli 命令,我可以用它来抑制安装图像或类似的东西。

我也在设置没有 docker 图像的织物。 这个link对我帮助很大。虽然它没有显示如何在主机上设置排序节点和节点。

以下是我在主机上 运行 订购者和对等方所遵循的配置和步骤(确保您已经安装了 hyperledger fabric 的所有先决条件):-

首先克隆 fabric 存储库并 运行 make.

git clone https://github.com/hyperledger/fabric.git

//cd into fabric folder and run
make release

以上将为您的主机在 release 文件夹中生成二进制文件。

fabric
 |
  -- release
    |
     -- linux-amd64
       |
        -- bin

将此 bin 文件夹复制到新文件夹 mynetwork 中,并创建以下配置文件。

mynetwork
 |
  -- bin
  -- crypto-config.yaml
  -- configtx.yaml
  -- order.yaml
  -- core.yaml

以下是我正在使用的配置。

加密-config.yaml

OrdererOrgs:
  - Name: Orderer
    Domain: example.com
    Specs:
      - Hostname: orderer
        SANS:
          - "localhost"
          - "127.0.0.1"

PeerOrgs:
  - Name: Org1
    Domain: org1.example.com
    EnableNodeOUs: true
    Template:
      Count: 1
      SANS:
        - "localhost"
        - "127.0.0.1"
    Users:
      Count: 1

接下来打开终端(我们称之为终端 1)并进入 mynetwork 文件夹和 运行 生成资产和密钥的密码原。

./bin/cryptogen generate --config=./crypto-config.yaml

以上将在 mynetwork 中创建包含所有网络资产的 crypto-config 文件夹,在本例中为 ordererOrganization 和 peerOrganization。

mynetwork
 |
  -- crypto-config
   |
    -- ordererOrganizations
    -- peerOrganizations

接下来你需要创建configtx.yaml

Organizations:
  - &OrdererOrg
    Name: OrdererOrg
    ID: OrdererMSP
    MSPDir: crypto-config/ordererOrganizations/example.com/msp

    Policies:
      Readers:
        Type: Signature
        Rule: "OR('OrdererMSP.member')"
      Writers:
        Type: Signature
        Rule: "OR('OrdererMSP.member')"
      Admins:
        Type: Signature
        Rule: "OR('OrdererMSP.admin')"

  - &Org1
    Name: Org1MSP
    ID: Org1MSP
    MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

    Policies:
      Readers:
        Type: Signature
        Rule: "OR('Org1MSP.admin', 'Org1MSP.peer', 'Org1MSP.client')"
      Writers:
        Type: Signature
        Rule: "OR('Org1MSP.admin', 'Org1MSP.client')"
      Admins:
        Type: Signature
        Rule: "OR('Org1MSP.admin')"

    AnchorPeers:
      - Host: 127.0.0.1
        Port: 7051


Capabilities:
  Channel: &ChannelCapabilities
    V1_3: true

  Orderer: &OrdererCapabilities
    V1_1: true

  Application: &ApplicationCapabilities
    V1_3: true

    V1_2: false

    V1_1: false


Application: &ApplicationDefaults
  Organizations:

  Policies:
    Readers:
      Type: ImplicitMeta
      Rule: "ANY Readers"
    Writers:
      Type: ImplicitMeta
      Rule: "ANY Writers"
    Admins:
      Type: ImplicitMeta
      Rule: "MAJORITY Admins"

  Capabilities:
    <<: *ApplicationCapabilities

Orderer: &OrdererDefaults
  OrdererType: solo
  Addresses:
    - orderer:7050
  BatchTimeout: 2s
  BatchSize:
    MaxMessageCount: 10
    AbsoluteMaxBytes: 99 MB
    PreferredMaxBytes: 512 KB

  Organizations:

  Policies:
    Readers:
      Type: ImplicitMeta
      Rule: "ANY Readers"
    Writers:
      Type: ImplicitMeta
      Rule: "ANY Writers"
    Admins: 
      Type: ImplicitMeta
      Rule: "MAJORITY Admins"
    BlockValidation:
      Type: ImplicitMeta
      Rule: "ANY Writers"

Channel: &ChannelDefaults

  Policies:
    Readers:
      Type: ImplicitMeta
      Rule: "ANY Readers"
    Writers:
      Type: ImplicitMeta
      Rule: "ANY Writers"
    Admins:
      Type: ImplicitMeta
      Rule: "MAJORITY Admins"

  Capabilities:
    <<: *ChannelCapabilities


Profiles:

  OneOrgOrdererGenesis:
    <<: *ChannelDefaults
    Orderer:
      <<: *OrdererDefaults
      Organizations:
        - *OrdererOrg
      Capabilities:
        <<: *OrdererCapabilities
    Consortiums:
      SampleConsortium:
        Organizations:
          - *Org1

  OneOrgChannel:
    Consortium: SampleConsortium
    <<: *ChannelDefaults
    Application:
      <<: *ApplicationDefaults
      Organizations:
        - *Org1
      Capabilities:
        <<: *ApplicationCapabilities

然后在终端 1 运行 上按顺序执行以下几个命令

export FABRIC_CFG_PATH=$PWD
mkdir channel-artifacts
./bin/configtxgen -profile OneOrgOrdererGenesis -channelID myfn-sys-channel -outputBlock ./channel-artifacts/genesis.block
export CHANNEL_NAME=mychannel
./bin/configtxgen -profile OneOrgChannel -outputCreateChannelTx ./channel-artifacts/channel.tx -channelID $CHANNEL_NAME
./bin/configtxgen -profile OneOrgChannel -outputAnchorPeersUpdate ./channel-artifacts/Org1MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org1MSP

接下来创建 orderer.yaml,并根据您的主机和文件夹位置更改证书路径。

General:
  LedgerType: file
  ListenAddress: 127.0.0.1
  ListenPort: 7050

  TLS:
    Enabled: true
    PrivateKey: /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
    Certificate: /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
    RootCAs:
      - /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt
    ClientAuthRequired: false

  Keepalive:
    ServerMinInterval: 60s
    ServerInterval: 7200s
    ServerTimeout: 20s

  GenesisMethod: file

  GenesisProfile: OneOrgOrdererGenesis

  GenesisFile: channel-artifacts/genesis.block

  LocalMSPDIR: /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp

  LocalMSPID: OrdererMSP

  Authentication:
    TimeWindow: 15m

FileLedger:
  Location: /home/fabric-release/data/orderer
  Prefix: hyperledger-fabric-ordererledger

Operations:
  ListenAddress: 127.0.0.1:8443
  TLS:
    Enabled: true
    Certificate: /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.crt
    PrivateKey: /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/server.key
    ClientAuthRequired: false
    ClientRootCAs: 
      - crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

在 terminal-1 上启动排序器

./bin/orderer

接下来打开另一个终端(Terminal-2)并转到我的网络文件夹。创建 core.yaml(同样,您需要更改证书和密钥路径)。

peer:
  id: peer1
  networkId: myfn

  listenAddress: 127.0.0.1:7051

  address: 127.0.0.1:7051

  addressAutoDetect: false

  gomaxprocs: -1

  keepalive:
    minInterval: 60s

    client:
      interval: 60s
      timeout: 20s

    deliveryClient:
      interval: 60s
      timeout: 20s
  gossip:
    bootstrap: 127.0.0.1:7051
    externalEndpoint: 127.0.0.1:7051
    useLeaderElection: true
    orgLeader: false
  tls:
    enabled: true
    clientAuthRequired: false
    cert:
      file: crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.crt

    key:
      file: crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/server.key

    rootcert:
      file: crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt

    clientRootCAs:
      file:
        - crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt


  authentication:
    timewindow: 15m

  fileSystemPath: /home/fabric-release/data

  mspConfigPath: /home/fabric-release/mynetwork/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp

  localMspId: Org1MSP

  client: 
    connTimeout: 3s

  deliveryclient:
    reconnectTotalTimeThreshold: 3600s
    connTimeout: 3s

  profile:
    enabled: false
    listenAddress: 0.0.0.0:6060

  handlers:
    authFilters:
      - name: DefaultAuth
      - name: ExpirationCheck
    decorators:
      - name: DefaultDecorator
    endorsers:
      escc:
        name: DefaultEndorsement
        library:
    validators:
      vscc:
        name: DefaultValidation
        library:

  discovery:
    enabled: true
    authCacheEnabled: true
    authCacheMaxSize: 1000
    authCachePurgeRetentionRatio: 0.75
    orgMembersAllowedAccess: false

vm:
  endpoint: unix:///var/run/docker.sock
  docker:
    tls:
      enabled: false
      ca:
        file:
      cert:
        file:
      key:
        file:
    attachStdout: false
    hostConfig:
      NetworkMode: host
      Dns:
        # - 192.168.0.1
      LogConfig:
        Type: json-file
        Config:
          max-size: "50m"
          max-file: "5"
      Memory: 2147483648

chaincode:
  id: 
    path:
    name:

  builder: $(DOCKER_NS)/fabric-ccenv:latest

  pull: true

  java:
    runtime: $(DOCKER_NS)/fabric-javaenv:$(ARCH)-1.4.1
    #runtime: $(DOCKER_NS)/fabric-javaenv:$(ARCH)-$(PROJECT_VERSION)
  startuptimeout: 300s
  executetimeout: 30s
  mode: net
  keepalive: 0
  system:
    cscc: enable
    lscc: enable
    escc: enable
    vscc: enable
    qscc: enable
  logging:
    level:  info
    shim:   warning
    format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'

ledger:
  blockchain:

  state:
    stateDatabase: goleveldb
    totalQueryLimit: 100000
    couchDBConfig:
      couchDBAddress: 127.0.0.1:5984
      username:
      password:
      maxRetries: 3
      maxRetriesOnStartup: 12
      requestTimeout: 35s
      internalQueryLimit: 1000
      maxBatchUpdateSize: 1000
      warmIndexesAfterNBlocks: 1
      createGlobalChangesDB: false

  history:
    enableHistoryDatabase: true

在 terminal-2 上启动对等节点

./bin/peer node start

接下来打开另一个终端(Terminal-3)并转到我的网络文件夹。 运行 依次执行以下命令。

export CORE_PEER_MSPCONFIGPATH=/home/fabric-release/mynetwork/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp
export CORE_PEER_ADDRESS=127.0.0.1:7051
export CORE_PEER_LOCALMSPID="Org1MSP"
export CORE_PEER_TLS_ROOTCERT_FILE=/home/fabric-release/mynetwork/crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt
export CHANNEL_NAME=mychannel

创建频道

/bin/peer channel create -o 127.0.0.1:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /home/fabric-release/mynetwork/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem 

加入频道

./bin/peer channel join -b mychannel.block

如果你做到了这一步,你的网络就已经启动了,你可以开始安装链码了。我仍在试验链代码。但是,我希望这会有所帮助。

如果您下载此脚本(并设置执行权限):

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

然后 运行 使用 -h 的脚本,您将看到禁止下载二进制文件或 Docker 图片的选项。