Where to include core.yaml in Hyperledger Fabric?

2019-08-09 10:37发布

问题:

I am working on Hyperledger fabric and trying to retrieve historical transaction records from the network. So, i found core.yaml config to enable ledger historic database. But, i don't find where to include the "core.yaml" in the application source repository.

I found few clues to add the file in docker-compose.yaml as

CORE_VM_ENDPOINT=core.yaml

So, is it the correct way of adding the "core.yaml" in the docker-compose.yaml file.?

docker-compose.yaml

version: '2'
services:

ca.org1.example.com:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_CA_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_CA_FIXTURE_TAG}
hostname: ca.org1.example.com
environment:
  - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
  - FABRIC_CA_SERVER_CA_NAME=ca.org1.example.com
  - FABRIC_CA_SERVER_CA_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
  - FABRIC_CA_SERVER_CA_KEYFILE=/etc/hyperledger/fabric-ca-server-config/0427fbe1849b3e146f05201e1d8c5e570337faaaa19ed37deda69bb7c88c71ef_sk
  - FABRIC_CA_SERVER_CFG_AFFILIATIONS_ALLOWREMOVE=true
  - FABRIC_CA_SERVER_CFG_IDENTITIES_ALLOWREMOVE=true
  - FABRIC_CA_SERVER_PORT=7054
  - FABRIC_CA_SERVER_TLS_ENABLED=false
  - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem
  - FABRIC_CA_SERVER_TLS_KEYFILE=/etc/hyperledger/fabric-ca-server-config/0427fbe1849b3e146f05201e1d8c5e570337faaaa19ed37deda69bb7c88c71ef_sk
ports:
  - 7054:7054
expose:
  - 7054
command: sh -c 'fabric-ca-server start --ca.certfile /etc/hyperledger/fabric-ca-server-config/ca.org1.example.com-cert.pem --ca.keyfile /etc/hyperledger/fabric-ca-server-config/0427fbe1849b3e146f05201e1d8c5e570337faaaa19ed37deda69bb7c88c71ef_sk -b admin:adminpw -d'
volumes:
  - ./crypto-config/peerOrganizations/org1.example.com/ca/:/etc/hyperledger/fabric-ca-server-config


 couchdb.peer0.org1.example.com:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_COUCHDB_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_COUCHDB_FIXTURE_TAG}
hostname: couchdb.peer0.org1.example.com
environment:
  - COUCHDB_USER=admin
  - COUCHDB_PASSWORD=adminpw
ports:
  - 5984:5984
expose:
  - 5984

 peer0.org1.example.com:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_PEER_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_PEER_FIXTURE_TAG}
hostname: peer0.org1.example.com
environment:
  - CORE_PEER_PROFILE_ENABLED=true
  - CORE_PEER_TLS_ENABLED=true
  - CORE_PEER_TLS_KEY_FILE=/var/hyperledger/tls/server.key
  - CORE_PEER_TLS_CERT_FILE=/var/hyperledger/tls/server.crt
  - CORE_PEER_TLS_ROOTCERT_FILE=/var/hyperledger/tls/ca.crt   
  - CORE_PEER_GOSSIP_USELEADERELECTION=true
  - CORE_PEER_GOSSIP_ORGLEADER=false
  - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
  - CORE_PEER_ADDRESSAUTODETECT=true
  - CORE_PEER_LISTENADDRESS=0.0.0.0:7051
  - CORE_PEER_LOCALMSPID=Org1MSP
  - CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp
  - CORE_LOGGING_PEER=info
  - CORE_LOGGING_CAUTHDSL=warning
  - CORE_LOGGING_GOSSIP=warning
  - CORE_LOGGING_LEDGER=info
  - CORE_LOGGING_MSP=warning
  - CORE_LOGGING_POLICIES=warning
  - CORE_LOGGING_GRPC=error
  - CORE_CHAINCODE_LOGGING_SHIM=info
  - CORE_CHAINCODE_LOGGING_LEVEL=info
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_CHAINCODE_BUILDER
  - CORE_CHAINCODE_GOLANG_RUNTIME
  - CORE_CHAINCODE_EXECUTETIMEOUT=120s
  - CORE_PEER_NETWORKID=multiorgledger
  - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
  - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
  - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin
  - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw
  - CORE_PEER_ID=peer0.org1.example.com
  - CORE_VM_DOCKER_ATTACHSTDOUT=true
  - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
  - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb.peer0.org1.example.com:5984
  - CORE_PEER_TLS_SERVERHOSTOVERRIDE=peer0.org1.example.com      
  - CORE_PEER_GOSSIP_BOOTSTRAP=peer1.org1.example.com:8051      
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
volumes:
  - /var/run/:/host/var/run/
  - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp:/var/hyperledger/msp
  - ./crypto-config/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls:/var/hyperledger/tls
  - core.yaml:/var/hyperledger/config
