-1

If all the peers stop working, how to make sure that the data is not lost?

Thanks!

Pratik Patil
  • 36
  • 1
  • 5

1 Answers1

0

I have verified my idea through testing, but To be precise, it should be called network restore ranther than reuse,if you have the genesis.block,channl.tx,and peer crypto artifacts, and /var/hyperledger/production of orderer and peer,you can restore same network, and you need not to create channel again and join channle again,the data will not lose.

I have push the project to github https://github.com/iamlzw/reuse-previous-network-data.git ,and you can pull it and test,if you start this network ,you need not create channel and join channel and so on ,you can just query or invoke,if you stop this network,you can start it again,and you can find the data not lose,you will get same result throgh by chaincode query.

you can reference https://hyperledger-fabric.readthedocs.io/en/release-1.4/chaincode4ade.html#install-hyperledger-fabric-samples

hope these can help you

Li Xian
  • 421
  • 4
  • 4
  • genesis.block and channl.tx are copied from the docker or are you using the one which are created for the first time? What I mean is that are are we making sure that it has the latest transactions. I am getting a little confused. Also, there is orderer.block, so ou are copying this from the orderer container, right? Thanks! – Pratik Patil Mar 29 '21 at 06:31
  • genesisi.block(orderer.block) and channel.tx are generate before.orderer.block is same as genesis.block,you can see it at docker-compose-simple.yaml use for genesis.block,and channel.tx now is useless,because you have create channel before.they are not copy from orderer container ,the orderer and peer directory are copy from container. – Li Xian Mar 29 '21 at 06:53
  • Okay, thanks. And in your repo, the "./msp" folder corresponds to the orderer or the org? – Pratik Patil Mar 29 '21 at 11:49
  • orderer and peer use same msp,you can you can take a look ```docker-compose-simple.yaml``` – Li Xian Mar 29 '21 at 12:23
  • Yes, in your case they are the same. But, if if have a look at this (https://github.com/hyperledger/fabric-samples/blob/main/test-network/docker/docker-compose-test-net.yaml), here there are separate msp for peer and orderer. – Pratik Patil Mar 29 '21 at 12:43
  • you are right,but this sample is a very simple network,so the separate msp is not the focus point,you can use ```test-network``` or ```first-network``` to test,it is also fine – Li Xian Mar 29 '21 at 12:52
  • Could you please explain what is the role of "exec_mycc.sh" script? I was running the javascript fabcar chaincode so how should I modify it? Thanks. – Pratik Patil Apr 01 '21 at 08:57
  • exec_mycc.sh is used to compile chaincode and exec it,and this network is running on devmod,so it different with normal fabric network.you can change script content to this https://paste.ubuntu.com/p/VtXYG6xzDB/ I am not familiar with js,so here I use fabcar go chaincode as an example,you can refenrence this https://hyperledger-fabric.readthedocs.io/en/release-1.4/chaincode4ade.html#terminal-2-build-start-the-chaincode – Li Xian Apr 01 '21 at 09:22
  • I wrote a related blog about how to backup and restore from hyperledger fabric,may be helpful, https://github.com/iamlzw/restore-hyperledger-fabric-network/blob/master/how-to-backup-and-restore-from-hyperledger-fabric.md – Li Xian Apr 01 '21 at 09:30