Hyperledger Composer v0.19.8 Error When Upgrading

2019-08-15 18:27发布

问题:

I am trying to upgrade hyperledger fabric business network and I get this error

composer archive create -t dir -n . && \
composer network install -a $BNA_FILE -c PeerAdmin@hlfv1 && \
composer network upgrade -c PeerAdmin@hlfv1 -n NETWORK-NAME -V 0.1.23

The version number corresponds to that one in the package.json like the documentation says it should. I get the below error when I run the upgrade command

Error: Error trying to upgrade business network. Error: No valid responses 
from any peers.
Response from attempted peer comms was an error: Error: 2 UNKNOWN: chaincode 
error (status: 500, message: could not find chaincode with name 'NETWORK-NAME')

I made sure that hyperledger fabric is running ./startFabric yet I still get this error

回答1:

The error message received is saying that there is no business network called NETWORK-NAME started. In order to upgrade a business network it has to have been previously started.

What it sounds like in this case is that you have started the simple fabric development server provided by composer and initially installed and started the business network NETWORK-NAME. At some point you have restarted the fabric but this restart has actually removed the existing fabric servers and created a new fresh fabric network. Because this is a clean fabric network, there now isn't a business network on the channel and you need to start again from scratch and install and start the business network. For example the startFabric.sh script actually completely removes your existing fabric network and creates a new one and as such the business network and data is lost.

These resources may help you if you want to look into ensuring your fabric server persists it's information under various circumstances.

https://hyperledger-fabric.readthedocs.io/en/release-1.1/build_network.html#a-note-on-data-persistence

https://github.com/hyperledger/composer-knowledge-wiki/blob/latest/knowledge.md#fabricsetup (see section on how to retain docker state)