ports:
  - 7051:7051
  - 7053:7051

 couchdb.peer1.org1.example.com:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_COUCHDB_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_COUCHDB_FIXTURE_TAG}
hostname: couchdb.peer1.org1.example.com
environment:
  - COUCHDB_USER=admin
  - COUCHDB_PASSWORD=adminpw
ports:
  - 6984:5984


 peer1.org1.example.com:
image: ${FABRIC_DOCKER_REGISTRY}${FABRIC_PEER_FIXTURE_IMAGE}:${ARCH}${ARCH_SEP}${FABRIC_PEER_FIXTURE_TAG}
hostname: peer1.org1.example.com   
environment:
  - CORE_PEER_PROFILE_ENABLED=true
  - CORE_PEER_TLS_ENABLED=true
  - CORE_PEER_TLS_KEY_FILE=/var/hyperledger/tls/server.key
  - CORE_PEER_TLS_CERT_FILE=/var/hyperledger/tls/server.crt
  - CORE_PEER_TLS_ROOTCERT_FILE=/var/hyperledger/tls/ca.crt   
  - CORE_PEER_GOSSIP_USELEADERELECTION=true
  - CORE_PEER_GOSSIP_ORGLEADER=false
  - CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
  - CORE_PEER_ADDRESSAUTODETECT=true
  - CORE_PEER_LISTENADDRESS=0.0.0.0:7051
  - CORE_PEER_LOCALMSPID=Org1MSP
  - CORE_PEER_MSPCONFIGPATH=/var/hyperledger/msp
  - CORE_LOGGING_PEER=info
  - CORE_LOGGING_CAUTHDSL=warning
  - CORE_LOGGING_GOSSIP=warning
  - CORE_LOGGING_LEDGER=info
  - CORE_LOGGING_MSP=warning
  - CORE_LOGGING_POLICIES=warning
  - CORE_LOGGING_GRPC=error
  - CORE_CHAINCODE_LOGGING_SHIM=info
  - CORE_CHAINCODE_LOGGING_LEVEL=info
  - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
  - CORE_CHAINCODE_BUILDER
  - CORE_CHAINCODE_GOLANG_RUNTIME
  - CORE_CHAINCODE_EXECUTETIMEOUT=120s
  - CORE_PEER_NETWORKID=multiorgledger
  - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE
  - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
  - CORE_LEDGER_STATE_COUCHDBCONFIG_USERNAME=admin
  - CORE_LEDGER_STATE_COUCHDBCONFIG_PASSWORD=adminpw
  - CORE_PEER_ID=peer1.org1.example.com
  - CORE_VM_DOCKER_ATTACHSTDOUT=true
  - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer1.org1.example.com:7051
  - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb.peer1.org1.example.com:5984
  - CORE_PEER_TLS_SERVERHOSTOVERRIDE=peer1.org1.example.com      
  - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:7051
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: peer node start
volumes:
  - /var/run/:/host/var/run/
  - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/msp:/var/hyperledger/msp
  - ./crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls:/var/hyperledger/tls
ports:
  - 8051:7051
  - 8053:7051    

Please suggest me some solution

回答1:

NO its not.

CORE_VM_ENDPOINT starts chaincode containers on the same bridge network as the peers.

You can mount the path of the folder containing core.yaml file on the peer container

If you are using fabric samples go to bellow path

fabric-samples/firest-network/base/

add the bellow code to the volumes section of peer-base.yaml if you want all peers to have history enabled OR add to the volumes of selective peers in docker-compose-base.yaml file

- "Path/to/the/folder/where/core.yaml/exists":/var/hyperledger/config

If any doubts do revert.